diff options
author | Florian Dold <florian.dold@gmail.com> | 2020-07-23 17:35:17 +0530 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2020-07-23 17:35:17 +0530 |
commit | d88829cfa8dc7bf2967fb494af0290e068466828 (patch) | |
tree | 682faf6027e572e2c28b548d65b0045692b2da29 /src/wallet.ts | |
parent | e60563fb540c04d9ba751fea69c1fc0f1de598b5 (diff) | |
download | wallet-core-d88829cfa8dc7bf2967fb494af0290e068466828.tar.xz |
towards refunds with updated protocol
Diffstat (limited to 'src/wallet.ts')
-rw-r--r-- | src/wallet.ts | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/wallet.ts b/src/wallet.ts index ff72f3c75..60ed695fd 100644 --- a/src/wallet.ts +++ b/src/wallet.ts @@ -51,6 +51,7 @@ import { Stores, ReserveRecordStatus, CoinSourceType, + RefundState, } from "./types/dbTypes"; import { CoinDumpJson } from "./types/talerTypes"; import { @@ -534,6 +535,7 @@ export class Wallet { [Stores.refreshGroups], async (tx) => { return await createRefreshGroup( + this.ws, tx, [{ coinPub: oldCoinPub }], RefreshReason.Manual, @@ -785,22 +787,23 @@ export class Wallet { if (!purchase) { throw Error("unknown purchase"); } - const refundsDoneAmounts = Object.values(purchase.refundsDone).map((x) => - Amounts.parseOrThrow(x.perm.refund_amount), - ); - const refundsPendingAmounts = Object.values( - purchase.refundsPending, - ).map((x) => Amounts.parseOrThrow(x.perm.refund_amount)); + const refundsDoneAmounts = Object.values(purchase.refunds) + .filter((x) => x.type === RefundState.Applied) + .map((x) => x.refundAmount); + + const refundsPendingAmounts = Object.values(purchase.refunds) + .filter((x) => x.type === RefundState.Pending) + .map((x) => x.refundAmount); const totalRefundAmount = Amounts.sum([ ...refundsDoneAmounts, ...refundsPendingAmounts, ]).amount; - const refundsDoneFees = Object.values(purchase.refundsDone).map((x) => - Amounts.parseOrThrow(x.perm.refund_amount), - ); - const refundsPendingFees = Object.values(purchase.refundsPending).map((x) => - Amounts.parseOrThrow(x.perm.refund_amount), - ); + const refundsDoneFees = Object.values(purchase.refunds) + .filter((x) => x.type === RefundState.Applied) + .map((x) => x.refundFee); + const refundsPendingFees = Object.values(purchase.refunds) + .filter((x) => x.type === RefundState.Pending) + .map((x) => x.refundFee); const totalRefundFees = Amounts.sum([ ...refundsDoneFees, ...refundsPendingFees, |