sandervanhooft / laravel-invoicable

Easy invoice creation for Laravel
https://www.sandervanhooft.com/blog/laravel/stop-creating-your-laravel-invoices-manually/
MIT License
146 stars 40 forks source link

Invoice number / reference does not comply with some countries #13

Open rabol opened 5 years ago

rabol commented 5 years ago

Hi

Package seems to work as described, but the reference or invoice number does not comply with may countries as the number should be a continuous number sequence

It would be nice if one was able to provide a 'InvoiceReferenceGenerator' instead of modifying the code directly.

sandervanhooft commented 5 years ago

Thanks for opening this issue.

I agree, we should set the InvoiceReferenceGenerator class in the config and bind it into the container. Can you submit a PR for this?

rabol commented 5 years ago

Hi

I'm really bad in PR... I don't know how to do it :(

I solved the problem like this:

in the config/invoicable.php i added a new key:

'invoice_reference_generator' => \SanderVanHooft\Invoicable\InvoiceReferenceGenerator::class

in the service provider:

$config = $this->app->config['invoicable']; $this->app->bind(InvoiceReferenceGenerator::class, $config['invoice_reference_generator']);

and then in the boot of the Invoice class

$model->reference = app()->make(InvoiceReferenceGenerator::class)->generate();

I also increased the table field: reference to 20