IP doesn't generate invoice number after download

Hi to all,

I’ve found a bug after updating to IP 1.5.8 (but also IP 1.5.9 is affected), with generate_invoice_number_for_draft set to No and mark_invoices_sent_pdf set to Yes, when I download a drafted invoice, the invoice changes his status to sent but doesn’t generate the invoice number and downloads a PDF without the invoice number.

But if I manually change invoice status from draft to sent, the invoice number generates correctly.

You can test this bug directly in the InvoicePlane demo with the latest version.

I think the bug is caused by this pull request [IP-602] & [IP-603] - Invoice/Quote number generated after sent.

I could be wrong but maybe adding this line in application/modules/invoices/controllers/Invoices.php fixes the problem:

public function generate_pdf($invoice_id, $stream = true, $invoice_template = null)

        if (get_setting('mark_invoices_sent_pdf') == 1) {
+           $this->mdl_invoices->generate_invoice_number_if_applicable($invoice_id);

        generate_invoice_pdf($invoice_id, $stream, $invoice_template, null);

And, of course, the same thing happens with quotes.

Thank you!

@Maxime_GRIMLER Could you take a look at this?

I’m in Berlin i’m Back tomorrow night so I will check it either in the night or this weekend !
(Thanks for the fix it looks actually good from a read point of view!)

Thank you! I hope that’s the right solution! :crossed_fingers::grin:

Any news about this fix? Sorry, just a reminder. :slight_smile:


Sorry for the late answer, hard time at work :wink:
Indeed I reproduce the bug on my env and your fix seems to work perfectly.
I’ve created an issue (https://development.invoiceplane.com/browse/IP-700) and I’m gonna make a pull request right now with your fix :wink:

Pull Request :


1 Like

No worries, I’m glad to have contributed to the resolution and thank you very much for the help! :grin::+1:t2: