2017 © Pedro Peláez
 

library laravel-invoicable

Easy invoice generation using Laravel Eloquent

image

sander-van-hooft/laravel-invoicable

Easy invoice generation using Laravel Eloquent

  • Tuesday, March 27, 2018
  • by sandervanhooft
  • Repository
  • 2 Watchers
  • 32 Stars
  • 843 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 7 Forks
  • 2 Open issues
  • 10 Versions
  • 35 % Grown

The README.md

laravel-invoicable

Latest Version on Packagist ![Software License][ico-license] Github Actions ![Total Downloads][ico-downloads], (*1)

Easy invoice creation for Laravel. Unlike Laravel Cashier, this package is payment gateway agnostic., (*2)

If you're looking for Mollie payment processing, be sure to check out laravel-payable-redirect-mollie., (*3)

Structure

database/
resources
src/
tests/
vendor/

Install

Via Composer, (*4)

``` bash $ composer require sander-van-hooft/laravel-invoicable, (*5)


You can publish the migration with: ``` bash $ php artisan vendor:publish --provider="SanderVanHooft\Invoicable\InvoicableServiceProvider" --tag="migrations"

After the migration has been published you can create the invoices and invoice_lines tables by running the migrations:, (*6)

``` bash $ php artisan migrate, (*7)


Optionally, you can also publish the `invoicable.php` config file with: ``` bash $ php artisan vendor:publish --provider="SanderVanHooft\Invoicable\InvoicableServiceProvider" --tag="config"

This is what the default config file looks like:, (*8)

``` php, (*9)

return [ 'default_currency' => 'EUR', 'default_status' => 'concept', 'locale' => 'nl_NL', ];, (*10)


If you'd like to override the design of the invoice blade view and pdf, publish the view: ``` bash $ php artisan vendor:publish --provider="SanderVanHooft\Invoicable\InvoicableServiceProvider" --tag="views"

You can now edit receipt.blade.php in <project_root>/resources/views/invoicable/receipt.blade.php to match your style., (*11)

Usage

Money figures are in cents!, (*12)

Add the invoicable trait to the Eloquent model which needs to be invoiced (typically an Order model):, (*13)

``` php use Illuminate\Database\Eloquent\Model; use SanderVanHooft\Invoicable\IsInvoicable\IsInvoicableTrait;, (*14)

class Order extends Model { use IsInvoicableTrait; // enables the ->invoices() Eloquent relationship }, (*15)


Now you can create invoices for an Order: ``` php $order = Order::first(); $invoice = $order->invoices()->create([]); // To add a line to the invoice, use these example parameters: // Amount: // 121 (€1,21) incl tax // 100 (€1,00) excl tax // Description: 'Some description' // Tax percentage: 0.21 (21%) $invoice = $invoice->addAmountInclTax(121, 'Some description', 0.21); $invoice = $invoice->addAmountExclTax(100, 'Some description', 0.21); // Invoice totals are now updated echo $invoice->total; // 242 echo $invoice->tax; // 42 // Set additional information (optional) $invoice->currency; // defaults to 'EUR' (see config file) $invoice->status; // defaults to 'concept' (see config file) $invoice->receiver_info; // defaults to null $invoice->sender_info; // defaults to null $invoice->payment_info; // defaults to null $invoice->note; // defaults to null // access individual invoice lines using Eloquent relationship $invoice->lines; $invoice->lines(); // Access as pdf $invoice->download(); // download as pdf (returns http response) $invoice->pdf(); // or just grab the pdf (raw bytes) // Handling discounts // By adding a line with a negative amount. $invoice = $invoice->addAmountInclTax(-121, 'A nice discount', 0.21); // Or by applying the discount and discribing the discount manually $invoice = $invoice->addAmountInclTax(121 * (1 - 0.30), 'Product XYZ incl 30% discount', 0.21); // Convenience methods Invoice::findByReference($reference); Invoice::findByReferenceOrFail($reference); $invoice->invoicable() // Access the related model

Change log

Please see CHANGELOG for more information on what has changed recently., (*16)

Testing

bash $ composer test, (*17)

Contributing

Please see CONTRIBUTING and CONDUCT for details., (*18)

Security

If you discover any security related issues, please email info@sandervanhooft.com instead of using the issue tracker., (*19)

Credits

License

The MIT License (MIT). Please see License File for more information., (*20)

The Versions

27/03 2018
27/03 2018
26/03 2018
20/03 2018
11/07 2017

1.0.5

1.0.5.0 https://github.com/SanderVanHooft/laravel-invoicable

Easy invoice generation using Laravel Eloquent

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel eloquent payments invoice sandervanhooft invoicable laravel-invoicable

21/06 2017

1.0.4

1.0.4.0 https://github.com/SanderVanHooft/laravel-invoicable

Easy invoice generation using Laravel Eloquent

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel eloquent payments invoice sandervanhooft invoicable laravel-invoicable

21/06 2017

1.0.3

1.0.3.0 https://github.com/SanderVanHooft/laravel-invoicable

Easy invoice generation using Laravel Eloquent

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel eloquent payments invoice sandervanhooft invoicable laravel-invoicable

21/06 2017

1.0.2

1.0.2.0 https://github.com/SanderVanHooft/laravel-invoicable

Easy invoice generation using Laravel Eloquent

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel eloquent payments invoice sandervanhooft invoicable laravel-invoicable

21/06 2017

1.0.1

1.0.1.0 https://github.com/SanderVanHooft/laravel-invoicable

Easy invoice generation using Laravel Eloquent

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel eloquent payments invoice sandervanhooft invoicable laravel-invoicable

21/06 2017

1.0.0

1.0.0.0 https://github.com/SanderVanHooft/laravel-invoicable

Easy invoice generation using Laravel Eloquent

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel eloquent payments invoice sandervanhooft invoicable laravel-invoicable