From 919a065c6d72140613910b3d853f08989af4d3be Mon Sep 17 00:00:00 2001 From: albinagu <47886428+albinagu@users.noreply.github.com> Date: Fri, 20 Dec 2024 09:08:27 +0000 Subject: [PATCH 1/3] fix(inheritance-report): Fixes for go live (#17295) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- .../templates/inheritance-report/utils/mappers.ts | 3 +++ .../inheritance-report/src/forms/prerequisites.ts | 2 -- .../src/forms/sections/assets.ts | 14 ++++++++++---- .../src/forms/sections/debtsAndFuneralCost.ts | 3 +++ .../forms/sections/prepaidInheritance/applicant.ts | 2 +- .../prepaidInheritance/inheritanceExecutor.ts | 4 ++-- .../inheritance-report/src/lib/dataSchema.ts | 1 + .../inheritance-report/src/lib/messages.ts | 10 ++++++++++ .../templates/inheritance-report/src/types.ts | 1 + 9 files changed, 31 insertions(+), 9 deletions(-) diff --git a/libs/application/template-api-modules/src/lib/modules/templates/inheritance-report/utils/mappers.ts b/libs/application/template-api-modules/src/lib/modules/templates/inheritance-report/utils/mappers.ts index b4e0e2ab0f8e..87fbccb3d32e 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/inheritance-report/utils/mappers.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/inheritance-report/utils/mappers.ts @@ -157,6 +157,7 @@ export const expandAnswers = ( deceasedShare: gun.deceasedShare ?? '', deceasedShareEnabled: gun.deceasedShareEnabled ?? [], deceasedShareAmount: gun.deceasedShareAmount ?? 0, + enabled: gun.enabled ?? true, } }), total: answers.assets.guns?.total ?? 0, @@ -199,6 +200,7 @@ export const expandAnswers = ( deceasedShare: realEstate.deceasedShare ?? '0', deceasedShareEnabled: realEstate.deceasedShareEnabled ?? [], deceasedShareAmount: realEstate.deceasedShareAmount ?? 0, + enabled: realEstate.enabled ?? true, } }), total: answers.assets.realEstate?.total ?? 0, @@ -227,6 +229,7 @@ export const expandAnswers = ( deceasedShare: vehicle.deceasedShare ?? '0', deceasedShareEnabled: vehicle.deceasedShareEnabled ?? [], deceasedShareAmount: vehicle?.deceasedShareAmount ?? 0, + enabled: vehicle.enabled ?? true, } }), total: answers.assets.vehicles?.total ?? 0, diff --git a/libs/application/templates/inheritance-report/src/forms/prerequisites.ts b/libs/application/templates/inheritance-report/src/forms/prerequisites.ts index 74b17ab2358b..5296679ded4b 100644 --- a/libs/application/templates/inheritance-report/src/forms/prerequisites.ts +++ b/libs/application/templates/inheritance-report/src/forms/prerequisites.ts @@ -38,8 +38,6 @@ export const getForm = ({ value: ESTATE_INHERITANCE, label: m.preDataCollectionApplicationForDefault, disabled: !allowEstateApplication, - //TODO: remove tooltip when this application is ready to go live - tooltip: m.preDataCollectionApplicationForDefaultTooltip, }, { value: PREPAID_INHERITANCE, diff --git a/libs/application/templates/inheritance-report/src/forms/sections/assets.ts b/libs/application/templates/inheritance-report/src/forms/sections/assets.ts index a8b9ab5fe2fd..b2c3d8b511ab 100644 --- a/libs/application/templates/inheritance-report/src/forms/sections/assets.ts +++ b/libs/application/templates/inheritance-report/src/forms/sections/assets.ts @@ -345,7 +345,7 @@ export const assets = buildSection({ [ESTATE_INHERITANCE]: m.bankAccountCapital, [PREPAID_INHERITANCE]: m.bankAccountCapitalPrePaid, }, - id: 'propertyValuation', + id: 'amount', required: true, currency: true, }, @@ -376,7 +376,7 @@ export const assets = buildSection({ fromExternalData: 'bankAccounts', skipPushRight: true, repeaterButtonText: m.bankAccountRepeaterButton, - sumField: 'propertyValuation', + sumField: 'amount', sumField2: 'exchangeRateOrInterest', }, ), @@ -494,13 +494,19 @@ export const assets = buildSection({ format: '######-####', }, { - title: m.stocksFaceValue, + title: { + [ESTATE_INHERITANCE]: m.stocksFaceValue, + [PREPAID_INHERITANCE]: m.stocksFaceValuePrePaid, + }, id: 'amount', currency: true, required: true, }, { - title: m.stocksRateOfChange, + title: { + [ESTATE_INHERITANCE]: m.stocksRateOfChange, + [PREPAID_INHERITANCE]: m.stocksRateOfChangePrePaid, + }, id: 'exchangeRateOrInterest', type: 'currency', required: true, diff --git a/libs/application/templates/inheritance-report/src/forms/sections/debtsAndFuneralCost.ts b/libs/application/templates/inheritance-report/src/forms/sections/debtsAndFuneralCost.ts index ed46966a1955..8651c95870f1 100644 --- a/libs/application/templates/inheritance-report/src/forms/sections/debtsAndFuneralCost.ts +++ b/libs/application/templates/inheritance-report/src/forms/sections/debtsAndFuneralCost.ts @@ -87,6 +87,9 @@ export const debtsAndFuneralCost = buildSection({ { label: DebtTypes.OtherDebts, }, + { + label: DebtTypes.InsuranceInstitute, + }, ], }, ), diff --git a/libs/application/templates/inheritance-report/src/forms/sections/prepaidInheritance/applicant.ts b/libs/application/templates/inheritance-report/src/forms/sections/prepaidInheritance/applicant.ts index dc53eb07648d..89606f99a45b 100644 --- a/libs/application/templates/inheritance-report/src/forms/sections/prepaidInheritance/applicant.ts +++ b/libs/application/templates/inheritance-report/src/forms/sections/prepaidInheritance/applicant.ts @@ -20,7 +20,7 @@ export const prePaidApplicant = buildSection({ children: [ buildNationalIdWithNameField({ id: 'prePaidApplicant', - title: m.name, + title: '', width: 'full', required: true, }), diff --git a/libs/application/templates/inheritance-report/src/forms/sections/prepaidInheritance/inheritanceExecutor.ts b/libs/application/templates/inheritance-report/src/forms/sections/prepaidInheritance/inheritanceExecutor.ts index a411304e2a32..593efcd2b8ae 100644 --- a/libs/application/templates/inheritance-report/src/forms/sections/prepaidInheritance/inheritanceExecutor.ts +++ b/libs/application/templates/inheritance-report/src/forms/sections/prepaidInheritance/inheritanceExecutor.ts @@ -26,7 +26,7 @@ export const inheritanceExecutor = buildSection({ }), buildNationalIdWithNameField({ id: 'executors.executor', - title: m.name, + title: '', required: true, }), buildTextField({ @@ -73,7 +73,7 @@ export const inheritanceExecutor = buildSection({ }), buildNationalIdWithNameField({ id: 'executors.spouse', - title: m.name, + title: '', required: true, condition: (answers) => !!((answers.executors as any)?.includeSpouse as Array) diff --git a/libs/application/templates/inheritance-report/src/lib/dataSchema.ts b/libs/application/templates/inheritance-report/src/lib/dataSchema.ts index 3e437681836f..0e77b8b62b09 100644 --- a/libs/application/templates/inheritance-report/src/lib/dataSchema.ts +++ b/libs/application/templates/inheritance-report/src/lib/dataSchema.ts @@ -55,6 +55,7 @@ const assetSchema = ({ withShare }: { withShare?: boolean } = {}) => .refine((v) => (withShare ? validateAssetNumber(v) : true)), description: z.string(), propertyValuation: z.string(), + enabled: z.boolean(), ...(withShare ? { share: z.string() } : {}), ...deceasedShare, }) diff --git a/libs/application/templates/inheritance-report/src/lib/messages.ts b/libs/application/templates/inheritance-report/src/lib/messages.ts index 84f67d71a06a..e0b816cab74e 100644 --- a/libs/application/templates/inheritance-report/src/lib/messages.ts +++ b/libs/application/templates/inheritance-report/src/lib/messages.ts @@ -708,11 +708,21 @@ export const m = defineMessages({ }, stocksFaceValue: { id: 'ir.application:stocksFaceValue', + defaultMessage: 'Nafnverð á dánardegi', + description: '', + }, + stocksFaceValuePrePaid: { + id: 'ir.application:stocksFaceValuePrePaid', defaultMessage: 'Nafnverð', description: '', }, stocksRateOfChange: { id: 'ir.application:stocksRateOfChange', + defaultMessage: 'Gengi á dánardegi', + description: '', + }, + stocksRateOfChangePrePaid: { + id: 'ir.application:stocksRateOfChangePrePaid', defaultMessage: 'Gengi', description: '', }, diff --git a/libs/application/templates/inheritance-report/src/types.ts b/libs/application/templates/inheritance-report/src/types.ts index 5b4b730a8fbb..c23a10263a35 100644 --- a/libs/application/templates/inheritance-report/src/types.ts +++ b/libs/application/templates/inheritance-report/src/types.ts @@ -305,4 +305,5 @@ export enum DebtTypes { PropertyFees = 'Fasteignagjöld', OtherDebts = 'Aðrar skuldir', PublicCharges = 'Opinber gjöld', + InsuranceInstitute = 'Tryggingarstofnun ríkisins', } From 8c63c9a0c9672b3e733af1ad2cd975b21e73cbc1 Mon Sep 17 00:00:00 2001 From: albinagu <47886428+albinagu@users.noreply.github.com> Date: Fri, 20 Dec 2024 12:16:00 +0000 Subject: [PATCH 2/3] fix(inheritance-report): bugfixing 20.12 (#17322) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- .../modules/templates/inheritance-report/utils/mappers.ts | 5 ++++- .../templates/inheritance-report/src/lib/dataSchema.ts | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/libs/application/template-api-modules/src/lib/modules/templates/inheritance-report/utils/mappers.ts b/libs/application/template-api-modules/src/lib/modules/templates/inheritance-report/utils/mappers.ts index 87fbccb3d32e..6d1e0229f4f0 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/inheritance-report/utils/mappers.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/inheritance-report/utils/mappers.ts @@ -125,12 +125,13 @@ export const expandAnswers = ( data: (answers.assets.bankAccounts?.data ?? []).map((account) => { return { assetNumber: account.assetNumber ?? '', - propertyValuation: account.propertyValuation ?? '', + amount: account.amount ?? '', exchangeRateOrInterest: account.exchangeRateOrInterest ?? '', foreignBankAccount: account?.foreignBankAccount ?? [], deceasedShare: account.deceasedShare ?? '', deceasedShareEnabled: account.deceasedShareEnabled ?? [], deceasedShareAmount: account.deceasedShareAmount ?? 0, + enabled: account.enabled ?? true, } }), total: answers.assets.bankAccounts?.total ?? 0, @@ -144,6 +145,7 @@ export const expandAnswers = ( deceasedShare: claim.deceasedShare ?? '', deceasedShareEnabled: claim.deceasedShareEnabled ?? [], deceasedShareAmount: claim.deceasedShareAmount ?? 0, + enabled: claim.enabled ?? true, } }), total: answers.assets.claims?.total ?? 0, @@ -216,6 +218,7 @@ export const expandAnswers = ( deceasedShare: stock?.deceasedShare ?? '', deceasedShareEnabled: stock?.deceasedShareEnabled ?? [], deceasedShareAmount: stock?.deceasedShareAmount ?? 0, + enabled: stock.enabled ?? true, } }), total: answers.assets.stocks?.total ?? 0, diff --git a/libs/application/templates/inheritance-report/src/lib/dataSchema.ts b/libs/application/templates/inheritance-report/src/lib/dataSchema.ts index 0e77b8b62b09..2e369699cc60 100644 --- a/libs/application/templates/inheritance-report/src/lib/dataSchema.ts +++ b/libs/application/templates/inheritance-report/src/lib/dataSchema.ts @@ -221,8 +221,9 @@ export const inheritanceReportSchema = z.object({ .object({ foreignBankAccount: z.array(z.enum([YES])).optional(), assetNumber: z.string().refine((v) => v), - propertyValuation: z.string().refine((v) => v), + amount: z.string().refine((v) => v), exchangeRateOrInterest: z.string().refine((v) => v), + enabled: z.boolean(), ...deceasedShare, }) .refine( @@ -248,6 +249,7 @@ export const inheritanceReportSchema = z.object({ description: z.string(), assetNumber: z.string(), propertyValuation: z.string().refine((v) => v), + enabled: z.boolean(), ...deceasedShare, }) .refine( @@ -285,6 +287,7 @@ export const inheritanceReportSchema = z.object({ amount: z.string(), exchangeRateOrInterest: z.string(), value: z.string().refine((v) => v), + enabled: z.boolean(), ...deceasedShare, }) .refine( From 89cf87e48c2a0358c097767faa4b31e19ada3c37 Mon Sep 17 00:00:00 2001 From: juni-haukur <158475136+juni-haukur@users.noreply.github.com> Date: Fri, 20 Dec 2024 15:53:28 +0000 Subject: [PATCH 3/3] fix(inheritance-report): Send uploaded files data to syslumenn (#17325) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- .../inheritance-report.module.ts | 2 + .../inheritance-report.service.ts | 53 ++++++++++++++++++- .../inheritance-report/src/lib/dataSchema.ts | 8 +++ 3 files changed, 62 insertions(+), 1 deletion(-) diff --git a/libs/application/template-api-modules/src/lib/modules/templates/inheritance-report/inheritance-report.module.ts b/libs/application/template-api-modules/src/lib/modules/templates/inheritance-report/inheritance-report.module.ts index 3e22223815d3..b69ac6eeb172 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/inheritance-report/inheritance-report.module.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/inheritance-report/inheritance-report.module.ts @@ -5,12 +5,14 @@ import { SyslumennClientModule } from '@island.is/clients/syslumenn' import { InheritanceReportService } from './inheritance-report.service' import { NationalRegistryXRoadModule } from '@island.is/api/domains/national-registry-x-road' +import { AwsModule } from '@island.is/nest/aws' @Module({ imports: [ SharedTemplateAPIModule, SyslumennClientModule, NationalRegistryXRoadModule, + AwsModule, ], providers: [InheritanceReportService], exports: [InheritanceReportService], diff --git a/libs/application/template-api-modules/src/lib/modules/templates/inheritance-report/inheritance-report.service.ts b/libs/application/template-api-modules/src/lib/modules/templates/inheritance-report/inheritance-report.service.ts index 3edd5317d203..ca260f1cf23d 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/inheritance-report/inheritance-report.service.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/inheritance-report/inheritance-report.service.ts @@ -1,5 +1,6 @@ import { Inject, Injectable } from '@nestjs/common' import { + Attachment, DataUploadResponse, Person, PersonType, @@ -18,6 +19,7 @@ import { inheritanceReportSchema } from '@island.is/application/templates/inheri import type { Logger } from '@island.is/logging' import { expandAnswers } from './utils/mappers' import { NationalRegistryXRoadService } from '@island.is/api/domains/national-registry-x-road' +import { S3Service } from '@island.is/nest/aws' type InheritanceSchema = zinfer @@ -27,6 +29,7 @@ export class InheritanceReportService extends BaseTemplateApiService { @Inject(LOGGER_PROVIDER) private logger: Logger, private readonly syslumennService: SyslumennService, private readonly nationalRegistryService: NationalRegistryXRoadService, + private readonly s3Service: S3Service, ) { super(ApplicationTypes.INHERITANCE_REPORT) } @@ -105,9 +108,44 @@ export class InheritanceReportService extends BaseTemplateApiService { const uploadDataName = 'erfdafjarskysla1.0' const uploadDataId = 'erfdafjarskysla1.0' + const attachments: Attachment[] = [] + + if (answers?.heirsAdditionalInfoPrivateTransferFiles) { + attachments.push( + ...(await Promise.all( + answers.heirsAdditionalInfoPrivateTransferFiles.map(async (file) => { + const content = await this.getFileContentBase64(file.key) + return { + name: file.name, + content, + } + }), + )), + ) + } + + if (answers?.heirsAdditionalInfoFilesOtherDocuments) { + attachments.push( + ...(await Promise.all( + answers.heirsAdditionalInfoFilesOtherDocuments.map(async (file) => { + const content = await this.getFileContentBase64(file.key) + return { + name: file.name, + content, + } + }), + )), + ) + } const result: DataUploadResponse = await this.syslumennService - .uploadData([person], undefined, uploadData, uploadDataName, uploadDataId) + .uploadData( + [person], + attachments, + uploadData, + uploadDataName, + uploadDataId, + ) .catch((e) => { return { success: false, @@ -131,4 +169,17 @@ export class InheritanceReportService extends BaseTemplateApiService { const spouse = await this.nationalRegistryService.getSpouse(auth.nationalId) return { ...spouse, fullName: spouse?.name } } + + async getFileContentBase64(fileName: string): Promise { + try { + const fileContent = await this.s3Service.getFileContent( + fileName, + 'base64', + ) + return fileContent || '' + } catch (e) { + this.logger.warn('[estate]: Failed to get file content - ', e) + return 'err' + } + } } diff --git a/libs/application/templates/inheritance-report/src/lib/dataSchema.ts b/libs/application/templates/inheritance-report/src/lib/dataSchema.ts index 2e369699cc60..054423f72638 100644 --- a/libs/application/templates/inheritance-report/src/lib/dataSchema.ts +++ b/libs/application/templates/inheritance-report/src/lib/dataSchema.ts @@ -676,6 +676,14 @@ export const inheritanceReportSchema = z.object({ }), heirsAdditionalInfo: z.string().optional(), + heirsAdditionalInfoPrivateTransferFiles: z + .object({ key: z.string(), name: z.string() }) + .array() + .optional(), + heirsAdditionalInfoFilesOtherDocuments: z + .object({ key: z.string(), name: z.string() }) + .array() + .optional(), spouse: z .object({