diff --git a/invoices/models.py b/invoices/models.py index 89dcd50..93fcfc9 100644 --- a/invoices/models.py +++ b/invoices/models.py @@ -137,11 +137,11 @@ class Quote(NameSlugModel): return '{}'.format(color, self.get_status_display()) def get_paid_amount(self): - """مبلغ پرداخت شده برای این پیشفاکتور بر اساس پرداختهای فاکتور مرتبط""" + """خالص پرداختی (دریافتی از مشتری منهای پرداختی به مشتری) برای این پیشفاکتور بر اساس پرداختهای فاکتور مرتبط""" invoice = Invoice.objects.filter(quote=self).first() if not invoice: return Decimal('0') - return sum(p.amount for p in invoice.payments.filter(is_deleted=False).all()) + return sum((p.amount if p.direction == 'in' else -p.amount) for p in invoice.payments.filter(is_deleted=False).all()) def get_remaining_amount(self): """مبلغ باقیمانده بر اساس پرداختها""" diff --git a/invoices/templates/invoices/quote_payment_step.html b/invoices/templates/invoices/quote_payment_step.html index 4a071f8..05096e4 100644 --- a/invoices/templates/invoices/quote_payment_step.html +++ b/invoices/templates/invoices/quote_payment_step.html @@ -153,6 +153,7 @@
| نوع | مبلغ | تاریخ پرداخت/سررسید چک | روش | @@ -163,7 +164,8 @@||
|---|---|---|---|---|---|
| {{ p.amount|floatformat:0|intcomma:False }} تومان | +{% if p.direction == 'in' %}دریافتی{% else %}پرداختی{% endif %} | +{{ p.amount|floatformat:0|intcomma:False }} تومان | {{ p.jpayment_date }} | {{ p.get_payment_method_display }} | {{ p.reference_number|default:'-' }} | @@ -175,9 +177,7 @@ {% endif %} {% if is_broker %} - + {% endif %}