Skip to content

Commit

Permalink
fix: total amount calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
Hantex9 committed May 23, 2024
1 parent 79b73c3 commit 9a4afbb
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/features/payments/persistence/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ const generateUserTransaction = (
transactionId,
payeeName: faker.company.name(),
payeeTaxCode,
amount: (additionalTransactionInfo.payments?.[0]?.amount.toString() ??
faker.finance.amount(1, 1000)) as TransactionListItem["amount"],
amount: additionalTransactionInfo.payments?.[0]?.amount.toString(),
transactionDate: new Date().toISOString(),
isCart: false,
};
Expand All @@ -63,7 +62,7 @@ const generateUserTransaction = (
subject: faker.lorem.sentence(
faker.datatype.number({ min: 2, max: 4 })
),
amount: randomTransaction.amount,
amount: faker.finance.amount(1, 1000),
payee: {
name: randomTransaction.payeeName,
taxCode: randomTransaction.payeeTaxCode
Expand All @@ -79,6 +78,11 @@ const generateUserTransaction = (
}));
// eslint-disable-next-line functional/immutable-data
randomTransaction.isCart = cartList.length > 1;
// eslint-disable-next-line functional/immutable-data
randomTransaction.amount = cartList.reduce(
(acc, item) => acc + Number(item.amount),
0
).toString();
addUserTransaction(randomTransaction);

const randomTransactionDetails: TransactionDetailResponse = {
Expand Down

0 comments on commit 9a4afbb

Please sign in to comment.