Skip to content

Commit

Permalink
feat: change paysubsidy to string, remove validations
Browse files Browse the repository at this point in the history
  • Loading branch information
sirtawast committed Sep 13, 2023
1 parent 33ba20b commit 080fc0e
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 8 deletions.
10 changes: 4 additions & 6 deletions backend/benefit/applications/api/v1/serializers/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@ def _get_handler_attachment_requirements(application):
return []

def get_attachment_requirements(self, obj):
print(obj.benefit_type)
if obj.apprenticeship_program:
return (
[
Expand All @@ -580,6 +581,7 @@ def get_attachment_requirements(self, obj):
elif obj.benefit_type in [
BenefitType.EMPLOYMENT_BENEFIT,
BenefitType.SALARY_BENEFIT,
BenefitType.UNCLARIFIED_BENEFIT,
]:
return (
[
Expand Down Expand Up @@ -752,10 +754,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 Expand Up @@ -862,7 +860,7 @@ def _validate_benefit_type(
apprenticeship_program,
pay_subsidy_granted,
):
if benefit_type == "":
if benefit_type == "unclarified_benefit":
return
if (
benefit_type
Expand All @@ -888,7 +886,7 @@ def _get_available_benefit_types(
Make the logic of determining available benefit types available both for generating the list of
benefit types and validating the incoming data
"""

return [BenefitType.UNCLARIFIED_BENEFIT]
if (
OrganizationType.resolve_organization_type(company.company_form_code)
== OrganizationType.ASSOCIATION
Expand Down
1 change: 1 addition & 0 deletions backend/benefit/applications/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class BenefitType(models.TextChoices):
EMPLOYMENT_BENEFIT = "employment_benefit", _("Employment Benefit")
SALARY_BENEFIT = "salary_benefit", _("Salary Benefit")
COMMISSION_BENEFIT = "commission_benefit", _("Commission Benefit")
UNCLARIFIED_BENEFIT = "unclarified_benefit", _("Unclarified Benefit")


class ApplicationStep(models.TextChoices):
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),
),
]
12 changes: 10 additions & 2 deletions 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 Expand Up @@ -306,12 +310,16 @@ def get_available_benefit_types(self):
self.is_association_application()
and not self.association_has_business_activities
):
return [BenefitType.SALARY_BENEFIT]
return [
BenefitType.SALARY_BENEFIT,
BenefitType.UNCLARIFIED_BENEFIT,
]
else:
return [
BenefitType.SALARY_BENEFIT,
BenefitType.COMMISSION_BENEFIT,
BenefitType.EMPLOYMENT_BENEFIT,
BenefitType.UNCLARIFIED_BENEFIT,
]

"""
Expand Down

0 comments on commit 080fc0e

Please sign in to comment.