After upgrade to 3.3.6 generating receipts via “Generate Documents” we get the error:
Jinja Template
unsupported operand type(s) for +: 'float' and 'decimal.Decimal'
This error does not occur in template editor.
The relevant code we use seems to be
{% set data = namespace(counter=0, brut=0, tax=0) %}
...
{% for field in registration.field_data if field.actual_price %}
{% set data.counter = data.counter + 1 %}
{% set tv = field.actual_price * 0.16666666 %}
{% set data.brut = data.brut + field.actual_price %} // if this line and
{% set data.tax = data.tax + tv %} // and this line are removed the error disappears, but obvs wrong values
... some printing ...
{% endfor %}
I suppose that I need to cast in the set data line, but it’s not clear to me how I’d do it in the template.
Thanks. Those changes cause the template to render.
Still I’m curious - is there a way to perform the calculation in decimal?
I mean I get that multiplying with that odd value for tax would need to be in float. But the line {% set data.brut = data.brut + field.actual_price %} looks like it should be possible without introducing rounding.
That’s fine and I can work around it. It’s just surprising as it was not required for previous version and the template editor still seems fine without these adjustments.
When I edit the template and do the “old” calculation (without the float conversion), it renders the “How to build a Stargate” Receipt preview without error.