fix(core-flows): aggregate payment status (#10278)
This commit is contained in:
1 parent
9f204817b0
commit
a8eec16122
2 files changed
+15
-1
No files matched your search
@@ -100,6 +100,16 @@ describe("Aggregate Order Status", () => {
|
|||||||
} as any)
|
} as any)
|
||||||
).toEqual("captured")
|
).toEqual("captured")
|
||||||
|
|
||||||
|
expect(
|
||||||
|
getLastPaymentStatus({
|
||||||
|
payment_collections: [
|
||||||
|
{ status: "authorized", captured_amount: 0, amount: 0 },
|
||||||
|
{ status: "authorized", captured_amount: 12, amount: 12 },
|
||||||
|
{ status: "canceled" },
|
||||||
|
],
|
||||||
|
} as any)
|
||||||
|
).toEqual("captured")
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
getLastPaymentStatus({
|
getLastPaymentStatus({
|
||||||
payment_collections: [
|
payment_collections: [
|
||||||
|
|||||||
@@ -21,7 +21,11 @@ export const getLastPaymentStatus = (order: OrderDetailDTO) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const paymentCollection of order.payment_collections) {
|
for (const paymentCollection of order.payment_collections) {
|
||||||
if (MathBN.gt(paymentCollection.captured_amount ?? 0, 0)) {
|
if (
|
||||||
|
MathBN.gt(paymentCollection.captured_amount ?? 0, 0) ||
|
||||||
|
(isDefined(paymentCollection.amount) &&
|
||||||
|
MathBN.eq(paymentCollection.amount, 0))
|
||||||
|
) {
|
||||||
paymentStatus[PaymentStatus.CAPTURED] += MathBN.eq(
|
paymentStatus[PaymentStatus.CAPTURED] += MathBN.eq(
|
||||||
paymentCollection.captured_amount as number,
|
paymentCollection.captured_amount as number,
|
||||||
paymentCollection.amount
|
paymentCollection.amount
|
||||||
|
|||||||
Reference in new issue
Block a user