Skip to content

Commit

Permalink
revert(financial-aid): wide revert of financial aid main (#17091)
Browse files Browse the repository at this point in the history
* Revert "fix: revert back to previous version of filelist (#16825)"

This reverts commit b90bbfa.

* Revert "fix(financial-adi): use account number and ledger when sending bank info (#16599)"

This reverts commit 45ec2fd.

* Revert "fix(financial-aid): dynamic logo (#16518)"

This reverts commit 4678927.

* Revert "chore(financial-aid): refactor custom components out (#15549)"

This reverts commit 18b87eb.

* chore: undo changes in veita

* chore: nx format:write update dirty files

* fix: remove duplicate imports after merge conflict

---------

Co-authored-by: andes-it <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Dec 3, 2024
1 parent 9c6a570 commit dc014ba
Show file tree
Hide file tree
Showing 231 changed files with 3,023 additions and 7,135 deletions.
45 changes: 0 additions & 45 deletions libs/application/core/src/lib/fieldBuilders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ import {
StaticTableField,
HiddenInputWithWatchedValueField,
HiddenInputField,
AccordionField,
BankAccountField,
SliderField,
MaybeWithApplication,
MaybeWithApplicationAndFieldAndLocale,
Expand Down Expand Up @@ -459,49 +457,6 @@ export const buildKeyValueField = (data: {
}
}

export const buildAccordionField = (
data: Omit<AccordionField, 'type' | 'component' | 'children'>,
): AccordionField => {
const {
accordionItems,
title,
titleVariant,
id,
marginTop,
marginBottom,
condition,
} = data
return {
children: undefined,
id,
title,
titleVariant,
marginTop,
marginBottom,
accordionItems,
condition,
type: FieldTypes.ACCORDION,
component: FieldComponents.ACCORDION,
}
}

export const buildBankAccountField = (
data: Omit<BankAccountField, 'type' | 'component' | 'children'>,
): BankAccountField => {
const { title, id, marginBottom, marginTop, titleVariant } = data

return {
children: undefined,
id,
title,
marginBottom,
marginTop,
titleVariant,
type: FieldTypes.BANK_ACCOUNT,
component: FieldComponents.BANK_ACCOUNT,
}
}

export const buildSubmitField = (data: {
id: string
title: FormText
Expand Down
15 changes: 0 additions & 15 deletions libs/application/core/src/lib/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,21 +318,6 @@ export const coreDefaultFieldMessages = defineMessages({
defaultMessage: 'Veljið skjöl til að hlaða upp',
description: 'Default file upload button label',
},
defaultBankAccountBankNumber: {
id: 'application.system:core.default.bankAccount.bankNumber',
defaultMessage: 'Bankanúmer',
description: 'Bank account bank number',
},
defaultBankAccountLedger: {
id: 'application.system:core.default.bankAccount.ledger',
defaultMessage: 'Höfuðbók',
description: 'Bank account ledger',
},
defaultBankAccountAccountNumber: {
id: 'application.system:core.default.bankAccount.accountNumber',
defaultMessage: 'Reikningsnúmer',
description: 'Bank account account number',
},
defaultDownloadButtonTitle: {
id: 'application.system:core.default.pdfLinkButtonField.downloadButtonTitle',
defaultMessage: 'Hlaða niður skjali',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { Injectable } from '@nestjs/common'

import {
FinancialAidAnswers,
ApproveOptions,
ChildrenSchoolInfo,
CurrentApplication,
FinancialAidExternalData,
FAApplication,
findFamilyStatus,
TaxData,
} from '@island.is/application/templates/financial-aid'
Expand All @@ -14,7 +12,6 @@ import { AuthMiddleware } from '@island.is/auth-nest-tools'
import {
ApplicationState,
FileType,
PersonalTaxReturn,
UserType,
} from '@island.is/financial-aid/shared/lib'
import {
Expand All @@ -27,17 +24,15 @@ import {
import { TemplateApiModuleActionProps } from '../../../types'
import { BaseTemplateApiService } from '../../base-template-api.service'
import {
Application,
ApplicationAnswerFile,
ApplicationTypes,
} from '@island.is/application/types'
import { FetchError } from '@island.is/clients/middlewares'
import { messages } from '@island.is/application/templates/financial-aid'
import { TemplateApiError } from '@island.is/nest/problem'
import { getValueViaPath } from '@island.is/application/core'

type Props = Omit<TemplateApiModuleActionProps, 'application'> & {
application: Application
application: FAApplication
}

@Injectable()
Expand Down Expand Up @@ -80,26 +75,15 @@ export class FinancialAidService extends BaseTemplateApiService {
auth,
}: Props): Promise<CurrentApplication> {
const { id, answers, externalData } = application
const answersSchema = answers as FinancialAidAnswers
const externalDataSchema =
externalData as unknown as FinancialAidExternalData
const currentApplicationId = getValueViaPath(
externalData,
'currentApplication.data.currentApplicationId',
) as string | undefined

const childrenSchoolInfo = getValueViaPath(
answers,
'childrenSchoolInfo',
) as Array<ChildrenSchoolInfo>

if (currentApplicationId) {
if (externalData.currentApplication.data?.currentApplicationId) {
return {
currentApplicationId,
currentApplicationId:
externalData.currentApplication.data.currentApplicationId,
}
}
const children = answers.childrenSchoolInfo
? childrenSchoolInfo.map((child) => {
? answers.childrenSchoolInfo.map((child) => {
return {
name: child.fullName,
nationalId: child.nationalId,
Expand All @@ -124,117 +108,102 @@ export class FinancialAidService extends BaseTemplateApiService {
})
}

const personalTaxReturn = getValueViaPath(
externalData,
'taxData.data.municipalitiesPersonalTaxReturn.personalTaxReturn',
) as PersonalTaxReturn | undefined

const spouseTaxReturn = getValueViaPath(
externalData,
'taxDataSpouse.data.municipalitiesPersonalTaxReturn.personalTaxReturn',
) as PersonalTaxReturn | undefined

const spouseTaxFiles = () => {
if (spouseTaxReturn == null) {
if (
externalData?.taxDataSpouse?.data?.municipalitiesPersonalTaxReturn
?.personalTaxReturn == null
) {
return []
}
return [spouseTaxReturn]
return [
externalData?.taxDataSpouse?.data?.municipalitiesPersonalTaxReturn
?.personalTaxReturn,
]
}

const applicantTaxFiles = () => {
if (personalTaxReturn == null) {
if (
externalData?.taxData?.data?.municipalitiesPersonalTaxReturn
?.personalTaxReturn == null
) {
return []
}
return [personalTaxReturn]
return [
externalData?.taxData?.data?.municipalitiesPersonalTaxReturn
?.personalTaxReturn,
]
}

const directTaxPayments = () => {
const combinedTaxPayments = [
...(externalDataSchema?.taxData?.data?.municipalitiesDirectTaxPayments
?.directTaxPayments || []),
...(externalDataSchema?.taxDataSpouse?.data
?.municipalitiesDirectTaxPayments?.directTaxPayments || []),
]

return combinedTaxPayments.map((d) => {
d.userType = application.assignees.includes(auth.nationalId)
? UserType.SPOUSE
: UserType.APPLICANT
return d
})
if (externalData?.taxDataSpouse?.data) {
externalData?.taxData?.data?.municipalitiesDirectTaxPayments?.directTaxPayments.concat(
externalData?.taxDataSpouse?.data.municipalitiesDirectTaxPayments
?.directTaxPayments,
)
}
return externalData?.taxData?.data?.municipalitiesDirectTaxPayments?.directTaxPayments.map(
(d) => {
d.userType = application.assignees.includes(auth.nationalId)
? UserType.SPOUSE
: UserType.APPLICANT
return d
},
)
}

const files = formatFiles(
answersSchema?.taxReturnFiles ?? [],
FileType.TAXRETURN,
)
.concat(formatFiles(answersSchema.incomeFiles ?? [], FileType.INCOME))
.concat(
formatFiles(
answersSchema.spouseIncomeFiles ?? [],
FileType.SPOUSEFILES,
),
)
.concat(
formatFiles(
answersSchema.spouseTaxReturnFiles ?? [],
FileType.SPOUSEFILES,
),
)
const files = formatFiles(answers.taxReturnFiles, FileType.TAXRETURN)
.concat(formatFiles(answers.incomeFiles, FileType.INCOME))
.concat(formatFiles(answers.spouseIncomeFiles, FileType.SPOUSEFILES))
.concat(formatFiles(answers.spouseTaxReturnFiles, FileType.SPOUSEFILES))
.concat(formatFiles(spouseTaxFiles(), FileType.SPOUSEFILES))
.concat(formatFiles(applicantTaxFiles(), FileType.TAXRETURN))
.concat(
formatFiles(answersSchema.childrenFiles ?? [], FileType.CHILDRENFILES),
)
.concat(formatFiles(answers.childrenFiles, FileType.CHILDRENFILES))

const newApplication = {
name: externalDataSchema.nationalRegistry.data.fullName,
nationalId: externalDataSchema.nationalRegistry.data.nationalId,
phoneNumber: answersSchema.contactInfo.phone,
email: answersSchema.contactInfo.email,
homeCircumstances: answersSchema.homeCircumstances.type,
homeCircumstancesCustom: answersSchema.homeCircumstances.custom,
student: Boolean(answersSchema.student.isStudent === ApproveOptions.Yes),
studentCustom: answersSchema.student.custom,
hasIncome: Boolean(answersSchema.income.type === ApproveOptions.Yes),
name: externalData.nationalRegistry.data.fullName,
nationalId: externalData.nationalRegistry.data.nationalId,
phoneNumber: answers.contactInfo.phone,
email: answers.contactInfo.email,
homeCircumstances: answers.homeCircumstances.type,
homeCircumstancesCustom: answers.homeCircumstances.custom,
student: Boolean(answers.student.isStudent === ApproveOptions.Yes),
studentCustom: answers.student.custom,
hasIncome: Boolean(answers.income === ApproveOptions.Yes),
usePersonalTaxCredit: Boolean(
answersSchema.personalTaxCredit.type === ApproveOptions.Yes,
answers.personalTaxCredit === ApproveOptions.Yes,
),
bankNumber: answersSchema.bankInfo.bankNumber,
ledger: answersSchema.bankInfo.ledger,
accountNumber: answersSchema.bankInfo.accountNumber,
employment: answersSchema.employment.type,
employmentCustom: answersSchema.employment.custom,
formComment: answersSchema.formComment,
bankNumber: answers.bankInfo.bankNumber,
ledger: answers.bankInfo.ledger,
accountNumber: answers.bankInfo.accountNumber,
employment: answers.employment.type,
employmentCustom: answers.employment.custom,
formComment: answers.formComment,
state: ApplicationState.NEW,
files: files,
children,
childrenComment: answersSchema.childrenComment,
children: children,
childrenComment: answers.childrenComment,
spouseNationalId:
externalDataSchema.nationalRegistrySpouse.data?.nationalId ||
answersSchema.relationshipStatus?.spouseNationalId,
externalData.nationalRegistrySpouse.data?.nationalId ||
answers.relationshipStatus?.spouseNationalId,
spouseEmail:
answersSchema.spouseContactInfo?.email ||
answersSchema.spouse?.email ||
answersSchema.relationshipStatus?.spouseEmail,
spousePhoneNumber: answersSchema.spouseContactInfo?.phone,
answers.spouseContactInfo?.email ||
answers.spouse?.email ||
answers.relationshipStatus?.spouseEmail,
spousePhoneNumber: answers.spouseContactInfo?.phone,
spouseName:
externalDataSchema.nationalRegistrySpouse.data?.name ||
answersSchema.spouseName,
spouseFormComment: answersSchema.spouseFormComment,
familyStatus: findFamilyStatus(answersSchema, externalData),
streetName:
externalDataSchema.nationalRegistry.data.address?.streetAddress,
postalCode: externalDataSchema.nationalRegistry.data.address?.postalCode,
city: externalDataSchema.nationalRegistry.data.address?.locality,
externalData.nationalRegistrySpouse.data?.name || answers.spouseName,
spouseFormComment: answers.spouseFormComment,
familyStatus: findFamilyStatus(answers, externalData),
streetName: externalData.nationalRegistry.data.address?.streetAddress,
postalCode: externalData.nationalRegistry.data.address?.postalCode,
city: externalData.nationalRegistry.data.address?.locality,
municipalityCode:
externalDataSchema.nationalRegistry.data.address?.municipalityCode,
externalData.nationalRegistry.data.address?.municipalityCode,
directTaxPayments: directTaxPayments(),
hasFetchedDirectTaxPayment:
externalDataSchema?.taxData?.data?.municipalitiesDirectTaxPayments
?.success,
externalData?.taxData?.data?.municipalitiesDirectTaxPayments?.success,
spouseHasFetchedDirectTaxPayment:
externalDataSchema?.taxDataSpouse?.data?.municipalitiesDirectTaxPayments
externalData?.taxDataSpouse?.data?.municipalitiesDirectTaxPayments
?.success,
applicationSystemId: id,
}
Expand Down Expand Up @@ -274,10 +243,8 @@ export class FinancialAidService extends BaseTemplateApiService {
auth,
application,
}: Props): Promise<MunicipalityModel | null> {
const municiplaityCode = getValueViaPath(
application.externalData,
'nationalRegistry.data.address.municipalityCode',
) as string
const municiplaityCode =
application.externalData.nationalRegistry.data.address?.municipalityCode
if (municiplaityCode == null) {
return null
}
Expand Down Expand Up @@ -320,26 +287,23 @@ export class FinancialAidService extends BaseTemplateApiService {
application,
}: Props): Promise<{ success: boolean }> {
const { answers, externalData } = application
const answersSchema = answers as unknown as FinancialAidAnswers
const externalDataSchema =
externalData as unknown as FinancialAidExternalData
try {
return await this.applicationApiWithAuth(
auth,
).applicationControllerSendSpouseEmail({
spouseEmailDto: {
name: externalDataSchema.nationalRegistry.data.fullName,
email: answersSchema.contactInfo.email,
name: externalData.nationalRegistry.data.fullName,
email: answers.contactInfo.email,
spouseName:
externalDataSchema.nationalRegistrySpouse.data?.name ||
answersSchema.spouseName ||
externalData.nationalRegistrySpouse.data?.name ||
answers.spouseName ||
'',
spouseEmail:
answersSchema.spouse?.email ||
answersSchema.relationshipStatus.spouseEmail ||
answers.spouse?.email ||
answers.relationshipStatus.spouseEmail ||
'',
municipalityCode:
externalDataSchema.municipality.data?.municipalityId || '',
externalData.municipality.data?.municipalityId || '',
created: application.created,
applicationSystemId: application.id,
},
Expand Down
Loading

0 comments on commit dc014ba

Please sign in to comment.