Skip to content

Commit

Permalink
feat: add model for application alterations
Browse files Browse the repository at this point in the history
  • Loading branch information
EmiliaMakelaVincit committed Feb 22, 2024
1 parent 7f88cc5 commit 191d031
Show file tree
Hide file tree
Showing 6 changed files with 313 additions and 15 deletions.
5 changes: 5 additions & 0 deletions backend/benefit/applications/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Original file line number Diff line number Diff line change
@@ -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,
},
),
]
91 changes: 91 additions & 0 deletions backend/benefit/applications/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from applications.enums import (
AhjoDecision,
AhjoStatus,
ApplicationAlterationType,
ApplicationBatchStatus,
ApplicationOrigin,
ApplicationStatus,
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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,
)
57 changes: 52 additions & 5 deletions backend/benefit/locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -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"
Expand All @@ -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 "
Expand Down Expand Up @@ -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 ""

Expand Down Expand Up @@ -862,9 +912,6 @@ msgstr ""
msgid "handler"
msgstr ""

msgid "applicant"
msgstr ""

msgid "calculation"
msgstr ""

Expand Down
63 changes: 58 additions & 5 deletions backend/benefit/locale/fi/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>\n"
"Language-Team: \n"
Expand Down Expand Up @@ -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"
Expand All @@ -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 "
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -934,9 +987,6 @@ msgstr "Laskelma on jo olemassa"
msgid "handler"
msgstr "käsittelijä"

msgid "applicant"
msgstr "hakija"

msgid "calculation"
msgstr "laskelma"

Expand Down Expand Up @@ -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"

Expand Down
Loading

0 comments on commit 191d031

Please sign in to comment.