Merge branch 'main' into storefront-nuxt

This commit is contained in:
Egor Pavlovich Gorbunov 2025-11-17 16:03:10 +03:00
commit 3e20e70bd1
2 changed files with 25 additions and 3 deletions

View file

@ -1,5 +1,5 @@
{% extends 'admin/base.html' %}
{% load i18n unfold static %}
{% load i18n unfold static arith %}
{% block title %}
{% if subtitle %}
@ -68,7 +68,7 @@
{% endcomponent %}
{% if total and total > 0 %}
{% with net=revenue_net_30|default:0 %}
{% with tax_amt=gross|add:-net %}
{% with tax_amt=gross|sub:net %}
{% with returns_capped=returns %}
{% if returns > gross %}
{% with returns_capped=gross %}{% endwith %}
@ -77,7 +77,7 @@
{% if tax_amt_pos < 0 %}
{% with tax_amt_pos=0 %}{% endwith %}
{% endif %}
{% with net_for_pie=gross|add:-tax_amt_pos|add:-returns_capped %}
{% with net_for_pie=gross|sub:tax_amt_pos|sub:returns_capped %}
{% if net_for_pie < 0 %}
{% with net_for_pie=0 %}{% endwith %}
{% endif %}

View file

@ -0,0 +1,22 @@
from contextlib import suppress
from django import template
register = template.Library()
def _to_float(val: object) -> float:
conv: float = 0.0
with suppress(Exception):
return float(val) # type: ignore [arg-type]
return conv
@register.filter(name="sub")
def sub(value: object, arg: object) -> float:
return _to_float(value) - _to_float(arg)
@register.filter(name="neg")
def neg(value: object) -> float:
return -_to_float(value)