Skip to content

Commit

Permalink
Merge branch 'develop' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
shahednasser authored Nov 26, 2024
2 parents 5de501d + a8eec16 commit 62cb853
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ describe("Aggregate Order Status", () => {
} as any)
).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(
getLastPaymentStatus({
payment_collections: [
Expand Down
6 changes: 5 additions & 1 deletion packages/core/core-flows/src/order/utils/aggregate-status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ export const getLastPaymentStatus = (order: OrderDetailDTO) => {
}

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(
paymentCollection.captured_amount as number,
paymentCollection.amount
Expand Down

0 comments on commit 62cb853

Please sign in to comment.