fix(core-flows): refresh payment collection (#13103)

This commit is contained in:
Carlos R. L. Rodrigues authored and GitHub committed 2025-07-31 09:06:20 -03:00
1 parent a48063ec26
commit f6736d9661
3 files changed
+8 -3

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
---
"@medusajs/core-flows": patch
---
fix(core-flows): refresh payment collection using raw total
@@ -120,7 +120,7 @@ export const refreshPaymentCollectionForCartWorkflow = createWorkflow(
return { return {
selector: { id: cart.payment_collection.id }, selector: { id: cart.payment_collection.id },
update: { update: {
amount: cart.total, amount: cart.raw_total,
currency_code: cart.currency_code, currency_code: cart.currency_code,
}, },
} }
@@ -26,7 +26,7 @@ export const getLastPaymentStatus = (order: OrderDetailDTO) => {
(isDefined(paymentCollection.amount) && (isDefined(paymentCollection.amount) &&
MathBN.eq(paymentCollection.amount, 0)) MathBN.eq(paymentCollection.amount, 0))
) { ) {
paymentStatus[PaymentStatus.CAPTURED] += MathBN.eq( paymentStatus[PaymentStatus.CAPTURED] += MathBN.gte(
paymentCollection.captured_amount as number, paymentCollection.captured_amount as number,
paymentCollection.amount paymentCollection.amount
) )
@@ -35,7 +35,7 @@ export const getLastPaymentStatus = (order: OrderDetailDTO) => {
} }
if (MathBN.gt(paymentCollection.refunded_amount ?? 0, 0)) { if (MathBN.gt(paymentCollection.refunded_amount ?? 0, 0)) {
paymentStatus[PaymentStatus.REFUNDED] += MathBN.eq( paymentStatus[PaymentStatus.REFUNDED] += MathBN.gte(
paymentCollection.refunded_amount as number, paymentCollection.refunded_amount as number,
paymentCollection.amount paymentCollection.amount
) )