• Stars
    star
    1,341
  • Rank 34,936 (Top 0.7 %)
  • Language
    PHP
  • License
    GNU General Publi...
  • Created almost 5 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Laravel package to generate PDF invoices from various customizable parameters

![Banner]

Laravel Invoices

Latest Stable Version Total Downloads Latest Unstable Version License

version 2 version 1

This Laravel package provides an easy to use interface to generate Invoice PDF files with your provided data.

Invoice file can be stored, downloaded, streamed on any of the filesystems you have configured. Supports different templates and locales.

Originally package was developed on PHP 7.3.11 and Laravel 6.2, but should work on lower versions too.

Features

  • Taxes - fixed or rate - for item or for invoice
  • Discounts - fixed or by percentage - for item or for invoice
  • Shipping - add shipping price to your invoices
  • Automatic calculation - provide minimal set of information, or calculate yourself and provide what to print
  • Due date
  • Easy to customize currency format
  • Serial numbers as you like it
  • Templates
  • Translations
  • Global settings and overrides on-the-fly

Change log

Please see the changelog for more information on what has changed recently.

Installation

Via Composer

Laravel version <= 10

$ composer require laraveldaily/laravel-invoices:^3.0

Laravel version <= 8

$ composer require laraveldaily/laravel-invoices:^2.0

Laravel version <= 7

$ composer require laraveldaily/laravel-invoices:^1.3

After installing Laravel Invoices, publish its assets, views, translations and config using the invoices:install Artisan command:

$ php artisan invoices:install

Updates

Since it is evolving fast you might want to have latest template after update using Artisan command:

$ php artisan invoices:update

It will give a warning if you really want to override default resources

Or alternatively it can be done separately.

$ php artisan vendor:publish --tag=invoices.views --force
$ php artisan vendor:publish --tag=invoices.translations --force

For Laravel version < 5.5

If you don't use auto-discovery, add the ServiceProvider to the providers array in config/app.php

LaravelDaily\Invoices\InvoiceServiceProvider::class,

If you want to use the facade to generate invoices, add this to your facades in config/app.php

'Invoice' => LaravelDaily\Invoices\Facades\Invoice::class

Basic Usage

RandomController.php

use LaravelDaily\Invoices\Invoice;
use LaravelDaily\Invoices\Classes\Buyer;
use LaravelDaily\Invoices\Classes\InvoiceItem;

<...>

        $customer = new Buyer([
            'name'          => 'John Doe',
            'custom_fields' => [
                'email' => '[email protected]',
            ],
        ]);

        $item = (new InvoiceItem())->title('Service 1')->pricePerUnit(2);

        $invoice = Invoice::make()
            ->buyer($customer)
            ->discountByPercent(10)
            ->taxRate(15)
            ->shipping(1.99)
            ->addItem($item);

        return $invoice->stream();

See result Invoice_AA_00001.pdf.

Advanced Usage

use LaravelDaily\Invoices\Invoice;
use LaravelDaily\Invoices\Classes\Party;
use LaravelDaily\Invoices\Classes\InvoiceItem;

<...>

        $client = new Party([
            'name'          => 'Roosevelt Lloyd',
            'phone'         => '(520) 318-9486',
            'custom_fields' => [
                'note'        => 'IDDQD',
                'business id' => '365#GG',
            ],
        ]);

        $customer = new Party([
            'name'          => 'Ashley Medina',
            'address'       => 'The Green Street 12',
            'code'          => '#22663214',
            'custom_fields' => [
                'order number' => '> 654321 <',
            ],
        ]);

        $items = [
            (new InvoiceItem())
                ->title('Service 1')
                ->description('Your product or service description')
                ->pricePerUnit(47.79)
                ->quantity(2)
                ->discount(10),
            (new InvoiceItem())->title('Service 2')->pricePerUnit(71.96)->quantity(2),
            (new InvoiceItem())->title('Service 3')->pricePerUnit(4.56),
            (new InvoiceItem())->title('Service 4')->pricePerUnit(87.51)->quantity(7)->discount(4)->units('kg'),
            (new InvoiceItem())->title('Service 5')->pricePerUnit(71.09)->quantity(7)->discountByPercent(9),
            (new InvoiceItem())->title('Service 6')->pricePerUnit(76.32)->quantity(9),
            (new InvoiceItem())->title('Service 7')->pricePerUnit(58.18)->quantity(3)->discount(3),
            (new InvoiceItem())->title('Service 8')->pricePerUnit(42.99)->quantity(4)->discountByPercent(3),
            (new InvoiceItem())->title('Service 9')->pricePerUnit(33.24)->quantity(6)->units('m2'),
            (new InvoiceItem())->title('Service 11')->pricePerUnit(97.45)->quantity(2),
            (new InvoiceItem())->title('Service 12')->pricePerUnit(92.82),
            (new InvoiceItem())->title('Service 13')->pricePerUnit(12.98),
            (new InvoiceItem())->title('Service 14')->pricePerUnit(160)->units('hours'),
            (new InvoiceItem())->title('Service 15')->pricePerUnit(62.21)->discountByPercent(5),
            (new InvoiceItem())->title('Service 16')->pricePerUnit(2.80),
            (new InvoiceItem())->title('Service 17')->pricePerUnit(56.21),
            (new InvoiceItem())->title('Service 18')->pricePerUnit(66.81)->discountByPercent(8),
            (new InvoiceItem())->title('Service 19')->pricePerUnit(76.37),
            (new InvoiceItem())->title('Service 20')->pricePerUnit(55.80),
        ];

        $notes = [
            'your multiline',
            'additional notes',
            'in regards of delivery or something else',
        ];
        $notes = implode("<br>", $notes);

        $invoice = Invoice::make('receipt')
            ->series('BIG')
            // ability to include translated invoice status
            // in case it was paid
            ->status(__('invoices::invoice.paid'))
            ->sequence(667)
            ->serialNumberFormat('{SEQUENCE}/{SERIES}')
            ->seller($client)
            ->buyer($customer)
            ->date(now()->subWeeks(3))
            ->dateFormat('m/d/Y')
            ->payUntilDays(14)
            ->currencySymbol('$')
            ->currencyCode('USD')
            ->currencyFormat('{SYMBOL}{VALUE}')
            ->currencyThousandsSeparator('.')
            ->currencyDecimalPoint(',')
            ->filename($client->name . ' ' . $customer->name)
            ->addItems($items)
            ->notes($notes)
            ->logo(public_path('vendor/invoices/sample-logo.png'))
            // You can additionally save generated invoice to configured disk
            ->save('public');

        $link = $invoice->url();
        // Then send email to party with link

        // And return invoice itself to browser or have a different view
        return $invoice->stream();

See result Roosevelt Lloyd Ashley Medina.pdf.

Alternatives using facade

Optionally you can use a facade to make new party or item

use Invoice;

$customer = Invoice::makeParty([
    'name' => 'John Doe',
]);

$item = Invoice::makeItem('Your service or product title')->pricePerUnit(9.99);

return Invoice::make()->buyer($customer)->addItem($item)->stream();

Templates

After publishing assets you can modify or make your own template for invoices.

Templates are stored in the resources/views/vendor/invoices/templates directory. There you will find default.blade.php template which is used by default.

You can specify which template to use by calling template method on Invoice object.

For example if you have resources/views/vendor/invoices/templates/my_company.blade.php it should look like this:

Invoice::make('receipt')->template('my_company');

Too see how things work in a template you can view default.blade.php as an example.

Config

return [
    'date' => [
        /**
         * Carbon date format
         */
        'format'         => 'Y-m-d',
        /**
         * Due date for payment since invoice's date.
         */
        'pay_until_days' => 7,
    ],

    'serial_number' => [
        'series'           => 'AA',
        'sequence'         => 1,
        /**
         * Sequence will be padded accordingly, for ex. 00001
         */
        'sequence_padding' => 5,
        'delimiter'        => '.',
        /**
         * Supported tags {SERIES}, {DELIMITER}, {SEQUENCE}
         * Example: AA.00001
         */
        'format'           => '{SERIES}{DELIMITER}{SEQUENCE}',
    ],

    'currency' => [
        'code'                => 'eur',
        /**
         * Usually cents
         * Used when spelling out the amount and if your currency has decimals.
         *
         * Example: Amount in words: Eight hundred fifty thousand sixty-eight EUR and fifteen ct.
         */
        'fraction'            => 'ct.',
        'symbol'              => '€',
        /**
         * Example: 19.00
         */
        'decimals'            => 2,
        /**
         * Example: 1.99
         */
        'decimal_point'       => '.',
        /**
         * By default empty.
         * Example: 1,999.00
         */
        'thousands_separator' => '',
        /**
         * Supported tags {VALUE}, {SYMBOL}, {CODE}
         * Example: 1.99 €
         */
        'format'              => '{VALUE} {SYMBOL}',
    ],

    'paper' => [
        // A4 = 210 mm x 297 mm = 595 pt x 842 pt
        'size'        => 'a4',
        'orientation' => 'portrait',
    ],

    'disk' => 'local',

    'seller' => [
        /**
         * Class used in templates via $invoice->seller
         *
         * Must implement LaravelDaily\Invoices\Contracts\PartyContract
         *      or extend LaravelDaily\Invoices\Classes\Party
         */
        'class' => \LaravelDaily\Invoices\Classes\Seller::class,

        /**
         * Default attributes for Seller::class
         */
        'attributes' => [
            'name'          => 'Towne, Smith and Ebert',
            'address'       => '89982 Pfeffer Falls Damianstad, CO 66972-8160',
            'code'          => '41-1985581',
            'vat'           => '123456789',
            'phone'         => '760-355-3930',
            'custom_fields' => [
                /**
                 * Custom attributes for Seller::class
                 *
                 * Used to display additional info on Seller section in invoice
                 * attribute => value
                 */
                'SWIFT' => 'BANK101',
            ],
        ],
    ],
];

Available Methods

Almost every configuration value can be overrided dynamically by methods.

Invoice

General

  • addItem(InvoiceItem $item)
  • addItems(Iterable)
  • name(string)
  • status(string) - invoice status [paid/due] if needed
  • seller(PartyContract)
  • buyer(PartyContract)
  • setCustomData(mixed) - allows user to attach additional data to invoice
  • getCustomData() - retrieves additional data to use in template
  • template(string)
  • logo(string) - path to logo
  • getLogo() - returns base64 encoded image, used in template to avoid path issues
  • filename(string) - overrides automatic filename
  • taxRate(float)
  • shipping(float) - shipping amount
  • totalDiscount(float) - If not provided calculates itself
  • totalTaxes(float) - If not provided calculates itself
  • totalAmount(float) - If not provided calculates itself
  • taxableAmount(float) - If not provided calculates itself

Serial number

  • series(string)
  • sequence(int)
  • delimiter(string)
  • sequencePadding(int)
  • serialNumberFormat(string)
  • getSerialNumber() - returns formatted serial number

Date

  • date(Carbon)
  • dateFormat(string) - Carbon format of date
  • payUntilDays(int) - Days payment due since invoice issued
  • getDate() - returns formatted date
  • getPayUntilDate() - return formatted due date

Currency

  • currencyCode(string) - EUR, USD etc.
  • currencyFraction(string) - Cents, Centimes, Pennies etc.
  • currencySymbol(string)
  • currencyDecimals(int)
  • currencyDecimalPoint(string)
  • currencyThousandsSeparator(string)
  • currencyFormat(string)
  • getAmountInWords(float, ?string $locale) - Spells out float to words, second parameter is locale
  • getTotalAmountInWords() - spells out total_amount
  • formatCurrency(float) - returns formatted value with currency settings '$ 1,99'

File

  • stream() - opens invoice in browser
  • download() - offers to download invoice
  • save($disk) - saves invoice to storage, use ->filename() for filename
  • url() - return url of saved invoice
  • toHtml() - render html view instead of pdf

InvoiceItem

  • title(string) - product or service name
  • description(string) - additional information for service entry
  • units(string) - measurement units of item (adds units columns if set)
  • quantity(float) - amount of units of item
  • pricePerUnit(float)
  • discount(float) - discount in currency
  • discountByPercent(float) - discount by percents discountByPercent(15) means 15%
  • tax(float)
  • taxByPercent(float)
  • subTotalPrice(float) - If not provided calculates itself

Testing

$ composer test

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Author

License

GPL-3.0-only. Please see the license file for more information.

More Repositories

1

laravel-tips

Awesome tips for Laravel
6,267
star
2

Laravel-Roadmap-Learning-Path

5,264
star
3

Larastarters

SCSS
753
star
4

laravel-roles-permissions-manager

Laravel 6 adminpanel starter boilerplate project with roles-permissions management.
PHP
654
star
5

quickadmin

Quick adminpanel builder package for Laravel 5
CSS
602
star
6

laravel-charts

Package to draw charts in Laravel with Chart.js
PHP
460
star
7

Best-Laravel-Packages

398
star
8

Laravel-Support-Ticketing

Laravel 6 Project for Support Tickets. Partly generated with QuickAdminPanel.
PHP
255
star
9

Laravel-Vue-First-CRUD

Simple demo project for Laravel 5.5 and Vue.js with one CRUD operation.
PHP
254
star
10

Laravel-Passport-API-Server-Client-Demo

Demo project to show how Laravel Passport works - we have both Server and Client here.
HTML
228
star
11

Laraquiz-QuickAdminPanel

Laravel 5.6 based quiz system - generated with QuickAdmin https://quickadminpanel.com
CSS
222
star
12

FilaStart

PHP
217
star
13

Hotel-Booking

Laravel 5.5 Demo-project for booking hotel rooms, mostly generated with https://quickadminpanel.com
HTML
176
star
14

laravel-roles-permissions-bouncer

Laravel 6 adminpanel starter boilerplate project with roles-permissions based on Bouncer package.
PHP
173
star
15

Laravel-School-Timetable-Calendar

Laravel 6 demo project for school timetable. Partly generated with https://quickadminpanel.com
PHP
171
star
16

Laravel-Appointments

Laravel 6 demo project for appointments management. Generated with https://2019.quickadminpanel.com.
PHP
153
star
17

Laravel-Asset-Stock-Management

Laravel 7 demo project for managing stock in multiple hospitals. Partly generated with https://quickadminpanel.com
PHP
152
star
18

QuickLMS

Simple Learning Management System based on Laravel 5.4.
HTML
140
star
19

Laravel-Vue-Login-Register

Demo-project of Laravel Login/Register via API from Vue.js client
PHP
140
star
20

Larancer-QuickAdminPanel

Laravel 5.5 system for freelancers to manage their clients/projects/income - generated with QuickAdmin
JavaScript
137
star
21

Laravel-Datatables-Advanced

A few advanced examples of Laravel + Datatables.net
PHP
127
star
22

Laravel-Jetstream-CRUD-Roles

PHP
127
star
23

Laravel-AdminLTE3-Boilerplate

Boilerplate adminpanel: Laravel 6.0 + AdminLTE 3 (Bootstrap 4) and simple CRUD examples. Based on new QuickAdminPanel 2019.
PHP
119
star
24

Test-Laravel-Routes

PHP
116
star
25

Laravel-Import-CSV-Demo

Small demo project to import CSV in Laravel 5.5 with matching the columns.
PHP
112
star
26

LaraAppointments-QuickAdminPanel

Laravel 5.5 based appointment-management system created with QuickAdminPanel https://quickadminpanel.com
JavaScript
109
star
27

Laravel-Roadmap-Beginner-Challenge

109
star
28

Laravel-Event-Conference-Demo

Laravel 6 demo project to manage conference/event data. Adminpanel generated with https://2019.quickadminpanel.com
PHP
105
star
29

Laravel-CoreUI-AdminPanel

Boilerplate adminpanel: Laravel 6.0 + CoreUI Theme (Bootstrap 4) and simple CRUD examples. Based on new QuickAdminPanel 2019.
PHP
102
star
30

Laravel-Checklister

PHP
96
star
31

Laravel-File-Storage

Laravel 5.5 Demo-project to store files, mini-Dropbox with multi-tenancy and Stripe payments.
HTML
96
star
32

QuickAdminPanel-Freelancer-CRM

Laravel 6 demo project for freelancers to manage their projects and income. Generated with https://2019.quickadminpanel.com
PHP
92
star
33

api-generator

API Generator for Laravel 5
PHP
87
star
34

Larancer-Vue

Vue+Laravel panel to manage freelancer's projects/income. Generated with our QuickAdminPanel.
HTML
86
star
35

Laravel-Demo-Courses-Enrollment

Demo Laravel project (task from Upwork) for students to register for courses from various universities.
PHP
86
star
36

Laravel-Real-Estate-Venue-Portal

Laravel 6 Real Estate demo-project based on Bootstrap theme
HTML
83
star
37

Laravel-Vue-Sidebar-Filters

Demo-project with Laravel API and Vue.js - Sidebar Filters for Catalog/E-Shop
PHP
83
star
38

laravel-permission-ui

Blade
82
star
39

Laravel-Shops-Map-QuickAdminPanel

Laravel 6 demo project for shops map. Adminpanel generated with https://quickadminpanel.com
PHP
81
star
40

Laravel-Vue-Employees-Adminpanel

Laravel + Vue.js Demo-project generated with our generator https://vue.quickadminpanel.com
HTML
80
star
41

Vue-Laravel-SPA-Boilerplate

PHP
78
star
42

Laravel-Vue-3-Composition-API-CRUD

PHP
77
star
43

QuickAdminPanel-Tailwind

PHP
75
star
44

Laravel-SOLID-Course-Examples

PHP
75
star
45

Laravel-Restaurant-Menu

Laravel demo-project: manage restaurant menu with reordering positions. Partly generated with https://quickadminpanel.com
PHP
75
star
46

Laravel-Job-Listings-QuickAdminPanel

Laravel 6 demo project for job listings directory. Adminpanel generated with https://2019.quickadminpanel.com
PHP
75
star
47

Laravel-KnowledgeBase-FAQ

Laravel 6 demo project to manage FAQ Knowledge Base. Adminpanel generated with https://2019.quickadminpanel.com
PHP
73
star
48

Laravel-Roadmap-Advanced-Beginner-Challenge

72
star
49

Test-Laravel-Blade-Basics

PHP
71
star
50

Laravel-Classimax-Directory

Demo project of Laravel simple classifieds list based on front-end theme Classimax.
HTML
70
star
51

Laravel-Breeze-Pages-Skeleton

PHP
67
star
52

Laravel-Loan-Management-Demo

PHP
67
star
53

Livewire-Parent-Child-Master-Detail

PHP
64
star
54

LaraEventTickets-QuickAdminPanel

Laravel 5.4 based simple event tickets admin + page created with QuickAdminPanel https://quickadminpanel.com
HTML
64
star
55

Test-Laravel-Auth-Basics

PHP
64
star
56

Laravel-Auth-Invitations

Demo project of Laravel 5.5 Auth extended so that only invited users can register.
PHP
63
star
57

Laravel-Adminator-QuickAdminPanel

Simple Laravel adminpanel based on Adminator theme, partly generated with QuickAdminPanel
PHP
63
star
58

Test-Laravel-Eloquent-Basics

PHP
62
star
59

Laravel-Faculty-RoomBooking

Laravel 7 Demo Project for Room Booking with Stripe. Generated with https://quickadminpanel.com and CoreUI theme.
PHP
62
star
60

Laravel-Admin-User-Layouts

PHP
61
star
61

Laravel-Job-Board-Demo

Demo Job Board project with Laravel 5.8. Partly generated with our QuickAdminPanel 2019.
PHP
61
star
62

QuickAdminPanel-ExpenseManager

Laravel 6 Demo project: Expense manager with multi-tenancy registration. Generated with https://2019.quickadminpanel.com
PHP
60
star
63

Laravel-Multi-Domain-Tenancy-Shops

Example Laravel 6 Project to have sub-domains for companies. Partly created with QuickAdminPanel.
PHP
60
star
64

Test-Laravel-File-Upload

PHP
58
star
65

Laravel-Envoyer-SaaS-Generator

Laravel 7 Demo Project re-creating Envoyer plans structure. Generated with SaaS Generator at https://quickadminpanel.com
PHP
58
star
66

Laravel-Demo-Support-Tickets

PHP
57
star
67

Laravel-Two-Factor-Auth-Email

PHP
57
star
68

Laravel-Test-Result-PDF

Laravel Quiz/Test Project with PDF Results. Adminpanel generated with https://www.quickadminpanel.com
PHP
56
star
69

Laravel-Datatables-Demo

Simple demo project for Datatables.net in Laravel 5.5 - with default and server-side rendering.
PHP
55
star
70

Laravel-AmazonS3-Video

Demo project of uploading video file to Amazon S3 with Laravel+AJAX
HTML
55
star
71

Laravel-Excel-Export-Import-Large-Files

PHP
54
star
72

Test-Eloquent-Relationships

PHP
54
star
73

Laravel-Login-Activity-Dashboard

Demo-project with dashboard on how many users logged in recently. Partly generated with QuickAdminPanel 2019.
PHP
53
star
74

Laravel-Vue-SPA-Vuetify

PHP
51
star
75

QuickAdminPanel-Material-Dashboard

Simple Laravel adminpanel based on Material Dashboard theme from Creative Tim
PHP
51
star
76

Laravel-Vue3-CRUD-Course-2022

PHP
51
star
77

Laravel-SaaS-Subscriptions-Demo

PHP
51
star
78

Laravel-Mobile-Phone-Verification-Demo

PHP
50
star
79

Test-Laravel-Migrations

PHP
50
star
80

Laravel-Filament-Admin-Course

JavaScript
49
star
81

Laravel-useful-seeds

Some migrations/seeds and data that may be useful for various Laravel projects
PHP
48
star
82

Laravel-Notifications-Database

Laravel Notifications Example with Database Driver
PHP
48
star
83

Laravel-OpenAPI-Swagger-Documentation-Example

Laravel documentation example with OpenAPI (ex. Swagger)
PHP
47
star
84

Landlord-Tenants-Laravel

Laravel 5.6 Demo-project where landlords and tenants can exchange documents/notes/messages.
HTML
47
star
85

Test-Laravel-Validation

PHP
46
star
86

Laravel-Jetstream-MultiAuth-Roles

PHP
46
star
87

Laravel-Multi-Level-Categories-Eshop

PHP
45
star
88

ExpenseManager

Laravel 5.5 Demo project - Expense manager with multi-tenancy registration. Partly generated by https://quickadminpanel.com
HTML
44
star
89

Laravel-API-Vue-Catalog

Demo-project with Laravel API and Vue.js
PHP
43
star
90

Laravel-Roadmap-Advanced-Beginner-Roadmap

PHP
42
star
91

Laravel-SaaS-Demo-Project

PHP
42
star
92

tutorials-api-auth

PHP
41
star
93

Livewire-jQuery-Three-Dropdowns

PHP
40
star
94

laravel-permission-editor

Visual UI for managing Roles/Permissions for Spatie Laravel Permission package
Blade
40
star
95

Laravel-8-Import-CSV

PHP
40
star
96

QuickAdminPanel-Livewire-Tailwind-Example

PHP
39
star
97

QuickInvitations

Simple Event Invitations System based on Laravel 5.5. Partly created with https://quickadminpanel.com
HTML
38
star
98

Laravel-8-Fortify-Bootstrap-Demo

PHP
37
star
99

Laravel-Room-Booking-Filters

Demo-project for managing bookings at hotels and rooms.
PHP
37
star
100

Laravel-Todoist-SaaS

PHP
36
star