[UPDT] PAYROLL: Added total, paid and balance amount to installment view

This commit is contained in:
Horilla
2024-08-22 17:36:01 +05:30
parent e8279272f5
commit 358a1581f0
2 changed files with 25 additions and 2 deletions

View File

@@ -70,7 +70,21 @@
</a>
<div class="oh-modal__dialog-header" style="padding-top: 5px">
<h3 class="oh-faq-card__title">{{loan.title}}</h3>
{% comment %} <h3 class="oh-faq-card__title">{{loan.loan_amount}}</h3> {% endcomment %}
<div class="container">
<div class="row">
<div class="col-md-4">
<b>{% trans "Total Amount" %} :</b> <div>{{loan.loan_amount}} </div>
</div>
<div class="col-md-4">
<b>{% trans "Paid Amount" %} :</b><div> {{installments|paid_amount}}</div>
</div>
<div class="col-md-4">
<b>{% trans "Balance Amount" %} :</b> <div>{{loan.loan_amount|balance_amount:installments}} </div>
</div>
</div>
</div>
<div class="oh-sticky-table__table mt-3" id="deductionContainer">
{% if messages %}
<div class="oh-wrapper">

View File

@@ -3,7 +3,16 @@ from django import template
register = template.Library()
@register.filter(name="paid_amount")
def paid_amount(installment):
paid = [
deduction.amount for deduction in installment if deduction.installment_payslip()
]
return sum(paid)
@register.filter(name="balance_amount")
def balance_amount(amount, installment):
balance = amount - sum(installment.values_list("amount", flat=True))
balance = amount - paid_amount(installment)
return balance