diff --git a/backend/order/templatetags/__init__.py b/backend/order/templatetags/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/backend/order/templatetags/price_filters.py b/backend/order/templatetags/price_filters.py new file mode 100644 index 0000000..0895e62 --- /dev/null +++ b/backend/order/templatetags/price_filters.py @@ -0,0 +1,18 @@ +from django import template + +register = template.Library() + + +@register.filter(name='price_format') +def price_format(value): + """ + Format a number with thousand separators (commas). + Example: 1234567 -> 1,234,567 + """ + try: + # Convert to int to remove decimals + value = int(float(value)) + # Format with thousand separators + return "{:,}".format(value) + except (ValueError, TypeError): + return value diff --git a/backend/templates/order/invoice_order.html b/backend/templates/order/invoice_order.html index 834baeb..824a69a 100644 --- a/backend/templates/order/invoice_order.html +++ b/backend/templates/order/invoice_order.html @@ -1,4 +1,4 @@ -{% load humanize %} +{% load price_filters %} @@ -277,22 +277,22 @@ {{ item_data.item.product.product.name }} {{ item_data.item.product.title }} {{ item_data.item.quantity }} - {{ item_data.price_before_discount|floatformat:0|intcomma }} تومان + {{ item_data.price_before_discount|price_format }} تومان {% if item_data.item.discount_percent > 0 %} - {{ item_data.item.discount_percent }}% ({{ item_data.discount_amount|floatformat:0|intcomma }} تومان) + {{ item_data.item.discount_percent }}% ({{ item_data.discount_amount|price_format }} تومان) {% else %} --- {% endif %} {% if item_data.item.special_discount_amount > 0 %} - {{ item_data.item.special_discount_amount|floatformat:0|intcomma }} تومان + {{ item_data.item.special_discount_amount|price_format }} تومان {% else %} --- {% endif %} - {{ item_data.item.price|floatformat:0|intcomma }} تومان + {{ item_data.item.price|price_format }} تومان {% endfor %} @@ -306,27 +306,27 @@
جمع کل: - {{ subtotal|floatformat:0|intcomma }} تومان + {{ subtotal|price_format }} تومان
{% if discount_amount > 0 %}
تخفیف کد: - {{ discount_amount|floatformat:0|intcomma }} تومان + {{ discount_amount|price_format }} تومان
{% endif %} {% if special_discount_total > 0 %}
تخفیف ویژه: - {{ special_discount_total|floatformat:0|intcomma }} تومان + {{ special_discount_total|price_format }} تومان
{% endif %}
مالیات: - {{ tax|floatformat:0|intcomma }} تومان + {{ tax|price_format }} تومان
مبلغ قابل پرداخت: - {{ final_price|floatformat:0|intcomma }} تومان + {{ final_price|price_format }} تومان
diff --git a/backend/templates/order/invoice_shop_order.html b/backend/templates/order/invoice_shop_order.html index 4891106..0f10123 100644 --- a/backend/templates/order/invoice_shop_order.html +++ b/backend/templates/order/invoice_shop_order.html @@ -1,4 +1,4 @@ -{% load humanize %} +{% load price_filters %} @@ -354,22 +354,22 @@ {{ item.order_item.product.product.name }} {{ item.order_item.product.title }} {{ item.quantity }} - {{ item.unit_price|floatformat:0|intcomma }} تومان + {{ item.unit_price|price_format }} تومان {% if item.discount_amount > 0 %} - {{ item.order_item.discount_percent }}% ({{ item.discount_amount|floatformat:0|intcomma }} تومان) + {{ item.order_item.discount_percent }}% ({{ item.discount_amount|price_format }} تومان) {% else %} --- {% endif %} {% if item.special_discount_amount > 0 %} - {{ item.special_discount_amount|floatformat:0|intcomma }} تومان + {{ item.special_discount_amount|price_format }} تومان {% else %} --- {% endif %} - {{ item.total_price|floatformat:0|intcomma }} تومان + {{ item.total_price|price_format }} تومان {% endfor %} @@ -384,23 +384,23 @@
جمع کل (Subtotal): - {{ subtotal|floatformat:0|intcomma }} تومان + {{ subtotal|price_format }} تومان
{% if discount_amount > 0 %}
تخفیف معمولی: - {{ discount_amount|floatformat:0|intcomma }} تومان + {{ discount_amount|price_format }} تومان
{% endif %} {% if special_discount_amount > 0 %}
تخفیف ویژه: - {{ special_discount_amount|floatformat:0|intcomma }} تومان + {{ special_discount_amount|price_format }} تومان
{% endif %}
مالیات: - {{ tax_amount|floatformat:0|intcomma }} تومان + {{ tax_amount|price_format }} تومان
@@ -412,7 +412,7 @@
مبلغ کمیسیون: - {{ commission_amount|floatformat:0|intcomma }} تومان + {{ commission_amount|price_format }} تومان
@@ -420,7 +420,7 @@

مبلغ نهایی

مبلغ قابل پرداخت به فروشگاه: - {{ payable_amount|floatformat:0|intcomma }} تومان + {{ payable_amount|price_format }} تومان