Skip to content

Commit

Permalink
Merge branch 'main' into feat/allow-specific-days-from-actual-birth-date
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Nov 25, 2024
2 parents 4d52b15 + 49cd9ac commit 9f3ba87
Show file tree
Hide file tree
Showing 260 changed files with 3,944 additions and 1,343 deletions.
8 changes: 4 additions & 4 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,10 @@ 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/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
Expand Down Expand Up @@ -315,10 +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/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

/libs/application/templates/criminal-record/ @island-is/origo
/libs/application/template-api-modules/src/lib/modules/templates/criminal-record-submission/ @island-is/origo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ import { ApplicationResponseDto } from './dto/application.response.dto'
import { PresignedUrlResponseDto } from './dto/presignedUrl.response.dto'
import { AssignApplicationDto } from './dto/assignApplication.dto'
import { verifyToken } from './utils/tokenUtils'
import { getApplicationLifecycle } from './utils/application'
import {
getApplicationLifecycle,
removeObjectWithKeyFromAnswers,
} from './utils/application'
import { DecodedAssignmentToken } from './types'
import { ApplicationAccessService } from './tools/applicationAccess.service'
import { CurrentLocale } from './utils/currentLocale'
Expand Down Expand Up @@ -870,6 +873,10 @@ export class ApplicationController {
existingApplication.id,
{
attachments: omit(existingApplication.attachments, key),
answers: removeObjectWithKeyFromAnswers(
existingApplication.answers,
key,
),
},
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ class MockChargeFjsV2ClientService {
chargeItemName: '1',
priceAmount: 1,
},
{
performingOrgID: performingOrganizationID,
chargeType: '1',
chargeItemCode: 'asdf2',
chargeItemName: '2',
priceAmount: 2,
},
],
})
}
Expand Down Expand Up @@ -97,12 +104,12 @@ describe('Payment Service', () => {

it('should create a charge', async () => {
const performingOrganizationID = '1'
const chargeItemCodes: string[] = ['asdf']
const chargeItems = [{ code: 'asdf' }]

const result = await service.createCharge(
user,
performingOrganizationID,
chargeItemCodes,
chargeItems,
applicationId,
undefined,
)
Expand All @@ -112,12 +119,27 @@ describe('Payment Service', () => {

it('should create a charge with multiple charge items', async () => {
const performingOrganizationID = '1'
const chargeItemCodes: string[] = ['asdf', 'asdf']
const chargeItems = [{ code: 'asdf' }, { code: 'asdf' }]

const result = await service.createCharge(
user,
performingOrganizationID,
chargeItems,
applicationId,
undefined,
)

expect(result).toBeTruthy()
})

it('should create a charge with multiple charge items using quantity', async () => {
const performingOrganizationID = '1'
const chargeItems = [{ code: 'asdf', quantity: 3 }]

const result = await service.createCharge(
user,
performingOrganizationID,
chargeItemCodes,
chargeItems,
applicationId,
undefined,
)
Expand All @@ -127,13 +149,13 @@ describe('Payment Service', () => {

it('should throw an error when charge item is not found', async () => {
const performingOrganizationID = '1'
const chargeItemCodes: string[] = ['13']
const chargeItems = [{ code: '13' }]

await expect(
service.createCharge(
user,
performingOrganizationID,
chargeItemCodes,
chargeItems,
applicationId,
undefined,
),
Expand All @@ -142,12 +164,12 @@ describe('Payment Service', () => {

it('should get a payment status', async () => {
const performingOrganizationID = '1'
const chargeItemCodes: string[] = ['asdf', 'asdf']
const chargeItems = [{ code: 'asdf' }, { code: 'asdf' }]

const charge = await service.createCharge(
user,
performingOrganizationID,
chargeItemCodes,
chargeItems,
applicationId,
undefined,
)
Expand All @@ -158,12 +180,12 @@ describe('Payment Service', () => {

it('should get a fulfilled payment status', async () => {
const performingOrganizationID = '1'
const chargeItemCodes: string[] = ['asdf', 'asdf']
const chargeItems = [{ code: 'asdf' }, { code: 'asdf' }]

const charge = await service.createCharge(
user,
performingOrganizationID,
chargeItemCodes,
chargeItems,
applicationId,
undefined,
)
Expand All @@ -177,9 +199,43 @@ describe('Payment Service', () => {
expect(result.fulfilled).toBe(true)
})

it('should find charge items using quantity', async () => {
const performingOrganizationID = '1'
const chargeItems = [
{ code: 'asdf', quantity: 2 },
{ code: 'asdf2', quantity: 3 },
]

const catalogChargeItems = await service.findCatalogChargeItems(
performingOrganizationID,
chargeItems,
)

// make sure quantity is correct for item 1 (code 'asdf')
const catalogQuantityItem1 = catalogChargeItems.find(
({ chargeItemCode }) => chargeItemCode === chargeItems[0].code,
)?.quantity
expect(catalogQuantityItem1).toBe(chargeItems[0].quantity)

// make sure quantity is correct for item 2 (code 'asdf2')
const catalogQuantityItem2 = catalogChargeItems.find(
({ chargeItemCode }) => chargeItemCode === chargeItems[1].code,
)?.quantity
expect(catalogQuantityItem2).toBe(chargeItems[1].quantity)

// make sure total sum is correct
const catalogTotalQuantity = catalogChargeItems.reduce(
(sum, item) => sum + (item.quantity || 0),
0,
)
expect(catalogTotalQuantity).toBe(
chargeItems[0].quantity + chargeItems[1].quantity,
)
})

it('Should throw when payment exists and status is in progress.', async () => {
const performingOrganizationID = '1'
const chargeItemCodes: string[] = ['asdf', 'asdf']
const chargeItems = [{ code: 'asdf' }, { code: 'asdf' }]

jest.spyOn(fjsClient, 'getChargeStatus').mockResolvedValueOnce({
statusResult: {
Expand All @@ -192,13 +248,13 @@ describe('Payment Service', () => {
},
})

const chargeItems = await service.findChargeItems(
const catalogChargeItems = await service.findCatalogChargeItems(
performingOrganizationID,
chargeItemCodes,
chargeItems,
)

const payment = await service.createPaymentModel(
chargeItems,
catalogChargeItems,
applicationId,
performingOrganizationID,
)
Expand All @@ -207,7 +263,7 @@ describe('Payment Service', () => {
service.createCharge(
user,
performingOrganizationID,
chargeItemCodes,
chargeItems,
applicationId,
undefined,
),
Expand All @@ -216,7 +272,7 @@ describe('Payment Service', () => {

it('Should continue with a payment that exists and status with an unpaid status.', async () => {
const performingOrganizationID = '1'
const chargeItemCodes: string[] = ['asdf', 'asdf']
const chargeItems = [{ code: 'asdf' }, { code: 'asdf' }]

const mock = jest.spyOn(fjsClient, 'getChargeStatus')

Expand All @@ -233,21 +289,21 @@ describe('Payment Service', () => {
}),
)

const chargeItems = await service.findChargeItems(
const catalogChargeItems = await service.findCatalogChargeItems(
performingOrganizationID,
chargeItemCodes,
chargeItems,
)

const payment = await service.createPaymentModel(
chargeItems,
catalogChargeItems,
applicationId,
performingOrganizationID,
)

const charge = await service.createCharge(
user,
performingOrganizationID,
chargeItemCodes,
chargeItems,
applicationId,
undefined,
)
Expand All @@ -257,7 +313,7 @@ describe('Payment Service', () => {

it('Should not create a new charge and a payment when payment exists', async () => {
const performingOrganizationID = '1'
const chargeItemCodes: string[] = ['asdf', 'asdf']
const chargeItems = [{ code: 'asdf' }, { code: 'asdf' }]

const mock = jest.spyOn(fjsClient, 'getChargeStatus')
const createChargeSpy = jest.spyOn(fjsClient, 'createCharge')
Expand All @@ -275,21 +331,21 @@ describe('Payment Service', () => {
}),
)

const chargeItems = await service.findChargeItems(
const catalogChargeItems = await service.findCatalogChargeItems(
performingOrganizationID,
chargeItemCodes,
chargeItems,
)

const payment = await service.createPaymentModel(
chargeItems,
catalogChargeItems,
applicationId,
performingOrganizationID,
)

const charge = await service.createCharge(
user,
performingOrganizationID,
chargeItemCodes,
chargeItems,
applicationId,
undefined,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class MockPaymentService {
}
}

async findChargeItems() {
async findCatalogChargeItems() {
return [
{
performingOrgID: faker.datatype.number(),
Expand Down
Loading

0 comments on commit 9f3ba87

Please sign in to comment.