diff --git a/backend/benefit/applications/api/v1/serializers/application.py b/backend/benefit/applications/api/v1/serializers/application.py index ac7033a22f..711bbab066 100755 --- a/backend/benefit/applications/api/v1/serializers/application.py +++ b/backend/benefit/applications/api/v1/serializers/application.py @@ -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 ( [ @@ -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 ( [ @@ -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: @@ -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 @@ -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 diff --git a/backend/benefit/applications/enums.py b/backend/benefit/applications/enums.py index 269b1732f3..fb742effbb 100644 --- a/backend/benefit/applications/enums.py +++ b/backend/benefit/applications/enums.py @@ -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): diff --git a/backend/benefit/applications/migrations/0040_alter_benefit_type_and_pay_subsidy_granted.py b/backend/benefit/applications/migrations/0040_alter_benefit_type_and_pay_subsidy_granted.py new file mode 100644 index 0000000000..780e01deed --- /dev/null +++ b/backend/benefit/applications/migrations/0040_alter_benefit_type_and_pay_subsidy_granted.py @@ -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), + ), + ] diff --git a/backend/benefit/applications/models.py b/backend/benefit/applications/models.py index 2375d33364..44bfa63c6a 100755 --- a/backend/benefit/applications/models.py +++ b/backend/benefit/applications/models.py @@ -37,6 +37,8 @@ ("en", "english"), ) +PAY_SUBSIDY_TYPES = (("aged", "aged"), ("default", "default"), ("none", "none")) + PAY_SUBSIDY_PERCENT_CHOICES = ( (50, "50%"), (70, "70%"), @@ -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. @@ -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, ] """