From e2eab588507888d9f338f71af0f91b242d23e603 Mon Sep 17 00:00:00 2001 From: Horilla Date: Fri, 15 Mar 2024 16:37:29 +0530 Subject: [PATCH] [UPDT] PAYROLL: Allowance and deduction card style and form submission updates --- payroll/models/models.py | 14 +++++ .../payroll/allowance/card_allowance.html | 29 +++++----- .../payroll/deduction/card_deduction.html | 55 ++++++++++--------- 3 files changed, 58 insertions(+), 40 deletions(-) diff --git a/payroll/models/models.py b/payroll/models/models.py index fac699b2b..8be97b680 100644 --- a/payroll/models/models.py +++ b/payroll/models/models.py @@ -963,6 +963,13 @@ class Allowance(models.Model): self.field = None self.condition = None self.value = None + if not self.is_fixed: + if not self.based_on: + raise ValidationError( + _( + "If the 'Is fixed' field is disabled, the 'Based on' field is required." + ) + ) if self.is_condition_based: if not self.field or not self.value or not self.condition: raise ValidationError( @@ -1221,6 +1228,13 @@ class Deduction(models.Model): if self.is_tax: self.is_pretax = False + if not self.is_fixed: + if not self.based_on: + raise ValidationError( + _( + "If the 'Is fixed' field is disabled, the 'Based on' field is required." + ) + ) if self.is_pretax and self.based_on in ["taxable_gross_pay"]: raise ValidationError( { diff --git a/payroll/templates/payroll/allowance/card_allowance.html b/payroll/templates/payroll/allowance/card_allowance.html index ef885934e..29ad84411 100644 --- a/payroll/templates/payroll/allowance/card_allowance.html +++ b/payroll/templates/payroll/allowance/card_allowance.html @@ -28,13 +28,8 @@
{{allowance}} -
-
- {% trans "Taxable" %} - {{allowance.is_taxable|yesno|capfirst}} -
-
- {% trans "Amount" %} + + {% trans "Amount" %} {% if allowance.is_fixed %} {{allowance.amount}} {% else %} @@ -54,16 +49,22 @@ {{allowance.amount_per_one_hr}} {{currency}} {% trans "Amount Per One Hour" %} {% endif %} {% endif %} + +
+
+ {% trans "One Time Allowance" %} + {% if allowance.one_time_date %} + {% trans "On" %} {{allowance.one_time_date}} + {% else %} + {% trans "No" %} + {% endif %} +
+
+ {% trans "Taxable" %} + {{allowance.is_taxable|yesno|capfirst}}
- {% trans "One Time Allowance" %} - {% if allowance.one_time_date %} - {% trans "On" %} {{allowance.one_time_date}} - {% else %} - {% trans "No" %} - {% endif %} -
diff --git a/payroll/templates/payroll/deduction/card_deduction.html b/payroll/templates/payroll/deduction/card_deduction.html index 8d0c092c3..d069eeebd 100644 --- a/payroll/templates/payroll/deduction/card_deduction.html +++ b/payroll/templates/payroll/deduction/card_deduction.html @@ -18,37 +18,40 @@
{{deduction}} + + {% trans "Amount" %} + {% if deduction.update_compensation %} + {% if deduction.is_fixed %} + {{deduction.amount}}{{currency}} Deduct From {{deduction.get_update_compensation_display}} + {% else %} + {{deduction.rate}}% {% trans "of" %} {{deduction.get_update_compensation_display}} + {% endif %} + {% else %} + {% if deduction.is_fixed %} + {{deduction.amount}}{{currency}} + {% else %} + {% trans "Employer Rate :" %} {{deduction.employer_rate}}% {% trans "of" %} {{deduction.get_based_on_display}} + {% trans "Employee Rate :" %} {{deduction.rate}}% {% trans "of" %} {{deduction.get_based_on_display}} + {% endif %} + {% endif %} + +
-
- {% trans "Taxable" %} - {{deduction.is_tax|yesno|capfirst}} +
+ {% trans "One Time Deduction" %} + {% if deduction.one_time_date %} + {% trans "On" %} {{deduction.one_time_date}} + {% else %} + {% trans "No" %} + {% endif %} +
-
- {% trans "Amount" %} - {% if deduction.update_compensation %} - {% if deduction.is_fixed %} - {{deduction.amount}}{{currency}} Deduct From {{deduction.get_update_compensation_display}} - {% else %} - {{deduction.rate}}% {% trans "of" %} {{deduction.get_update_compensation_display}} - {% endif %} - {% else %} - {% if deduction.is_fixed %} - {{deduction.amount}}{{currency}} - {% else %} - {% trans "Employer Rate :" %} {{deduction.employer_rate}}% {% trans "of" %} {{deduction.get_based_on_display}} - {% trans "Employee Rate :" %} {{deduction.rate}}% {% trans "of" %} {{deduction.get_based_on_display}} - {% endif %} - {% endif %} +
+ {% trans "Pretax" %} + {{deduction.is_pretax|yesno|capfirst}}
- {% trans "One Time Allowance" %} - {% if allowance.one_time_date %} - {% trans "On" %} {{allowance.one_time_date}} - {% else %} - {% trans "No" %} - {% endif %} -