diff --git a/payroll/methods/payslip_calc.py b/payroll/methods/payslip_calc.py index 4166838fd..7f52d342b 100644 --- a/payroll/methods/payslip_calc.py +++ b/payroll/methods/payslip_calc.py @@ -22,6 +22,11 @@ from payroll.models.models import ( MultipleCondition, ) + +def return_none(a, b): + return None + + operator_mapping = { "equal": operator.eq, "notequal": operator.ne, @@ -30,6 +35,7 @@ operator_mapping = { "le": operator.le, "ge": operator.ge, "icontains": operator.contains, + "range": return_none, } filter_mapping = { "work_type_id": { diff --git a/payroll/models/models.py b/payroll/models/models.py index 94db2024b..83876ea8e 100644 --- a/payroll/models/models.py +++ b/payroll/models/models.py @@ -18,6 +18,7 @@ from django.utils import timezone from django.utils.translation import gettext_lazy as _ from base.horilla_company_manager import HorillaCompanyManager +from base.methods import get_next_month_same_date from base.models import ( Company, Department, @@ -1508,19 +1509,10 @@ class LoanAccount(HorillaModel): installment_schedule = {} installment_date = installment_start_date - installment_date_copy = installment_start_date installment_schedule = {} for _ in range(total_installments): installment_schedule[str(installment_date)] = installment_amount - month = installment_date.month + 1 - year = installment_date.year - if month > 12: - month = 1 - year = year + 1 - day = installment_date_copy.day - total_days_in_month = calendar.monthrange(year, month)[1] - day = min(day, total_days_in_month) - installment_date = date(day=day, month=month, year=year) + installment_date = get_next_month_same_date(installment_date) return installment_schedule @@ -1561,7 +1553,7 @@ class LoanAccount(HorillaModel): def _create_deductions(instance, amount, date): installment = Deduction() - installment.title = instance.title + installment.title = f"{instance.title} - {date}" installment.include_active_employees = False installment.amount = amount installment.is_fixed = True diff --git a/payroll/templates/payroll/loan/installments.html b/payroll/templates/payroll/loan/installments.html index cca66f81b..d7f607ac0 100644 --- a/payroll/templates/payroll/loan/installments.html +++ b/payroll/templates/payroll/loan/installments.html @@ -70,7 +70,19 @@

{{loan.title}}

-
+ {% comment %}

{{loan.loan_amount}}

{% endcomment %} +
+ {% if messages %} +
+ {% for message in messages %} +
+
+ {{ message }} +
+
+ {% endfor %} +
+ {% endif %}
{{ deduction.one_time_date }}
-
- {{ deduction.amount|floatformat:2 }} -
+
{% if deduction.installment_payslip %} @@ -151,3 +173,17 @@
+ + diff --git a/payroll/urls/component_urls.py b/payroll/urls/component_urls.py index 492785a4a..763fffdc2 100644 --- a/payroll/urls/component_urls.py +++ b/payroll/urls/component_urls.py @@ -101,6 +101,11 @@ urlpatterns = [ component_views.view_installments, name="view-installments", ), + path( + "edit-installment-amount/", + component_views.edit_installment_amount, + name="edit-installment-amount", + ), path("delete-loan/", component_views.delete_loan, name="delete-loan"), path("search-loan/", component_views.search_loan, name="search-loan"), path(