Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#160955325] Round non exact amounts during verifica #152

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/utils/PaymentsConverter.ts
Expand Up @@ -71,8 +71,9 @@ export function getPaymentRequestsGetResponse(

const response = datiPagamentoPA
? {
importoSingoloVersamento:
datiPagamentoPA.importoSingoloVersamento * 100,
importoSingoloVersamento: Math.round(
datiPagamentoPA.importoSingoloVersamento * 100
),
codiceContestoPagamento: codiceContestoPagamentoApi,
ibanAccredito: datiPagamentoPA.ibanAccredito,
causaleVersamento: getCausaleVersamentoForController(datiPagamentoPA),
Expand Down
23 changes: 23 additions & 0 deletions src/utils/__tests__/PaymentConverter.test.ts
Expand Up @@ -242,6 +242,29 @@ describe("getPaymentsCheckResponse", () => {
datiPagamentoPA.ibanAccredito
);
});

it("should convert non integer amounts to integer amounts", () => {
const verificaOutputWithFloating = {
...MockedData.aVerificaRPTOutput,
datiPagamentoPA: {
...MockedData.aVerificaRPTOutput.datiPagamentoPA,
importoSingoloVersamento: 6656.999999999999
}
};

const errorOrPaymentCheckResponse = PaymentsConverter.getPaymentRequestsGetResponse(
verificaOutputWithFloating,
MockedData.aCodiceContestoPagamento
);

// Check correct field mapping
expect(isRight(errorOrPaymentCheckResponse)).toBeTruthy();

expect(errorOrPaymentCheckResponse.value).toHaveProperty(
"importoSingoloVersamento",
665700
);
});
});

describe("getNodoAttivaRPTInput", () => {
Expand Down