From 191d031688bb95f1d5f4c5310bb13d2ec295e137 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilia=20M=C3=A4kel=C3=A4?= Date: Mon, 19 Feb 2024 10:55:32 +0200 Subject: [PATCH] feat: add model for application alterations --- backend/benefit/applications/enums.py | 5 + .../migrations/0059_applicationalteration.py | 38 ++++++++ backend/benefit/applications/models.py | 91 +++++++++++++++++++ .../benefit/locale/en/LC_MESSAGES/django.po | 57 +++++++++++- .../benefit/locale/fi/LC_MESSAGES/django.po | 63 ++++++++++++- .../benefit/locale/sv/LC_MESSAGES/django.po | 74 ++++++++++++++- 6 files changed, 313 insertions(+), 15 deletions(-) create mode 100644 backend/benefit/applications/migrations/0059_applicationalteration.py diff --git a/backend/benefit/applications/enums.py b/backend/benefit/applications/enums.py index 0f60ea5ea3..0855afb7dd 100644 --- a/backend/benefit/applications/enums.py +++ b/backend/benefit/applications/enums.py @@ -207,3 +207,8 @@ class DecisionProposalTemplateSectionType(models.TextChoices): class DecisionType(models.TextChoices): ACCEPTED = "accepted_decision", _("An accepted decision") DENIED = "denied_decision", _("A denied decision") + + +class ApplicationAlterationType(models.TextChoices): + TERMINATION = "termination", _("Termination") + SUSPENSION = "suspension", _("Suspension") diff --git a/backend/benefit/applications/migrations/0059_applicationalteration.py b/backend/benefit/applications/migrations/0059_applicationalteration.py new file mode 100644 index 0000000000..a6bfb49772 --- /dev/null +++ b/backend/benefit/applications/migrations/0059_applicationalteration.py @@ -0,0 +1,38 @@ +# Generated by Django 3.2.23 on 2024-02-22 08:04 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('applications', '0058_alter_historicalapplication_history_change_reason'), + ] + + operations = [ + migrations.CreateModel( + name='ApplicationAlteration', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='time created')), + ('modified_at', models.DateTimeField(auto_now=True, verbose_name='time modified')), + ('alteration_type', models.TextField(choices=[('termination', 'Termination'), ('suspension', 'Suspension')], verbose_name='type of alteration')), + ('end_date', models.DateField(verbose_name='new benefit end date')), + ('resume_date', models.DateField(blank=True, null=True, verbose_name='date when employment resumes after suspended')), + ('reason', models.TextField(verbose_name='reason for alteration')), + ('handled_at', models.DateField(blank=True, null=True, verbose_name='date when alteration notice was handled')), + ('recovery_start_date', models.DateField(blank=True, null=True, verbose_name='the first day the unwarranted benefit will be collected from')), + ('recovery_end_date', models.DateField(blank=True, null=True, verbose_name='the last day the unwarranted benefit will be collected from')), + ('recovery_amount', models.DecimalField(decimal_places=2, max_digits=8, null=True, verbose_name='amount of unwarranted benefit to be collected')), + ('use_alternate_einvoice_provider', models.BooleanField(default=False, verbose_name='whether to use a separate e-invoice address from the one of the applicant organization')), + ('einvoice_provider_name', models.TextField(blank=True, verbose_name='name of the e-invoice provider')), + ('einvoice_provider_identifier', models.TextField(blank=True, verbose_name='identifier of the e-invoice provider')), + ('einvoice_address', models.TextField(blank=True, verbose_name='e-invoice address')), + ('application', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='alteration_set', to='applications.application', verbose_name='alteration of application')), + ], + options={ + 'abstract': False, + }, + ), + ] diff --git a/backend/benefit/applications/models.py b/backend/benefit/applications/models.py index c82732acb4..311affa46b 100755 --- a/backend/benefit/applications/models.py +++ b/backend/benefit/applications/models.py @@ -13,6 +13,7 @@ from applications.enums import ( AhjoDecision, AhjoStatus, + ApplicationAlterationType, ApplicationBatchStatus, ApplicationOrigin, ApplicationStatus, @@ -377,6 +378,20 @@ def calculated_benefit_amount(self): else: return None + @property + def calculated_effective_benefit_amount(self): + original_benefit = self.calculated_benefit_amount + + if original_benefit is not None and self.alteration_set is not None: + return original_benefit - sum( + [ + alteration.collection_amount + for alteration in self.alteration_set.all() + ] + ) + else: + return original_benefit + @property def ahjo_decision(self): if self.batch: @@ -1023,3 +1038,79 @@ class Meta: db_table = "bf_applications_ahjo_decision_text" verbose_name = _("ahjo decision text") verbose_name_plural = _("ahjo decision texts") + + +class ApplicationAlteration(TimeStampedModel): + """ + An alteration reported by the applying organization, due to changes in + the employment of the employee in question. An application may have + multiple alterations applied to it. + """ + + application = models.ForeignKey( + Application, + verbose_name=_("alteration of application"), + related_name="alteration_set", + on_delete=models.CASCADE, + ) + + alteration_type = models.TextField( + verbose_name=_("type of alteration"), choices=ApplicationAlterationType.choices + ) + + end_date = models.DateField(verbose_name=_("new benefit end date")) + + resume_date = models.DateField( + verbose_name=_("date when employment resumes after suspended"), + null=True, + blank=True, + ) + + reason = models.TextField(verbose_name=_("reason for alteration")) + + handled_at = models.DateField( + verbose_name=_("date when alteration notice was handled"), + null=True, + blank=True, + ) + + recovery_start_date = models.DateField( + verbose_name=_("the first day the unwarranted benefit will be collected from"), + null=True, + blank=True, + ) + + recovery_end_date = models.DateField( + verbose_name=_("the last day the unwarranted benefit will be collected from"), + null=True, + blank=True, + ) + + recovery_amount = models.DecimalField( + max_digits=8, + decimal_places=2, + verbose_name=_("amount of unwarranted benefit to be collected"), + null=True, + ) + + use_alternate_einvoice_provider = models.BooleanField( + verbose_name=_( + "whether to use a separate e-invoice address from the one of the applicant organization" + ), + default=False, + ) + + einvoice_provider_name = models.TextField( + verbose_name=_("name of the e-invoice provider"), + blank=True, + ) + + einvoice_provider_identifier = models.TextField( + verbose_name=_("identifier of the e-invoice provider"), + blank=True, + ) + + einvoice_address = models.TextField( + verbose_name=_("e-invoice address"), + blank=True, + ) diff --git a/backend/benefit/locale/en/LC_MESSAGES/django.po b/backend/benefit/locale/en/LC_MESSAGES/django.po index ece95e439a..fdce927071 100644 --- a/backend/benefit/locale/en/LC_MESSAGES/django.po +++ b/backend/benefit/locale/en/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-01-25 18:30+0200\n" +"POT-Creation-Date: 2024-02-19 10:35+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -374,7 +374,7 @@ msgstr "" msgid "Delete request received" msgstr "" -msgid "Allow/disallow applicant's modifications" +msgid "Allow/disallow applicant's modifications to the application" msgstr "" msgid "Success" @@ -389,6 +389,15 @@ msgstr "" msgid "Delete application in Ahjo" msgstr "" +msgid "Update application in Ahjo" +msgstr "" + +msgid "Termination" +msgstr "" + +msgid "Suspension" +msgstr "" + #, python-brace-format msgid "" "Your application {id} will be deleted soon. If you want to continue the " @@ -632,6 +641,47 @@ msgstr "" msgid "ahjo statuses" msgstr "" +msgid "alteration of application" +msgstr "" + +msgid "type of alteration" +msgstr "" + +msgid "new benefit end date" +msgstr "" + +msgid "date when employment resumes after suspended" +msgstr "" + +msgid "reason for alteration" +msgstr "" + +msgid "date when alteration notice was handled" +msgstr "" + +msgid "the first day the unwarranted benefit will be collected from" +msgstr "" + +msgid "the last day the unwarranted benefit will be collected from" +msgstr "" + +msgid "amount of unwarranted benefit to be collected" +msgstr "" + +msgid "" +"whether to use a separate e-invoice address from the one of the applicant " +"organization" +msgstr "" + +msgid "name of the e-invoice provider" +msgstr "" + +msgid "identifier of the e-invoice provider" +msgstr "" + +msgid "e-invoice address" +msgstr "" + msgid "Not found" msgstr "" @@ -862,9 +912,6 @@ msgstr "" msgid "handler" msgstr "" -msgid "applicant" -msgstr "" - msgid "calculation" msgstr "" diff --git a/backend/benefit/locale/fi/LC_MESSAGES/django.po b/backend/benefit/locale/fi/LC_MESSAGES/django.po index a9436efb00..1335cba64b 100644 --- a/backend/benefit/locale/fi/LC_MESSAGES/django.po +++ b/backend/benefit/locale/fi/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-01-25 18:30+0200\n" +"POT-Creation-Date: 2024-02-19 10:35+0200\n" "PO-Revision-Date: 2022-11-01 10:45+0200\n" "Last-Translator: Kari Salminen \n" "Language-Team: \n" @@ -409,7 +409,7 @@ msgstr "" msgid "Delete request received" msgstr "" -msgid "Allow/disallow applicant's modifications" +msgid "Allow/disallow applicant's modifications to the application" msgstr "" msgid "Success" @@ -428,6 +428,17 @@ msgstr "Hylätty Ahjossa" msgid "Delete application in Ahjo" msgstr "Puutteellinen hakemus" +#, fuzzy +#| msgid "Incomplete application" +msgid "Update application in Ahjo" +msgstr "Puutteellinen hakemus" + +msgid "Termination" +msgstr "Päättynyt" + +msgid "Suspension" +msgstr "Keskeytynyt" + #, python-brace-format msgid "" "Your application {id} will be deleted soon. If you want to continue the " @@ -691,6 +702,48 @@ msgstr "tila" msgid "ahjo statuses" msgstr "tila" +msgid "alteration of application" +msgstr "Muutos hakemukseen" + +msgid "type of alteration" +msgstr "Muutoksen tyyppi" + +msgid "new benefit end date" +msgstr "Uusi avustuksen päättymispäivä" + +msgid "date when employment resumes after suspended" +msgstr "Avustuksen jatkumispäivä keskeytymisen jälkeen" + +msgid "reason for alteration" +msgstr "Muutoksen syy" + +msgid "date when alteration notice was handled" +msgstr "Muutosilmoituksen käsittelypäivä" + +msgid "the first day the unwarranted benefit will be collected from" +msgstr "Takaisinperinnän alkamispäivä" + +msgid "the last day the unwarranted benefit will be collected from" +msgstr "Takaisinperinnän päättymispäivä" + +msgid "amount of unwarranted benefit to be collected" +msgstr "Takaisinperittävä summa" + +msgid "" +"whether to use a separate e-invoice address from the one of the applicant " +"organization" +msgstr "Käytetäänkö eri verkkolaskuosoitetta kuin hakijaorganisaation " +"verkkolaskuosoitetta?" + +msgid "name of the e-invoice provider" +msgstr "Verkkolaskuoperaattorin nimi" + +msgid "identifier of the e-invoice provider" +msgstr "Välittäjän tunnus" + +msgid "e-invoice address" +msgstr "Verkkolaskuosoite" + #, fuzzy #| msgid "File not found." msgid "Not found" @@ -934,9 +987,6 @@ msgstr "Laskelma on jo olemassa" msgid "handler" msgstr "käsittelijä" -msgid "applicant" -msgstr "hakija" - msgid "calculation" msgstr "laskelma" @@ -1211,6 +1261,9 @@ msgstr "palveluehtojen hyväksyntä" msgid "terms of service approvals" msgstr "palveluehtojen hyväksynnät" +#~ msgid "applicant" +#~ msgstr "hakija" + #~ msgid "Social security number checksum invalid" #~ msgstr "Epäkelpo henkilötunnuksen tarkistussumma" diff --git a/backend/benefit/locale/sv/LC_MESSAGES/django.po b/backend/benefit/locale/sv/LC_MESSAGES/django.po index ed9cf4cba3..0e59a83e9a 100644 --- a/backend/benefit/locale/sv/LC_MESSAGES/django.po +++ b/backend/benefit/locale/sv/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-01-25 18:30+0200\n" +"POT-Creation-Date: 2024-02-19 10:35+0200\n" "PO-Revision-Date: 2022-11-01 10:47+0200\n" "Last-Translator: Kari Salminen \n" "Language-Team: \n" @@ -405,7 +405,7 @@ msgstr "" msgid "Delete request received" msgstr "" -msgid "Allow/disallow applicant's modifications" +msgid "Allow/disallow applicant's modifications to the application" msgstr "" msgid "Success" @@ -424,6 +424,17 @@ msgstr "Avvisad i Ahjo" msgid "Delete application in Ahjo" msgstr "Ofullständig ansökan" +#, fuzzy +#| msgid "Incomplete application" +msgid "Update application in Ahjo" +msgstr "Ofullständig ansökan" + +msgid "Termination" +msgstr "" + +msgid "Suspension" +msgstr "" + #, python-brace-format msgid "" "Your application {id} will be deleted soon. If you want to continue the " @@ -687,6 +698,59 @@ msgstr "status" msgid "ahjo statuses" msgstr "status" +#, fuzzy +#| msgid "application batches" +msgid "alteration of application" +msgstr "ansökningssatser" + +#, fuzzy +#| msgid "type of terms" +msgid "type of alteration" +msgstr "typ av villkor" + +#, fuzzy +#| msgid "benefit end date" +msgid "new benefit end date" +msgstr "slutdatum för understöd" + +msgid "date when employment resumes after suspended" +msgstr "" + +msgid "reason for alteration" +msgstr "" + +msgid "date when alteration notice was handled" +msgstr "" + +msgid "the first day the unwarranted benefit will be collected from" +msgstr "" + +msgid "the last day the unwarranted benefit will be collected from" +msgstr "" + +#, fuzzy +#| msgid "amount of the benefit granted, calculated by the system" +msgid "amount of unwarranted benefit to be collected" +msgstr "understödsbelopp som beviljats, beräknat av systemet" + +msgid "" +"whether to use a separate e-invoice address from the one of the applicant " +"organization" +msgstr "" + +#, fuzzy +#| msgid "Name of the employer" +msgid "name of the e-invoice provider" +msgstr "Arbetsgivarens namn" + +msgid "identifier of the e-invoice provider" +msgstr "" + +#, fuzzy +#| msgid "Delivery address" +msgid "e-invoice address" +msgstr "Leveransadress" + #, fuzzy #| msgid "File not found." msgid "Not found" @@ -924,9 +988,6 @@ msgstr "Beräkning finns redan" msgid "handler" msgstr "handläggare" -msgid "applicant" -msgstr "sökande" - msgid "calculation" msgstr "beräkning" @@ -1202,6 +1263,9 @@ msgstr "godkännande av villkoren för tjänsten" msgid "terms of service approvals" msgstr "godkännanden av villkoren för tjänsten" +#~ msgid "applicant" +#~ msgstr "sökande" + #~ msgid "Social security number checksum invalid" #~ msgstr "Personbeteckning kontrollsumma felaktig"