refund awating is empty when puchase is paid, returning last refund id
This commit is contained in:
parent
26aca142fe
commit
5ad96b178e
@ -2321,7 +2321,6 @@ async function acceptRefunds(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const refreshCoinsMap: Record<string, CoinRefreshRequest> = {};
|
const refreshCoinsMap: Record<string, CoinRefreshRequest> = {};
|
||||||
|
|
||||||
for (const refundStatus of refunds) {
|
for (const refundStatus of refunds) {
|
||||||
const refundKey = getRefundKey(refundStatus);
|
const refundKey = getRefundKey(refundStatus);
|
||||||
const existingRefundInfo = p.refunds[refundKey];
|
const existingRefundInfo = p.refunds[refundKey];
|
||||||
@ -2412,6 +2411,7 @@ async function acceptRefunds(
|
|||||||
}
|
}
|
||||||
} else if (p.purchaseStatus === PurchaseStatus.QueryingRefund) {
|
} else if (p.purchaseStatus === PurchaseStatus.QueryingRefund) {
|
||||||
p.purchaseStatus = PurchaseStatus.Paid;
|
p.purchaseStatus = PurchaseStatus.Paid;
|
||||||
|
p.refundAmountAwaiting = undefined;
|
||||||
}
|
}
|
||||||
logger.trace("refund query done");
|
logger.trace("refund query done");
|
||||||
ws.notify({
|
ws.notify({
|
||||||
@ -2572,10 +2572,26 @@ export async function applyRefundFromPurchaseId(
|
|||||||
const summary = await calculateRefundSummary(ws, purchase);
|
const summary = await calculateRefundSummary(ws, purchase);
|
||||||
const download = await expectProposalDownload(ws, purchase);
|
const download = await expectProposalDownload(ws, purchase);
|
||||||
|
|
||||||
|
const lastExec = Object.values(purchase.refunds).reduce(
|
||||||
|
(prev, cur) => {
|
||||||
|
return TalerProtocolTimestamp.max(cur.executionTime, prev);
|
||||||
|
},
|
||||||
|
{ t_s: 0 } as TalerProtocolTimestamp,
|
||||||
|
);
|
||||||
|
|
||||||
|
const transactionId =
|
||||||
|
lastExec.t_s === "never" || lastExec.t_s === 0
|
||||||
|
? makeTransactionId(TransactionType.Payment, proposalId)
|
||||||
|
: makeTransactionId(
|
||||||
|
TransactionType.Refund,
|
||||||
|
proposalId,
|
||||||
|
String(lastExec.t_s),
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
contractTermsHash: download.contractData.contractTermsHash,
|
contractTermsHash: download.contractData.contractTermsHash,
|
||||||
proposalId: purchase.proposalId,
|
proposalId: purchase.proposalId,
|
||||||
transactionId: makeTransactionId(TransactionType.Payment, proposalId), //FIXME: can we have the tx id of the refund
|
transactionId,
|
||||||
amountEffectivePaid: Amounts.stringify(summary.amountEffectivePaid),
|
amountEffectivePaid: Amounts.stringify(summary.amountEffectivePaid),
|
||||||
amountRefundGone: Amounts.stringify(summary.amountRefundGone),
|
amountRefundGone: Amounts.stringify(summary.amountRefundGone),
|
||||||
amountRefundGranted: Amounts.stringify(summary.amountRefundGranted),
|
amountRefundGranted: Amounts.stringify(summary.amountRefundGranted),
|
||||||
|
Loading…
Reference in New Issue
Block a user