@pax2pay/model-banking 0.1.540 → 0.1.542
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Account/Charge.ts +11 -14
- package/Rule/State/Transaction.ts +1 -4
- package/Settlement/Entry/Creatable.ts +2 -47
- package/Settlement/Entry/index.ts +16 -4
- package/Settlement/index.ts +0 -33
- package/Transaction/Amount.ts +4 -3
- package/Transaction/Creatable.ts +5 -0
- package/Transaction/index.ts +6 -3
- package/dist/cjs/Account/Charge.d.ts +2 -1
- package/dist/cjs/Account/Charge.js +8 -10
- package/dist/cjs/Account/Charge.js.map +1 -1
- package/dist/cjs/Client/Transactions/index.d.ts +1 -1
- package/dist/cjs/Rail/index.d.ts +2 -2
- package/dist/cjs/Rule/State/Transaction.d.ts +0 -1
- package/dist/cjs/Rule/State/Transaction.js +1 -5
- package/dist/cjs/Rule/State/Transaction.js.map +1 -1
- package/dist/cjs/Settlement/Entry/Creatable.d.ts +0 -4
- package/dist/cjs/Settlement/Entry/Creatable.js +2 -47
- package/dist/cjs/Settlement/Entry/Creatable.js.map +1 -1
- package/dist/cjs/Settlement/Entry/index.d.ts +4 -4
- package/dist/cjs/Settlement/Entry/index.js +6 -4
- package/dist/cjs/Settlement/Entry/index.js.map +1 -1
- package/dist/cjs/Settlement/index.d.ts +0 -2
- package/dist/cjs/Settlement/index.js +0 -32
- package/dist/cjs/Settlement/index.js.map +1 -1
- package/dist/cjs/Transaction/Amount.d.ts +1 -1
- package/dist/cjs/Transaction/Amount.js +4 -3
- package/dist/cjs/Transaction/Amount.js.map +1 -1
- package/dist/cjs/Transaction/Creatable.d.ts +3 -0
- package/dist/cjs/Transaction/Creatable.js +5 -0
- package/dist/cjs/Transaction/Creatable.js.map +1 -1
- package/dist/cjs/Transaction/index.d.ts +2 -2
- package/dist/cjs/Transaction/index.js +4 -3
- package/dist/cjs/Transaction/index.js.map +1 -1
- package/dist/mjs/Account/Charge.d.ts +2 -1
- package/dist/mjs/Account/Charge.js +8 -10
- package/dist/mjs/Account/Charge.js.map +1 -1
- package/dist/mjs/Client/Transactions/index.d.ts +1 -1
- package/dist/mjs/Rail/index.d.ts +2 -2
- package/dist/mjs/Rule/State/Transaction.d.ts +0 -1
- package/dist/mjs/Rule/State/Transaction.js +1 -5
- package/dist/mjs/Rule/State/Transaction.js.map +1 -1
- package/dist/mjs/Settlement/Entry/Creatable.d.ts +0 -4
- package/dist/mjs/Settlement/Entry/Creatable.js +2 -47
- package/dist/mjs/Settlement/Entry/Creatable.js.map +1 -1
- package/dist/mjs/Settlement/Entry/index.d.ts +4 -4
- package/dist/mjs/Settlement/Entry/index.js +6 -4
- package/dist/mjs/Settlement/Entry/index.js.map +1 -1
- package/dist/mjs/Settlement/index.d.ts +0 -2
- package/dist/mjs/Settlement/index.js +0 -32
- package/dist/mjs/Settlement/index.js.map +1 -1
- package/dist/mjs/Transaction/Amount.d.ts +1 -1
- package/dist/mjs/Transaction/Amount.js +4 -3
- package/dist/mjs/Transaction/Amount.js.map +1 -1
- package/dist/mjs/Transaction/Creatable.d.ts +3 -0
- package/dist/mjs/Transaction/Creatable.js +5 -0
- package/dist/mjs/Transaction/Creatable.js.map +1 -1
- package/dist/mjs/Transaction/index.d.ts +2 -2
- package/dist/mjs/Transaction/index.js +4 -3
- package/dist/mjs/Transaction/index.js.map +1 -1
- package/package.json +1 -1
- package/Settlement/Entry/Legacy/Cancel.ts +0 -42
- package/Settlement/Entry/Legacy/Capture.ts +0 -47
- package/Settlement/Entry/Legacy/Creatable.ts +0 -15
- package/Settlement/Entry/Legacy/Refund.ts +0 -58
- package/Settlement/Entry/Legacy/Unknown.ts +0 -40
- package/Settlement/Entry/Legacy/index.ts +0 -55
- package/Settlement/Entry/fromLegacy.ts +0 -95
- package/dist/cjs/Settlement/Entry/Legacy/Cancel.d.ts +0 -27
- package/dist/cjs/Settlement/Entry/Legacy/Cancel.js +0 -32
- package/dist/cjs/Settlement/Entry/Legacy/Cancel.js.map +0 -1
- package/dist/cjs/Settlement/Entry/Legacy/Capture.d.ts +0 -29
- package/dist/cjs/Settlement/Entry/Legacy/Capture.js +0 -37
- package/dist/cjs/Settlement/Entry/Legacy/Capture.js.map +0 -1
- package/dist/cjs/Settlement/Entry/Legacy/Creatable.d.ts +0 -9
- package/dist/cjs/Settlement/Entry/Legacy/Creatable.js +0 -13
- package/dist/cjs/Settlement/Entry/Legacy/Creatable.js.map +0 -1
- package/dist/cjs/Settlement/Entry/Legacy/Refund.d.ts +0 -36
- package/dist/cjs/Settlement/Entry/Legacy/Refund.js +0 -43
- package/dist/cjs/Settlement/Entry/Legacy/Refund.js.map +0 -1
- package/dist/cjs/Settlement/Entry/Legacy/Unknown.d.ts +0 -24
- package/dist/cjs/Settlement/Entry/Legacy/Unknown.js +0 -32
- package/dist/cjs/Settlement/Entry/Legacy/Unknown.js.map +0 -1
- package/dist/cjs/Settlement/Entry/Legacy/index.d.ts +0 -19
- package/dist/cjs/Settlement/Entry/Legacy/index.js +0 -53
- package/dist/cjs/Settlement/Entry/Legacy/index.js.map +0 -1
- package/dist/cjs/Settlement/Entry/fromLegacy.d.ts +0 -3
- package/dist/cjs/Settlement/Entry/fromLegacy.js +0 -90
- package/dist/cjs/Settlement/Entry/fromLegacy.js.map +0 -1
- package/dist/mjs/Settlement/Entry/Legacy/Cancel.d.ts +0 -27
- package/dist/mjs/Settlement/Entry/Legacy/Cancel.js +0 -29
- package/dist/mjs/Settlement/Entry/Legacy/Cancel.js.map +0 -1
- package/dist/mjs/Settlement/Entry/Legacy/Capture.d.ts +0 -29
- package/dist/mjs/Settlement/Entry/Legacy/Capture.js +0 -34
- package/dist/mjs/Settlement/Entry/Legacy/Capture.js.map +0 -1
- package/dist/mjs/Settlement/Entry/Legacy/Creatable.d.ts +0 -9
- package/dist/mjs/Settlement/Entry/Legacy/Creatable.js +0 -10
- package/dist/mjs/Settlement/Entry/Legacy/Creatable.js.map +0 -1
- package/dist/mjs/Settlement/Entry/Legacy/Refund.d.ts +0 -36
- package/dist/mjs/Settlement/Entry/Legacy/Refund.js +0 -40
- package/dist/mjs/Settlement/Entry/Legacy/Refund.js.map +0 -1
- package/dist/mjs/Settlement/Entry/Legacy/Unknown.d.ts +0 -24
- package/dist/mjs/Settlement/Entry/Legacy/Unknown.js +0 -29
- package/dist/mjs/Settlement/Entry/Legacy/Unknown.js.map +0 -1
- package/dist/mjs/Settlement/Entry/Legacy/index.d.ts +0 -19
- package/dist/mjs/Settlement/Entry/Legacy/index.js +0 -50
- package/dist/mjs/Settlement/Entry/Legacy/index.js.map +0 -1
- package/dist/mjs/Settlement/Entry/fromLegacy.d.ts +0 -3
- package/dist/mjs/Settlement/Entry/fromLegacy.js +0 -87
- package/dist/mjs/Settlement/Entry/fromLegacy.js.map +0 -1
package/Account/Charge.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { cryptly } from "cryptly"
|
|
|
2
2
|
import { isoly } from "isoly"
|
|
3
3
|
import { isly } from "isly"
|
|
4
4
|
import { Card } from "../Card"
|
|
5
|
+
import type { Rail } from "../Rail"
|
|
5
6
|
import { Transaction } from "../Transaction"
|
|
6
7
|
|
|
7
8
|
export interface Charge extends Charge.Creatable {
|
|
@@ -36,22 +37,18 @@ export namespace Charge {
|
|
|
36
37
|
}
|
|
37
38
|
export function evaluate(
|
|
38
39
|
charges: Charge[] = [],
|
|
39
|
-
|
|
40
|
+
counterpart: Rail.Address.Card.Counterpart,
|
|
41
|
+
currency: isoly.Currency,
|
|
42
|
+
amount: number
|
|
40
43
|
): Transaction.Amount.Charge[] {
|
|
41
44
|
const result: Transaction.Amount.Charge[] = []
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
amount: isoly.Currency.multiply(
|
|
50
|
-
transaction.currency,
|
|
51
|
-
typeof transaction.amount == "number" ? transaction.amount : -transaction.amount.original,
|
|
52
|
-
charge.rate
|
|
53
|
-
),
|
|
54
|
-
})
|
|
45
|
+
for (const charge of charges)
|
|
46
|
+
if (charge.applies.to.merchants.some(merchant => Card.Restriction.Merchant.check(merchant, counterpart)))
|
|
47
|
+
result.push({
|
|
48
|
+
destination: charge.destination,
|
|
49
|
+
type: "merchant",
|
|
50
|
+
amount: isoly.Currency.multiply(currency, amount, charge.rate),
|
|
51
|
+
})
|
|
55
52
|
return result
|
|
56
53
|
}
|
|
57
54
|
export function sum(charges: Transaction.Amount.Charge[], currency: isoly.Currency): number {
|
|
@@ -12,7 +12,6 @@ export type Transaction = ModelTransaction.Creatable.Resolved & {
|
|
|
12
12
|
risk?: number
|
|
13
13
|
original: {
|
|
14
14
|
currency: isoly.Currency
|
|
15
|
-
charges?: ModelTransaction.Amount.Charge[]
|
|
16
15
|
total: number
|
|
17
16
|
amount: number
|
|
18
17
|
charge?: { current: number; total: number } //Legacy
|
|
@@ -25,7 +24,6 @@ export namespace Transaction {
|
|
|
25
24
|
kind: Rule.Base.Kind,
|
|
26
25
|
stage: "finalize" | "initiate"
|
|
27
26
|
): Transaction {
|
|
28
|
-
const charges = ModelAccount.Charge.evaluate(account.charges, transaction)
|
|
29
27
|
const amount = Math.abs(typeof transaction.amount == "number" ? transaction.amount : transaction.amount.original)
|
|
30
28
|
return {
|
|
31
29
|
...transaction,
|
|
@@ -36,9 +34,8 @@ export namespace Transaction {
|
|
|
36
34
|
type: ModelTransaction.getType(transaction.counterpart, account.name),
|
|
37
35
|
original: {
|
|
38
36
|
currency: transaction.currency,
|
|
39
|
-
charges,
|
|
40
37
|
amount,
|
|
41
|
-
total:
|
|
38
|
+
total: amount,
|
|
42
39
|
},
|
|
43
40
|
}
|
|
44
41
|
}
|
|
@@ -6,7 +6,6 @@ import { Exchange } from "../../Transaction/Exchange"
|
|
|
6
6
|
import { Batch } from "../Batch"
|
|
7
7
|
import { Fee } from "../Fee"
|
|
8
8
|
import { Identifier as SettlementIdentifier } from "../Identifier"
|
|
9
|
-
import { Entry as LegacyEntry } from "./Legacy"
|
|
10
9
|
|
|
11
10
|
export type Creatable = Creatable.Known | Creatable.Unknown
|
|
12
11
|
export namespace Creatable {
|
|
@@ -44,62 +43,18 @@ export namespace Creatable {
|
|
|
44
43
|
type: "capture"
|
|
45
44
|
}
|
|
46
45
|
export namespace Capture {
|
|
47
|
-
export const type = Base.type.extend<Capture>({
|
|
48
|
-
type: isly.string("capture"),
|
|
49
|
-
})
|
|
50
|
-
export function fromLegacy(maybeLegacy: Capture | LegacyEntry.Capture.Creatable): Capture {
|
|
51
|
-
return type.is(maybeLegacy)
|
|
52
|
-
? maybeLegacy
|
|
53
|
-
: {
|
|
54
|
-
type: maybeLegacy.type,
|
|
55
|
-
card: maybeLegacy.authorization.card.id,
|
|
56
|
-
transaction: maybeLegacy.authorization.transaction?.id,
|
|
57
|
-
account: maybeLegacy.authorization.account || "unknown",
|
|
58
|
-
approvalCode: maybeLegacy.authorization.approvalCode ?? "unknown",
|
|
59
|
-
merchant: maybeLegacy.authorization.merchant,
|
|
60
|
-
acquirer: maybeLegacy.authorization.acquirer,
|
|
61
|
-
reference: maybeLegacy.reference,
|
|
62
|
-
batch: maybeLegacy.batch,
|
|
63
|
-
fee: maybeLegacy.fee,
|
|
64
|
-
amount: maybeLegacy.amount,
|
|
65
|
-
settlement: maybeLegacy.settlement ?? "unknown",
|
|
66
|
-
}
|
|
67
|
-
}
|
|
46
|
+
export const type = Base.type.extend<Capture>({ type: isly.string("capture") })
|
|
68
47
|
}
|
|
69
48
|
export interface Refund extends Base {
|
|
70
49
|
type: "refund"
|
|
71
50
|
}
|
|
72
51
|
export namespace Refund {
|
|
73
|
-
export const type = Base.type.extend<Refund>({
|
|
74
|
-
type: isly.string("refund"),
|
|
75
|
-
})
|
|
76
|
-
export function fromLegacy(maybeLegacy: Refund | LegacyEntry.Refund.Creatable): Refund {
|
|
77
|
-
return type.is(maybeLegacy)
|
|
78
|
-
? maybeLegacy
|
|
79
|
-
: {
|
|
80
|
-
type: maybeLegacy.type,
|
|
81
|
-
card: maybeLegacy.card,
|
|
82
|
-
account: maybeLegacy.account ?? "unknown",
|
|
83
|
-
approvalCode: maybeLegacy.authorization.approvalCode ?? "unknown",
|
|
84
|
-
merchant: maybeLegacy.merchant,
|
|
85
|
-
acquirer: maybeLegacy.acquirer,
|
|
86
|
-
reference: maybeLegacy.reference,
|
|
87
|
-
batch: maybeLegacy.batch,
|
|
88
|
-
fee: maybeLegacy.fee,
|
|
89
|
-
amount: maybeLegacy.amount,
|
|
90
|
-
settlement: maybeLegacy.settlement ?? "unknown",
|
|
91
|
-
}
|
|
92
|
-
}
|
|
52
|
+
export const type = Base.type.extend<Refund>({ type: isly.string("refund") })
|
|
93
53
|
}
|
|
94
54
|
export type Known = Capture | Refund
|
|
95
55
|
|
|
96
56
|
export namespace Known {
|
|
97
57
|
export const type = isly.union(Capture.type, Refund.type)
|
|
98
|
-
export function fromLegacy(
|
|
99
|
-
maybeLegacy: Creatable.Known | LegacyEntry.Capture.Creatable | LegacyEntry.Refund.Creatable
|
|
100
|
-
): Creatable.Known {
|
|
101
|
-
return maybeLegacy.type == "capture" ? Capture.fromLegacy(maybeLegacy) : Refund.fromLegacy(maybeLegacy)
|
|
102
|
-
}
|
|
103
58
|
}
|
|
104
59
|
export interface Unknown extends Partial<Base> {
|
|
105
60
|
type: "unknown"
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { isoly } from "isoly"
|
|
2
|
+
import { Account } from "../../Account"
|
|
3
|
+
import type { Rail } from "../../Rail"
|
|
4
|
+
import type { Transaction } from "../../Transaction"
|
|
1
5
|
import { Creatable as EntryCreatable } from "./Creatable"
|
|
2
6
|
import { Failed as EntryFailed } from "./Failed"
|
|
3
7
|
import { fromCreatable } from "./fromCreatable"
|
|
4
|
-
import { fromLegacy as entryFromLegacy } from "./fromLegacy"
|
|
5
|
-
import { Entry as LegacyEntry } from "./Legacy"
|
|
6
8
|
import { Succeeded as EntrySucceeded } from "./Succeeded"
|
|
7
9
|
import { Summary as EntrySummary } from "./Summary"
|
|
8
10
|
import { type as entryType } from "./type"
|
|
@@ -19,8 +21,18 @@ export namespace Entry {
|
|
|
19
21
|
export import Failed = EntryFailed
|
|
20
22
|
export import Succeeded = EntrySucceeded
|
|
21
23
|
export import Summary = EntrySummary
|
|
22
|
-
export import Legacy = LegacyEntry
|
|
23
24
|
export const type = entryType
|
|
24
|
-
export const fromLegacy = entryFromLegacy
|
|
25
25
|
export const from = fromCreatable
|
|
26
|
+
export function charge(
|
|
27
|
+
charges: Account.Charge[] = [],
|
|
28
|
+
counterpart: Rail.Address.Card.Counterpart,
|
|
29
|
+
capture: Creatable.Capture
|
|
30
|
+
): Transaction.Amount.Charge[] {
|
|
31
|
+
return Account.Charge.evaluate(
|
|
32
|
+
charges,
|
|
33
|
+
counterpart,
|
|
34
|
+
capture.amount[0],
|
|
35
|
+
isoly.Currency.add(capture.amount[0], capture.amount[1], capture.fee.other[capture.amount[0]] ?? 0)
|
|
36
|
+
)
|
|
37
|
+
}
|
|
26
38
|
}
|
package/Settlement/index.ts
CHANGED
|
@@ -65,39 +65,6 @@ export namespace Settlement {
|
|
|
65
65
|
outcome: OldTotal
|
|
66
66
|
settled?: { paid: Amounts; transactions: string[] }
|
|
67
67
|
}
|
|
68
|
-
export type MaybeOld = Settlement | OldSettlement
|
|
69
|
-
export function fromLegacy(settlement: MaybeOld): Settlement {
|
|
70
|
-
let result: Settlement
|
|
71
|
-
if (!type.is(settlement)) {
|
|
72
|
-
const totalToAmount: (currency: isoly.Currency, total?: OldTotal) => Amount = (currency, oldTotal) => ({
|
|
73
|
-
net: oldTotal?.amount[currency] ?? 0,
|
|
74
|
-
fee: { other: oldTotal?.fee.other[currency] ?? 0 },
|
|
75
|
-
})
|
|
76
|
-
const { expected, collected, outcome, settled, ...partialSettlement } = settlement
|
|
77
|
-
const currencies = Array.from(
|
|
78
|
-
new Set<isoly.Currency>([
|
|
79
|
-
...Object.keys(expected?.amount ?? {}),
|
|
80
|
-
...Object.keys(collected?.amount ?? {}),
|
|
81
|
-
...Object.keys(settled?.paid ?? {}),
|
|
82
|
-
...Object.keys(outcome.amount),
|
|
83
|
-
] as isoly.Currency[])
|
|
84
|
-
)
|
|
85
|
-
const totals = currencies.reduce((total, currency) => {
|
|
86
|
-
total[currency] = {
|
|
87
|
-
expected: totalToAmount(currency, expected),
|
|
88
|
-
...(outcome ? { outcome: totalToAmount(currency, outcome) } : {}),
|
|
89
|
-
...(collected
|
|
90
|
-
? { collected: { ...totalToAmount(currency, collected), transactions: { net: "", fee: "", charge: "" } } } //TODO: Find transactions?
|
|
91
|
-
: {}),
|
|
92
|
-
...(settled ? { settled: { net: settled.paid[currency] ?? 0, transactions: settled.transactions } } : {}), //Find transactions?
|
|
93
|
-
}
|
|
94
|
-
return total
|
|
95
|
-
}, {} as Totals)
|
|
96
|
-
result = { ...partialSettlement, totals }
|
|
97
|
-
} else
|
|
98
|
-
result = settlement
|
|
99
|
-
return result
|
|
100
|
-
}
|
|
101
68
|
export const type = SettlementCreatable.type.extend<Settlement>({
|
|
102
69
|
id: isly.union(SettlementIdentifier.type, isly.string()),
|
|
103
70
|
by: isly.string().optional(),
|
package/Transaction/Amount.ts
CHANGED
|
@@ -33,15 +33,16 @@ export namespace Amount {
|
|
|
33
33
|
total: isly.number(),
|
|
34
34
|
exchange: Exchange.type.optional(),
|
|
35
35
|
})
|
|
36
|
-
export function fromState(state: Rule.State): Amount {
|
|
36
|
+
export function fromState(state: Rule.State, charges?: Charge[]): Amount {
|
|
37
37
|
const sign = ["outbound", "authorization", "capture"].some(direction => direction == state.transaction.kind)
|
|
38
38
|
? -1
|
|
39
39
|
: 1
|
|
40
|
+
const charge = Amount.Charge.total(state.transaction.original.currency, charges)
|
|
40
41
|
return {
|
|
41
42
|
original: sign * state.transaction.original.amount,
|
|
42
43
|
charge: sign * (state.transaction.original.charge?.total ?? 0),
|
|
43
|
-
charges
|
|
44
|
-
total: sign * state.transaction.original.total,
|
|
44
|
+
charges,
|
|
45
|
+
total: sign * isoly.Currency.add(state.transaction.original.currency, state.transaction.original.total, charge),
|
|
45
46
|
exchange: state?.transaction.exchange ?? state.authorization?.exchange,
|
|
46
47
|
}
|
|
47
48
|
}
|
package/Transaction/Creatable.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { isoly } from "isoly"
|
|
2
2
|
import { isly } from "isly"
|
|
3
|
+
import { Account } from "../Account"
|
|
3
4
|
import { Rail } from "../Rail"
|
|
5
|
+
import { Amount } from "./Amount"
|
|
4
6
|
import { Exchange } from "./Exchange"
|
|
5
7
|
|
|
6
8
|
export interface Creatable {
|
|
@@ -34,5 +36,8 @@ export namespace Creatable {
|
|
|
34
36
|
reference: isly.object<{ reference: string }>({ reference: isly.string() }),
|
|
35
37
|
approvalCode: isly.string().optional(),
|
|
36
38
|
})
|
|
39
|
+
export function charge(charges: Account.Charge[], creatable: CardTransaction): Amount.Charge[] {
|
|
40
|
+
return Account.Charge.evaluate(charges, creatable.counterpart, creatable.currency, creatable.amount)
|
|
41
|
+
}
|
|
37
42
|
}
|
|
38
43
|
}
|
package/Transaction/index.ts
CHANGED
|
@@ -89,9 +89,10 @@ export namespace Transaction {
|
|
|
89
89
|
state: isly.any().optional(),
|
|
90
90
|
})
|
|
91
91
|
export function amountFromOperations(
|
|
92
|
-
transaction: Transaction
|
|
92
|
+
transaction: Transaction,
|
|
93
93
|
operations: Operation[],
|
|
94
|
-
state?: Rule.State
|
|
94
|
+
state?: Rule.State,
|
|
95
|
+
charges?: Amount.Charge[]
|
|
95
96
|
): Amount {
|
|
96
97
|
const stateAmount = state && Amount.fromState(state)
|
|
97
98
|
const changes = Operation.sum(operations)
|
|
@@ -103,6 +104,7 @@ export namespace Transaction {
|
|
|
103
104
|
return {
|
|
104
105
|
original: typeof transaction.amount == "number" ? transaction.amount : transaction.amount.original,
|
|
105
106
|
charge: stateAmount?.charge ?? 0,
|
|
107
|
+
charges,
|
|
106
108
|
total: changes.available ?? reserved ?? 0,
|
|
107
109
|
exchange: state?.transaction.exchange ?? state?.authorization?.exchange,
|
|
108
110
|
}
|
|
@@ -152,6 +154,7 @@ export namespace Transaction {
|
|
|
152
154
|
account: { id: string; name: string; organization: string; address: Rail.Address },
|
|
153
155
|
balance: { actual: number; reserved: number; available: number },
|
|
154
156
|
operation: Operation | Status.Reason,
|
|
157
|
+
charges: Amount.Charge[],
|
|
155
158
|
by: string | undefined
|
|
156
159
|
): Transaction {
|
|
157
160
|
const status: Status =
|
|
@@ -171,7 +174,7 @@ export namespace Transaction {
|
|
|
171
174
|
: "fasterpayments"
|
|
172
175
|
return {
|
|
173
176
|
...creatable,
|
|
174
|
-
amount: Amount.fromState(state),
|
|
177
|
+
amount: Amount.fromState(state, charges),
|
|
175
178
|
type: getType(creatable.counterpart, account.name),
|
|
176
179
|
direction: "outbound",
|
|
177
180
|
organization: account.organization,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isoly } from "isoly";
|
|
2
2
|
import { Card } from "../Card";
|
|
3
|
+
import type { Rail } from "../Rail";
|
|
3
4
|
import { Transaction } from "../Transaction";
|
|
4
5
|
export interface Charge extends Charge.Creatable {
|
|
5
6
|
id: string;
|
|
@@ -21,6 +22,6 @@ export declare namespace Charge {
|
|
|
21
22
|
}
|
|
22
23
|
const type: import("isly/dist/cjs/object").IslyObject<Charge, Creatable>;
|
|
23
24
|
function fromCreatable(creatable: Creatable): Charge;
|
|
24
|
-
function evaluate(charges: Charge[] | undefined,
|
|
25
|
+
function evaluate(charges: Charge[] | undefined, counterpart: Rail.Address.Card.Counterpart, currency: isoly.Currency, amount: number): Transaction.Amount.Charge[];
|
|
25
26
|
function sum(charges: Transaction.Amount.Charge[], currency: isoly.Currency): number;
|
|
26
27
|
}
|
|
@@ -26,17 +26,15 @@ var Charge;
|
|
|
26
26
|
return { ...creatable, id: cryptly_1.cryptly.Identifier.generate(16) };
|
|
27
27
|
}
|
|
28
28
|
Charge.fromCreatable = fromCreatable;
|
|
29
|
-
function evaluate(charges = [],
|
|
29
|
+
function evaluate(charges = [], counterpart, currency, amount) {
|
|
30
30
|
const result = [];
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
amount: isoly_1.isoly.Currency.multiply(transaction.currency, typeof transaction.amount == "number" ? transaction.amount : -transaction.amount.original, charge.rate),
|
|
39
|
-
});
|
|
31
|
+
for (const charge of charges)
|
|
32
|
+
if (charge.applies.to.merchants.some(merchant => Card_1.Card.Restriction.Merchant.check(merchant, counterpart)))
|
|
33
|
+
result.push({
|
|
34
|
+
destination: charge.destination,
|
|
35
|
+
type: "merchant",
|
|
36
|
+
amount: isoly_1.isoly.Currency.multiply(currency, amount, charge.rate),
|
|
37
|
+
});
|
|
40
38
|
return result;
|
|
41
39
|
}
|
|
42
40
|
Charge.evaluate = evaluate;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Charge.js","sourceRoot":"","sources":["../../../Account/Charge.ts"],"names":[],"mappings":";;;AAAA,qCAAiC;AACjC,iCAA6B;AAC7B,+BAA2B;AAC3B,kCAA8B;
|
|
1
|
+
{"version":3,"file":"Charge.js","sourceRoot":"","sources":["../../../Account/Charge.ts"],"names":[],"mappings":";;;AAAA,qCAAiC;AACjC,iCAA6B;AAC7B,+BAA2B;AAC3B,kCAA8B;AAO9B,IAAiB,MAAM,CA8CtB;AA9CD,WAAiB,MAAM;IAUtB,IAAiB,SAAS,CAUzB;IAVD,WAAiB,SAAS;QACZ,cAAI,GAAG,WAAI,CAAC,MAAM,CAAY;YAC1C,WAAW,EAAE,WAAI,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,WAAI,CAAC,MAAM,EAAE,EAAE,CAAC;YACpD,IAAI,EAAE,WAAI,CAAC,MAAM,EAAE;YACnB,OAAO,EAAE,WAAI,CAAC,MAAM,CAAC;gBACpB,EAAE,EAAE,WAAI,CAAC,MAAM,CAA6B;oBAC3C,SAAS,EAAE,WAAI,CAAC,WAAW,CA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E,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAA;IAC5F,CAAC;IAFe,UAAG,MAElB,CAAA;AACF,CAAC,EA9CgB,MAAM,sBAAN,MAAM,QA8CtB"}
|
|
@@ -50,7 +50,7 @@ export declare namespace Transactions {
|
|
|
50
50
|
end: string | undefined;
|
|
51
51
|
currency: string | undefined;
|
|
52
52
|
organization: string | undefined;
|
|
53
|
-
rail: "paxgiro" | "mastercard" | "diners" | "visa" | "internal" | "paxgiro-credit" | "
|
|
53
|
+
rail: "paxgiro" | "mastercard" | "diners" | "visa" | "internal" | "paxgiro-credit" | "transfer" | "fasterpayments" | "chaps" | "bacs" | "credit" | undefined;
|
|
54
54
|
type: "internal" | "card" | "external" | "system" | undefined;
|
|
55
55
|
}>;
|
|
56
56
|
function parse(query: string | http.Request["search"]): Query;
|
package/dist/cjs/Rail/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { Address as RailAddress } from "./Address";
|
|
|
4
4
|
export type Rail = typeof Rail.rails[number];
|
|
5
5
|
export declare namespace Rail {
|
|
6
6
|
const rails: readonly ["internal", "paxgiro", "paxgiro-credit", "mastercard", "diners", "visa", "fasterpayments", "chaps", "bacs", "transfer", "credit"];
|
|
7
|
-
const type: isly.Type<"paxgiro" | "mastercard" | "diners" | "visa" | "internal" | "paxgiro-credit" | "
|
|
8
|
-
const type2: isly2.String<"paxgiro" | "mastercard" | "diners" | "visa" | "internal" | "paxgiro-credit" | "
|
|
7
|
+
const type: isly.Type<"paxgiro" | "mastercard" | "diners" | "visa" | "internal" | "paxgiro-credit" | "transfer" | "fasterpayments" | "chaps" | "bacs" | "credit">;
|
|
8
|
+
const type2: isly2.String<"paxgiro" | "mastercard" | "diners" | "visa" | "internal" | "paxgiro-credit" | "transfer" | "fasterpayments" | "chaps" | "bacs" | "credit">;
|
|
9
9
|
export import Address = RailAddress;
|
|
10
10
|
}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Transaction = void 0;
|
|
4
|
-
const isoly_1 = require("isoly");
|
|
5
|
-
const Account_1 = require("../../Account");
|
|
6
4
|
const Transaction_1 = require("../../Transaction");
|
|
7
5
|
var Transaction;
|
|
8
6
|
(function (Transaction) {
|
|
9
7
|
function from(account, transaction, kind, stage) {
|
|
10
|
-
const charges = Account_1.Account.Charge.evaluate(account.charges, transaction);
|
|
11
8
|
const amount = Math.abs(typeof transaction.amount == "number" ? transaction.amount : transaction.amount.original);
|
|
12
9
|
return {
|
|
13
10
|
...transaction,
|
|
@@ -18,9 +15,8 @@ var Transaction;
|
|
|
18
15
|
type: Transaction_1.Transaction.getType(transaction.counterpart, account.name),
|
|
19
16
|
original: {
|
|
20
17
|
currency: transaction.currency,
|
|
21
|
-
charges,
|
|
22
18
|
amount,
|
|
23
|
-
total:
|
|
19
|
+
total: amount,
|
|
24
20
|
},
|
|
25
21
|
};
|
|
26
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transaction.js","sourceRoot":"","sources":["../../../../Rule/State/Transaction.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Transaction.js","sourceRoot":"","sources":["../../../../Rule/State/Transaction.ts"],"names":[],"mappings":";;;AAEA,mDAAmE;AAiBnE,IAAiB,WAAW,CA0C3B;AA1CD,WAAiB,WAAW;IAC3B,SAAgB,IAAI,CACnB,OAAqB,EACrB,WAAmE,EACnE,IAAoB,EACpB,KAA8B;QAE9B,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,WAAW,CAAC,MAAM,IAAI,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;QACjH,OAAO;YACN,GAAG,WAAW;YACd,EAAE,EAAE,IAAI,IAAI,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,EAAE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,KAAK,CAAC;aACtG;SACD,CAAA;IACF,CAAC;IAnBe,8BAAkB,qBAmBjC,CAAA;AACF,CAAC,EA1CgB,WAAW,2BAAX,WAAW,QA0C3B"}
|
|
@@ -6,7 +6,6 @@ import { Exchange } from "../../Transaction/Exchange";
|
|
|
6
6
|
import { Batch } from "../Batch";
|
|
7
7
|
import { Fee } from "../Fee";
|
|
8
8
|
import { Identifier as SettlementIdentifier } from "../Identifier";
|
|
9
|
-
import { Entry as LegacyEntry } from "./Legacy";
|
|
10
9
|
export type Creatable = Creatable.Known | Creatable.Unknown;
|
|
11
10
|
export declare namespace Creatable {
|
|
12
11
|
interface Base {
|
|
@@ -31,19 +30,16 @@ export declare namespace Creatable {
|
|
|
31
30
|
}
|
|
32
31
|
namespace Capture {
|
|
33
32
|
const type: import("isly/dist/cjs/object").IslyObject<Capture, Base>;
|
|
34
|
-
function fromLegacy(maybeLegacy: Capture | LegacyEntry.Capture.Creatable): Capture;
|
|
35
33
|
}
|
|
36
34
|
interface Refund extends Base {
|
|
37
35
|
type: "refund";
|
|
38
36
|
}
|
|
39
37
|
namespace Refund {
|
|
40
38
|
const type: import("isly/dist/cjs/object").IslyObject<Refund, Base>;
|
|
41
|
-
function fromLegacy(maybeLegacy: Refund | LegacyEntry.Refund.Creatable): Refund;
|
|
42
39
|
}
|
|
43
40
|
type Known = Capture | Refund;
|
|
44
41
|
namespace Known {
|
|
45
42
|
const type: isly.Type<Capture | Refund>;
|
|
46
|
-
function fromLegacy(maybeLegacy: Creatable.Known | LegacyEntry.Capture.Creatable | LegacyEntry.Refund.Creatable): Creatable.Known;
|
|
47
43
|
}
|
|
48
44
|
interface Unknown extends Partial<Base> {
|
|
49
45
|
type: "unknown";
|
|
@@ -30,60 +30,15 @@ var Creatable;
|
|
|
30
30
|
})(Base = Creatable.Base || (Creatable.Base = {}));
|
|
31
31
|
let Capture;
|
|
32
32
|
(function (Capture) {
|
|
33
|
-
Capture.type = Base.type.extend({
|
|
34
|
-
type: isly_1.isly.string("capture"),
|
|
35
|
-
});
|
|
36
|
-
function fromLegacy(maybeLegacy) {
|
|
37
|
-
return Capture.type.is(maybeLegacy)
|
|
38
|
-
? maybeLegacy
|
|
39
|
-
: {
|
|
40
|
-
type: maybeLegacy.type,
|
|
41
|
-
card: maybeLegacy.authorization.card.id,
|
|
42
|
-
transaction: maybeLegacy.authorization.transaction?.id,
|
|
43
|
-
account: maybeLegacy.authorization.account || "unknown",
|
|
44
|
-
approvalCode: maybeLegacy.authorization.approvalCode ?? "unknown",
|
|
45
|
-
merchant: maybeLegacy.authorization.merchant,
|
|
46
|
-
acquirer: maybeLegacy.authorization.acquirer,
|
|
47
|
-
reference: maybeLegacy.reference,
|
|
48
|
-
batch: maybeLegacy.batch,
|
|
49
|
-
fee: maybeLegacy.fee,
|
|
50
|
-
amount: maybeLegacy.amount,
|
|
51
|
-
settlement: maybeLegacy.settlement ?? "unknown",
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
Capture.fromLegacy = fromLegacy;
|
|
33
|
+
Capture.type = Base.type.extend({ type: isly_1.isly.string("capture") });
|
|
55
34
|
})(Capture = Creatable.Capture || (Creatable.Capture = {}));
|
|
56
35
|
let Refund;
|
|
57
36
|
(function (Refund) {
|
|
58
|
-
Refund.type = Base.type.extend({
|
|
59
|
-
type: isly_1.isly.string("refund"),
|
|
60
|
-
});
|
|
61
|
-
function fromLegacy(maybeLegacy) {
|
|
62
|
-
return Refund.type.is(maybeLegacy)
|
|
63
|
-
? maybeLegacy
|
|
64
|
-
: {
|
|
65
|
-
type: maybeLegacy.type,
|
|
66
|
-
card: maybeLegacy.card,
|
|
67
|
-
account: maybeLegacy.account ?? "unknown",
|
|
68
|
-
approvalCode: maybeLegacy.authorization.approvalCode ?? "unknown",
|
|
69
|
-
merchant: maybeLegacy.merchant,
|
|
70
|
-
acquirer: maybeLegacy.acquirer,
|
|
71
|
-
reference: maybeLegacy.reference,
|
|
72
|
-
batch: maybeLegacy.batch,
|
|
73
|
-
fee: maybeLegacy.fee,
|
|
74
|
-
amount: maybeLegacy.amount,
|
|
75
|
-
settlement: maybeLegacy.settlement ?? "unknown",
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
Refund.fromLegacy = fromLegacy;
|
|
37
|
+
Refund.type = Base.type.extend({ type: isly_1.isly.string("refund") });
|
|
79
38
|
})(Refund = Creatable.Refund || (Creatable.Refund = {}));
|
|
80
39
|
let Known;
|
|
81
40
|
(function (Known) {
|
|
82
41
|
Known.type = isly_1.isly.union(Capture.type, Refund.type);
|
|
83
|
-
function fromLegacy(maybeLegacy) {
|
|
84
|
-
return maybeLegacy.type == "capture" ? Capture.fromLegacy(maybeLegacy) : Refund.fromLegacy(maybeLegacy);
|
|
85
|
-
}
|
|
86
|
-
Known.fromLegacy = fromLegacy;
|
|
87
42
|
})(Known = Creatable.Known || (Creatable.Known = {}));
|
|
88
43
|
let Unknown;
|
|
89
44
|
(function (Unknown) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Creatable.js","sourceRoot":"","sources":["../../../../Settlement/Entry/Creatable.ts"],"names":[],"mappings":";;;AAAA,+BAA2B;AAC3B,6CAAyC;AACzC,yCAAqC;AACrC,6CAAyC;AACzC,yDAAqD;AACrD,oCAAgC;AAChC,gCAA4B;AAC5B,8CAAkE;
|
|
1
|
+
{"version":3,"file":"Creatable.js","sourceRoot":"","sources":["../../../../Settlement/Entry/Creatable.ts"],"names":[],"mappings":";;;AAAA,+BAA2B;AAC3B,6CAAyC;AACzC,yCAAqC;AACrC,6CAAyC;AACzC,yDAAqD;AACrD,oCAAgC;AAChC,gCAA4B;AAC5B,8CAAkE;AAGlE,IAAiB,SAAS,CA8DzB;AA9DD,WAAiB,SAAS;IAezB,IAAiB,IAAI,CAepB;IAfD,WAAiB,IAAI;QACP,SAAI,GAAG,WAAI,CAAC,MAAM,CAAO;YACrC,IAAI,EAAE,WAAI,CAAC,MAAM,EAAE;YACnB,WAAW,EAAE,WAAI,CAAC,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G,WAAI,CAAC,MAAM,CAAU;YACxC,GAAI,MAAM,CAAC,WAAW,CACrB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAClC;YAC3C,IAAI,EAAE,WAAI,CAAC,MAAM,CAAC,SAAS,CAAC;YAC5B,IAAI,EAAE,WAAI,CAAC,MAAM,CAA0B,WAAI,CAAC,MAAM,EAAE,EAAE,WAAI,CAAC,GAAG,EAAE,CAAC;SACrE,CAAC,CAAA;IACH,CAAC,EARgB,OAAO,GAAP,iBAAO,KAAP,iBAAO,QAQvB;IACY,cAAI,GAAG,WAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAA;AACzD,CAAC,EA9DgB,SAAS,yBAAT,SAAS,QA8DzB"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { Account } from "../../Account";
|
|
2
|
+
import type { Rail } from "../../Rail";
|
|
3
|
+
import type { Transaction } from "../../Transaction";
|
|
1
4
|
import { Creatable as EntryCreatable } from "./Creatable";
|
|
2
5
|
import { Failed as EntryFailed } from "./Failed";
|
|
3
6
|
import { fromCreatable } from "./fromCreatable";
|
|
4
|
-
import { fromLegacy as entryFromLegacy } from "./fromLegacy";
|
|
5
|
-
import { Entry as LegacyEntry } from "./Legacy";
|
|
6
7
|
import { Succeeded as EntrySucceeded } from "./Succeeded";
|
|
7
8
|
import { Summary as EntrySummary } from "./Summary";
|
|
8
9
|
export type Entry = EntrySucceeded | EntryFailed;
|
|
@@ -17,8 +18,7 @@ export declare namespace Entry {
|
|
|
17
18
|
export import Failed = EntryFailed;
|
|
18
19
|
export import Succeeded = EntrySucceeded;
|
|
19
20
|
export import Summary = EntrySummary;
|
|
20
|
-
export import Legacy = LegacyEntry;
|
|
21
21
|
const type: import("isly/dist/cjs/Type").Type<Entry>;
|
|
22
|
-
const fromLegacy: typeof entryFromLegacy;
|
|
23
22
|
const from: typeof fromCreatable;
|
|
23
|
+
function charge(charges: Account.Charge[] | undefined, counterpart: Rail.Address.Card.Counterpart, capture: Creatable.Capture): Transaction.Amount.Charge[];
|
|
24
24
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Entry = void 0;
|
|
4
|
+
const isoly_1 = require("isoly");
|
|
5
|
+
const Account_1 = require("../../Account");
|
|
4
6
|
const Creatable_1 = require("./Creatable");
|
|
5
7
|
const Failed_1 = require("./Failed");
|
|
6
8
|
const fromCreatable_1 = require("./fromCreatable");
|
|
7
|
-
const fromLegacy_1 = require("./fromLegacy");
|
|
8
|
-
const Legacy_1 = require("./Legacy");
|
|
9
9
|
const Succeeded_1 = require("./Succeeded");
|
|
10
10
|
const Summary_1 = require("./Summary");
|
|
11
11
|
const type_1 = require("./type");
|
|
@@ -15,9 +15,11 @@ var Entry;
|
|
|
15
15
|
Entry.Failed = Failed_1.Failed;
|
|
16
16
|
Entry.Succeeded = Succeeded_1.Succeeded;
|
|
17
17
|
Entry.Summary = Summary_1.Summary;
|
|
18
|
-
Entry.Legacy = Legacy_1.Entry;
|
|
19
18
|
Entry.type = type_1.type;
|
|
20
|
-
Entry.fromLegacy = fromLegacy_1.fromLegacy;
|
|
21
19
|
Entry.from = fromCreatable_1.fromCreatable;
|
|
20
|
+
function charge(charges = [], counterpart, capture) {
|
|
21
|
+
return Account_1.Account.Charge.evaluate(charges, counterpart, capture.amount[0], isoly_1.isoly.Currency.add(capture.amount[0], capture.amount[1], capture.fee.other[capture.amount[0]] ?? 0));
|
|
22
|
+
}
|
|
23
|
+
Entry.charge = charge;
|
|
22
24
|
})(Entry || (exports.Entry = Entry = {}));
|
|
23
25
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../Settlement/Entry/index.ts"],"names":[],"mappings":";;;AAAA,2CAAyD;AACzD,qCAAgD;AAChD,mDAA+C;AAC/C,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../Settlement/Entry/index.ts"],"names":[],"mappings":";;;AAAA,iCAA6B;AAC7B,2CAAuC;AAGvC,2CAAyD;AACzD,qCAAgD;AAChD,mDAA+C;AAC/C,2CAAyD;AACzD,uCAAmD;AACnD,iCAA0C;AAG1C,IAAiB,KAAK,CAyBrB;AAzBD,WAAiB,KAAK;IAOP,eAAS,GAAG,qBAAc,CAAA;IAC1B,YAAM,GAAG,eAAW,CAAA;IACpB,eAAS,GAAG,qBAAc,CAAA;IAC1B,aAAO,GAAG,iBAAY,CAAA;IACvB,UAAI,GAAG,WAAS,CAAA;IAChB,UAAI,GAAG,6BAAa,CAAA;IACjC,SAAgB,MAAM,CACrB,UAA4B,EAAE,EAC9B,WAA0C,EAC1C,OAA0B;QAE1B,OAAO,iBAAO,CAAC,MAAM,CAAC,QAAQ,CAC7B,OAAO,EACP,WAAW,EACX,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EACjB,aAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CACnG,CAAA;IACF,CAAC;IAXe,YAAM,SAWrB,CAAA;AACF,CAAC,EAzBgB,KAAK,qBAAL,KAAK,QAyBrB"}
|
|
@@ -43,8 +43,6 @@ export declare namespace Settlement {
|
|
|
43
43
|
transactions: string[];
|
|
44
44
|
};
|
|
45
45
|
};
|
|
46
|
-
export type MaybeOld = Settlement | OldSettlement;
|
|
47
|
-
export function fromLegacy(settlement: MaybeOld): Settlement;
|
|
48
46
|
export const type: import("isly/dist/cjs/object").IslyObject<Settlement, Creatable>;
|
|
49
47
|
export {};
|
|
50
48
|
}
|
|
@@ -55,38 +55,6 @@ var Settlement;
|
|
|
55
55
|
return result;
|
|
56
56
|
}
|
|
57
57
|
Settlement.compile = compile;
|
|
58
|
-
function fromLegacy(settlement) {
|
|
59
|
-
let result;
|
|
60
|
-
if (!Settlement.type.is(settlement)) {
|
|
61
|
-
const totalToAmount = (currency, oldTotal) => ({
|
|
62
|
-
net: oldTotal?.amount[currency] ?? 0,
|
|
63
|
-
fee: { other: oldTotal?.fee.other[currency] ?? 0 },
|
|
64
|
-
});
|
|
65
|
-
const { expected, collected, outcome, settled, ...partialSettlement } = settlement;
|
|
66
|
-
const currencies = Array.from(new Set([
|
|
67
|
-
...Object.keys(expected?.amount ?? {}),
|
|
68
|
-
...Object.keys(collected?.amount ?? {}),
|
|
69
|
-
...Object.keys(settled?.paid ?? {}),
|
|
70
|
-
...Object.keys(outcome.amount),
|
|
71
|
-
]));
|
|
72
|
-
const totals = currencies.reduce((total, currency) => {
|
|
73
|
-
total[currency] = {
|
|
74
|
-
expected: totalToAmount(currency, expected),
|
|
75
|
-
...(outcome ? { outcome: totalToAmount(currency, outcome) } : {}),
|
|
76
|
-
...(collected
|
|
77
|
-
? { collected: { ...totalToAmount(currency, collected), transactions: { net: "", fee: "", charge: "" } } }
|
|
78
|
-
: {}),
|
|
79
|
-
...(settled ? { settled: { net: settled.paid[currency] ?? 0, transactions: settled.transactions } } : {}),
|
|
80
|
-
};
|
|
81
|
-
return total;
|
|
82
|
-
}, {});
|
|
83
|
-
result = { ...partialSettlement, totals };
|
|
84
|
-
}
|
|
85
|
-
else
|
|
86
|
-
result = settlement;
|
|
87
|
-
return result;
|
|
88
|
-
}
|
|
89
|
-
Settlement.fromLegacy = fromLegacy;
|
|
90
58
|
Settlement.type = Creatable_1.Creatable.type.extend({
|
|
91
59
|
id: isly_1.isly.union(Identifier_1.Identifier.type, isly_1.isly.string()),
|
|
92
60
|
by: isly_1.isly.string().optional(),
|