Problems using Templates

Hi everyone!

Version v5.10.30
Environment Docker

I really have a hard time using the template feature in invoice ninja. All i want to achieve is, that i get a pdf which looks exactly the same like a qoute, but instead of the word “Quote” there need to be “Order Confirmation”. It seems the way to go is using templates.

Ideally i would just paste my invoice design to the template and substitute “Quote” with “Order Confirmation” and that would be it. But this seems not how things work. Because it’s not possible to just use

  • <table id=“product-table” cellspacing=“0” data-ref=“table”> or
  • <div id=“table-totals” cellspacing=“0”>$status_logo

like in designs. For me its hard to understand, but ok. So i redo the whole layout using the template tools described here. Now, nearly finished, i tried to do the “totals table” with sub-total, net amount, discount, tax amount and total. like this:
Screenshot 2024-10-13 at 18.48.20

Using “{{ quote.amount }}” for the total amount works, no problem.

First problem is using “{{ quote.total_taxes }}”. This should be “formatted currency” like mentioned in the documentation, but its not. it looks like “total_taxes_raw” described in the documentation (no currency, no thousands sperator, wrong comma sign).

Second problem: there is no “formatted currency” variable for discount, only the raw value.

Third problem: i can’t calculate with these values. “{{ quote.amount - quote.total_taxes }}” works in the preview where it shows the correct calculated value (where i create my template), but trying to apply the template to a quote, it gets stuck “Processing”. Log says:

[previous exception] [object] (ErrorException(code: 0): A non-numeric value encountered at /var/www/app/vendor/twig/twig/src/Environment.php(391) : eval()'d code:117)

One would think: “just use the raw values”, like this: “{{ quote.amount_raw - quote.total_taxes_raw }}”. Which only shows 0 as calculated value (in preview and in the generated pdf). Aside from that, i don’t know how to show the result in a “formatted currency”-way.

Here is a screenshot of the template in preview:

Which leaves me with two questions:

  • Is there a better way to achieve my goal?
  • Is there something i dont get or are the described problems bugs?

Hi,

Maybe you can use a custom label for ‘Quote’ on Settings > Localization instead?

Otherwise, is there a reason you’re using a custom template rather than a custom design?

Hi Hillel,

Here’s how the order flow currently works:

  • A client requests services and products.
  • I send a quote as a PDF via email.
  • The client places an order based on the quote.
  • I send an order confirmation via email (this step is what’s missing in Invoice Ninja).
  • Once everything is delivered, the client receives the final invoice as email.

When I replace the term “Quote” with “Order Confirmation” in the localization, it prevents me from generating quotes. What I need is to add the “Order Confirmation” in addition to the quote, not replace it.

Additionally, I can’t solve this by adjusting the design, since—if I understand correctly—design options allow customization of the quote and invoice layout but don’t support creating an entirely new document type.

Do you have any suggestions or workarounds for this?

Thanks!

BG
Thomas

The app doesn’t support creating new document types.

One option may be use custom designs and custom email templates to present certain quotes differently to your clients.

Hi!

The app doesn’t support creating new document types.

I thought this is what are template for.

One option may be use custom designs and custom email templates to present certain quotes differently to your clients.

I can’t use custom design because i don’t want present certain quotes differently for customers. I need quotes AND order confirmations AND invoices.

I guess it depends on how you define document type.

If you’d like a change in the app feel free to create an issue on GitHub.

Hi Hillel,

I don’t think it’s necessary to request a change to the document type. Everything I need to achieve my goal is nearly in place but contains a few errors:

• {{ quote.total_taxes }} should be displayed in a formatted currency format, as specified in the official Invoice Ninja documentation.
• The calculation {{ quote.amount - quote.total_taxes }} should behave consistently, as it does in the preview. If it works in the preview but not when applying the template, it seems like either there’s an error in the template generation or in the preview itself, which wouldn’t make sense.
• {{ quote.amount_raw }} and {{ quote.total_taxes_raw }} should reflect the values described in the documentation, but currently, they do not.

The only missing feature (which wouldn’t be a big issue if left out) is that the array doesn’t contain a formatted value for the discount amount. If we can address the other bugs first, I can submit a feature request for this later.

BR
Thomas

In that case I suggest creating an issue on GitHub for the template bugs you’ve encountered.