This is observable on the demo site without any changes.
The InvenTree Sales Order uses max_decimal_places=2 on all prices, looking at the output it shows 4 decimals.
Adding decimal_places=2 will show the correct amount of decimals.
Expected behaviour
To have render_currency only show the configured amount of decimals like the Docs say.
Please verify that this bug has NOT been raised before.
Describe the bug*
When using the
render_currency
helper in templates it will render too many decimals until you have bothdecimal_places
andmax_decimal_places
set.The docs say that if
decimal_places
is specified it will ignoremax_decimal_places
. https://docs.inventree.org/en/stable/report/helpers/#currency-formattingFrom looking at the code this line will always pick the max amount of decimals without respecting the other setting. https://github.com/inventree/InvenTree/blob/d1c835485982650dfa4a9c6b51142ab9660584d4/src/backend/InvenTree/InvenTree/helpers_model.py#L238
Steps to Reproduce
This is observable on the demo site without any changes.
The
InvenTree Sales Order
usesmax_decimal_places=2
on all prices, looking at the output it shows 4 decimals. Addingdecimal_places=2
will show the correct amount of decimals.Expected behaviour
To have
render_currency
only show the configured amount of decimals like the Docs say.Deployment Method
Version Information
Version Information:
InvenTree-Version: 0.16.0 Django Version: 4.2.15 Commit Hash: 3f2ac5a Commit Date: 2024-08-25
Database: postgresql Debug-Mode: False Deployed using Docker: True Platform: Linux-6.1.21-v8+-aarch64-with Installer: DOC
Active plugins: [{'name': 'InvenTreeBarcode', 'slug': 'inventreebarcode', 'version': '2.1.0'}, {'name': 'InvenTreeCoreNotificationsPlugin', 'slug': 'inventreecorenotificationsplugin', 'version': '1.0.0'}, {'name': 'InvenTreeCurrencyExchange', 'slug': 'inventreecurrencyexchange', 'version': '1.0.0'}, {'name': 'InvenTreeLabel', 'slug': 'inventreelabel', 'version': '1.1.0'}, {'name': 'InvenTreeLabelMachine', 'slug': 'inventreelabelmachine', 'version': '1.0.0'}, {'name': 'InvenTreeLabelSheet', 'slug': 'inventreelabelsheet', 'version': '1.0.0'}, {'name': 'DigiKeyPlugin', 'slug': 'digikeyplugin', 'version': '1.0.0'}, {'name': 'LCSCPlugin', 'slug': 'lcscplugin', 'version': '1.0.0'}, {'name': 'MouserPlugin', 'slug': 'mouserplugin', 'version': '1.0.0'}, {'name': 'TMEPlugin', 'slug': 'tmeplugin', 'version': '1.0.0'}]
Please verify if you can reproduce this bug on the demo site.
Relevant log output
No response