|
1
|
import { AdminPaymentCollection } from "@medusajs/types" |
|
2
|
|
|
3
|
export const getTotalCaptured = ( |
|
4
|
paymentCollections: AdminPaymentCollection[] |
|
5
|
) => |
|
6
|
paymentCollections.reduce((acc, paymentCollection) => { |
|
7
|
acc = |
|
8
|
acc + |
|
9
|
((paymentCollection.captured_amount as number) - |
|
10
|
(paymentCollection.refunded_amount as number)) |
|
11
|
return acc |
|
12
|
}, 0) |
|
13
|
|
|
14
|
export const getTotalPending = (paymentCollections: AdminPaymentCollection[]) => |
|
15
|
paymentCollections |
|
16
|
.filter((pc) => pc.status !== "canceled") |
|
17
|
.reduce((acc, paymentCollection) => { |
|
18
|
acc += |
|
19
|
(paymentCollection.amount as number) - |
|
20
|
(paymentCollection.captured_amount as number) |
|
21
|
|
|
22
|
return acc |
|
23
|
}, 0) |