feat(dashboard,core-flows): ability to refund payment post RMA flow (#8685)

This commit is contained in:
Riqwan Thamir authored and GitHub committed 2024-08-21 09:58:09 +02:00
1 parent cc3e84f081
commit a7d03ec562
7 files changed
+107 -27

No files matched your search

@@ -57,17 +57,18 @@ export const createOrUpdateOrderPaymentCollectionWorkflow = createWorkflow(
}).config({ name: "payment-collection-query" })
const amountPending = transform({ order, input }, ({ order, input }) => {
const pendingPayment =
const amountToCharge = input.amount ?? 0
const amountPending =
order.summary.raw_pending_difference ?? order.summary.pending_difference
if (MathBN.gt(input.amount ?? 0, pendingPayment)) {
if (amountToCharge > 0 && MathBN.gt(amountToCharge, amountPending)) {
throw new MedusaError(
MedusaError.Types.NOT_ALLOWED,
`Amount cannot be greater than ${pendingPayment}`
`Amount cannot be greater than ${amountPending}`
)
}
return pendingPayment
return amountPending
})
const updatedPaymentCollections = when(