From 7232a8a93053adedd964659c1f370aa9fddc0e44 Mon Sep 17 00:00:00 2001 From: Riqwan Thamir Date: Mon, 13 Jan 2025 17:25:39 +0100 Subject: [PATCH] fix(core-flows): return refunded when all captured payments have been refunded (#10923) what: - returns refunded when all captured payments have been refunded --- .changeset/sixty-peaches-hug.md | 5 +++++ packages/core/core-flows/src/order/utils/aggregate-status.ts | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .changeset/sixty-peaches-hug.md diff --git a/.changeset/sixty-peaches-hug.md b/.changeset/sixty-peaches-hug.md new file mode 100644 index 0000000000..7ee7546002 --- /dev/null +++ b/.changeset/sixty-peaches-hug.md @@ -0,0 +1,5 @@ +--- +"@medusajs/core-flows": patch +--- + +fix(core-flows): return refunded when all captured payments have been refunded diff --git a/packages/core/core-flows/src/order/utils/aggregate-status.ts b/packages/core/core-flows/src/order/utils/aggregate-status.ts index 3b5585dfa5..94abf727ae 100644 --- a/packages/core/core-flows/src/order/utils/aggregate-status.ts +++ b/packages/core/core-flows/src/order/utils/aggregate-status.ts @@ -55,7 +55,10 @@ export const getLastPaymentStatus = (order: OrderDetailDTO) => { } if (paymentStatus[PaymentStatus.REFUNDED] > 0) { - if (paymentStatus[PaymentStatus.REFUNDED] === totalPaymentExceptCanceled) { + if ( + paymentStatus[PaymentStatus.REFUNDED] === + paymentStatus[PaymentStatus.CAPTURED] + ) { return PaymentStatus.REFUNDED }