From 044b7236572089b98a9f230499bb4cd9ad0342a3 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Tue, 1 Sep 2020 20:37:50 +0530 Subject: correct refund amounts and better testing --- .../taler-wallet-core/src/operations/transactions.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'packages/taler-wallet-core/src/operations') diff --git a/packages/taler-wallet-core/src/operations/transactions.ts b/packages/taler-wallet-core/src/operations/transactions.ts index 2515415d2..da75f6e53 100644 --- a/packages/taler-wallet-core/src/operations/transactions.ts +++ b/packages/taler-wallet-core/src/operations/transactions.ts @@ -281,22 +281,27 @@ export async function getTransactions( groupKey, ); let r0: WalletRefundItem | undefined; - let amountEffective = Amounts.getZero( + let amountRaw = Amounts.getZero( pr.contractData.amount.currency, ); - let amountRaw = Amounts.getZero(pr.contractData.amount.currency); + let amountEffective = Amounts.getZero(pr.contractData.amount.currency); for (const rk of Object.keys(pr.refunds)) { const refund = pr.refunds[rk]; + const myGroupKey = `${refund.executionTime.t_ms}`; + if (myGroupKey !== groupKey) { + continue; + } if (!r0) { r0 = refund; } + if (refund.type === RefundState.Applied) { - amountEffective = Amounts.add( - amountEffective, - refund.refundAmount, - ).amount; amountRaw = Amounts.add( amountRaw, + refund.refundAmount, + ).amount; + amountEffective = Amounts.add( + amountEffective, Amounts.sub( refund.refundAmount, refund.refundFee, -- cgit v1.2.3