Hi all,
I’m using custom html in the sales invoice priint formats to add a field to show this :
{{557.6-250.92 }}
but the result shown :
306.68000000000006
I’ve also tried {{557.6|round(2,‘ceil’) - 250.92|round(2,‘ceil’), but it shown same result…
Why ? how can i fix this ? pls help
@lx_eclipse_xl try this
{{ "{:,.2f}".format(557.6-250.92) }}
2 Likes
yes Its work.
And then i apply it to the actual environment , its failed, I think it is the rounding function problem :
{{ “$ {:,.2f}”.format((((doc.grand_total | round(2,‘ceil’)) - (doc.total_commission|round(2,‘ceil’)))|round(2,‘ceil’))) }}
finally i use this method to resolve :
{{ “$ {:,}”.format((((doc.grand_total * 10000000000 | round(2,‘ceil’)) - (doc.total_commission * 10000000000|round(2,‘ceil’)))|round(2,‘ceil’)) / 10000000000) }}
@lx_eclipse_xl you don’t need to use the | round just use
{{ “$ {:,.2f}”.format(doc.grand_total - doc.total_commission) }}
or any other expression inside the format
1 Like
@bahaou thanks , its work !