From 730c4721fcfcb48b12a256c0ed834531a331b30c Mon Sep 17 00:00:00 2001 From: Jonni Date: Wed, 20 Nov 2024 13:36:51 +0000 Subject: [PATCH 01/12] feat: add in the dataverse check before you enter the application --- ...ncial-statement-political-party.service.ts | 2 +- .../src/forms/notAllowed/index.ts | 10 +++++++ .../src/forms/notAllowed/notAllowedSection.ts | 17 +++++++++++ .../lib/financialStatementCemeteryTemplate.ts | 29 +++++++++++++++---- .../src/lib/messages.ts | 12 ++++++++ .../src/types/types.ts | 1 + .../src/utils/constants.ts | 1 + .../src/forms/notAllowedForm/index.ts | 10 +++++++ .../forms/notAllowedForm/notAllowedSection.ts | 17 +++++++++++ .../forms/prerequsites/prerequsitesSection.ts | 2 ++ ...inancialStatementPoliticalPartyTemplate.ts | 26 ++++++++++++++--- .../src/lib/messages.ts | 12 ++++++++ .../src/types/types.ts | 2 ++ .../src/utils/constants.ts | 1 + .../src/utils/helpers.ts | 4 ++- .../src/lib/financialStatementsInao.config.ts | 4 +-- .../financialStatementsInaoClient.service.ts | 1 + 17 files changed, 138 insertions(+), 13 deletions(-) create mode 100644 libs/application/templates/inao/financial-statement-cemetery/src/forms/notAllowed/index.ts create mode 100644 libs/application/templates/inao/financial-statement-cemetery/src/forms/notAllowed/notAllowedSection.ts create mode 100644 libs/application/templates/inao/financial-statement-political-party/src/forms/notAllowedForm/index.ts create mode 100644 libs/application/templates/inao/financial-statement-political-party/src/forms/notAllowedForm/notAllowedSection.ts diff --git a/libs/application/template-api-modules/src/lib/modules/templates/financial-statement-political-party/financial-statement-political-party.service.ts b/libs/application/template-api-modules/src/lib/modules/templates/financial-statement-political-party/financial-statement-political-party.service.ts index c28b45850209..ad28aa593ad9 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/financial-statement-political-party/financial-statement-political-party.service.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/financial-statement-political-party/financial-statement-political-party.service.ts @@ -89,7 +89,7 @@ export class FinancialStatementPoliticalPartyTemplateService extends BaseTemplat async getUserType({ auth }: TemplateApiModuleActionProps) { const { nationalId } = auth if (kennitala.isPerson(nationalId)) { - return this.financialStatementClientService.getClientType('Einstaklingur') + return null } else { return this.financialStatementClientService.getUserClientType(nationalId) } diff --git a/libs/application/templates/inao/financial-statement-cemetery/src/forms/notAllowed/index.ts b/libs/application/templates/inao/financial-statement-cemetery/src/forms/notAllowed/index.ts new file mode 100644 index 000000000000..64b658b27a8e --- /dev/null +++ b/libs/application/templates/inao/financial-statement-cemetery/src/forms/notAllowed/index.ts @@ -0,0 +1,10 @@ +import { buildForm } from '@island.is/application/core' +import { notAllowedSection } from './notAllowedSection' +import Logo from '../../components/Logo' + +export const notAllowedForm = buildForm({ + id: 'notAllowedForm', + title: '', + logo: Logo, + children: [notAllowedSection], +}) diff --git a/libs/application/templates/inao/financial-statement-cemetery/src/forms/notAllowed/notAllowedSection.ts b/libs/application/templates/inao/financial-statement-cemetery/src/forms/notAllowed/notAllowedSection.ts new file mode 100644 index 000000000000..5c8359dd2a4b --- /dev/null +++ b/libs/application/templates/inao/financial-statement-cemetery/src/forms/notAllowed/notAllowedSection.ts @@ -0,0 +1,17 @@ +import { + buildDescriptionField, + buildSection, +} from '@island.is/application/core' +import { m } from '../../lib/messages' + +export const notAllowedSection = buildSection({ + id: 'notAllowedSection', + title: '', + children: [ + buildDescriptionField({ + id: 'notAllowedDescription', + title: m.notAllowedTitle, + description: m.notAllowedDescription, + }), + ], +}) diff --git a/libs/application/templates/inao/financial-statement-cemetery/src/lib/financialStatementCemeteryTemplate.ts b/libs/application/templates/inao/financial-statement-cemetery/src/lib/financialStatementCemeteryTemplate.ts index 127341d014f5..8bbd4e5bb7d4 100644 --- a/libs/application/templates/inao/financial-statement-cemetery/src/lib/financialStatementCemeteryTemplate.ts +++ b/libs/application/templates/inao/financial-statement-cemetery/src/lib/financialStatementCemeteryTemplate.ts @@ -1,8 +1,8 @@ import { DefaultStateLifeCycle, pruneAfterDays, + getValueViaPath, } from '@island.is/application/core' - import { ApplicationTemplate, ApplicationTypes, @@ -17,7 +17,6 @@ import { import { m } from './messages' import { AuthDelegationType } from '@island.is/shared/types' import { dataSchema } from './dataSchema' - import { CurrentUserTypeProvider, IndentityApiProvider, @@ -26,6 +25,7 @@ import { } from '../dataProviders' import { ApiActions, Events, Roles, States } from '../types/types' import { Features } from '@island.is/feature-flags' +import { CEMETERY_USER_TYPE } from '../utils/constants' const configuration = ApplicationConfigurations[ApplicationTypes.FINANCIAL_STATEMENT_CEMETERY] @@ -50,6 +50,10 @@ const FinancialStatementCemeteryTemplate: ApplicationTemplate< name: States.PREREQUISITES, progress: 0, status: 'draft', + onEntry: defineTemplateApi({ + action: ApiActions.getUserType, + shouldPersistToExternalData: true, + }), actionCard: { pendingAction: { title: '', @@ -80,6 +84,15 @@ const FinancialStatementCemeteryTemplate: ApplicationTemplate< UserInfoApi, ], }, + { + id: Roles.NOTALLOWED, + formLoader: () => + import('../forms/notAllowed').then((val) => + Promise.resolve(val.notAllowedForm), + ), + write: 'all', + delete: true, + }, ], }, on: { @@ -136,13 +149,19 @@ const FinancialStatementCemeteryTemplate: ApplicationTemplate< }, }, mapUserToRole( - nationalId: string, + _nationalId: string, application: Application, ): ApplicationRole | undefined { - if (application.applicant === nationalId) { + const userType = getValueViaPath( + application.externalData, + 'getUserType.data.value', + ) + console.log(userType) + + if (userType === CEMETERY_USER_TYPE) { return Roles.APPLICANT } - return undefined + return Roles.NOTALLOWED }, } diff --git a/libs/application/templates/inao/financial-statement-cemetery/src/lib/messages.ts b/libs/application/templates/inao/financial-statement-cemetery/src/lib/messages.ts index 2cf2aa890850..a78cd7e4296a 100644 --- a/libs/application/templates/inao/financial-statement-cemetery/src/lib/messages.ts +++ b/libs/application/templates/inao/financial-statement-cemetery/src/lib/messages.ts @@ -670,4 +670,16 @@ export const m = defineMessages({ defaultMessage: 'Áfram', description: 'continue', }, + notAllowedTitle: { + id: 'fsc.application:notAllowedTitle', + defaultMessage: + 'Þessi kennitala er ekki skráð sem kirkjugarður hjá Ríkisendurskoðun', + description: 'Title when user is not allowed to apply', + }, + notAllowedDescription: { + id: 'fsc.application:notAllowedDescription', + defaultMessage: + 'Ef þú telur að þessi kennitala ætti að vera skráð sem kirkjugarður þá bendum við þér á að hafa samband við Ríkisendurskoðun í síma 448 8800', + description: 'Descriptionwhen user is not allowed to apply', + }, }) diff --git a/libs/application/templates/inao/financial-statement-cemetery/src/types/types.ts b/libs/application/templates/inao/financial-statement-cemetery/src/types/types.ts index 5d9619eecf6c..274aeaf840e3 100644 --- a/libs/application/templates/inao/financial-statement-cemetery/src/types/types.ts +++ b/libs/application/templates/inao/financial-statement-cemetery/src/types/types.ts @@ -34,4 +34,5 @@ export enum States { export enum Roles { APPLICANT = 'applicant', + NOTALLOWED = 'notAllowed', } diff --git a/libs/application/templates/inao/financial-statement-cemetery/src/utils/constants.ts b/libs/application/templates/inao/financial-statement-cemetery/src/utils/constants.ts index 87efecc3fb85..1ed243c52fa7 100644 --- a/libs/application/templates/inao/financial-statement-cemetery/src/utils/constants.ts +++ b/libs/application/templates/inao/financial-statement-cemetery/src/utils/constants.ts @@ -14,6 +14,7 @@ export const PartiesBackwardLimit = 'PartiesBackwardLimit' export const CemeteriesBackwardLimit = 'CemeteriesBackwardLimit' export const PartiesYearAllowed = 'PartiesYearAllowed' export const CemeteriesYearAllowed = 'CemeteriesYearAllowed' +export const CEMETERY_USER_TYPE = 150000002 // error helpers export const VALIDATOR = 'validator' diff --git a/libs/application/templates/inao/financial-statement-political-party/src/forms/notAllowedForm/index.ts b/libs/application/templates/inao/financial-statement-political-party/src/forms/notAllowedForm/index.ts new file mode 100644 index 000000000000..64b658b27a8e --- /dev/null +++ b/libs/application/templates/inao/financial-statement-political-party/src/forms/notAllowedForm/index.ts @@ -0,0 +1,10 @@ +import { buildForm } from '@island.is/application/core' +import { notAllowedSection } from './notAllowedSection' +import Logo from '../../components/Logo' + +export const notAllowedForm = buildForm({ + id: 'notAllowedForm', + title: '', + logo: Logo, + children: [notAllowedSection], +}) diff --git a/libs/application/templates/inao/financial-statement-political-party/src/forms/notAllowedForm/notAllowedSection.ts b/libs/application/templates/inao/financial-statement-political-party/src/forms/notAllowedForm/notAllowedSection.ts new file mode 100644 index 000000000000..5c8359dd2a4b --- /dev/null +++ b/libs/application/templates/inao/financial-statement-political-party/src/forms/notAllowedForm/notAllowedSection.ts @@ -0,0 +1,17 @@ +import { + buildDescriptionField, + buildSection, +} from '@island.is/application/core' +import { m } from '../../lib/messages' + +export const notAllowedSection = buildSection({ + id: 'notAllowedSection', + title: '', + children: [ + buildDescriptionField({ + id: 'notAllowedDescription', + title: m.notAllowedTitle, + description: m.notAllowedDescription, + }), + ], +}) diff --git a/libs/application/templates/inao/financial-statement-political-party/src/forms/prerequsites/prerequsitesSection.ts b/libs/application/templates/inao/financial-statement-political-party/src/forms/prerequsites/prerequsitesSection.ts index 40dca0ccb508..6be6c3c8e9e4 100644 --- a/libs/application/templates/inao/financial-statement-political-party/src/forms/prerequsites/prerequsitesSection.ts +++ b/libs/application/templates/inao/financial-statement-political-party/src/forms/prerequsites/prerequsitesSection.ts @@ -4,6 +4,7 @@ import { buildSection, buildSubmitField, coreMessages, + getValueViaPath, } from '@island.is/application/core' import { m } from '../../lib/messages' import { @@ -12,6 +13,7 @@ import { UserInfoApi, } from '../../dataProviders' import { DefaultEvents } from '@island.is/application/types' +import { POLITICALPARTY_USER_TYPE } from '../../utils/constants' export const prerequisitesSection = buildSection({ id: 'ExternalDataSection', diff --git a/libs/application/templates/inao/financial-statement-political-party/src/lib/financialStatementPoliticalPartyTemplate.ts b/libs/application/templates/inao/financial-statement-political-party/src/lib/financialStatementPoliticalPartyTemplate.ts index 8324c1ec8af1..e73406c985fb 100644 --- a/libs/application/templates/inao/financial-statement-political-party/src/lib/financialStatementPoliticalPartyTemplate.ts +++ b/libs/application/templates/inao/financial-statement-political-party/src/lib/financialStatementPoliticalPartyTemplate.ts @@ -14,6 +14,7 @@ import { m } from './messages' import { dataSchema } from './dataSchema' import { DefaultStateLifeCycle, + getValueViaPath, pruneAfterDays, } from '@island.is/application/core' import { @@ -24,6 +25,7 @@ import { } from '../dataProviders' import { AuthDelegationType } from '@island.is/shared/types' import { Features } from '@island.is/feature-flags' +import { POLITICALPARTY_USER_TYPE } from '../utils/constants' const configuration = ApplicationConfigurations[ @@ -50,6 +52,10 @@ const FinancialStatementPoliticalPartyTemplate: ApplicationTemplate< name: States.PREREQUISITES, progress: 0, status: 'draft', + onEntry: defineTemplateApi({ + action: ApiActions.getUserType, + shouldPersistToExternalData: true, + }), actionCard: { pendingAction: { title: '', @@ -64,7 +70,6 @@ const FinancialStatementPoliticalPartyTemplate: ApplicationTemplate< import('../forms/prerequsites').then((val) => Promise.resolve(val.PrerequisitesForm), ), - actions: [ { event: DefaultEvents.SUBMIT, @@ -81,6 +86,15 @@ const FinancialStatementPoliticalPartyTemplate: ApplicationTemplate< UserInfoApi, ], }, + { + id: Roles.NOTALLOWED, + formLoader: () => + import('../forms/notAllowedForm').then((val) => + Promise.resolve(val.notAllowedForm), + ), + write: 'all', + delete: true, + }, ], }, on: { @@ -142,13 +156,17 @@ const FinancialStatementPoliticalPartyTemplate: ApplicationTemplate< }, }, mapUserToRole( - nationalId: string, + _nationalId: string, application: Application, ): ApplicationRole | undefined { - if (application.applicant === nationalId) { + const userType = getValueViaPath( + application.externalData, + 'getUserType.data.value', + ) + if (userType === POLITICALPARTY_USER_TYPE) { return Roles.APPLICANT } - return undefined + return Roles.NOTALLOWED }, } diff --git a/libs/application/templates/inao/financial-statement-political-party/src/lib/messages.ts b/libs/application/templates/inao/financial-statement-political-party/src/lib/messages.ts index e82dddf8af80..917fa4927876 100644 --- a/libs/application/templates/inao/financial-statement-political-party/src/lib/messages.ts +++ b/libs/application/templates/inao/financial-statement-political-party/src/lib/messages.ts @@ -558,4 +558,16 @@ export const m = defineMessages({ defaultMessage: 'Ekki er leyfilegt að setja inn neikvæðar tölur', description: 'Error message when a required field has not been filled', }, + notAllowedTitle: { + id: 'fspp.application:notAllowedTitle', + defaultMessage: + 'Þessi kennitala er ekki skráð sem stjórnmálasamtök hjá Ríkisendurskoðun', + description: 'Title when user is not allowed to apply', + }, + notAllowedDescription: { + id: 'fspp.application:notAllowedDescription', + defaultMessage: + 'Ef þú telur að þessi kennitala ætti að vera skráð sem stjórnmálasamtök þá bendum við þér á að hafa samband við Ríkisendurskoðun í síma 448 8800', + description: 'Descriptionwhen user is not allowed to apply', + }, }) diff --git a/libs/application/templates/inao/financial-statement-political-party/src/types/types.ts b/libs/application/templates/inao/financial-statement-political-party/src/types/types.ts index d4e6d3e5aea0..39af21a2f7dd 100644 --- a/libs/application/templates/inao/financial-statement-political-party/src/types/types.ts +++ b/libs/application/templates/inao/financial-statement-political-party/src/types/types.ts @@ -6,10 +6,12 @@ export enum States { PREREQUISITES = 'prerequisites', DRAFT = 'draft', DONE = 'done', + REJECTED = 'rejected', } export enum Roles { APPLICANT = 'applicant', + NOTALLOWED = 'notAllowed', } export type Config = { key: string; value: string } diff --git a/libs/application/templates/inao/financial-statement-political-party/src/utils/constants.ts b/libs/application/templates/inao/financial-statement-political-party/src/utils/constants.ts index 0efc55f7997e..5882c668bede 100644 --- a/libs/application/templates/inao/financial-statement-political-party/src/utils/constants.ts +++ b/libs/application/templates/inao/financial-statement-political-party/src/utils/constants.ts @@ -5,6 +5,7 @@ export const TOTAL = 'total' export const LESS = 'less' export const GREATER = 'greater' export const ELECTIONLIMIT = 550000 +export const POLITICALPARTY_USER_TYPE = 150000001 export const ABOUTIDS = { operatingYear: 'conditionalAbout.operatingYear', diff --git a/libs/application/templates/inao/financial-statement-political-party/src/utils/helpers.ts b/libs/application/templates/inao/financial-statement-political-party/src/utils/helpers.ts index 82ac09edeb37..3fc9b1ce270c 100644 --- a/libs/application/templates/inao/financial-statement-political-party/src/utils/helpers.ts +++ b/libs/application/templates/inao/financial-statement-political-party/src/utils/helpers.ts @@ -1,7 +1,9 @@ import { Config } from '../types/types' import subYears from 'date-fns/subYears' import getYear from 'date-fns/getYear' -import { TOTAL } from './constants' +import { POLITICALPARTY_USER_TYPE, TOTAL } from './constants' +import { ApplicationContext } from '@island.is/application/types' +import { getValueViaPath } from '@island.is/application/core' export const getConfigInfoForKey = (config: Config[], configKey: string) => { return config?.filter((config: Config) => config.key === configKey)[0].value diff --git a/libs/clients/financial-statements-inao/src/lib/financialStatementsInao.config.ts b/libs/clients/financial-statements-inao/src/lib/financialStatementsInao.config.ts index be5dc230be9d..56487d0eccaf 100644 --- a/libs/clients/financial-statements-inao/src/lib/financialStatementsInao.config.ts +++ b/libs/clients/financial-statements-inao/src/lib/financialStatementsInao.config.ts @@ -5,7 +5,7 @@ export const FinancialStatementsInaoClientConfig = defineConfig({ load: (env) => ({ basePath: env.required( 'FINANCIAL_STATEMENTS_INAO_BASE_PATH', - 'https://star-re.crm4.dynamics.com/api/data/v9.1', + 'https://dev-re.crm4.dynamics.com/api/data/v9.1', ), issuer: env.required( 'FINANCIAL_STATEMENTS_INAO_ISSUER', @@ -13,7 +13,7 @@ export const FinancialStatementsInaoClientConfig = defineConfig({ ), scope: env.required( 'FINANCIAL_STATEMENTS_INAO_SCOPE', - 'https://star-re.crm4.dynamics.com/.default', + 'https://dev-re.crm4.dynamics.com/.default', ), tokenEndpoint: env.required( 'FINANCIAL_STATEMENTS_INAO_TOKEN_ENDPOINT', diff --git a/libs/clients/financial-statements-inao/src/lib/financialStatementsInaoClient.service.ts b/libs/clients/financial-statements-inao/src/lib/financialStatementsInaoClient.service.ts index 509d98b84ffd..70cd392e5121 100644 --- a/libs/clients/financial-statements-inao/src/lib/financialStatementsInaoClient.service.ts +++ b/libs/clients/financial-statements-inao/src/lib/financialStatementsInaoClient.service.ts @@ -92,6 +92,7 @@ export class FinancialStatementsInaoClientService { const data = await this.getData(url) if (!data || !data.value) return null + console.dir(data, { depth: null }) const typeValue = data.value.map((x: any) => { return x.star_type From 585ea1633c69df5440a1f8dbb569716a24eea052 Mon Sep 17 00:00:00 2001 From: Jonni Date: Wed, 20 Nov 2024 13:58:19 +0000 Subject: [PATCH 02/12] feat: adjust cemetery client --- .../financial-statement-cemetery.service.ts | 83 ++++++++----------- ...ncial-statement-political-party.service.ts | 4 +- 2 files changed, 36 insertions(+), 51 deletions(-) diff --git a/libs/application/template-api-modules/src/lib/modules/templates/financial-statement-cemetery/financial-statement-cemetery.service.ts b/libs/application/template-api-modules/src/lib/modules/templates/financial-statement-cemetery/financial-statement-cemetery.service.ts index 76f62d720852..a658f7116f11 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/financial-statement-cemetery/financial-statement-cemetery.service.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/financial-statement-cemetery/financial-statement-cemetery.service.ts @@ -5,7 +5,6 @@ import { LOGGER_PROVIDER } from '@island.is/logging' import { CemeteryFinancialStatementValues, FinancialStatementsInaoClientService, - ClientRoles, } from '@island.is/clients/financial-statements-inao' import { ApplicationTypes, @@ -36,9 +35,9 @@ export const getCurrentUserType = ( answers: Application['answers'], externalData: Application['externalData'], ) => { - const fakeUserType: any = getValueViaPath(answers, 'fakeData.options') + const fakeUserType = getValueViaPath(answers, 'fakeData.options') - const currentUserType: any = getValueViaPath( + const currentUserType = getValueViaPath( externalData, 'getUserType.data.value', ) @@ -86,9 +85,7 @@ export class FinancialStatementCemeteryTemplateService extends BaseTemplateApiSe async getUserType({ auth }: TemplateApiModuleActionProps) { const { nationalId } = auth if (kennitala.isPerson(nationalId)) { - return this.financialStatementClientService.getClientType( - ClientRoles.Individual, - ) + return null } else { return this.financialStatementClientService.getUserClientType(nationalId) } @@ -97,63 +94,51 @@ export class FinancialStatementCemeteryTemplateService extends BaseTemplateApiSe async submitApplication({ application, auth }: TemplateApiModuleActionProps) { const { nationalId, actor } = auth const answers = application.answers - const externalData = application.externalData - const currentUserType = getCurrentUserType(answers, externalData) - - // Todo test before this goes live - // if (currentUserType !== FSIUSERTYPE.CEMETRY) { - // throw new Error('Application submission failed') - // } - if (!actor) { return new Error('Enginn umboðsmaður fannst') } - const values: CemeteryFinancialStatementValues = - mapValuesToCemeterytype(answers) - + const values = this.prepareValues(application) + const client = { nationalId } const { year, actorsName, contactsAnswer, clientPhone, clientEmail, file } = getNeededCemeteryValues(answers) - + const digitalSignee = mapDigitalSignee(clientEmail, clientPhone) const fileName = file ? await this.getAttachments(application) : undefined - - const client = { nationalId } - const contacts = mapContactsAnswersToContacts( actor, actorsName, contactsAnswer, ) - const digitalSignee = mapDigitalSignee(clientEmail, clientPhone) - const result: DataResponse = await this.financialStatementClientService - .postFinancialStatementForCemetery( - client, - contacts, - digitalSignee, - year, - '', - values, - fileName, - ) - .then((data) => { - if (data === true) { - return { success: true } - } else { - return { success: false } - } - }) - .catch((e) => { - return { - success: false, - errorMessages: e.message, - } - }) - - if (!result.success) { - throw new Error('Application submission failed') + try { + const result = + await this.financialStatementClientService.postFinancialStatementForCemetery( + client, + contacts, + digitalSignee, + year, + '', + values, + fileName, + ) + + if (!result) { + throw new Error('Application submission failed') + } + + return { success: true } + } catch (error) { + this.logger.error('Error submitting application', error) + return { + success: false, + message: error.message, + } } + } - return { success: result.success } + private prepareValues( + application: Application, + ): CemeteryFinancialStatementValues { + return mapValuesToCemeterytype(application.answers) } } diff --git a/libs/application/template-api-modules/src/lib/modules/templates/financial-statement-political-party/financial-statement-political-party.service.ts b/libs/application/template-api-modules/src/lib/modules/templates/financial-statement-political-party/financial-statement-political-party.service.ts index ad28aa593ad9..45d7bf885fc0 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/financial-statement-political-party/financial-statement-political-party.service.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/financial-statement-political-party/financial-statement-political-party.service.ts @@ -33,13 +33,13 @@ export const getCurrentUserType = ( answers: Application['answers'], externalData: Application['externalData'], ) => { + const fakeUserType = getValueViaPath(answers, 'fakeData.options') + const currentUserType = getValueViaPath( externalData, 'getUserType.data.value', ) - const fakeUserType = getValueViaPath(answers, 'fakeData.options') - return fakeUserType ?? currentUserType } From d424572264052710671bd300d3201a6fffceb328 Mon Sep 17 00:00:00 2001 From: Jonni Date: Wed, 20 Nov 2024 14:08:18 +0000 Subject: [PATCH 03/12] chore: remove console.dir --- .../src/lib/financialStatementsInaoClient.service.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/libs/clients/financial-statements-inao/src/lib/financialStatementsInaoClient.service.ts b/libs/clients/financial-statements-inao/src/lib/financialStatementsInaoClient.service.ts index 70cd392e5121..509d98b84ffd 100644 --- a/libs/clients/financial-statements-inao/src/lib/financialStatementsInaoClient.service.ts +++ b/libs/clients/financial-statements-inao/src/lib/financialStatementsInaoClient.service.ts @@ -92,7 +92,6 @@ export class FinancialStatementsInaoClientService { const data = await this.getData(url) if (!data || !data.value) return null - console.dir(data, { depth: null }) const typeValue = data.value.map((x: any) => { return x.star_type From 0b763e03934fabedc9e4bc6b9028fb55094b5d31 Mon Sep 17 00:00:00 2001 From: Jonni Date: Wed, 20 Nov 2024 14:11:47 +0000 Subject: [PATCH 04/12] chore: remove unused imports --- .../src/forms/prerequsites/prerequsitesSection.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/libs/application/templates/inao/financial-statement-political-party/src/forms/prerequsites/prerequsitesSection.ts b/libs/application/templates/inao/financial-statement-political-party/src/forms/prerequsites/prerequsitesSection.ts index 6be6c3c8e9e4..40dca0ccb508 100644 --- a/libs/application/templates/inao/financial-statement-political-party/src/forms/prerequsites/prerequsitesSection.ts +++ b/libs/application/templates/inao/financial-statement-political-party/src/forms/prerequsites/prerequsitesSection.ts @@ -4,7 +4,6 @@ import { buildSection, buildSubmitField, coreMessages, - getValueViaPath, } from '@island.is/application/core' import { m } from '../../lib/messages' import { @@ -13,7 +12,6 @@ import { UserInfoApi, } from '../../dataProviders' import { DefaultEvents } from '@island.is/application/types' -import { POLITICALPARTY_USER_TYPE } from '../../utils/constants' export const prerequisitesSection = buildSection({ id: 'ExternalDataSection', From 19c2c56d9355fa017ee0a25b5e971362f0cd2173 Mon Sep 17 00:00:00 2001 From: Jonni Date: Wed, 20 Nov 2024 14:12:50 +0000 Subject: [PATCH 05/12] chore: remove console.log --- .../src/lib/financialStatementCemeteryTemplate.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/libs/application/templates/inao/financial-statement-cemetery/src/lib/financialStatementCemeteryTemplate.ts b/libs/application/templates/inao/financial-statement-cemetery/src/lib/financialStatementCemeteryTemplate.ts index 8bbd4e5bb7d4..dea4e7456b1d 100644 --- a/libs/application/templates/inao/financial-statement-cemetery/src/lib/financialStatementCemeteryTemplate.ts +++ b/libs/application/templates/inao/financial-statement-cemetery/src/lib/financialStatementCemeteryTemplate.ts @@ -156,7 +156,6 @@ const FinancialStatementCemeteryTemplate: ApplicationTemplate< application.externalData, 'getUserType.data.value', ) - console.log(userType) if (userType === CEMETERY_USER_TYPE) { return Roles.APPLICANT From d5f51ea4d3b3f8f490280c01c9cb96275fd28fe4 Mon Sep 17 00:00:00 2001 From: Jonni Date: Wed, 20 Nov 2024 14:14:14 +0000 Subject: [PATCH 06/12] chore: remove unused imports --- .../financial-statement-political-party/src/utils/helpers.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libs/application/templates/inao/financial-statement-political-party/src/utils/helpers.ts b/libs/application/templates/inao/financial-statement-political-party/src/utils/helpers.ts index 3fc9b1ce270c..82ac09edeb37 100644 --- a/libs/application/templates/inao/financial-statement-political-party/src/utils/helpers.ts +++ b/libs/application/templates/inao/financial-statement-political-party/src/utils/helpers.ts @@ -1,9 +1,7 @@ import { Config } from '../types/types' import subYears from 'date-fns/subYears' import getYear from 'date-fns/getYear' -import { POLITICALPARTY_USER_TYPE, TOTAL } from './constants' -import { ApplicationContext } from '@island.is/application/types' -import { getValueViaPath } from '@island.is/application/core' +import { TOTAL } from './constants' export const getConfigInfoForKey = (config: Config[], configKey: string) => { return config?.filter((config: Config) => config.key === configKey)[0].value From e37f9dfb924bc4ff1e4f5d7ee610c0bdae72c8cf Mon Sep 17 00:00:00 2001 From: Jonni Date: Wed, 20 Nov 2024 14:18:57 +0000 Subject: [PATCH 07/12] chore: change codeowners of inao client --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 00932606d1b3..3db5e373dd4e 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -234,6 +234,7 @@ codemagic.yaml /libs/application/template-api-modules/src/lib/modules/templates/general-fishing-license/ @island-is/norda /libs/application/template-api-modules/src/lib/modules/templates/data-protection-complaint/ @island-is/norda /libs/shared/form-fields/ @island-is/norda @island-is/island-ui +/libs/clients/financial-statements-inao @island-is/norda /libs/portals/my-pages/applications/ @island-is/norda-applications /libs/portals/admin/application-system/ @island-is/norda-applications @@ -316,7 +317,6 @@ codemagic.yaml /apps/services/auth/personal-representative/ @island-is/programm @island-is/aranja /apps/services/auth/personal-representative-public/ @island-is/programm @island-is/aranja /libs/api/domains/financial-statements-inao/ @island-is/programm -/libs/clients/financial-statements-inao @island-is/programm /libs/application/templates/financial-statements-inao/ @island-is/programm /libs/application/template-api-modules/src/lib/modules/templates/financial-statements-inao @island-is/programm From 830a5ae92a1bde6f9d041c03ae2854be69d57ba2 Mon Sep 17 00:00:00 2001 From: Jonni Date: Wed, 20 Nov 2024 14:36:48 +0000 Subject: [PATCH 08/12] fix: remove delegation check once you are in the application --- .../src/fields/DelegationCheck/index.tsx | 43 ------------------- .../src/fields/index.ts | 1 - .../clientInfoSection/index.ts | 5 --- .../DelegationCheck/DelegationCheck.tsx | 43 ------------------- .../src/fields/index.ts | 1 - .../clientInfoSection/index.ts | 5 --- 6 files changed, 98 deletions(-) delete mode 100644 libs/application/templates/inao/financial-statement-cemetery/src/fields/DelegationCheck/index.tsx delete mode 100644 libs/application/templates/inao/financial-statement-political-party/src/fields/DelegationCheck/DelegationCheck.tsx diff --git a/libs/application/templates/inao/financial-statement-cemetery/src/fields/DelegationCheck/index.tsx b/libs/application/templates/inao/financial-statement-cemetery/src/fields/DelegationCheck/index.tsx deleted file mode 100644 index 7c31e9fd9672..000000000000 --- a/libs/application/templates/inao/financial-statement-cemetery/src/fields/DelegationCheck/index.tsx +++ /dev/null @@ -1,43 +0,0 @@ -import { FieldBaseProps } from '@island.is/application/types' -import { AlertBanner, Box } from '@island.is/island-ui/core' -import { useLocale } from '@island.is/localization' -import { useFormContext } from 'react-hook-form' -import { FinancialStatementCemetery } from '../../lib/dataSchema' -import { m } from '../../lib/messages' -import { VALIDATOR } from '../../utils/constants' - -export const DelegationCheck = ({ - application, - setBeforeSubmitCallback, -}: FieldBaseProps) => { - const { formatMessage } = useLocale() - const { - formState: { errors }, - setError, - } = useFormContext() - setBeforeSubmitCallback && - setBeforeSubmitCallback(async () => { - const userType = application.externalData.getUserType?.data - const hasUserType = !!userType - - if (hasUserType) { - setError(VALIDATOR, { - type: 'custom', - message: formatMessage(m.wrongDelegation), - }) - return [false, formatMessage(m.wrongDelegation)] - } else { - return [true, null] - } - }) - - return errors && errors.validator ? ( - - - - ) : null -} diff --git a/libs/application/templates/inao/financial-statement-cemetery/src/fields/index.ts b/libs/application/templates/inao/financial-statement-cemetery/src/fields/index.ts index a3db9a6b56c7..38e7219bec44 100644 --- a/libs/application/templates/inao/financial-statement-cemetery/src/fields/index.ts +++ b/libs/application/templates/inao/financial-statement-cemetery/src/fields/index.ts @@ -4,6 +4,5 @@ export { KeyNumbersCapital } from './KeyNumbersCapital' export { CemeteryEquities } from './CemeteryEquities' export { OperatingYear } from './OperatingYear' export { PowerOfAttorneyFields } from './PowerOfAttorney' -export { DelegationCheck } from './DelegationCheck' export { CemeteryOverview } from './CemeteryOverview' export { Success } from './Success' diff --git a/libs/application/templates/inao/financial-statement-cemetery/src/forms/applicationForm/clientInfoSection/index.ts b/libs/application/templates/inao/financial-statement-cemetery/src/forms/applicationForm/clientInfoSection/index.ts index f763eeb88a19..387a2072098f 100644 --- a/libs/application/templates/inao/financial-statement-cemetery/src/forms/applicationForm/clientInfoSection/index.ts +++ b/libs/application/templates/inao/financial-statement-cemetery/src/forms/applicationForm/clientInfoSection/index.ts @@ -85,11 +85,6 @@ export const clientInfoSection = buildSection({ return userProfile.mobilePhoneNumber }, }), - buildCustomField({ - id: 'delegation check', - component: 'DelegationCheck', - title: '', - }), ], }), ], diff --git a/libs/application/templates/inao/financial-statement-political-party/src/fields/DelegationCheck/DelegationCheck.tsx b/libs/application/templates/inao/financial-statement-political-party/src/fields/DelegationCheck/DelegationCheck.tsx deleted file mode 100644 index 79510986f3c2..000000000000 --- a/libs/application/templates/inao/financial-statement-political-party/src/fields/DelegationCheck/DelegationCheck.tsx +++ /dev/null @@ -1,43 +0,0 @@ -import { FieldBaseProps } from '@island.is/application/types' -import { AlertBanner, Box } from '@island.is/island-ui/core' -import { useLocale } from '@island.is/localization' -import { useFormContext } from 'react-hook-form' -import { VALIDATOR } from '../../utils/constants' -import { m } from '../../lib/messages' -import { FinancialStatementPoliticalParty } from '../../lib/dataSchema' - -export const DelegationCheck = ({ - application, - setBeforeSubmitCallback, -}: FieldBaseProps) => { - const { formatMessage } = useLocale() - const { - formState: { errors }, - setError, - } = useFormContext() - setBeforeSubmitCallback && - setBeforeSubmitCallback(async () => { - const userType = application.externalData.getUserType?.data - const hasUserType = !!userType - - if (hasUserType) { - setError(VALIDATOR, { - type: 'custom', - message: formatMessage(m.wrongDelegation), - }) - return [false, formatMessage(m.wrongDelegation)] - } else { - return [true, null] - } - }) - - return errors && errors.validator ? ( - - - - ) : null -} diff --git a/libs/application/templates/inao/financial-statement-political-party/src/fields/index.ts b/libs/application/templates/inao/financial-statement-political-party/src/fields/index.ts index 45ccedc9d599..4d9e7b24f065 100644 --- a/libs/application/templates/inao/financial-statement-political-party/src/fields/index.ts +++ b/libs/application/templates/inao/financial-statement-political-party/src/fields/index.ts @@ -1,6 +1,5 @@ export { OperatingYear } from './OperatingYear/OperatingYear' export { PowerOfAttorneyFields } from './PowerOfAttorneyFields/PowerOfAttorneyFields' -export { DelegationCheck } from './DelegationCheck/DelegationCheck' export { PartyOperatingIncome } from './PartyOperatingIncome/PartyOperatingIncome' export { KeyNumbersCapital } from './KeyNumbersCapital/KeyNumbersCapital' export { ElectionEquities } from './ElectionEquities/ElectionEquities' diff --git a/libs/application/templates/inao/financial-statement-political-party/src/forms/applicationForm/clientInfoSection/index.ts b/libs/application/templates/inao/financial-statement-political-party/src/forms/applicationForm/clientInfoSection/index.ts index 6343af9dfa42..5045043e3bdd 100644 --- a/libs/application/templates/inao/financial-statement-political-party/src/forms/applicationForm/clientInfoSection/index.ts +++ b/libs/application/templates/inao/financial-statement-political-party/src/forms/applicationForm/clientInfoSection/index.ts @@ -83,11 +83,6 @@ export const clientInfoSection = buildSection({ return userProfile.mobilePhoneNumber }, }), - buildCustomField({ - id: 'delegationCheck', - title: '', - component: 'DelegationCheck', - }), ], }), ], From eff9e2d1767bd6aa3a8af8d411b2cbf4742b0e43 Mon Sep 17 00:00:00 2001 From: Jonni Date: Wed, 20 Nov 2024 14:49:48 +0000 Subject: [PATCH 09/12] chore: remove fakeUser, not used any more --- .../financial-statement-cemetery.service.ts | 6 ++---- .../financial-statement-political-party.service.ts | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/libs/application/template-api-modules/src/lib/modules/templates/financial-statement-cemetery/financial-statement-cemetery.service.ts b/libs/application/template-api-modules/src/lib/modules/templates/financial-statement-cemetery/financial-statement-cemetery.service.ts index a658f7116f11..15112a493849 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/financial-statement-cemetery/financial-statement-cemetery.service.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/financial-statement-cemetery/financial-statement-cemetery.service.ts @@ -32,16 +32,14 @@ export interface DataResponse { } export const getCurrentUserType = ( - answers: Application['answers'], + _answers: Application['answers'], externalData: Application['externalData'], ) => { - const fakeUserType = getValueViaPath(answers, 'fakeData.options') - const currentUserType = getValueViaPath( externalData, 'getUserType.data.value', ) - return fakeUserType ?? currentUserType + return currentUserType } export class FinancialStatementCemeteryTemplateService extends BaseTemplateApiService { diff --git a/libs/application/template-api-modules/src/lib/modules/templates/financial-statement-political-party/financial-statement-political-party.service.ts b/libs/application/template-api-modules/src/lib/modules/templates/financial-statement-political-party/financial-statement-political-party.service.ts index 45d7bf885fc0..0d4ddd01cad9 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/financial-statement-political-party/financial-statement-political-party.service.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/financial-statement-political-party/financial-statement-political-party.service.ts @@ -30,17 +30,15 @@ export interface DataResponse { } export const getCurrentUserType = ( - answers: Application['answers'], + _answers: Application['answers'], externalData: Application['externalData'], ) => { - const fakeUserType = getValueViaPath(answers, 'fakeData.options') - const currentUserType = getValueViaPath( externalData, 'getUserType.data.value', ) - return fakeUserType ?? currentUserType + return currentUserType } @Injectable() From 7b41d06a731c2756265d24a842b2c091118380b8 Mon Sep 17 00:00:00 2001 From: Jonni Date: Wed, 20 Nov 2024 14:53:15 +0000 Subject: [PATCH 10/12] chore: add documentation --- .../inao/financial-statement-cemetery/src/utils/constants.ts | 2 +- .../financial-statement-political-party/src/utils/constants.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/application/templates/inao/financial-statement-cemetery/src/utils/constants.ts b/libs/application/templates/inao/financial-statement-cemetery/src/utils/constants.ts index 1ed243c52fa7..a7981b212bbc 100644 --- a/libs/application/templates/inao/financial-statement-cemetery/src/utils/constants.ts +++ b/libs/application/templates/inao/financial-statement-cemetery/src/utils/constants.ts @@ -14,7 +14,7 @@ export const PartiesBackwardLimit = 'PartiesBackwardLimit' export const CemeteriesBackwardLimit = 'CemeteriesBackwardLimit' export const PartiesYearAllowed = 'PartiesYearAllowed' export const CemeteriesYearAllowed = 'CemeteriesYearAllowed' -export const CEMETERY_USER_TYPE = 150000002 +export const CEMETERY_USER_TYPE = 150000002 // Number that comes from the INAO API // error helpers export const VALIDATOR = 'validator' diff --git a/libs/application/templates/inao/financial-statement-political-party/src/utils/constants.ts b/libs/application/templates/inao/financial-statement-political-party/src/utils/constants.ts index 5882c668bede..6a4de5c9f7b5 100644 --- a/libs/application/templates/inao/financial-statement-political-party/src/utils/constants.ts +++ b/libs/application/templates/inao/financial-statement-political-party/src/utils/constants.ts @@ -5,7 +5,7 @@ export const TOTAL = 'total' export const LESS = 'less' export const GREATER = 'greater' export const ELECTIONLIMIT = 550000 -export const POLITICALPARTY_USER_TYPE = 150000001 +export const POLITICALPARTY_USER_TYPE = 150000001 // Number that comes from the INAO API export const ABOUTIDS = { operatingYear: 'conditionalAbout.operatingYear', From 224db5b0829b67195d3c2aed609938ea3a1a8cac Mon Sep 17 00:00:00 2001 From: Jonni Date: Wed, 20 Nov 2024 15:04:11 +0000 Subject: [PATCH 11/12] chore: edit not allowed permissions --- .../src/lib/financialStatementCemeteryTemplate.ts | 3 +-- .../src/lib/financialStatementPoliticalPartyTemplate.ts | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/libs/application/templates/inao/financial-statement-cemetery/src/lib/financialStatementCemeteryTemplate.ts b/libs/application/templates/inao/financial-statement-cemetery/src/lib/financialStatementCemeteryTemplate.ts index dea4e7456b1d..a92fbc786cb5 100644 --- a/libs/application/templates/inao/financial-statement-cemetery/src/lib/financialStatementCemeteryTemplate.ts +++ b/libs/application/templates/inao/financial-statement-cemetery/src/lib/financialStatementCemeteryTemplate.ts @@ -90,8 +90,7 @@ const FinancialStatementCemeteryTemplate: ApplicationTemplate< import('../forms/notAllowed').then((val) => Promise.resolve(val.notAllowedForm), ), - write: 'all', - delete: true, + read: 'all', }, ], }, diff --git a/libs/application/templates/inao/financial-statement-political-party/src/lib/financialStatementPoliticalPartyTemplate.ts b/libs/application/templates/inao/financial-statement-political-party/src/lib/financialStatementPoliticalPartyTemplate.ts index e73406c985fb..627860da4841 100644 --- a/libs/application/templates/inao/financial-statement-political-party/src/lib/financialStatementPoliticalPartyTemplate.ts +++ b/libs/application/templates/inao/financial-statement-political-party/src/lib/financialStatementPoliticalPartyTemplate.ts @@ -92,8 +92,7 @@ const FinancialStatementPoliticalPartyTemplate: ApplicationTemplate< import('../forms/notAllowedForm').then((val) => Promise.resolve(val.notAllowedForm), ), - write: 'all', - delete: true, + read: 'all', }, ], }, From e6e6352434c674131e08eda231fed406ccd21c9f Mon Sep 17 00:00:00 2001 From: Jonni Date: Fri, 22 Nov 2024 13:11:48 +0000 Subject: [PATCH 12/12] feat: change financial-statements codeowner to Norda by Programm request --- .github/CODEOWNERS | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 3db5e373dd4e..d9d7ad29b0f6 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -235,6 +235,9 @@ codemagic.yaml /libs/application/template-api-modules/src/lib/modules/templates/data-protection-complaint/ @island-is/norda /libs/shared/form-fields/ @island-is/norda @island-is/island-ui /libs/clients/financial-statements-inao @island-is/norda +/libs/api/domains/financial-statements-inao/ @island-is/norda +/libs/application/templates/financial-statements-inao/ @island-is/norda +/libs/application/template-api-modules/src/lib/modules/templates/financial-statements-inao @island-is/norda /libs/portals/my-pages/applications/ @island-is/norda-applications /libs/portals/admin/application-system/ @island-is/norda-applications @@ -316,9 +319,6 @@ codemagic.yaml /apps/services/auth/personal-representative/ @island-is/programm @island-is/aranja /apps/services/auth/personal-representative-public/ @island-is/programm @island-is/aranja -/libs/api/domains/financial-statements-inao/ @island-is/programm -/libs/application/templates/financial-statements-inao/ @island-is/programm -/libs/application/template-api-modules/src/lib/modules/templates/financial-statements-inao @island-is/programm /libs/application/templates/criminal-record/ @island-is/origo /libs/application/template-api-modules/src/lib/modules/templates/criminal-record-submission/ @island-is/origo