Report maths tweaks (#10604)

* Maths tags updates

- Allow maths operations on non-float values
- Add tests for Decimal values
- Add tests for Money values
- Convert string values to floating point

* Add modulo tag
This commit is contained in:
Oliver authored and GitHub committed 2025-10-17 20:54:20 +11:00
1 parent 24dfbe815e
commit d534f67c62
3 files changed
+101 -15

No files matched your search

+12 -1
View File
@@ -263,7 +263,11 @@ Total Price: {% render_currency order.total_price currency='NZD' decimal_places=
## Maths Operations
Simple mathematical operators are available, as demonstrated in the example template below:
Simple mathematical operators are available, as demonstrated in the example template below. These operators can be used to perform basic arithmetic operations within the report template.
### Input Types
These mathematical functions accept inputs of various input types, and attempt to perform the operation accordingly. Note that any inputs which are provided as strings will be converted to floating point numbers before the operation is performed.
### add
@@ -293,6 +297,13 @@ Simple mathematical operators are available, as demonstrated in the example temp
show_docstring_description: false
show_source: False
### modulo
::: report.templatetags.report.modulo
options:
show_docstring_description: false
show_source: False
### Example
```html