Allow to round taxes on order-level (#5019)

* Allow to round taxes on order-level

* Rename get_cart_total

* Persist rounding mode with order

* Add general docs

* Order creation API

* Update fee algorithm

* Rounding on payment method change

* Round when splitting order

* Fix failing tests

* Add settings page

* Add tests

* Replace algorithm

* Add test case for currency rounding

* Improve order change

* Update flowchart

* Update discount logic (more hypothetical, we don't store rounding on cart positions atm)

* Rename internal method

* Fix typo

* Update help text

* Apply suggestions from code review

Co-authored-by: luelista <weller@rami.io>

* Order rounding refactor (#5571)

* Add RoundingCorrectionMixin providing before-rounding-values as properties

* Use gross_price_before_rounding in more places

* Update doc/development/algorithms/pricing.rst

Co-authored-by: Martin Gross <gross@rami.io>

* Allow to override on perform_order

* Rebase migration

* Fix event cancellation

---------

Co-authored-by: luelista <weller@rami.io>
Co-authored-by: Martin Gross <gross@rami.io>
This commit is contained in:
Raphael Michel
2025-10-30 11:49:31 +01:00
committed by GitHub
parent cdeb1e86bd
commit 3e972eddbf
37 changed files with 1923 additions and 319 deletions

View File

@@ -681,6 +681,16 @@
</small>
{% endif %}
{% endif %}
{% if django_settings.DEBUG %}
<br/>
<small class="admin-only">
price = {{ line.price|floatformat:2 }}<br>
rounding_correction = {{ line.price_includes_rounding_correction|floatformat:2 }}<br>
tax_value = {{ line.tax_value|floatformat:2 }}<br>
tax_value_rounding_correction = {{ line.tax_value_includes_rounding_correction|floatformat:2 }}<br>
voucher_budget_use = {{ line.voucher_budget_use|floatformat:2 }}
</small>
{% endif %}
</div>
<div class="clearfix"></div>
</div>
@@ -721,6 +731,16 @@
</small>
{% endif %}
{% endif %}
{% if django_settings.DEBUG %}
<br/>
<small class="admin-only">
price = {{ fee.value|floatformat:2 }}<br>
rounding_correction = {{ fee.value_includes_rounding_correction|floatformat:2 }}<br>
tax_value = {{ fee.tax_value|floatformat:2 }}<br>
tax_value_rounding_correction = {{ fee.tax_value_includes_rounding_correction|floatformat:2 }}<br>
voucher_budget_use = {{ fee.voucher_budget_use|floatformat:2 }}
</small>
{% endif %}
</div>
<div class="clearfix"></div>
</div>
@@ -749,6 +769,10 @@
</div>
<div class="col-md-3 col-xs-6 col-md-offset-5 price">
<strong>{{ items.total|money:event.currency }}</strong>
<br/>
<small class="admin-only">
tax_rounding_mode = {{ order.tax_rounding_mode }}
</small>
</div>
<div class="clearfix"></div>
</div>

View File

@@ -56,8 +56,26 @@
<td>{{ t.get_tax_code_display }}</td>
<td class="text-right flip">{{ t.count }} &times;</td>
<td class="text-right flip">{{ t.price|money:request.event.currency }}</td>
<td class="text-right flip">{{ t.full_tax_value|money:request.event.currency }}</td>
<td class="text-right flip">{{ t.full_price|money:request.event.currency }}</td>
<td class="text-right flip">
{{ t.full_tax_value|money:request.event.currency }}
{% if t.full_price_includes_rounding_correction %}
<br><small>
{% blocktrans trimmed with amount=t.full_tax_value_includes_rounding_correction|money:request.event.currency %}
incl. {{ amount }} rounding correction
{% endblocktrans %}
</small>
{% endif %}
</td>
<td class="text-right flip">
{{ t.full_price|money:request.event.currency }}
{% if t.full_price_includes_rounding_correction %}
<br><small>
{% blocktrans trimmed with amount=t.full_price_includes_rounding_correction|money:request.event.currency %}
incl. {{ amount }} rounding correction
{% endblocktrans %}
</small>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>