From 33162115e7f7b6f62e97bff980b3c827e60b2c6f Mon Sep 17 00:00:00 2001 From: Alessandro Izzo Date: Fri, 4 Oct 2024 12:33:55 +0200 Subject: [PATCH 1/3] chore: Adapt IDPay definitions mock API --- package.json | 2 +- .../features/idpay/get-timeline-detail.ts | 2 +- src/persistence/idpay.ts | 22 +++++++++---------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index f48796ba..bef742d6 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "api_cdc": "https://raw.githubusercontent.com/pagopa/io-app/master/assets/CdcSwagger.yml", "api_fci": "https://raw.githubusercontent.com/pagopa/io-backend/v14.3.0-RELEASE/api_io_sign.yaml", "api_pn": "https://raw.githubusercontent.com/pagopa/io-backend/v14.3.0-RELEASE/api_pn.yaml", - "api_idpay": "https://raw.githubusercontent.com/pagopa/cstar-infrastructure/v6.5.0/src/domains/idpay-app/api/idpay_appio_full/openapi.appio.full.yml", + "api_idpay": "https://raw.githubusercontent.com/pagopa/cstar-infrastructure/v8.25.1/src/domains/idpay-app/api/idpay_appio_full/openapi.appio.full.yml", "api_fast_login": "https://raw.githubusercontent.com/pagopa/io-auth-n-identity-domain/io-session-manager@1.0.0/apps/io-session-manager/api/fast-login.yaml", "api_trial_system": "https://raw.githubusercontent.com/pagopa/io-backend/v14.3.0-RELEASE/api_trial_system.yaml", "api_pagopa_walletv3": "https://raw.githubusercontent.com/pagopa/pagopa-infra/v1.64.0/src/domains/pay-wallet-app/api/io-payment-wallet/v1/_openapi.json.tpl", diff --git a/src/payloads/features/idpay/get-timeline-detail.ts b/src/payloads/features/idpay/get-timeline-detail.ts index f3a89509..7b3858b9 100644 --- a/src/payloads/features/idpay/get-timeline-detail.ts +++ b/src/payloads/features/idpay/get-timeline-detail.ts @@ -24,7 +24,7 @@ const generateRandomOperationDetailDTO = ( case "TRANSACTION": return { ...operation, - accrued: operation.accrued || faker.datatype.number(100), + accruedCents: operation.accruedCents || faker.datatype.number(10000), idTrxAcquirer: ulid(), idTrxIssuer: ulid() }; diff --git a/src/persistence/idpay.ts b/src/persistence/idpay.ts index af2597f9..0372f2a0 100644 --- a/src/persistence/idpay.ts +++ b/src/persistence/idpay.ts @@ -65,19 +65,19 @@ const { idPay: walletConfig } = ioDevServerConfig.wallet; const pagoPaWallet: WalletV2 = getWalletV2()[0]; const generateRandomInitiativeDTO = (): InitiativeDTO => { - const amount = faker.datatype.number({ min: 50, max: 200, precision: 10 }); - const accrued = faker.datatype.number({ max: 200, precision: 10 }); - const refunded = faker.datatype.number({ max: accrued, precision: 10 }); + const amountCents = faker.datatype.number({ min: 500, max: 200 }); + const accruedCents = faker.datatype.number({ max: 20000 }); + const refundedCents = faker.datatype.number({ max: accruedCents }); return { initiativeId: ulid(), initiativeName: faker.company.name(), status: getRandomEnumValue(InitiativeStatus), endDate: faker.date.future(1), - amount, - accrued, + amountCents, + accruedCents, initiativeRewardType: getRandomEnumValue(InitiativeRewardTypeEnum), - refunded, + refundedCents, lastCounterUpdate: faker.date.recent(1), iban: faker.helpers.arrayElement(ibanList)?.iban || "", nInstr: 1, @@ -107,8 +107,8 @@ const generateRandomTransactionOperationDTO = ( operationType: getRandomEnumValue(TransactionOperationTypeEnum), operationDate: new Date(), operationId: ulid(), - accrued: faker.datatype.number({ min: 5, max: 25 }), - amount: faker.datatype.number({ min: 50, max: 100 }), + accruedCents: faker.datatype.number({ min: 500, max: 2500 }), + amountCents: faker.datatype.number({ min: 5000, max: 10000 }), brand, circuitType: "01", brandLogo, @@ -128,7 +128,7 @@ const generateRandomRefundOperationDTO = ( operationDate: new Date(), operationId: ulid(), eventId: ulid(), - amount: faker.datatype.number({ min: 5, max: 100 }), + amountCents: faker.datatype.number({ min: 500, max: 10000 }), ...withInfo }); @@ -525,8 +525,8 @@ range(0, walletConfig.discountCount).forEach(() => { status: InitiativeStatus.REFUNDABLE, iban: undefined, nInstr: 0, - accrued: 0, - refunded: 0 + accruedCents: 0, + refundedCents: 0 }; const { initiativeId } = initiative; From cdb95b190fdb126e66a20fb2dbc7a35a9ec73893 Mon Sep 17 00:00:00 2001 From: Alessandro Izzo Date: Fri, 4 Oct 2024 12:48:55 +0200 Subject: [PATCH 2/3] fix: max amount with cents --- src/persistence/idpay.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/persistence/idpay.ts b/src/persistence/idpay.ts index 0372f2a0..9cb9e450 100644 --- a/src/persistence/idpay.ts +++ b/src/persistence/idpay.ts @@ -65,7 +65,7 @@ const { idPay: walletConfig } = ioDevServerConfig.wallet; const pagoPaWallet: WalletV2 = getWalletV2()[0]; const generateRandomInitiativeDTO = (): InitiativeDTO => { - const amountCents = faker.datatype.number({ min: 500, max: 200 }); + const amountCents = faker.datatype.number({ min: 5000, max: 20000 }); const accruedCents = faker.datatype.number({ max: 20000 }); const refundedCents = faker.datatype.number({ max: accruedCents }); From 9c668b7023315af8aa1f19bab15918e6d2b4debc Mon Sep 17 00:00:00 2001 From: Alessandro Izzo Date: Fri, 4 Oct 2024 12:49:52 +0200 Subject: [PATCH 3/3] fix: Residual budget with cents amount --- src/routers/features/idpay/payment.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/routers/features/idpay/payment.ts b/src/routers/features/idpay/payment.ts index 44fc0727..cbbe69a1 100644 --- a/src/routers/features/idpay/payment.ts +++ b/src/routers/features/idpay/payment.ts @@ -16,8 +16,8 @@ import { addIdPayHandler } from "./router"; const generateRandomAuthPaymentResponseDTO = (): AuthPaymentResponseDTO => { const amount = faker.datatype.number({ - min: 100, - max: 10000 + min: 10000, + max: 1000000 }); return { @@ -25,12 +25,12 @@ const generateRandomAuthPaymentResponseDTO = (): AuthPaymentResponseDTO => { initiativeId: Object.values(initiatives)[0]?.initiativeId ?? ulid(), status: getRandomEnumValue(PaymentStatusEnum), trxCode: faker.datatype.string(), - reward: amount, + rewardCents: amount, amountCents: amount, businessName: faker.commerce.productName(), initiativeName: faker.company.name(), trxDate: faker.date.recent(0), - residualBudget: faker.datatype.number({ + residualBudgetCents: faker.datatype.number({ min: 1000, max: 20000 })