Skip to content

Commit

Permalink
[UPDT] PAYROLL: Added validations to loan creation
Browse files Browse the repository at this point in the history
  • Loading branch information
horilla-opensource committed Aug 22, 2024
1 parent 3cf4a19 commit e827927
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions payroll/forms/component_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,21 @@ def __init__(self, *args, **kwargs):
if field in self.fields:
del self.fields[field]

def clean(self, *args, **kwargs):
cleaned_data = super().clean(*args, **kwargs)

if cleaned_data.get("installment_start_date") < cleaned_data.get(
"provided_date"
):
raise forms.ValidationError(
"Installment start date should be greater than or equal to provided date"
)

if cleaned_data.get("installments") <= 0:
raise forms.ValidationError("Installments needs to be a positive integer")

return cleaned_data


class AssetFineForm(LoanAccountForm):
verbose_name = "Asset Fine"
Expand Down

0 comments on commit e827927

Please sign in to comment.