Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(death-benefits): new application #16629

Open
wants to merge 71 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
82ad524
set up survivors benefits template
karenbjorg Nov 7, 2023
8918cdb
[TS-235] review page
veronikasif Nov 8, 2023
089b1ca
[TS-251] & [TS-252]: add additional documents and comments page
ylfahfa Nov 17, 2023
d38f809
merge with main
ylfahfa Jan 3, 2024
f37f830
make changes according to comments on oap and start applicant info page
ylfahfa Jan 4, 2024
add4bad
add applicant api
ylfahfa Jan 5, 2024
e030a7b
Merge remote-tracking branch 'origin/main' into feat/survivors-benefits
ylfahfa Jan 5, 2024
46181ad
Merge branch 'main' into feat/survivors-benefits
veronikasif Jan 5, 2024
5c305d5
Updated sb to use sia core messages and [TS-254] conclusion screen
veronikasif Jan 5, 2024
3ebb4fb
changes messages to core messages
ylfahfa Jan 8, 2024
6bcf557
merge changes
ylfahfa Jan 8, 2024
476f3f4
remove duplicate
ylfahfa Jan 8, 2024
4b58192
change text title
ylfahfa Jan 8, 2024
42394b2
add base information to overview screen
ylfahfa Jan 8, 2024
65ce38a
Format
veronikasif Jan 8, 2024
abbf9a2
[TS-256] application history and pending actions and [TS-258] additio…
veronikasif Jan 8, 2024
f0331c4
[TS-248]: add payment page to form
ylfahfa Jan 8, 2024
60bf755
merge with existinging branch changes
ylfahfa Jan 8, 2024
a96ddd6
Updated external data messages
veronikasif Jan 8, 2024
654695d
add tax info and personal allowance to payment page
ylfahfa Jan 8, 2024
eabbe0d
Merge branch 'feat/survivors-benefits' of https://github.com/island-i…
ylfahfa Jan 8, 2024
800c5ee
[TS-248]: Add spouse allowance to payment page and overview
ylfahfa Jan 9, 2024
e475f1d
[TS-250] Children with same domicile as applicant page
veronikasif Jan 9, 2024
ea20184
add paymentInfo to dataSchema
ylfahfa Jan 9, 2024
90f0a9f
Merge branch 'feat/survivors-benefits' of https://github.com/island-i…
veronikasif Jan 9, 2024
dd41df7
Update comment in review
veronikasif Jan 9, 2024
1ade4c8
add currencies api
ylfahfa Jan 9, 2024
b724460
Merge branch 'main' into feat/survivors-benefits
veronikasif Jan 10, 2024
ac1d4c7
add expecting child page and validation
ylfahfa Jan 11, 2024
ad15402
add file upload page and add information to review page
ylfahfa Jan 12, 2024
fb52e77
merge with main
ylfahfa Jan 17, 2024
1a2cb9f
[TS-257]: read me + flow chart
ylfahfa Jan 17, 2024
19cf09f
Merge remote-tracking branch 'origin/main' into feat/survivors-benefits
ylfahfa Jan 17, 2024
3714e44
add marital status and last modified to answers
ylfahfa Jan 18, 2024
6505a8e
Merge remote-tracking branch 'origin/main' into feat/survivors-benefits
ylfahfa Jan 19, 2024
fb82e5f
feat(survivors-benefits): Add marital status check to expecting baby …
ylfahfa Jan 19, 2024
3828500
merge main
karenbjorg Apr 22, 2024
73953d0
call user profile and show error alert warning when no email register…
karenbjorg Apr 22, 2024
6261be7
Merge branch 'main' into feat/survivors-benefits
karenbjorg May 17, 2024
ab867fb
Merge branch 'main' into feat/survivors-benefits
karenbjorg Jun 26, 2024
a32efe8
Merge branch 'main' into feat/survivors-benefits
karenbjorg Jul 3, 2024
cb42e21
update and generate TR apis + add eligible for survivors benefits
karenbjorg Jul 3, 2024
42ac4f3
Merge branch 'main' into feat/survivors-benefits
karenbjorg Jul 5, 2024
effb9e3
call eligible with deathbenefits instead of survivorsbenefits
karenbjorg Jul 5, 2024
d582978
eligible page
karenbjorg Jul 5, 2024
d907a7c
change eligible text
karenbjorg Aug 13, 2024
7b28ac5
change personal allowance message for conformity between fields
ylfahfa Aug 29, 2024
419c4af
merge main
ylfahfa Aug 29, 2024
da93ba5
add back code lost in merge
ylfahfa Aug 29, 2024
ac776c1
add missing texts and remove console.log
ylfahfa Aug 30, 2024
deb7966
add unit tests for state transitions
ylfahfa Sep 2, 2024
6205106
updated README
ylfahfa Sep 2, 2024
3d71f98
further update to README
ylfahfa Sep 2, 2024
ebf04e5
fix extract strings path
ylfahfa Sep 3, 2024
5dd2e71
feat(survivors-benefits): Spousal info (#15550)
helgifr Sep 30, 2024
694b354
add application documents to sendApplication and show in confirmation…
ylfahfa Oct 1, 2024
9139daa
rename application + minor changes
ylfahfa Oct 2, 2024
dd6f9f1
update README and flow chart
ylfahfa Oct 4, 2024
089569a
add feature flag
ylfahfa Oct 15, 2024
453ca91
remove screens for manually adding spouse when not found
ylfahfa Oct 24, 2024
b9bc882
Merge branch 'main' into feat/survivors-benefits
ylfahfa Oct 30, 2024
a06d096
merge main
ylfahfa Oct 30, 2024
8ddc4bc
fix after merge
ylfahfa Oct 30, 2024
119614c
Update libs/application/templates/social-insurance-administration/dea…
ylfahfa Oct 30, 2024
cc3f3f2
chore: nx format:write update dirty files
andes-it Oct 30, 2024
4c21bbc
Update libs/application/templates/social-insurance-administration/dea…
ylfahfa Oct 30, 2024
ebf1753
remove unnecessary constant
ylfahfa Oct 30, 2024
aca50a9
Merge branch 'feat/survivors-benefits' of https://github.com/island-i…
ylfahfa Oct 30, 2024
c56be77
Update libs/application/types/src/lib/InstitutionMapper.ts
ylfahfa Oct 30, 2024
19f8a7c
Merge branch 'main' into feat/survivors-benefits
ylfahfa Oct 30, 2024
e57936b
remove extra line
ylfahfa Oct 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ import {
getApplicationExternalData as getPSApplicationExternalData,
} from '@island.is/application/templates/social-insurance-administration/pension-supplement'

import {
ChildInformation,
getApplicationAnswers as getDBApplicationAnswers,
getApplicationExternalData as getDBApplicationExternalData,
} from '@island.is/application/templates/social-insurance-administration/death-benefits'

import {
INCOME,
getApplicationAnswers as getIPApplicationAnswers,
Expand Down Expand Up @@ -305,6 +311,77 @@ export const transformApplicationToPensionSupplementDTO = (
return pensionSupplementDTO
}

export const transformApplicationToDeathBenefitsDTO = (
application: Application,
uploads: Attachment[],
): ApplicationDTO => {
const {
applicantPhonenumber,
comment,
bankAccountType,
bank,
iban,
swift,
bankName,
bankAddress,
currency,
paymentInfo,
personalAllowance,
personalAllowanceUsage,
spouseAllowance,
spouseAllowanceUsage,
taxLevel,
deceasedSpouseNationalId,
} = getDBApplicationAnswers(application.answers)
const { bankInfo, userProfileEmail, children } = getDBApplicationExternalData(
application.externalData,
)

const deathBenefitsDTO: ApplicationDTO = {
deceasedNationalId: deceasedSpouseNationalId,
childrenNationalIds: getChildrenNationalIds(children),
spouseTaxCardUsage: {
usecard: spouseAllowance === YES,
ratio: Number(spouseAllowanceUsage),
},
ylfahfa marked this conversation as resolved.
Show resolved Hide resolved
applicantInfo: {
email: userProfileEmail,
phonenumber: applicantPhonenumber,
},
period: {
year: new Date().getFullYear(),
month: new Date().getMonth() + 1,
},
ylfahfa marked this conversation as resolved.
Show resolved Hide resolved
comment,
applicationId: application.id,
uploads,
...(!shouldNotUpdateBankAccount(bankInfo, paymentInfo) && {
...((bankAccountType === undefined ||
bankAccountType === BankAccountType.ICELANDIC) && {
domesticBankInfo: {
bank: formatBank(bank),
},
}),
...(bankAccountType === BankAccountType.FOREIGN && {
foreignBankInfo: {
iban: iban.replace(/[\s]+/g, ''),
swift: swift.replace(/[\s]+/g, ''),
foreignBankName: bankName,
foreignBankAddress: bankAddress,
foreignCurrency: currency,
},
}),
}),
taxInfo: {
personalAllowance: YES === personalAllowance,
personalAllowanceUsage:
YES === personalAllowance ? +personalAllowanceUsage : 0,
taxLevel: +taxLevel,
},
}
return deathBenefitsDTO
}

export const transformApplicationToIncomePlanDTO = (
application: Application,
): ApplicationDTO => {
Expand Down Expand Up @@ -392,6 +469,10 @@ export const getMonthNumber = (monthName: string): number => {
return monthNumber.getMonth() + 1
}

export const getChildrenNationalIds = (
children: ChildInformation[],
): string[] => children.map(({ nationalId }) => nationalId)

export const getApplicationType = (application: Application): string => {
const { applicationType } = getOAPApplicationAnswers(application.answers)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import {
isEarlyRetirement,
} from '@island.is/application/templates/social-insurance-administration/old-age-pension'
import { getApplicationAnswers as getPSApplicationAnswers } from '@island.is/application/templates/social-insurance-administration/pension-supplement'
import {
getApplicationAnswers as getDBApplicationAnswers,
ChildInformation,
} from '@island.is/application/templates/social-insurance-administration/death-benefits'
import {
Application,
ApplicationTypes,
Expand All @@ -35,7 +39,10 @@ import {
transformApplicationToIncomePlanDTO,
transformApplicationToOldAgePensionDTO,
transformApplicationToPensionSupplementDTO,
transformApplicationToDeathBenefitsDTO,
} from './social-insurance-administration-utils'
import { NationalRegistryClientService } from '@island.is/clients/national-registry-v2'
import * as kennitala from 'kennitala'
ylfahfa marked this conversation as resolved.
Show resolved Hide resolved
import { sharedModuleConfig } from '../../shared'
import { ConfigType } from '@nestjs/config'
import { S3Service } from '@island.is/nest/aws'
Expand All @@ -50,6 +57,7 @@ export class SocialInsuranceAdministrationService extends BaseTemplateApiService
@Inject(sharedModuleConfig.KEY)
private config: ConfigType<typeof sharedModuleConfig>,
private readonly s3Service: S3Service,
private readonly nationalRegistryApi: NationalRegistryClientService,
) {
super('SocialInsuranceAdministration')
}
Expand Down Expand Up @@ -106,6 +114,11 @@ export class SocialInsuranceAdministrationService extends BaseTemplateApiService
application.answers,
).additionalAttachmentsRequired
}
if (application.typeId === ApplicationTypes.DEATH_BENEFITS) {
additionalAttachmentsRequired = getDBApplicationAnswers(
application.answers,
).additionalAttachmentsRequired
}

if (
additionalAttachmentsRequired &&
Expand Down Expand Up @@ -377,6 +390,55 @@ export class SocialInsuranceAdministrationService extends BaseTemplateApiService
return attachments
}

private async getDBAttachments(
application: Application,
): Promise<Attachment[]> {
const {
additionalAttachments,
expectingChildAttachments,
deathCertificateAttachments,
isExpectingChild,
} = getDBApplicationAnswers(application.answers)

const attachments: Attachment[] = []

if (additionalAttachments && additionalAttachments.length > 0) {
attachments.push(
...(await this.initAttachments(
application,
DocumentTypeEnum.OTHER,
additionalAttachments,
)),
)
}

if (deathCertificateAttachments && deathCertificateAttachments.length > 0) {
attachments.push(
...(await this.initAttachments(
application,
DocumentTypeEnum.DEATH_CERTIFICATE,
deathCertificateAttachments,
)),
)
}

if (
expectingChildAttachments &&
expectingChildAttachments.length > 0 &&
isExpectingChild === YES
) {
attachments.push(
...(await this.initAttachments(
application,
DocumentTypeEnum.EXPECTING_CHILD,
expectingChildAttachments,
)),
)
}

return attachments
}
ylfahfa marked this conversation as resolved.
Show resolved Hide resolved

async getPdf(key: string): Promise<string> {
const fileContent = await this.s3Service.getFileContent(
{ bucket: this.config.templateApi.attachmentBucket, key },
Expand Down Expand Up @@ -458,6 +520,22 @@ export class SocialInsuranceAdministrationService extends BaseTemplateApiService
return response
}

if (application.typeId === ApplicationTypes.DEATH_BENEFITS) {
const attachments = await this.getDBAttachments(application)

const deathBenefitsDTO = transformApplicationToDeathBenefitsDTO(
application,
attachments,
)

const response = await this.siaClientService.sendApplication(
auth,
deathBenefitsDTO,
application.typeId.toLowerCase(),
)
return response
}

if (application.typeId === ApplicationTypes.INCOME_PLAN) {
const incomePlanDTO = transformApplicationToIncomePlanDTO(application)

Expand All @@ -466,7 +544,6 @@ export class SocialInsuranceAdministrationService extends BaseTemplateApiService
incomePlanDTO,
application.typeId.toLowerCase(),
)

return response
}
}
Expand Down Expand Up @@ -525,6 +602,47 @@ export class SocialInsuranceAdministrationService extends BaseTemplateApiService
return await this.siaClientService.getCurrencies(auth)
}

async getChildrenWithSameDomicile({ auth }: TemplateApiModuleActionProps) {
const cohabitants = await this.nationalRegistryApi.getCohabitants(
auth.nationalId,
)

const children: Array<ChildInformation | null> = await Promise.all(
cohabitants.map(async (cohabitantsNationalId) => {
if (
cohabitantsNationalId !== auth.nationalId &&
kennitala.info(cohabitantsNationalId).age < 18
) {
const child = await this.nationalRegistryApi.getIndividual(
cohabitantsNationalId,
)

if (!child) {
return null
}

return (
child && {
nationalId: child.nationalId,
fullName: child.name,
}
)
} else {
return null
}
}),
)

const filteredChildren = children.filter(
(child): child is ChildInformation => child != null,
)
return filteredChildren
}

async getSpousalInfo({ auth }: TemplateApiModuleActionProps) {
return await this.siaClientService.getSpousalInfo(auth)
}

async getCategorizedIncomeTypes({ auth }: TemplateApiModuleActionProps) {
return await this.siaClientService.getCategorizedIncomeTypes(auth)
}
Expand Down
4 changes: 4 additions & 0 deletions libs/application/template-loader/src/lib/templateLoaders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ const templates: Record<ApplicationTypes, () => Promise<unknown>> = {
import(
'@island.is/application/templates/aosh/transfer-of-machine-ownership'
),
[ApplicationTypes.DEATH_BENEFITS]: () =>
import(
'@island.is/application/templates/social-insurance-administration/death-benefits'
),
[ApplicationTypes.HOME_SUPPORT]: () =>
import('@island.is/application/templates/home-support'),
[ApplicationTypes.CHANGE_MACHINE_SUPERVISOR]: () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,13 @@ export const socialInsuranceAdministrationMessage: MessageDir = {
defaultMessage: 'Fylgiskjöl',
description: 'Attachments',
},
additionalFileDescription: {
id: 'sia.application:fileUpload.additionalFile.description',
defaultMessage:
'Hér getur þú skilað viðbótargögnum til Tryggingastofnunar ef þú telur þörf á.',
description:
'Below you can submit additional data to the Social Insurance Administration, if need be.',
},
attachmentButton: {
id: 'sia.application:fileUpload.attachment.button',
defaultMessage: 'Veldu skjal',
Expand Down Expand Up @@ -411,13 +418,7 @@ export const socialInsuranceAdministrationMessage: MessageDir = {
defaultMessage: 'Fylgiskjöl viðbótargögn',
description: 'Additional attachments',
},
additionalFileDescription: {
id: 'sia.application:fileUpload.additionalFile.description',
defaultMessage:
'Hér getur þú skilað viðbótargögnum til Tryggingastofnunar ef þú telur þörf á.',
description:
'Below you can submit additional data to the Social Insurance Administration, if need be.',
},

additionalDocumentsEditSubmit: {
id: 'sia.application:fileUpload.additionalDocumentsEditSubmit',
defaultMessage: 'Senda inn',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"presets": [
[
"@nx/react/babel",
{
"runtime": "automatic",
"useBuiltIns": "usage"
}
]
],
"plugins": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": ["plugin:@nx/react", "../../../../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
Loading
Loading