laravel-invoicable icon indicating copy to clipboard operation
laravel-invoicable copied to clipboard

Invoice number / reference does not comply with some countries

Open rabol opened this issue 5 years ago • 2 comments

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.

rabol avatar Mar 09 '19 13:03 rabol

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?

sandervanhooft avatar Mar 10 '19 21:03 sandervanhooft

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

rabol avatar Mar 18 '19 09:03 rabol