Issue with custom fields: $amount and other fields should only contain float, no (currency) text

I’m currently working on implementing a Swiss QR-Bill template in v5. To make it as dynamic as possible, I have to work with custom fields.

I come across a weird problem when switching the currency formats between Symbol and Code (ref Client with CHF, currency not shown - Self-Hosted | v5 - Discourse).

When using “Code” as Currency Format, the amounts contain the currency name (e.g. CHF) inside the variable. You can see this very good when I use the fields $amount, $total and $balance in the template:

<p>Amount is: $amount</p>
<p>Total is: $total</p>
<p>Balance is: $balance</p>

When I switch to “Symbol”, the fields only contain the sum without any currency text:

This is what I need to create the Swiss QR Bill template. If the $amount contains anything different than a float, the creation of the Swiss QR Bill payment slip fails. So far so good, but now the currency is missing in the “totals” section of the invoice.

I can currently work around with this using the $balance_due_raw field (in hope that this value correctly represents the invoice amount to be paid), but IMHO the fields $amount, $total and $balance should only contain the float number and never the currency as additional text. The currency can still be read using the $client.currency field.

Hi,

@david do you have any thoughts?

@napsty

You may want to use

$balance_due_raw
$amount_raw

these will not be formatted at all.

1 Like

Thanks for the hint, @david , $amount_raw works correctly.
I sent a PR to update the documentation https://github.com/invoiceninja/invoiceninja.github.io/pull/66.

1 Like