Skip to content

Commit

Permalink
refactor!: change pay_subsidy_granted to string value, extract to new…
Browse files Browse the repository at this point in the history
… types
  • Loading branch information
sirtawast committed Sep 13, 2023
1 parent 1f3b45f commit 085da70
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -753,10 +753,6 @@ def _validate_co_operation_negotiations(
def _validate_pay_subsidy(
self, pay_subsidy_granted, pay_subsidy_percent, additional_pay_subsidy_percent
):
if pay_subsidy_granted and pay_subsidy_percent is None:
raise serializers.ValidationError(
{"pay_subsidy_percent": _("Pay subsidy percent required")}
)
if not pay_subsidy_granted:
for key in ["pay_subsidy_percent", "additional_pay_subsidy_percent"]:
if locals()[key] is not None:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Generated by Django 3.2.18 on 2023-09-11 11:28

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('applications', '0039_alter_paysubsidy_percentages'),
]

operations = [
migrations.AlterField(
model_name='application',
name='benefit_type',
field=models.CharField(blank=True, choices=[('employment_benefit', 'Employment Benefit'), ('salary_benefit', 'Salary Benefit'), ('commission_benefit', 'Commission Benefit'), ('unclarified_benefit', 'Unclarified Benefit')], max_length=64),
),
migrations.AlterField(
model_name='application',
name='pay_subsidy_granted',
field=models.CharField(blank=True, choices=[('aged', 'aged'), ('default', 'default'), ('none', 'none')], max_length=128, null=True),
),
migrations.AlterField(
model_name='historicalapplication',
name='benefit_type',
field=models.CharField(blank=True, choices=[('employment_benefit', 'Employment Benefit'), ('salary_benefit', 'Salary Benefit'), ('commission_benefit', 'Commission Benefit'), ('unclarified_benefit', 'Unclarified Benefit')], max_length=64),
),
migrations.AlterField(
model_name='historicalapplication',
name='pay_subsidy_granted',
field=models.CharField(blank=True, choices=[('aged', 'aged'), ('default', 'default'), ('none', 'none')], max_length=128, null=True),
),
]
6 changes: 5 additions & 1 deletion backend/benefit/applications/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
("en", "english"),
)

PAY_SUBSIDY_TYPES = (("aged", "aged"), ("default", "default"), ("none", "none"))

PAY_SUBSIDY_PERCENT_CHOICES = (
(50, "50%"),
(70, "70%"),
Expand Down Expand Up @@ -255,7 +257,9 @@ class Application(UUIDModel, TimeStampedModel, DurationMixin):
blank=True,
)

pay_subsidy_granted = models.BooleanField(null=True)
pay_subsidy_granted = models.CharField(
null=True, choices=PAY_SUBSIDY_TYPES, max_length=128, blank=True
)

# The PaySubsidy model stores the values entered by handlers for the calculation.
# This field is filled by the applicant.
Expand Down

0 comments on commit 085da70

Please sign in to comment.