[UPDT] PAYROLL: Updated payroll allowance and deduction create,edit method by adding one more condition in def clean()

This commit is contained in:
Horilla
2024-05-20 14:22:19 +05:30
parent 919ed300ca
commit e9b0f8e46f

View File

@@ -939,6 +939,11 @@ class Allowance(HorillaModel):
"If the 'Is fixed' field is disabled, the 'Based on' field is required."
)
)
if not self.is_fixed and self.based_on and self.based_on == "basic_pay":
if not self.rate:
raise ValidationError(
_("Rate must be specified for allowances based on basic pay.")
)
if self.is_condition_based:
if not self.field or not self.value or not self.condition:
raise ValidationError(
@@ -1206,6 +1211,13 @@ class Deduction(HorillaModel):
"If the 'Is fixed' field is disabled, the 'Based on' field is required."
)
)
if not self.is_fixed and self.based_on and not self.rate:
raise ValidationError(
_(
"Employee rate must be specified for deductions that are not fixed amount"
)
)
if self.is_pretax and self.based_on in ["taxable_gross_pay"]:
raise ValidationError(
{