Print format: decimal separation with comma

Hey together,

I have another (simple looking) problem that I can’t find a solution for - even after looking through the internet…

Inside my sales invoice print format I’m currently using the following call to get the grad total of my invoice:

{{"%.2f €"|format(doc.grand_total)}}

Unfortunately this gives me a numbers formatting of 123.56 €. Since I’m living in germany I need the decimal separator to be a comma (123,45 €).

Can someone help me with a solution to achieve the desired number format #.###,## which I selected inside the system settings already aswell?

Thanks in advance!

Hi @Nicolai_Knr,

Please try it.

{{ '{:,.2f} €'.format(doc.grand_total) }}

Thank You!

Hi NCP,

Thanks for your response!
I think I already tried this approach and it didn‘t have an effect on the outcome, so I assumed that it would change the separation for thousands (atleast that was the topic of the article i found this line of code first).
But I will try it again anyway!

My second attempt was just using the „doc.get_formatted(„grand_total“) function and it did work for the comma, but the problem i got then was that it added an euro symbol infront of the value (€123,45) which is also not possible to use.
Maybe there is a way to get rid of this „€“ symbol instead?

Hi @Nicolai_Knr,

Please apply it.

{{ doc.get_formatted('grand_total') | replace("€","") }}

Then reload and check it.

Thank You!

1 Like

You are awesome!
For everyone else with a similar problem: The replace functionality is also working for the initial attempts. Probably not the cleanest way, but you can also use something like this:

{{"%.2f €"|format(doc.grand_total) | replace(".",",")}}

Thank you very much again!
May I ask were you did get all that syntax from? I’m always struggeling with stuff like that … how can I get such information if I just don’t know it?

Best regards