@pax2pay/model-banking 0.1.534 → 0.1.535
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 +50 -0
- package/Account/index.ts +4 -0
- package/Card/Restriction/Merchant.ts +7 -10
- package/Card/Restriction/index.ts +1 -1
- package/Rule/State/Transaction.ts +11 -18
- package/Rule/State/index.ts +2 -2
- package/Transaction/Amount.ts +22 -6
- package/dist/cjs/Account/Charge.d.ts +20 -0
- package/dist/cjs/Account/Charge.js +38 -0
- package/dist/cjs/Account/Charge.js.map +1 -0
- package/dist/cjs/Account/index.d.ts +3 -0
- package/dist/cjs/Account/index.js +3 -0
- package/dist/cjs/Account/index.js.map +1 -1
- package/dist/cjs/Card/Restriction/Merchant.d.ts +2 -2
- package/dist/cjs/Card/Restriction/Merchant.js +6 -6
- package/dist/cjs/Card/Restriction/Merchant.js.map +1 -1
- package/dist/cjs/Card/Restriction/index.js +1 -1
- package/dist/cjs/Card/Restriction/index.js.map +1 -1
- package/dist/cjs/Rule/State/Transaction.d.ts +3 -1
- package/dist/cjs/Rule/State/Transaction.js +9 -12
- package/dist/cjs/Rule/State/Transaction.js.map +1 -1
- package/dist/cjs/Rule/State/index.js +2 -2
- package/dist/cjs/Rule/State/index.js.map +1 -1
- package/dist/cjs/Transaction/Amount.d.ts +14 -2
- package/dist/cjs/Transaction/Amount.js +16 -3
- package/dist/cjs/Transaction/Amount.js.map +1 -1
- package/dist/mjs/Account/Charge.d.ts +20 -0
- package/dist/mjs/Account/Charge.js +35 -0
- package/dist/mjs/Account/Charge.js.map +1 -0
- package/dist/mjs/Account/index.d.ts +3 -0
- package/dist/mjs/Account/index.js +3 -0
- package/dist/mjs/Account/index.js.map +1 -1
- package/dist/mjs/Card/Restriction/Merchant.d.ts +2 -2
- package/dist/mjs/Card/Restriction/Merchant.js +6 -6
- package/dist/mjs/Card/Restriction/Merchant.js.map +1 -1
- package/dist/mjs/Card/Restriction/index.js +1 -1
- package/dist/mjs/Card/Restriction/index.js.map +1 -1
- package/dist/mjs/Rule/State/Transaction.d.ts +3 -1
- package/dist/mjs/Rule/State/Transaction.js +9 -12
- package/dist/mjs/Rule/State/Transaction.js.map +1 -1
- package/dist/mjs/Rule/State/index.js +2 -2
- package/dist/mjs/Rule/State/index.js.map +1 -1
- package/dist/mjs/Transaction/Amount.d.ts +14 -2
- package/dist/mjs/Transaction/Amount.js +16 -3
- package/dist/mjs/Transaction/Amount.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { isoly } from "isoly"
|
|
2
|
+
import { isly } from "isly"
|
|
3
|
+
import { Card } from "../Card"
|
|
4
|
+
import { Transaction } from "../Transaction"
|
|
5
|
+
|
|
6
|
+
export type Charge = {
|
|
7
|
+
id: string
|
|
8
|
+
destination: { account: string }
|
|
9
|
+
rate: number // rate: 0.01 for 1%
|
|
10
|
+
applies: {
|
|
11
|
+
to: {
|
|
12
|
+
merchants: Card.Restriction.Merchant[]
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export namespace Charge {
|
|
17
|
+
export const type = isly.object<Charge>({
|
|
18
|
+
id: isly.string(),
|
|
19
|
+
destination: isly.object({ account: isly.string() }),
|
|
20
|
+
rate: isly.number(),
|
|
21
|
+
applies: isly.object({
|
|
22
|
+
to: isly.object<Charge["applies"]["to"]>({
|
|
23
|
+
merchants: Card.Restriction.Merchant.type.array(),
|
|
24
|
+
}),
|
|
25
|
+
}),
|
|
26
|
+
})
|
|
27
|
+
export function evaluate(
|
|
28
|
+
charges: Charge[] = [],
|
|
29
|
+
transaction: Transaction.Creatable.Resolved | Transaction
|
|
30
|
+
): Transaction.Amount.Charge[] {
|
|
31
|
+
const result: Transaction.Amount.Charge[] = []
|
|
32
|
+
for (const charge of charges)
|
|
33
|
+
if ("merchant" in transaction.counterpart)
|
|
34
|
+
for (const merchant of charge.applies.to.merchants)
|
|
35
|
+
if (Card.Restriction.Merchant.check(merchant, transaction.counterpart))
|
|
36
|
+
result.push({
|
|
37
|
+
destination: charge.destination,
|
|
38
|
+
type: "merchant",
|
|
39
|
+
amount: isoly.Currency.multiply(
|
|
40
|
+
transaction.currency,
|
|
41
|
+
typeof transaction.amount == "number" ? transaction.amount : transaction.amount.original,
|
|
42
|
+
charge.rate
|
|
43
|
+
),
|
|
44
|
+
})
|
|
45
|
+
return result
|
|
46
|
+
}
|
|
47
|
+
export function sum(charges: Transaction.Amount.Charge[], currency: isoly.Currency): number {
|
|
48
|
+
return charges.reduce((sum, charge) => isoly.Currency.add(currency, sum, charge.amount), 0)
|
|
49
|
+
}
|
|
50
|
+
}
|
package/Account/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { isly } from "isly"
|
|
|
4
4
|
import { Balances } from "../Balances"
|
|
5
5
|
import { Rail } from "../Rail"
|
|
6
6
|
import { Rule } from "../Rule"
|
|
7
|
+
import { Charge as AccountCharge } from "./Charge"
|
|
7
8
|
import { Creatable as AccountCreatable } from "./Creatable"
|
|
8
9
|
import { Details as AccountDetails } from "./Details"
|
|
9
10
|
import { History as AccountHistory } from "./History"
|
|
@@ -18,10 +19,12 @@ export interface Account extends Account.Creatable {
|
|
|
18
19
|
details?: Account.Details
|
|
19
20
|
counterparts?: Record<string, Rail.Address>
|
|
20
21
|
key?: string
|
|
22
|
+
charges?: AccountCharge[]
|
|
21
23
|
rules?: Rule[]
|
|
22
24
|
status: Account.Status
|
|
23
25
|
}
|
|
24
26
|
export namespace Account {
|
|
27
|
+
export import Charge = AccountCharge
|
|
25
28
|
export import Creatable = AccountCreatable
|
|
26
29
|
export import Status = AccountStatus
|
|
27
30
|
export import History = AccountHistory
|
|
@@ -39,6 +42,7 @@ export namespace Account {
|
|
|
39
42
|
details: Details.type.optional(),
|
|
40
43
|
counterparts: isly.record<Record<string, Rail.Address>>(isly.string(), Rail.Address.type).optional(),
|
|
41
44
|
key: isly.string().optional(),
|
|
45
|
+
charges: AccountCharge.type.array().optional(),
|
|
42
46
|
rules: Rule.type.array().optional(),
|
|
43
47
|
status: AccountStatus.type,
|
|
44
48
|
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isly } from "isly"
|
|
2
2
|
import { isly as isly2 } from "isly2"
|
|
3
3
|
import { typedly } from "typedly"
|
|
4
|
-
import
|
|
4
|
+
import { Rail } from "../../Rail"
|
|
5
5
|
import { merchants } from "./merchants"
|
|
6
6
|
import { Merchant as Attribute } from "./merchants/Merchant"
|
|
7
7
|
|
|
@@ -10,22 +10,19 @@ export namespace Merchant {
|
|
|
10
10
|
export const values = typedly.Object.keys(merchants)
|
|
11
11
|
export const type = isly.string<Merchant>(values)
|
|
12
12
|
export const type2 = isly2.string<Merchant>("value", ...values)
|
|
13
|
-
export function check(
|
|
14
|
-
merchant: Merchant,
|
|
15
|
-
transaction: Transaction.Creatable.CardTransaction | Transaction.PreTransaction.Authorization
|
|
16
|
-
): boolean {
|
|
13
|
+
export function check(merchant: Merchant, counterpart: Rail.Address.Card.Counterpart): boolean {
|
|
17
14
|
const attribute: Attribute = merchants[merchant]
|
|
18
15
|
let result: boolean
|
|
19
|
-
if (attribute?.unambiguousMcc ==
|
|
16
|
+
if (attribute?.unambiguousMcc == counterpart.merchant.category)
|
|
20
17
|
result = true
|
|
21
18
|
else if (attribute.contains && attribute.mccs)
|
|
22
19
|
result =
|
|
23
|
-
attribute.mccs.some(mcc => mcc ==
|
|
24
|
-
attribute.contains.some(n =>
|
|
20
|
+
attribute.mccs.some(mcc => mcc == counterpart.merchant.category) &&
|
|
21
|
+
attribute.contains.some(n => counterpart.merchant.name.includes(n))
|
|
25
22
|
else if (attribute.startsWith && attribute.mccs)
|
|
26
23
|
result =
|
|
27
|
-
attribute.mccs.some(mcc => mcc ==
|
|
28
|
-
attribute.startsWith.some(n =>
|
|
24
|
+
attribute.mccs.some(mcc => mcc == counterpart.merchant.category) &&
|
|
25
|
+
attribute.startsWith.some(n => counterpart.merchant.name.startsWith(n))
|
|
29
26
|
else
|
|
30
27
|
result = false
|
|
31
28
|
return result
|
|
@@ -22,7 +22,7 @@ export namespace Restriction {
|
|
|
22
22
|
): boolean {
|
|
23
23
|
let result: boolean = true
|
|
24
24
|
if (restrictions.merchants?.length)
|
|
25
|
-
result = restrictions.merchants.some(merchant => Merchant.check(merchant, transaction))
|
|
25
|
+
result = restrictions.merchants.some(merchant => Merchant.check(merchant, transaction.counterpart))
|
|
26
26
|
return result
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isoly } from "isoly"
|
|
2
|
+
import { Account as ModelAccount } from "../../Account"
|
|
2
3
|
import { Transaction as ModelTransaction } from "../../Transaction"
|
|
3
4
|
import type { Rule } from "../index"
|
|
4
5
|
|
|
@@ -11,41 +12,33 @@ export type Transaction = ModelTransaction.Creatable.Resolved & {
|
|
|
11
12
|
risk?: number
|
|
12
13
|
original: {
|
|
13
14
|
currency: isoly.Currency
|
|
15
|
+
charges?: ModelTransaction.Amount.Charge[]
|
|
14
16
|
total: number
|
|
15
17
|
amount: number
|
|
16
|
-
charge?: { current: number; total: number }
|
|
18
|
+
charge?: { current: number; total: number } //Legacy
|
|
17
19
|
}
|
|
18
20
|
}
|
|
19
21
|
export namespace Transaction {
|
|
20
22
|
export function from(
|
|
21
|
-
|
|
23
|
+
account: ModelAccount,
|
|
22
24
|
transaction: ModelTransaction.Creatable.Resolved | ModelTransaction,
|
|
23
25
|
kind: Rule.Base.Kind,
|
|
24
26
|
stage: "finalize" | "initiate"
|
|
25
27
|
): Transaction {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
? [
|
|
29
|
-
transaction.state?.transaction.original.amount ?? transaction.amount,
|
|
30
|
-
isoly.Currency.subtract(
|
|
31
|
-
transaction.currency,
|
|
32
|
-
transaction.state?.transaction.original.total ??
|
|
33
|
-
(typeof transaction.amount == "number" ? transaction.amount : transaction.amount.total),
|
|
34
|
-
stage === "finalize" ? transaction.state?.transaction.original.charge?.total ?? 0 : 0
|
|
35
|
-
),
|
|
36
|
-
]
|
|
37
|
-
: [transaction.amount, transaction.amount]
|
|
28
|
+
const charges = ModelAccount.Charge.evaluate(account.charges, transaction)
|
|
29
|
+
const amount = Math.abs(typeof transaction.amount == "number" ? transaction.amount : transaction.amount.original)
|
|
38
30
|
return {
|
|
39
31
|
...transaction,
|
|
40
32
|
id: "id" in transaction ? transaction.id : ModelTransaction.Identifier.generate(),
|
|
41
33
|
stage,
|
|
42
34
|
kind,
|
|
43
|
-
amount
|
|
44
|
-
type: ModelTransaction.getType(transaction.counterpart,
|
|
35
|
+
amount,
|
|
36
|
+
type: ModelTransaction.getType(transaction.counterpart, account.name),
|
|
45
37
|
original: {
|
|
46
38
|
currency: transaction.currency,
|
|
47
|
-
|
|
48
|
-
|
|
39
|
+
charges,
|
|
40
|
+
amount,
|
|
41
|
+
total: isoly.Currency.add(transaction.currency, amount, ModelAccount.Charge.sum(charges, transaction.currency)),
|
|
49
42
|
},
|
|
50
43
|
}
|
|
51
44
|
}
|
package/Rule/State/index.ts
CHANGED
|
@@ -54,7 +54,7 @@ export namespace State {
|
|
|
54
54
|
return {
|
|
55
55
|
data,
|
|
56
56
|
account: Account.from(account, address, transactions, days),
|
|
57
|
-
transaction: Transaction.from(account
|
|
57
|
+
transaction: Transaction.from(account, transaction, kind, stage),
|
|
58
58
|
authorization: Authorization.from(transaction),
|
|
59
59
|
card,
|
|
60
60
|
organization,
|
|
@@ -78,7 +78,7 @@ export namespace State {
|
|
|
78
78
|
return {
|
|
79
79
|
data,
|
|
80
80
|
account: Account.from(account, address, transactions, days),
|
|
81
|
-
transaction: Transaction.from(account
|
|
81
|
+
transaction: Transaction.from(account, transaction, type[transaction.type], "initiate"),
|
|
82
82
|
card: card ? Card.from(card, card.statistics) : undefined,
|
|
83
83
|
organization,
|
|
84
84
|
}
|
package/Transaction/Amount.ts
CHANGED
|
@@ -5,14 +5,31 @@ import { Exchange } from "./Exchange"
|
|
|
5
5
|
|
|
6
6
|
export interface Amount {
|
|
7
7
|
original: number
|
|
8
|
-
charge
|
|
8
|
+
charge?: number //Legacy
|
|
9
|
+
charges?: Amount.Charge[]
|
|
9
10
|
total: number
|
|
10
11
|
exchange?: Exchange
|
|
11
12
|
}
|
|
12
13
|
export namespace Amount {
|
|
14
|
+
export interface Charge {
|
|
15
|
+
amount: number
|
|
16
|
+
type: "merchant" | "exchange"
|
|
17
|
+
destination: { account: string }
|
|
18
|
+
}
|
|
19
|
+
export namespace Charge {
|
|
20
|
+
export const type = isly.object<Charge>({
|
|
21
|
+
amount: isly.number(),
|
|
22
|
+
type: isly.string(["merchant", "exchange"]),
|
|
23
|
+
destination: isly.object({ account: isly.string() }),
|
|
24
|
+
})
|
|
25
|
+
export function total(currency: isoly.Currency, charges: Charge[] = []): number {
|
|
26
|
+
return charges.reduce((r, c) => isoly.Currency.add(currency, r, c.amount), 0)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
13
29
|
export const type = isly.object<Amount>({
|
|
14
30
|
original: isly.number(),
|
|
15
|
-
charge: isly.number(),
|
|
31
|
+
charge: isly.number().optional(),
|
|
32
|
+
charges: Charge.type.array().optional(),
|
|
16
33
|
total: isly.number(),
|
|
17
34
|
exchange: Exchange.type.optional(),
|
|
18
35
|
})
|
|
@@ -22,19 +39,18 @@ export namespace Amount {
|
|
|
22
39
|
: 1
|
|
23
40
|
return {
|
|
24
41
|
original: sign * state.transaction.original.amount,
|
|
25
|
-
|
|
42
|
+
charges: state.transaction.original.charges,
|
|
26
43
|
total: sign * state.transaction.original.total,
|
|
27
44
|
exchange: state?.transaction.exchange ?? state.authorization?.exchange,
|
|
28
45
|
}
|
|
29
46
|
}
|
|
30
|
-
|
|
31
47
|
export function change(
|
|
32
48
|
currency: isoly.Currency,
|
|
33
49
|
amount: Amount,
|
|
34
50
|
change: number,
|
|
35
|
-
type: Exclude<keyof Amount, "total" | "exchange">
|
|
51
|
+
type: Exclude<keyof Amount, "total" | "exchange" | "charges">
|
|
36
52
|
): Amount {
|
|
37
|
-
amount[type] = isoly.Currency.add(currency, amount[type], change)
|
|
53
|
+
amount[type] = isoly.Currency.add(currency, amount[type] ?? 0, change)
|
|
38
54
|
amount.total = isoly.Currency.add(currency, amount.total, change)
|
|
39
55
|
return amount
|
|
40
56
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { isoly } from "isoly";
|
|
2
|
+
import { Card } from "../Card";
|
|
3
|
+
import { Transaction } from "../Transaction";
|
|
4
|
+
export type Charge = {
|
|
5
|
+
id: string;
|
|
6
|
+
destination: {
|
|
7
|
+
account: string;
|
|
8
|
+
};
|
|
9
|
+
rate: number;
|
|
10
|
+
applies: {
|
|
11
|
+
to: {
|
|
12
|
+
merchants: Card.Restriction.Merchant[];
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export declare namespace Charge {
|
|
17
|
+
const type: import("isly/dist/cjs/object").IslyObject<Charge, object>;
|
|
18
|
+
function evaluate(charges: Charge[] | undefined, transaction: Transaction.Creatable.Resolved | Transaction): Transaction.Amount.Charge[];
|
|
19
|
+
function sum(charges: Transaction.Amount.Charge[], currency: isoly.Currency): number;
|
|
20
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Charge = void 0;
|
|
4
|
+
const isoly_1 = require("isoly");
|
|
5
|
+
const isly_1 = require("isly");
|
|
6
|
+
const Card_1 = require("../Card");
|
|
7
|
+
var Charge;
|
|
8
|
+
(function (Charge) {
|
|
9
|
+
Charge.type = isly_1.isly.object({
|
|
10
|
+
id: isly_1.isly.string(),
|
|
11
|
+
destination: isly_1.isly.object({ account: isly_1.isly.string() }),
|
|
12
|
+
rate: isly_1.isly.number(),
|
|
13
|
+
applies: isly_1.isly.object({
|
|
14
|
+
to: isly_1.isly.object({
|
|
15
|
+
merchants: Card_1.Card.Restriction.Merchant.type.array(),
|
|
16
|
+
}),
|
|
17
|
+
}),
|
|
18
|
+
});
|
|
19
|
+
function evaluate(charges = [], transaction) {
|
|
20
|
+
const result = [];
|
|
21
|
+
for (const charge of charges)
|
|
22
|
+
if ("merchant" in transaction.counterpart)
|
|
23
|
+
for (const merchant of charge.applies.to.merchants)
|
|
24
|
+
if (Card_1.Card.Restriction.Merchant.check(merchant, transaction.counterpart))
|
|
25
|
+
result.push({
|
|
26
|
+
destination: charge.destination,
|
|
27
|
+
type: "merchant",
|
|
28
|
+
amount: isoly_1.isoly.Currency.multiply(transaction.currency, typeof transaction.amount == "number" ? transaction.amount : transaction.amount.original, charge.rate),
|
|
29
|
+
});
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
Charge.evaluate = evaluate;
|
|
33
|
+
function sum(charges, currency) {
|
|
34
|
+
return charges.reduce((sum, charge) => isoly_1.isoly.Currency.add(currency, sum, charge.amount), 0);
|
|
35
|
+
}
|
|
36
|
+
Charge.sum = sum;
|
|
37
|
+
})(Charge || (exports.Charge = Charge = {}));
|
|
38
|
+
//# sourceMappingURL=Charge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Charge.js","sourceRoot":"","sources":["../../../Account/Charge.ts"],"names":[],"mappings":";;;AAAA,iCAA6B;AAC7B,+BAA2B;AAC3B,kCAA8B;AAa9B,IAAiB,MAAM,CAkCtB;AAlCD,WAAiB,MAAM;IACT,WAAI,GAAG,WAAI,CAAC,MAAM,CAAS;QACvC,EAAE,EAAE,WAAI,CAAC,MAAM,EAAE;QACjB,WAAW,EAAE,WAAI,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,WAAI,CAAC,MAAM,EAAE,EAAE,CAAC;QACpD,IAAI,EAAE,WAAI,CAAC,MAAM,EAAE;QACnB,OAAO,EAAE,WAAI,CAAC,MAAM,CAAC;YACpB,EAAE,EAAE,WAAI,CAAC,MAAM,CAA0B;gBACxC,SAAS,EAAE,WAAI,CAAC,WAAW,CAAC,QA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
import { Rail } from "../Rail";
|
|
5
5
|
import { Rule } from "../Rule";
|
|
6
|
+
import { Charge as AccountCharge } from "./Charge";
|
|
6
7
|
import { Creatable as AccountCreatable } from "./Creatable";
|
|
7
8
|
import { Details as AccountDetails } from "./Details";
|
|
8
9
|
import { History as AccountHistory } from "./History";
|
|
@@ -16,10 +17,12 @@ export interface Account extends Account.Creatable {
|
|
|
16
17
|
details?: Account.Details;
|
|
17
18
|
counterparts?: Record<string, Rail.Address>;
|
|
18
19
|
key?: string;
|
|
20
|
+
charges?: AccountCharge[];
|
|
19
21
|
rules?: Rule[];
|
|
20
22
|
status: Account.Status;
|
|
21
23
|
}
|
|
22
24
|
export declare namespace Account {
|
|
25
|
+
export import Charge = AccountCharge;
|
|
23
26
|
export import Creatable = AccountCreatable;
|
|
24
27
|
export import Status = AccountStatus;
|
|
25
28
|
export import History = AccountHistory;
|
|
@@ -7,12 +7,14 @@ const isly_1 = require("isly");
|
|
|
7
7
|
const Balances_1 = require("../Balances");
|
|
8
8
|
const Rail_1 = require("../Rail");
|
|
9
9
|
const Rule_1 = require("../Rule");
|
|
10
|
+
const Charge_1 = require("./Charge");
|
|
10
11
|
const Creatable_1 = require("./Creatable");
|
|
11
12
|
const Details_1 = require("./Details");
|
|
12
13
|
const History_1 = require("./History");
|
|
13
14
|
const Status_1 = require("./Status");
|
|
14
15
|
var Account;
|
|
15
16
|
(function (Account) {
|
|
17
|
+
Account.Charge = Charge_1.Charge;
|
|
16
18
|
Account.Creatable = Creatable_1.Creatable;
|
|
17
19
|
Account.Status = Status_1.Status;
|
|
18
20
|
Account.History = History_1.History;
|
|
@@ -30,6 +32,7 @@ var Account;
|
|
|
30
32
|
details: Account.Details.type.optional(),
|
|
31
33
|
counterparts: isly_1.isly.record(isly_1.isly.string(), Rail_1.Rail.Address.type).optional(),
|
|
32
34
|
key: isly_1.isly.string().optional(),
|
|
35
|
+
charges: Charge_1.Charge.type.array().optional(),
|
|
33
36
|
rules: Rule_1.Rule.type.array().optional(),
|
|
34
37
|
status: Status_1.Status.type,
|
|
35
38
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../Account/index.ts"],"names":[],"mappings":";;;AAAA,qCAAiC;AACjC,iCAA6B;AAC7B,+BAA2B;AAC3B,0CAAsC;AACtC,kCAA8B;AAC9B,kCAA8B;AAC9B,2CAA2D;AAC3D,uCAAqD;AACrD,uCAAqD;AACrD,qCAAkD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../Account/index.ts"],"names":[],"mappings":";;;AAAA,qCAAiC;AACjC,iCAA6B;AAC7B,+BAA2B;AAC3B,0CAAsC;AACtC,kCAA8B;AAC9B,kCAA8B;AAC9B,qCAAkD;AAClD,2CAA2D;AAC3D,uCAAqD;AACrD,uCAAqD;AACrD,qCAAkD;AAelD,IAAiB,OAAO,CA0BvB;AA1BD,WAAiB,OAAO;IACT,cAAM,GAAG,eAAa,CAAA;IACtB,iBAAS,GAAG,qBAAgB,CAAA;IAC5B,cAAM,GAAG,eAAa,CAAA;IACtB,eAAO,GAAG,iBAAc,CAAA;IACxB,eAAO,GAAG,iBAAc,CAAA;IAEtC,SAAgB,UAAU,CAAC,WAA6B,EAAE,MAAuB;QAChF,OAAO,EAAE,GAAG,WAAW,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC,QAAQ,IAAI,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAA;IACjH,CAAC;IAFe,kBAAU,aAEzB,CAAA;IACY,YAAI,GAAG,QAAA,SAAS,CAAC,IAAI,CAAC,MAAM,CAAU;QAClD,EAAE,EAAE,WAAI,CAAC,MAAM,EAAE;QACjB,OAAO,EAAE,WAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,aAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;QACzD,YAAY,EAAE,WAAI,CAAC,MAAM,EAAE;QAC3B,QAAQ,EAAE,mBAAQ,CAAC,IAAI;QACvB,KAAK,EAAE,WAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE;QAChC,OAAO,EAAE,QAAA,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE;QAChC,YAAY,EAAE,WAAI,CAAC,MAAM,CAA+B,WAAI,CAAC,MAAM,EAAE,EAAE,WAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE;QACpG,GAAG,EAAE,WAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAC7B,OAAO,EAAE,eAAa,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE;QAC9C,KAAK,EAAE,WAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE;QACnC,MAAM,EAAE,eAAa,CAAC,IAAI;KAC1B,CAAC,CAAA;IACF,SAAgB,YAAY,CAAC,KAA+B;QAC3D,OAAO,iBAAO,CAAC,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;IACvC,CAAC;IAFe,oBAAY,eAE3B,CAAA;AACF,CAAC,EA1BgB,OAAO,uBAAP,OAAO,QA0BvB"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { isly } from "isly";
|
|
2
2
|
import { isly as isly2 } from "isly2";
|
|
3
|
-
import
|
|
3
|
+
import { Rail } from "../../Rail";
|
|
4
4
|
export type Merchant = typeof Merchant.values[number];
|
|
5
5
|
export declare namespace Merchant {
|
|
6
6
|
const values: ("ryanair" | "easyjet" | "wizzair" | "aer lingus" | "air malta" | "vueling" | "jet2" | "eurowings" | "turkish air" | "tap" | "pegasus" | "royal air maroc" | "qatar air" | "blue island" | "klm" | "iberia" | "emirates" | "aegean airlines" | "tui" | "united airlines" | "cathay pacific airlines" | "air serbia" | "copa air" | "bamboo airways" | "latam airlines" | "flydubai" | "condor" | "transavia" | "austrian air" | "alitalia" | "apg airlines" | "iceland air" | "flyone" | "avianca" | "brussels airlines" | "saudia" | "aeromexico" | "gulf air" | "ethiopian airlines" | "egypt air" | "albawings" | "iberojet" | "norwegian air" | "vistara" | "air greenland" | "sky express" | "air canada" | "philippine airlines" | "south african airlink" | "air benelux" | "tunisair" | "lufthansa" | "corendon airlines" | "uganda airlines" | "freebird airlines" | "kenya airway" | "kuwait air" | "british airways" | "czech airlines" | "lot polish airlines" | "volotea" | "flybe" | "bulgaria air" | "sas" | "qantas" | "air india" | "air europa" | "royal jordanian" | "virgin atlantic" | "flexflight" | "rwandair" | "hahn air" | "american air" | "pakistan international airlines" | "singapore airlines" | "delta air lines" | "croatia airlines" | "air asia" | "hawaiian airlines" | "oman air" | "etihad air" | "middle east airlines" | "logan air" | "aurigny" | "eastern airways" | "sun express" | "spirit air" | "air france" | "malaysia airlines" | "finnair" | "swiss air" | "air china" | "ana air" | "ae bsp" | "thai airways" | "jet blue" | "westjet" | "aerolineas" | "air seoul" | "azerbaijan airlines" | "air dolomiti" | "bangkok airways" | "china airlines" | "china eastern airlines" | "eva air" | "jetstar airways" | "km malta airlines" | "ita airways" | "china southern airlines" | "world2fly" | "sata denmark" | "air baltic" | "ajet" | "flynorse" | "hainan air" | "sichuan airlines" | "korean air" | "gol airlines" | "azul brazilian airlines" | "flysafair" | "air mauritius" | "alaska airlines" | "allegiant air" | "plus ultra líneas aéreas" | "parkwing" | "albergo - food and drinks" | "amtrak" | "italo treno" | "ilsa web" | "rail ninja" | "irish rail" | "österreichische bundesbahnen" | "rail europe" | "via rail canada" | "direct ferries" | "booking.com" | "advertising" | "best western" | "una hotels" | "unaway hotels" | "albergo - lodging" | "leonardo hotels" | "hotel mercure" | "nh hotels & resorts" | "novotel hotels" | "ac hotels" | "marriott hotels" | "sheraton hotels and resorts" | "ih hotels" | "ibis hotels" | "hyatt hotels & resorts" | "hilton hotels & resorts" | "holiday inn" | "four seasons" | "doubletree by hilton" | "crowne plaza hotels")[];
|
|
7
7
|
const type: isly.Type<"ryanair" | "easyjet" | "wizzair" | "aer lingus" | "air malta" | "vueling" | "jet2" | "eurowings" | "turkish air" | "tap" | "pegasus" | "royal air maroc" | "qatar air" | "blue island" | "klm" | "iberia" | "emirates" | "aegean airlines" | "tui" | "united airlines" | "cathay pacific airlines" | "air serbia" | "copa air" | "bamboo airways" | "latam airlines" | "flydubai" | "condor" | "transavia" | "austrian air" | "alitalia" | "apg airlines" | "iceland air" | "flyone" | "avianca" | "brussels airlines" | "saudia" | "aeromexico" | "gulf air" | "ethiopian airlines" | "egypt air" | "albawings" | "iberojet" | "norwegian air" | "vistara" | "air greenland" | "sky express" | "air canada" | "philippine airlines" | "south african airlink" | "air benelux" | "tunisair" | "lufthansa" | "corendon airlines" | "uganda airlines" | "freebird airlines" | "kenya airway" | "kuwait air" | "british airways" | "czech airlines" | "lot polish airlines" | "volotea" | "flybe" | "bulgaria air" | "sas" | "qantas" | "air india" | "air europa" | "royal jordanian" | "virgin atlantic" | "flexflight" | "rwandair" | "hahn air" | "american air" | "pakistan international airlines" | "singapore airlines" | "delta air lines" | "croatia airlines" | "air asia" | "hawaiian airlines" | "oman air" | "etihad air" | "middle east airlines" | "logan air" | "aurigny" | "eastern airways" | "sun express" | "spirit air" | "air france" | "malaysia airlines" | "finnair" | "swiss air" | "air china" | "ana air" | "ae bsp" | "thai airways" | "jet blue" | "westjet" | "aerolineas" | "air seoul" | "azerbaijan airlines" | "air dolomiti" | "bangkok airways" | "china airlines" | "china eastern airlines" | "eva air" | "jetstar airways" | "km malta airlines" | "ita airways" | "china southern airlines" | "world2fly" | "sata denmark" | "air baltic" | "ajet" | "flynorse" | "hainan air" | "sichuan airlines" | "korean air" | "gol airlines" | "azul brazilian airlines" | "flysafair" | "air mauritius" | "alaska airlines" | "allegiant air" | "plus ultra líneas aéreas" | "parkwing" | "albergo - food and drinks" | "amtrak" | "italo treno" | "ilsa web" | "rail ninja" | "irish rail" | "österreichische bundesbahnen" | "rail europe" | "via rail canada" | "direct ferries" | "booking.com" | "advertising" | "best western" | "una hotels" | "unaway hotels" | "albergo - lodging" | "leonardo hotels" | "hotel mercure" | "nh hotels & resorts" | "novotel hotels" | "ac hotels" | "marriott hotels" | "sheraton hotels and resorts" | "ih hotels" | "ibis hotels" | "hyatt hotels & resorts" | "hilton hotels & resorts" | "holiday inn" | "four seasons" | "doubletree by hilton" | "crowne plaza hotels">;
|
|
8
8
|
const type2: isly2.String<"ryanair" | "easyjet" | "wizzair" | "aer lingus" | "air malta" | "vueling" | "jet2" | "eurowings" | "turkish air" | "tap" | "pegasus" | "royal air maroc" | "qatar air" | "blue island" | "klm" | "iberia" | "emirates" | "aegean airlines" | "tui" | "united airlines" | "cathay pacific airlines" | "air serbia" | "copa air" | "bamboo airways" | "latam airlines" | "flydubai" | "condor" | "transavia" | "austrian air" | "alitalia" | "apg airlines" | "iceland air" | "flyone" | "avianca" | "brussels airlines" | "saudia" | "aeromexico" | "gulf air" | "ethiopian airlines" | "egypt air" | "albawings" | "iberojet" | "norwegian air" | "vistara" | "air greenland" | "sky express" | "air canada" | "philippine airlines" | "south african airlink" | "air benelux" | "tunisair" | "lufthansa" | "corendon airlines" | "uganda airlines" | "freebird airlines" | "kenya airway" | "kuwait air" | "british airways" | "czech airlines" | "lot polish airlines" | "volotea" | "flybe" | "bulgaria air" | "sas" | "qantas" | "air india" | "air europa" | "royal jordanian" | "virgin atlantic" | "flexflight" | "rwandair" | "hahn air" | "american air" | "pakistan international airlines" | "singapore airlines" | "delta air lines" | "croatia airlines" | "air asia" | "hawaiian airlines" | "oman air" | "etihad air" | "middle east airlines" | "logan air" | "aurigny" | "eastern airways" | "sun express" | "spirit air" | "air france" | "malaysia airlines" | "finnair" | "swiss air" | "air china" | "ana air" | "ae bsp" | "thai airways" | "jet blue" | "westjet" | "aerolineas" | "air seoul" | "azerbaijan airlines" | "air dolomiti" | "bangkok airways" | "china airlines" | "china eastern airlines" | "eva air" | "jetstar airways" | "km malta airlines" | "ita airways" | "china southern airlines" | "world2fly" | "sata denmark" | "air baltic" | "ajet" | "flynorse" | "hainan air" | "sichuan airlines" | "korean air" | "gol airlines" | "azul brazilian airlines" | "flysafair" | "air mauritius" | "alaska airlines" | "allegiant air" | "plus ultra líneas aéreas" | "parkwing" | "albergo - food and drinks" | "amtrak" | "italo treno" | "ilsa web" | "rail ninja" | "irish rail" | "österreichische bundesbahnen" | "rail europe" | "via rail canada" | "direct ferries" | "booking.com" | "advertising" | "best western" | "una hotels" | "unaway hotels" | "albergo - lodging" | "leonardo hotels" | "hotel mercure" | "nh hotels & resorts" | "novotel hotels" | "ac hotels" | "marriott hotels" | "sheraton hotels and resorts" | "ih hotels" | "ibis hotels" | "hyatt hotels & resorts" | "hilton hotels & resorts" | "holiday inn" | "four seasons" | "doubletree by hilton" | "crowne plaza hotels">;
|
|
9
|
-
function check(merchant: Merchant,
|
|
9
|
+
function check(merchant: Merchant, counterpart: Rail.Address.Card.Counterpart): boolean;
|
|
10
10
|
}
|
|
@@ -10,19 +10,19 @@ var Merchant;
|
|
|
10
10
|
Merchant.values = typedly_1.typedly.Object.keys(merchants_1.merchants);
|
|
11
11
|
Merchant.type = isly_1.isly.string(Merchant.values);
|
|
12
12
|
Merchant.type2 = isly2_1.isly.string("value", ...Merchant.values);
|
|
13
|
-
function check(merchant,
|
|
13
|
+
function check(merchant, counterpart) {
|
|
14
14
|
const attribute = merchants_1.merchants[merchant];
|
|
15
15
|
let result;
|
|
16
|
-
if (attribute?.unambiguousMcc ==
|
|
16
|
+
if (attribute?.unambiguousMcc == counterpart.merchant.category)
|
|
17
17
|
result = true;
|
|
18
18
|
else if (attribute.contains && attribute.mccs)
|
|
19
19
|
result =
|
|
20
|
-
attribute.mccs.some(mcc => mcc ==
|
|
21
|
-
attribute.contains.some(n =>
|
|
20
|
+
attribute.mccs.some(mcc => mcc == counterpart.merchant.category) &&
|
|
21
|
+
attribute.contains.some(n => counterpart.merchant.name.includes(n));
|
|
22
22
|
else if (attribute.startsWith && attribute.mccs)
|
|
23
23
|
result =
|
|
24
|
-
attribute.mccs.some(mcc => mcc ==
|
|
25
|
-
attribute.startsWith.some(n =>
|
|
24
|
+
attribute.mccs.some(mcc => mcc == counterpart.merchant.category) &&
|
|
25
|
+
attribute.startsWith.some(n => counterpart.merchant.name.startsWith(n));
|
|
26
26
|
else
|
|
27
27
|
result = false;
|
|
28
28
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Merchant.js","sourceRoot":"","sources":["../../../../Card/Restriction/Merchant.ts"],"names":[],"mappings":";;;AAAA,+BAA2B;AAC3B,iCAAqC;AACrC,qCAAiC;AAEjC,2CAAuC;AAIvC,IAAiB,QAAQ,
|
|
1
|
+
{"version":3,"file":"Merchant.js","sourceRoot":"","sources":["../../../../Card/Restriction/Merchant.ts"],"names":[],"mappings":";;;AAAA,+BAA2B;AAC3B,iCAAqC;AACrC,qCAAiC;AAEjC,2CAAuC;AAIvC,IAAiB,QAAQ,CAqBxB;AArBD,WAAiB,QAAQ;IACX,eAAM,GAAG,iBAAO,CAAC,MAAM,CAAC,IAAI,CAAC,qBAAS,CAAC,CAAA;IACvC,aAAI,GAAG,WAAI,CAAC,MAAM,CAAW,SAAA,MAAM,CAAC,CAAA;IACpC,cAAK,GAAG,YAAK,CAAC,MAAM,CAAW,OAAO,EAAE,GAAG,SAAA,MAAM,CAAC,CAAA;IAC/D,SAAgB,KAAK,CAAC,QAAkB,EAAE,WAA0C;QACnF,MAAM,SAAS,GAAc,qBAAS,CAAC,QAAQ,CAAC,CAAA;QAChD,IAAI,MAAe,CAAA;QACnB,IAAI,SAAS,EAAE,cAAc,IAAI,WAAW,CAAC,QAAQ,CAAC,QAAQ;YAC7D,MAAM,GAAG,IAAI,CAAA;aACT,IAAI,SAAS,CAAC,QAAQ,IAAI,SAAS,CAAC,IAAI;YAC5C,MAAM;gBACL,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,WAAW,CAAC,QAAQ,CAAC,QAAQ,CAAC;oBAChE,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAA;aAChE,IAAI,SAAS,CAAC,UAAU,IAAI,SAAS,CAAC,IAAI;YAC9C,MAAM;gBACL,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,WAAW,CAAC,QAAQ,CAAC,QAAQ,CAAC;oBAChE,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;;YAExE,MAAM,GAAG,KAAK,CAAA;QACf,OAAO,MAAM,CAAA;IACd,CAAC;IAhBe,cAAK,QAgBpB,CAAA;AACF,CAAC,EArBgB,QAAQ,wBAAR,QAAQ,QAqBxB"}
|
|
@@ -18,7 +18,7 @@ var Restriction;
|
|
|
18
18
|
function check(restrictions, transaction) {
|
|
19
19
|
let result = true;
|
|
20
20
|
if (restrictions.merchants?.length)
|
|
21
|
-
result = restrictions.merchants.some(merchant => Restriction.Merchant.check(merchant, transaction));
|
|
21
|
+
result = restrictions.merchants.some(merchant => Restriction.Merchant.check(merchant, transaction.counterpart));
|
|
22
22
|
return result;
|
|
23
23
|
}
|
|
24
24
|
Restriction.check = check;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../Card/Restriction/index.ts"],"names":[],"mappings":";;;AAAA,+BAA2B;AAC3B,iCAAqC;AAErC,yCAA6D;AAK7D,IAAiB,WAAW,CAmB3B;AAnBD,WAAiB,WAAW;IACb,oBAAQ,GAAG,mBAAoB,CAAA;IAChC,gBAAI,GAAG,WAAI,CAAC,MAAM,CAAc,EAAE,SAAS,EAAE,YAAA,QAAQ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YACjC,MAAM,GAAG,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,YAAA,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC,CAAA;QACpG,OAAO,MAAM,CAAA;IACd,CAAC;IARe,iBAAK,QAQpB,CAAA;AACF,CAAC,EAnBgB,WAAW,2BAAX,WAAW,QAmB3B"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isoly } from "isoly";
|
|
2
|
+
import { Account as ModelAccount } from "../../Account";
|
|
2
3
|
import { Transaction as ModelTransaction } from "../../Transaction";
|
|
3
4
|
import type { Rule } from "../index";
|
|
4
5
|
export type Transaction = ModelTransaction.Creatable.Resolved & {
|
|
@@ -10,6 +11,7 @@ export type Transaction = ModelTransaction.Creatable.Resolved & {
|
|
|
10
11
|
risk?: number;
|
|
11
12
|
original: {
|
|
12
13
|
currency: isoly.Currency;
|
|
14
|
+
charges?: ModelTransaction.Amount.Charge[];
|
|
13
15
|
total: number;
|
|
14
16
|
amount: number;
|
|
15
17
|
charge?: {
|
|
@@ -19,6 +21,6 @@ export type Transaction = ModelTransaction.Creatable.Resolved & {
|
|
|
19
21
|
};
|
|
20
22
|
};
|
|
21
23
|
export declare namespace Transaction {
|
|
22
|
-
function from(
|
|
24
|
+
function from(account: ModelAccount, transaction: ModelTransaction.Creatable.Resolved | ModelTransaction, kind: Rule.Base.Kind, stage: "finalize" | "initiate"): Transaction;
|
|
23
25
|
function fromPreTransaction(accountName: string, transaction: ModelTransaction.PreTransaction | ModelTransaction, kind: Rule.Base.Kind, stage: "finalize" | "initiate"): Transaction;
|
|
24
26
|
}
|
|
@@ -2,28 +2,25 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Transaction = void 0;
|
|
4
4
|
const isoly_1 = require("isoly");
|
|
5
|
+
const Account_1 = require("../../Account");
|
|
5
6
|
const Transaction_1 = require("../../Transaction");
|
|
6
7
|
var Transaction;
|
|
7
8
|
(function (Transaction) {
|
|
8
|
-
function from(
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
transaction.state?.transaction.original.amount ?? transaction.amount,
|
|
12
|
-
isoly_1.isoly.Currency.subtract(transaction.currency, transaction.state?.transaction.original.total ??
|
|
13
|
-
(typeof transaction.amount == "number" ? transaction.amount : transaction.amount.total), stage === "finalize" ? transaction.state?.transaction.original.charge?.total ?? 0 : 0),
|
|
14
|
-
]
|
|
15
|
-
: [transaction.amount, transaction.amount];
|
|
9
|
+
function from(account, transaction, kind, stage) {
|
|
10
|
+
const charges = Account_1.Account.Charge.evaluate(account.charges, transaction);
|
|
11
|
+
const amount = Math.abs(typeof transaction.amount == "number" ? transaction.amount : transaction.amount.original);
|
|
16
12
|
return {
|
|
17
13
|
...transaction,
|
|
18
14
|
id: "id" in transaction ? transaction.id : Transaction_1.Transaction.Identifier.generate(),
|
|
19
15
|
stage,
|
|
20
16
|
kind,
|
|
21
|
-
amount
|
|
22
|
-
type: Transaction_1.Transaction.getType(transaction.counterpart,
|
|
17
|
+
amount,
|
|
18
|
+
type: Transaction_1.Transaction.getType(transaction.counterpart, account.name),
|
|
23
19
|
original: {
|
|
24
20
|
currency: transaction.currency,
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
charges,
|
|
22
|
+
amount,
|
|
23
|
+
total: isoly_1.isoly.Currency.add(transaction.currency, amount, Account_1.Account.Charge.sum(charges, transaction.currency)),
|
|
27
24
|
},
|
|
28
25
|
};
|
|
29
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transaction.js","sourceRoot":"","sources":["../../../../Rule/State/Transaction.ts"],"names":[],"mappings":";;;AAAA,iCAA6B;AAC7B,mDAAmE;
|
|
1
|
+
{"version":3,"file":"Transaction.js","sourceRoot":"","sources":["../../../../Rule/State/Transaction.ts"],"names":[],"mappings":";;;AAAA,iCAA6B;AAC7B,2CAAuD;AACvD,mDAAm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AC,QAAQ,EAAE;YACjF,KAAK;YACL,IAAI;YACJ,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,WAAW,CAAC,MAAM,IAAI,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC;YACvG,IAAI,EAAE,yBAAgB,CAAC,OAAO,CAAC,WAAW,CAAC,WAAW,EAAE,WAAW,CAAC;YACpE,QAAQ,EAAE;gBACT,QAAQ,EAAE,WAAW,CAAC,QAAQ;gBAC9B,MAAM,EAAE,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;gBAC1G,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,WAAW,CAAC,MAAM,IAAI,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC;aACtG;SACD,CAAA;IACF,CAAC;IAnBe,8BAAkB,qBAmBjC,CAAA;AACF,CAAC,EA5CgB,WAAW,2BAAX,WAAW,QA4C3B"}
|
|
@@ -25,7 +25,7 @@ var State;
|
|
|
25
25
|
return {
|
|
26
26
|
data,
|
|
27
27
|
account: State.Account.from(account, address, transactions, days),
|
|
28
|
-
transaction: State.Transaction.from(account
|
|
28
|
+
transaction: State.Transaction.from(account, transaction, kind, stage),
|
|
29
29
|
authorization: State.Authorization.from(transaction),
|
|
30
30
|
card,
|
|
31
31
|
organization,
|
|
@@ -41,7 +41,7 @@ var State;
|
|
|
41
41
|
return {
|
|
42
42
|
data,
|
|
43
43
|
account: State.Account.from(account, address, transactions, days),
|
|
44
|
-
transaction: State.Transaction.from(account
|
|
44
|
+
transaction: State.Transaction.from(account, transaction, State.type[transaction.type], "initiate"),
|
|
45
45
|
card: card ? State.Card.from(card, card.statistics) : undefined,
|
|
46
46
|
organization,
|
|
47
47
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../Rule/State/index.ts"],"names":[],"mappings":";;;AAAA,+BAA2B;AAM3B,uCAAmD;AACnD,mDAAqE;AACrE,iCAA0C;AAE1C,iDAAkE;AAClE,uCAAmD;AACnD,+CAA+D;AAU/D,IAAiB,KAAK,CA+DrB;AA/DD,WAAiB,KAAK;IACP,aAAO,GAAG,iBAAY,CAAA;IACtB,mBAAa,GAAG,6BAAkB,CAAA;IAClC,UAAI,GAAG,WAAS,CAAA;IAChB,aAAO,GAAG,iBAAY,CAAA;IACtB,iBAAW,GAAG,yBAAgB,CAAA;IAC9B,kBAAY,GAAG,2BAAiB,CAAA;IAG9C,IAAiB,OAAO,CAGvB;IAHD,WAAiB,OAAO;QACV,cAAM,GAAG,CAAC,SAAS,EAAE,QAAQ,EAAE,QAAQ,CAAU,CAAA;QACjD,YAAI,GAAG,WAAI,CAAC,MAAM,CAAU,QAAA,MAAM,CAAC,CAAA;IACjD,CAAC,EAHgB,OAAO,GAAP,aAAO,KAAP,aAAO,QAGvB;IAOD,SAAgB,IAAI,CACnB,IAAU,EACV,OAAqB,EACrB,OAAqB,EACrB,YAAkC,EAClC,IAAkB,EAClB,WAAmE,EACnE,IAAoB,EACpB,KAA8B,EAC9B,IAAW,EACX,YAA2B;QAE3B,OAAO;YACN,IAAI;YACJ,OAAO,EAAE,MAAA,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,CAAC;YAC3D,WAAW,EAAE,MAAA,WAAW,CAAC,IAAI,CAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../Rule/State/index.ts"],"names":[],"mappings":";;;AAAA,+BAA2B;AAM3B,uCAAmD;AACnD,mDAAqE;AACrE,iCAA0C;AAE1C,iDAAkE;AA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AA2B;QAE3B,OAAO;YACN,IAAI;YACJ,OAAO,EAAE,MAAA,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,CAAC;YAC3D,WAAW,EAAE,MAAA,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE,MAAA,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC;YACvF,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,MAAA,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS;YACzD,YAAY;SACZ,CAAA;IACF,CAAC;IAjBe,wBAAkB,qBAiBjC,CAAA;AACF,CAAC,EA/DgB,KAAK,qBAAL,KAAK,QA+DrB"}
|
|
@@ -3,12 +3,24 @@ import type { Rule } from "../Rule";
|
|
|
3
3
|
import { Exchange } from "./Exchange";
|
|
4
4
|
export interface Amount {
|
|
5
5
|
original: number;
|
|
6
|
-
charge
|
|
6
|
+
charge?: number;
|
|
7
|
+
charges?: Amount.Charge[];
|
|
7
8
|
total: number;
|
|
8
9
|
exchange?: Exchange;
|
|
9
10
|
}
|
|
10
11
|
export declare namespace Amount {
|
|
12
|
+
interface Charge {
|
|
13
|
+
amount: number;
|
|
14
|
+
type: "merchant" | "exchange";
|
|
15
|
+
destination: {
|
|
16
|
+
account: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
namespace Charge {
|
|
20
|
+
const type: import("isly/dist/cjs/object").IslyObject<Charge, object>;
|
|
21
|
+
function total(currency: isoly.Currency, charges?: Charge[]): number;
|
|
22
|
+
}
|
|
11
23
|
const type: import("isly/dist/cjs/object").IslyObject<Amount, object>;
|
|
12
24
|
function fromState(state: Rule.State): Amount;
|
|
13
|
-
function change(currency: isoly.Currency, amount: Amount, change: number, type: Exclude<keyof Amount, "total" | "exchange">): Amount;
|
|
25
|
+
function change(currency: isoly.Currency, amount: Amount, change: number, type: Exclude<keyof Amount, "total" | "exchange" | "charges">): Amount;
|
|
14
26
|
}
|
|
@@ -6,9 +6,22 @@ const isly_1 = require("isly");
|
|
|
6
6
|
const Exchange_1 = require("./Exchange");
|
|
7
7
|
var Amount;
|
|
8
8
|
(function (Amount) {
|
|
9
|
+
let Charge;
|
|
10
|
+
(function (Charge) {
|
|
11
|
+
Charge.type = isly_1.isly.object({
|
|
12
|
+
amount: isly_1.isly.number(),
|
|
13
|
+
type: isly_1.isly.string(["merchant", "exchange"]),
|
|
14
|
+
destination: isly_1.isly.object({ account: isly_1.isly.string() }),
|
|
15
|
+
});
|
|
16
|
+
function total(currency, charges = []) {
|
|
17
|
+
return charges.reduce((r, c) => isoly_1.isoly.Currency.add(currency, r, c.amount), 0);
|
|
18
|
+
}
|
|
19
|
+
Charge.total = total;
|
|
20
|
+
})(Charge = Amount.Charge || (Amount.Charge = {}));
|
|
9
21
|
Amount.type = isly_1.isly.object({
|
|
10
22
|
original: isly_1.isly.number(),
|
|
11
|
-
charge: isly_1.isly.number(),
|
|
23
|
+
charge: isly_1.isly.number().optional(),
|
|
24
|
+
charges: Charge.type.array().optional(),
|
|
12
25
|
total: isly_1.isly.number(),
|
|
13
26
|
exchange: Exchange_1.Exchange.type.optional(),
|
|
14
27
|
});
|
|
@@ -18,14 +31,14 @@ var Amount;
|
|
|
18
31
|
: 1;
|
|
19
32
|
return {
|
|
20
33
|
original: sign * state.transaction.original.amount,
|
|
21
|
-
|
|
34
|
+
charges: state.transaction.original.charges,
|
|
22
35
|
total: sign * state.transaction.original.total,
|
|
23
36
|
exchange: state?.transaction.exchange ?? state.authorization?.exchange,
|
|
24
37
|
};
|
|
25
38
|
}
|
|
26
39
|
Amount.fromState = fromState;
|
|
27
40
|
function change(currency, amount, change, type) {
|
|
28
|
-
amount[type] = isoly_1.isoly.Currency.add(currency, amount[type], change);
|
|
41
|
+
amount[type] = isoly_1.isoly.Currency.add(currency, amount[type] ?? 0, change);
|
|
29
42
|
amount.total = isoly_1.isoly.Currency.add(currency, amount.total, change);
|
|
30
43
|
return amount;
|
|
31
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Amount.js","sourceRoot":"","sources":["../../../Transaction/Amount.ts"],"names":[],"mappings":";;;AAAA,iCAA6B;AAC7B,+BAA2B;AAE3B,yCAAqC;
|
|
1
|
+
{"version":3,"file":"Amount.js","sourceRoot":"","sources":["../../../Transaction/Amount.ts"],"names":[],"mappings":";;;AAAA,iCAA6B;AAC7B,+BAA2B;AAE3B,yCAAqC;AASrC,IAAiB,MAAM,CA4CtB;AA5CD,WAAiB,MAAM;IAMtB,IAAiB,MAAM,CAStB;IATD,WAAiB,MAAM;QACT,WAAI,GAAG,WAAI,CAAC,MAAM,CAAS;YACvC,MAAM,EAAE,WAAI,CAAC,MAAM,EAAE;YACrB,IAAI,EAAE,WAAI,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;YAC3C,WAAW,EAAE,WAAI,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,WAAI,CAAC,MAAM,EAAE,EAAE,CAAC;SACpD,CAAC,CAAA;QACF,SAAgB,KAAK,CAAC,QAAwB,EAAE,UAAoB,EAAE;YACrE,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,aAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAA;QAC9E,CAAC;QAFe,YAAK,QAEpB,CAAA;IACF,CAAC,EATgB,MAAM,GAAN,aAAM,KAAN,aAAM,QAStB;IACY,WAAI,GAAG,WAAI,CAAC,MAAM,CAAS;QACvC,QAAQ,EAAE,WAAI,CAAC,MAAM,EAAE;QACvB,MAAM,EAAE,WAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAChC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC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|
|
1
|
+
import { isoly } from "isoly";
|
|
2
|
+
import { Card } from "../Card";
|
|
3
|
+
import { Transaction } from "../Transaction";
|
|
4
|
+
export type Charge = {
|
|
5
|
+
id: string;
|
|
6
|
+
destination: {
|
|
7
|
+
account: string;
|
|
8
|
+
};
|
|
9
|
+
rate: number;
|
|
10
|
+
applies: {
|
|
11
|
+
to: {
|
|
12
|
+
merchants: Card.Restriction.Merchant[];
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export declare namespace Charge {
|
|
17
|
+
const type: import("isly/dist/cjs/object").IslyObject<Charge, object>;
|
|
18
|
+
function evaluate(charges: Charge[] | undefined, transaction: Transaction.Creatable.Resolved | Transaction): Transaction.Amount.Charge[];
|
|
19
|
+
function sum(charges: Transaction.Amount.Charge[], currency: isoly.Currency): number;
|
|
20
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { isoly } from "isoly";
|
|
2
|
+
import { isly } from "isly";
|
|
3
|
+
import { Card } from "../Card";
|
|
4
|
+
export var Charge;
|
|
5
|
+
(function (Charge) {
|
|
6
|
+
Charge.type = isly.object({
|
|
7
|
+
id: isly.string(),
|
|
8
|
+
destination: isly.object({ account: isly.string() }),
|
|
9
|
+
rate: isly.number(),
|
|
10
|
+
applies: isly.object({
|
|
11
|
+
to: isly.object({
|
|
12
|
+
merchants: Card.Restriction.Merchant.type.array(),
|
|
13
|
+
}),
|
|
14
|
+
}),
|
|
15
|
+
});
|
|
16
|
+
function evaluate(charges = [], transaction) {
|
|
17
|
+
const result = [];
|
|
18
|
+
for (const charge of charges)
|
|
19
|
+
if ("merchant" in transaction.counterpart)
|
|
20
|
+
for (const merchant of charge.applies.to.merchants)
|
|
21
|
+
if (Card.Restriction.Merchant.check(merchant, transaction.counterpart))
|
|
22
|
+
result.push({
|
|
23
|
+
destination: charge.destination,
|
|
24
|
+
type: "merchant",
|
|
25
|
+
amount: isoly.Currency.multiply(transaction.currency, typeof transaction.amount == "number" ? transaction.amount : transaction.amount.original, charge.rate),
|
|
26
|
+
});
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
Charge.evaluate = evaluate;
|
|
30
|
+
function sum(charges, currency) {
|
|
31
|
+
return charges.reduce((sum, charge) => isoly.Currency.add(currency, sum, charge.amount), 0);
|
|
32
|
+
}
|
|
33
|
+
Charge.sum = sum;
|
|
34
|
+
})(Charge || (Charge = {}));
|
|
35
|
+
//# sourceMappingURL=Charge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Charge.js","sourceRoot":"","sources":["../../../Account/Charge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAa9B,MAAM,KAAW,MAAM,CAkCtB;AAlCD,WAAiB,MAAM;IACT,WAAI,GAAG,IAAI,CAAC,MAAM,CAAS;QACvC,EAAE,EAAE,IAAI,CAAC,MAAM,EAAE;QACjB,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;QACpD,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE;QACnB,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC;YACpB,EAAE,EAAE,IAAI,CAAC,MAAM,CAA0B;gBACxC,SAAS,EAAE,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE;aACjD,CAAC;SACF,CAAC;KACF,CAAC,CAAA;IACF,SAAgB,QAAQ,CACvB,UAAoB,EAAE,EACtB,WAAyD;QAEzD,MAAM,MAAM,GAAgC,EAAE,CAAA;QAC9C,KAAK,MAAM,MAAM,IAAI,OAAO;YAC3B,IAAI,UAAU,IAAI,WAAW,CAAC,WAAW;gBACxC,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,SAAS;oBACjD,IAAI,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,WAAW,CAAC,WAAW,CAAC;wBACrE,MAAM,CAAC,IAAI,CAAC;4BACX,WAAW,EAAE,MAAM,CAAC,WAAW;4BAC/B,IAAI,EAAE,UAAU;4BAChB,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAC9B,WAAW,CAAC,QAAQ,EACpB,OAAO,WAAW,CAAC,MAAM,IAAI,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,QAAQ,EACxF,MAAM,CAAC,IAAI,CACX;yBACD,CAAC,CAAA;QACN,OAAO,MAAM,CAAA;IACd,CAAC;IAnBe,eAAQ,WAmBvB,CAAA;IACD,SAAgB,GAAG,CAAC,OAAoC,EAAE,QAAwB;QACjF,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAA;IAC5F,CAAC;IAFe,UAAG,MAElB,CAAA;AACF,CAAC,EAlCgB,MAAM,KAAN,MAAM,QAkCtB"}
|
|
@@ -3,6 +3,7 @@ import { isoly } from "isoly";
|
|
|
3
3
|
import { Balances } from "../Balances";
|
|
4
4
|
import { Rail } from "../Rail";
|
|
5
5
|
import { Rule } from "../Rule";
|
|
6
|
+
import { Charge as AccountCharge } from "./Charge";
|
|
6
7
|
import { Creatable as AccountCreatable } from "./Creatable";
|
|
7
8
|
import { Details as AccountDetails } from "./Details";
|
|
8
9
|
import { History as AccountHistory } from "./History";
|
|
@@ -16,10 +17,12 @@ export interface Account extends Account.Creatable {
|
|
|
16
17
|
details?: Account.Details;
|
|
17
18
|
counterparts?: Record<string, Rail.Address>;
|
|
18
19
|
key?: string;
|
|
20
|
+
charges?: AccountCharge[];
|
|
19
21
|
rules?: Rule[];
|
|
20
22
|
status: Account.Status;
|
|
21
23
|
}
|
|
22
24
|
export declare namespace Account {
|
|
25
|
+
export import Charge = AccountCharge;
|
|
23
26
|
export import Creatable = AccountCreatable;
|
|
24
27
|
export import Status = AccountStatus;
|
|
25
28
|
export import History = AccountHistory;
|
|
@@ -4,12 +4,14 @@ import { isly } from "isly";
|
|
|
4
4
|
import { Balances } from "../Balances";
|
|
5
5
|
import { Rail } from "../Rail";
|
|
6
6
|
import { Rule } from "../Rule";
|
|
7
|
+
import { Charge as AccountCharge } from "./Charge";
|
|
7
8
|
import { Creatable as AccountCreatable } from "./Creatable";
|
|
8
9
|
import { Details as AccountDetails } from "./Details";
|
|
9
10
|
import { History as AccountHistory } from "./History";
|
|
10
11
|
import { Status as AccountStatus } from "./Status";
|
|
11
12
|
export var Account;
|
|
12
13
|
(function (Account) {
|
|
14
|
+
Account.Charge = AccountCharge;
|
|
13
15
|
Account.Creatable = AccountCreatable;
|
|
14
16
|
Account.Status = AccountStatus;
|
|
15
17
|
Account.History = AccountHistory;
|
|
@@ -27,6 +29,7 @@ export var Account;
|
|
|
27
29
|
details: Account.Details.type.optional(),
|
|
28
30
|
counterparts: isly.record(isly.string(), Rail.Address.type).optional(),
|
|
29
31
|
key: isly.string().optional(),
|
|
32
|
+
charges: AccountCharge.type.array().optional(),
|
|
30
33
|
rules: Rule.type.array().optional(),
|
|
31
34
|
status: AccountStatus.type,
|
|
32
35
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../Account/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,E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AY,eAE3B,CAAA;AACF,CAAC,EA1BgB,OAAO,KAAP,OAAO,QA0BvB"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { isly } from "isly";
|
|
2
2
|
import { isly as isly2 } from "isly2";
|
|
3
|
-
import
|
|
3
|
+
import { Rail } from "../../Rail";
|
|
4
4
|
export type Merchant = typeof Merchant.values[number];
|
|
5
5
|
export declare namespace Merchant {
|
|
6
6
|
const values: ("ryanair" | "easyjet" | "wizzair" | "aer lingus" | "air malta" | "vueling" | "jet2" | "eurowings" | "turkish air" | "tap" | "pegasus" | "royal air maroc" | "qatar air" | "blue island" | "klm" | "iberia" | "emirates" | "aegean airlines" | "tui" | "united airlines" | "cathay pacific airlines" | "air serbia" | "copa air" | "bamboo airways" | "latam airlines" | "flydubai" | "condor" | "transavia" | "austrian air" | "alitalia" | "apg airlines" | "iceland air" | "flyone" | "avianca" | "brussels airlines" | "saudia" | "aeromexico" | "gulf air" | "ethiopian airlines" | "egypt air" | "albawings" | "iberojet" | "norwegian air" | "vistara" | "air greenland" | "sky express" | "air canada" | "philippine airlines" | "south african airlink" | "air benelux" | "tunisair" | "lufthansa" | "corendon airlines" | "uganda airlines" | "freebird airlines" | "kenya airway" | "kuwait air" | "british airways" | "czech airlines" | "lot polish airlines" | "volotea" | "flybe" | "bulgaria air" | "sas" | "qantas" | "air india" | "air europa" | "royal jordanian" | "virgin atlantic" | "flexflight" | "rwandair" | "hahn air" | "american air" | "pakistan international airlines" | "singapore airlines" | "delta air lines" | "croatia airlines" | "air asia" | "hawaiian airlines" | "oman air" | "etihad air" | "middle east airlines" | "logan air" | "aurigny" | "eastern airways" | "sun express" | "spirit air" | "air france" | "malaysia airlines" | "finnair" | "swiss air" | "air china" | "ana air" | "ae bsp" | "thai airways" | "jet blue" | "westjet" | "aerolineas" | "air seoul" | "azerbaijan airlines" | "air dolomiti" | "bangkok airways" | "china airlines" | "china eastern airlines" | "eva air" | "jetstar airways" | "km malta airlines" | "ita airways" | "china southern airlines" | "world2fly" | "sata denmark" | "air baltic" | "ajet" | "flynorse" | "hainan air" | "sichuan airlines" | "korean air" | "gol airlines" | "azul brazilian airlines" | "flysafair" | "air mauritius" | "alaska airlines" | "allegiant air" | "plus ultra líneas aéreas" | "parkwing" | "albergo - food and drinks" | "amtrak" | "italo treno" | "ilsa web" | "rail ninja" | "irish rail" | "österreichische bundesbahnen" | "rail europe" | "via rail canada" | "direct ferries" | "booking.com" | "advertising" | "best western" | "una hotels" | "unaway hotels" | "albergo - lodging" | "leonardo hotels" | "hotel mercure" | "nh hotels & resorts" | "novotel hotels" | "ac hotels" | "marriott hotels" | "sheraton hotels and resorts" | "ih hotels" | "ibis hotels" | "hyatt hotels & resorts" | "hilton hotels & resorts" | "holiday inn" | "four seasons" | "doubletree by hilton" | "crowne plaza hotels")[];
|
|
7
7
|
const type: isly.Type<"ryanair" | "easyjet" | "wizzair" | "aer lingus" | "air malta" | "vueling" | "jet2" | "eurowings" | "turkish air" | "tap" | "pegasus" | "royal air maroc" | "qatar air" | "blue island" | "klm" | "iberia" | "emirates" | "aegean airlines" | "tui" | "united airlines" | "cathay pacific airlines" | "air serbia" | "copa air" | "bamboo airways" | "latam airlines" | "flydubai" | "condor" | "transavia" | "austrian air" | "alitalia" | "apg airlines" | "iceland air" | "flyone" | "avianca" | "brussels airlines" | "saudia" | "aeromexico" | "gulf air" | "ethiopian airlines" | "egypt air" | "albawings" | "iberojet" | "norwegian air" | "vistara" | "air greenland" | "sky express" | "air canada" | "philippine airlines" | "south african airlink" | "air benelux" | "tunisair" | "lufthansa" | "corendon airlines" | "uganda airlines" | "freebird airlines" | "kenya airway" | "kuwait air" | "british airways" | "czech airlines" | "lot polish airlines" | "volotea" | "flybe" | "bulgaria air" | "sas" | "qantas" | "air india" | "air europa" | "royal jordanian" | "virgin atlantic" | "flexflight" | "rwandair" | "hahn air" | "american air" | "pakistan international airlines" | "singapore airlines" | "delta air lines" | "croatia airlines" | "air asia" | "hawaiian airlines" | "oman air" | "etihad air" | "middle east airlines" | "logan air" | "aurigny" | "eastern airways" | "sun express" | "spirit air" | "air france" | "malaysia airlines" | "finnair" | "swiss air" | "air china" | "ana air" | "ae bsp" | "thai airways" | "jet blue" | "westjet" | "aerolineas" | "air seoul" | "azerbaijan airlines" | "air dolomiti" | "bangkok airways" | "china airlines" | "china eastern airlines" | "eva air" | "jetstar airways" | "km malta airlines" | "ita airways" | "china southern airlines" | "world2fly" | "sata denmark" | "air baltic" | "ajet" | "flynorse" | "hainan air" | "sichuan airlines" | "korean air" | "gol airlines" | "azul brazilian airlines" | "flysafair" | "air mauritius" | "alaska airlines" | "allegiant air" | "plus ultra líneas aéreas" | "parkwing" | "albergo - food and drinks" | "amtrak" | "italo treno" | "ilsa web" | "rail ninja" | "irish rail" | "österreichische bundesbahnen" | "rail europe" | "via rail canada" | "direct ferries" | "booking.com" | "advertising" | "best western" | "una hotels" | "unaway hotels" | "albergo - lodging" | "leonardo hotels" | "hotel mercure" | "nh hotels & resorts" | "novotel hotels" | "ac hotels" | "marriott hotels" | "sheraton hotels and resorts" | "ih hotels" | "ibis hotels" | "hyatt hotels & resorts" | "hilton hotels & resorts" | "holiday inn" | "four seasons" | "doubletree by hilton" | "crowne plaza hotels">;
|
|
8
8
|
const type2: isly2.String<"ryanair" | "easyjet" | "wizzair" | "aer lingus" | "air malta" | "vueling" | "jet2" | "eurowings" | "turkish air" | "tap" | "pegasus" | "royal air maroc" | "qatar air" | "blue island" | "klm" | "iberia" | "emirates" | "aegean airlines" | "tui" | "united airlines" | "cathay pacific airlines" | "air serbia" | "copa air" | "bamboo airways" | "latam airlines" | "flydubai" | "condor" | "transavia" | "austrian air" | "alitalia" | "apg airlines" | "iceland air" | "flyone" | "avianca" | "brussels airlines" | "saudia" | "aeromexico" | "gulf air" | "ethiopian airlines" | "egypt air" | "albawings" | "iberojet" | "norwegian air" | "vistara" | "air greenland" | "sky express" | "air canada" | "philippine airlines" | "south african airlink" | "air benelux" | "tunisair" | "lufthansa" | "corendon airlines" | "uganda airlines" | "freebird airlines" | "kenya airway" | "kuwait air" | "british airways" | "czech airlines" | "lot polish airlines" | "volotea" | "flybe" | "bulgaria air" | "sas" | "qantas" | "air india" | "air europa" | "royal jordanian" | "virgin atlantic" | "flexflight" | "rwandair" | "hahn air" | "american air" | "pakistan international airlines" | "singapore airlines" | "delta air lines" | "croatia airlines" | "air asia" | "hawaiian airlines" | "oman air" | "etihad air" | "middle east airlines" | "logan air" | "aurigny" | "eastern airways" | "sun express" | "spirit air" | "air france" | "malaysia airlines" | "finnair" | "swiss air" | "air china" | "ana air" | "ae bsp" | "thai airways" | "jet blue" | "westjet" | "aerolineas" | "air seoul" | "azerbaijan airlines" | "air dolomiti" | "bangkok airways" | "china airlines" | "china eastern airlines" | "eva air" | "jetstar airways" | "km malta airlines" | "ita airways" | "china southern airlines" | "world2fly" | "sata denmark" | "air baltic" | "ajet" | "flynorse" | "hainan air" | "sichuan airlines" | "korean air" | "gol airlines" | "azul brazilian airlines" | "flysafair" | "air mauritius" | "alaska airlines" | "allegiant air" | "plus ultra líneas aéreas" | "parkwing" | "albergo - food and drinks" | "amtrak" | "italo treno" | "ilsa web" | "rail ninja" | "irish rail" | "österreichische bundesbahnen" | "rail europe" | "via rail canada" | "direct ferries" | "booking.com" | "advertising" | "best western" | "una hotels" | "unaway hotels" | "albergo - lodging" | "leonardo hotels" | "hotel mercure" | "nh hotels & resorts" | "novotel hotels" | "ac hotels" | "marriott hotels" | "sheraton hotels and resorts" | "ih hotels" | "ibis hotels" | "hyatt hotels & resorts" | "hilton hotels & resorts" | "holiday inn" | "four seasons" | "doubletree by hilton" | "crowne plaza hotels">;
|
|
9
|
-
function check(merchant: Merchant,
|
|
9
|
+
function check(merchant: Merchant, counterpart: Rail.Address.Card.Counterpart): boolean;
|
|
10
10
|
}
|
|
@@ -7,19 +7,19 @@ export var Merchant;
|
|
|
7
7
|
Merchant.values = typedly.Object.keys(merchants);
|
|
8
8
|
Merchant.type = isly.string(Merchant.values);
|
|
9
9
|
Merchant.type2 = isly2.string("value", ...Merchant.values);
|
|
10
|
-
function check(merchant,
|
|
10
|
+
function check(merchant, counterpart) {
|
|
11
11
|
const attribute = merchants[merchant];
|
|
12
12
|
let result;
|
|
13
|
-
if (attribute?.unambiguousMcc ==
|
|
13
|
+
if (attribute?.unambiguousMcc == counterpart.merchant.category)
|
|
14
14
|
result = true;
|
|
15
15
|
else if (attribute.contains && attribute.mccs)
|
|
16
16
|
result =
|
|
17
|
-
attribute.mccs.some(mcc => mcc ==
|
|
18
|
-
attribute.contains.some(n =>
|
|
17
|
+
attribute.mccs.some(mcc => mcc == counterpart.merchant.category) &&
|
|
18
|
+
attribute.contains.some(n => counterpart.merchant.name.includes(n));
|
|
19
19
|
else if (attribute.startsWith && attribute.mccs)
|
|
20
20
|
result =
|
|
21
|
-
attribute.mccs.some(mcc => mcc ==
|
|
22
|
-
attribute.startsWith.some(n =>
|
|
21
|
+
attribute.mccs.some(mcc => mcc == counterpart.merchant.category) &&
|
|
22
|
+
attribute.startsWith.some(n => counterpart.merchant.name.startsWith(n));
|
|
23
23
|
else
|
|
24
24
|
result = false;
|
|
25
25
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Merchant.js","sourceRoot":"","sources":["../../../../Card/Restriction/Merchant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,IAAI,IAAI,KAAK,EAAE,MAAM,OAAO,CAAA;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEjC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAIvC,MAAM,KAAW,QAAQ,
|
|
1
|
+
{"version":3,"file":"Merchant.js","sourceRoot":"","sources":["../../../../Card/Restriction/Merchant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,IAAI,IAAI,KAAK,EA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CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;;YAExE,MAAM,GAAG,KAAK,CAAA;QACf,OAAO,MAAM,CAAA;IACd,CAAC;IAhBe,cAAK,QAgBpB,CAAA;AACF,CAAC,EArBgB,QAAQ,KAAR,QAAQ,QAqBxB"}
|
|
@@ -15,7 +15,7 @@ export var Restriction;
|
|
|
15
15
|
function check(restrictions, transaction) {
|
|
16
16
|
let result = true;
|
|
17
17
|
if (restrictions.merchants?.length)
|
|
18
|
-
result = restrictions.merchants.some(merchant => Restriction.Merchant.check(merchant, transaction));
|
|
18
|
+
result = restrictions.merchants.some(merchant => Restriction.Merchant.check(merchant, transaction.counterpart));
|
|
19
19
|
return result;
|
|
20
20
|
}
|
|
21
21
|
Restriction.check = check;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../Card/Restriction/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,IAAI,IAAI,KAAK,EAAE,MAAM,OAAO,CAAA;AAErC,OAAO,EAAE,QAAQ,IAAI,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAK7D,MAAM,KAAW,WAAW,CAmB3B;AAnBD,WAAiB,WAAW;IACb,oBAAQ,GAAG,oBAAoB,CAAA;IAChC,gBAAI,GAAG,IAAI,CAAC,MAAM,CAAc,EAAE,SAAS,EAAE,YAAA,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;IAChF,iBAAK,GAAG,KAAK,CAAC,MAAM,CAAc;QAC9C,SAAS,EAAE,YAAA,QAAQ,CAAC,KAAK;aACvB,KAAK,EAAE;aACP,QAAQ,EAAE;aACV,MAAM,CAAC,WAAW,CAAC;aACnB,QAAQ,CAAC,mDAAmD,CAAC;KAC/D,CAAC,CAAA;IACF,SAAgB,KAAK,CACpB,YAAyB,EACzB,WAA6F;QA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AC;IARe,iBAAK,QAQpB,CAAA;AACF,CAAC,EAnBgB,WAAW,KAAX,WAAW,QAmB3B"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isoly } from "isoly";
|
|
2
|
+
import { Account as ModelAccount } from "../../Account";
|
|
2
3
|
import { Transaction as ModelTransaction } from "../../Transaction";
|
|
3
4
|
import type { Rule } from "../index";
|
|
4
5
|
export type Transaction = ModelTransaction.Creatable.Resolved & {
|
|
@@ -10,6 +11,7 @@ export type Transaction = ModelTransaction.Creatable.Resolved & {
|
|
|
10
11
|
risk?: number;
|
|
11
12
|
original: {
|
|
12
13
|
currency: isoly.Currency;
|
|
14
|
+
charges?: ModelTransaction.Amount.Charge[];
|
|
13
15
|
total: number;
|
|
14
16
|
amount: number;
|
|
15
17
|
charge?: {
|
|
@@ -19,6 +21,6 @@ export type Transaction = ModelTransaction.Creatable.Resolved & {
|
|
|
19
21
|
};
|
|
20
22
|
};
|
|
21
23
|
export declare namespace Transaction {
|
|
22
|
-
function from(
|
|
24
|
+
function from(account: ModelAccount, transaction: ModelTransaction.Creatable.Resolved | ModelTransaction, kind: Rule.Base.Kind, stage: "finalize" | "initiate"): Transaction;
|
|
23
25
|
function fromPreTransaction(accountName: string, transaction: ModelTransaction.PreTransaction | ModelTransaction, kind: Rule.Base.Kind, stage: "finalize" | "initiate"): Transaction;
|
|
24
26
|
}
|
|
@@ -1,26 +1,23 @@
|
|
|
1
1
|
import { isoly } from "isoly";
|
|
2
|
+
import { Account as ModelAccount } from "../../Account";
|
|
2
3
|
import { Transaction as ModelTransaction } from "../../Transaction";
|
|
3
4
|
export var Transaction;
|
|
4
5
|
(function (Transaction) {
|
|
5
|
-
function from(
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
transaction.state?.transaction.original.amount ?? transaction.amount,
|
|
9
|
-
isoly.Currency.subtract(transaction.currency, transaction.state?.transaction.original.total ??
|
|
10
|
-
(typeof transaction.amount == "number" ? transaction.amount : transaction.amount.total), stage === "finalize" ? transaction.state?.transaction.original.charge?.total ?? 0 : 0),
|
|
11
|
-
]
|
|
12
|
-
: [transaction.amount, transaction.amount];
|
|
6
|
+
function from(account, transaction, kind, stage) {
|
|
7
|
+
const charges = ModelAccount.Charge.evaluate(account.charges, transaction);
|
|
8
|
+
const amount = Math.abs(typeof transaction.amount == "number" ? transaction.amount : transaction.amount.original);
|
|
13
9
|
return {
|
|
14
10
|
...transaction,
|
|
15
11
|
id: "id" in transaction ? transaction.id : ModelTransaction.Identifier.generate(),
|
|
16
12
|
stage,
|
|
17
13
|
kind,
|
|
18
|
-
amount
|
|
19
|
-
type: ModelTransaction.getType(transaction.counterpart,
|
|
14
|
+
amount,
|
|
15
|
+
type: ModelTransaction.getType(transaction.counterpart, account.name),
|
|
20
16
|
original: {
|
|
21
17
|
currency: transaction.currency,
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
charges,
|
|
19
|
+
amount,
|
|
20
|
+
total: isoly.Currency.add(transaction.currency, amount, ModelAccount.Charge.sum(charges, transaction.currency)),
|
|
24
21
|
},
|
|
25
22
|
};
|
|
26
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transaction.js","sourceRoot":"","sources":["../../../../Rule/State/Transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAC7B,OAAO,EAAE,WAAW,IAAI,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"Transaction.js","sourceRoot":"","sources":["../../../../Rule/State/Transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAC7B,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,eAAe,CAAA;AACvD,OAAO,EAAE,WAAW,IAAI,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAkBnE,MAAM,KAAW,WAAW,CA4C3B;AA5CD,WAAiB,WAAW;IAC3B,SAAgB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,GAAG,CAAC,OAAO,WAAW,CAAC,MAAM,IAAI,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC;YACvG,IAAI,EAAE,gBAAgB,CAAC,OAAO,CAAC,WAAW,CAAC,WAAW,EAAE,WAAW,CAAC;YACpE,QAAQ,EAAE;gBACT,QAAQ,EAAE,WAAW,CAAC,QAAQ;gBAC9B,MAAM,EAAE,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;gBAC1G,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,WAAW,CAAC,MAAM,IAAI,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC;aACtG;SACD,CAAA;IACF,CAAC;IAnBe,8BAAkB,qBAmBjC,CAAA;AACF,CAAC,EA5CgB,WAAW,KAAX,WAAW,QA4C3B"}
|
|
@@ -22,7 +22,7 @@ export var State;
|
|
|
22
22
|
return {
|
|
23
23
|
data,
|
|
24
24
|
account: State.Account.from(account, address, transactions, days),
|
|
25
|
-
transaction: State.Transaction.from(account
|
|
25
|
+
transaction: State.Transaction.from(account, transaction, kind, stage),
|
|
26
26
|
authorization: State.Authorization.from(transaction),
|
|
27
27
|
card,
|
|
28
28
|
organization,
|
|
@@ -38,7 +38,7 @@ export var State;
|
|
|
38
38
|
return {
|
|
39
39
|
data,
|
|
40
40
|
account: State.Account.from(account, address, transactions, days),
|
|
41
|
-
transaction: State.Transaction.from(account
|
|
41
|
+
transaction: State.Transaction.from(account, transaction, State.type[transaction.type], "initiate"),
|
|
42
42
|
card: card ? State.Card.from(card, card.statistics) : undefined,
|
|
43
43
|
organization,
|
|
44
44
|
};
|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E3B,OAAO;YACN,IAAI;YACJ,OAAO,EAAE,MAAA,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,CAAC;YAC3D,WAAW,EAAE,MAAA,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,CAAC;YAChE,aAAa,EAAE,MAAA,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC;YAC9C,IAAI;YACJ,YAAY;SACZ,CAAA;IACF,CAAC;IApBe,UAAI,OAoBnB,CAAA;IACY,UAAI,GAAoE;QACpF,aAAa,EAAE,eAAe;QAC9B,QAAQ,EAAE,SAAS;QACnB,QAAQ,EAAE,UAAU;KACpB,CAAA;IACD,SAAgB,kBAAkB,CACjC,IAAU,EACV,OAAqB,EACrB,OAAqB,EACrB,YAAkC,EAClC,IAAkB,EAClB,WAA4C,EAC5C,IAAkD,EAClD,YAA2B;QAE3B,OAAO;YACN,IAAI;YACJ,OAAO,EAAE,MAAA,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,CAAC;YAC3D,WAAW,EAAE,MAAA,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE,MAAA,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC;YACvF,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,MAAA,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS;YACzD,YAAY;SACZ,CAAA;IACF,CAAC;IAjBe,wBAAkB,qBAiBjC,CAAA;AACF,CAAC,EA/DgB,KAAK,KAAL,KAAK,QA+DrB"}
|
|
@@ -3,12 +3,24 @@ import type { Rule } from "../Rule";
|
|
|
3
3
|
import { Exchange } from "./Exchange";
|
|
4
4
|
export interface Amount {
|
|
5
5
|
original: number;
|
|
6
|
-
charge
|
|
6
|
+
charge?: number;
|
|
7
|
+
charges?: Amount.Charge[];
|
|
7
8
|
total: number;
|
|
8
9
|
exchange?: Exchange;
|
|
9
10
|
}
|
|
10
11
|
export declare namespace Amount {
|
|
12
|
+
interface Charge {
|
|
13
|
+
amount: number;
|
|
14
|
+
type: "merchant" | "exchange";
|
|
15
|
+
destination: {
|
|
16
|
+
account: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
namespace Charge {
|
|
20
|
+
const type: import("isly/dist/cjs/object").IslyObject<Charge, object>;
|
|
21
|
+
function total(currency: isoly.Currency, charges?: Charge[]): number;
|
|
22
|
+
}
|
|
11
23
|
const type: import("isly/dist/cjs/object").IslyObject<Amount, object>;
|
|
12
24
|
function fromState(state: Rule.State): Amount;
|
|
13
|
-
function change(currency: isoly.Currency, amount: Amount, change: number, type: Exclude<keyof Amount, "total" | "exchange">): Amount;
|
|
25
|
+
function change(currency: isoly.Currency, amount: Amount, change: number, type: Exclude<keyof Amount, "total" | "exchange" | "charges">): Amount;
|
|
14
26
|
}
|
|
@@ -3,9 +3,22 @@ import { isly } from "isly";
|
|
|
3
3
|
import { Exchange } from "./Exchange";
|
|
4
4
|
export var Amount;
|
|
5
5
|
(function (Amount) {
|
|
6
|
+
let Charge;
|
|
7
|
+
(function (Charge) {
|
|
8
|
+
Charge.type = isly.object({
|
|
9
|
+
amount: isly.number(),
|
|
10
|
+
type: isly.string(["merchant", "exchange"]),
|
|
11
|
+
destination: isly.object({ account: isly.string() }),
|
|
12
|
+
});
|
|
13
|
+
function total(currency, charges = []) {
|
|
14
|
+
return charges.reduce((r, c) => isoly.Currency.add(currency, r, c.amount), 0);
|
|
15
|
+
}
|
|
16
|
+
Charge.total = total;
|
|
17
|
+
})(Charge = Amount.Charge || (Amount.Charge = {}));
|
|
6
18
|
Amount.type = isly.object({
|
|
7
19
|
original: isly.number(),
|
|
8
|
-
charge: isly.number(),
|
|
20
|
+
charge: isly.number().optional(),
|
|
21
|
+
charges: Charge.type.array().optional(),
|
|
9
22
|
total: isly.number(),
|
|
10
23
|
exchange: Exchange.type.optional(),
|
|
11
24
|
});
|
|
@@ -15,14 +28,14 @@ export var Amount;
|
|
|
15
28
|
: 1;
|
|
16
29
|
return {
|
|
17
30
|
original: sign * state.transaction.original.amount,
|
|
18
|
-
|
|
31
|
+
charges: state.transaction.original.charges,
|
|
19
32
|
total: sign * state.transaction.original.total,
|
|
20
33
|
exchange: state?.transaction.exchange ?? state.authorization?.exchange,
|
|
21
34
|
};
|
|
22
35
|
}
|
|
23
36
|
Amount.fromState = fromState;
|
|
24
37
|
function change(currency, amount, change, type) {
|
|
25
|
-
amount[type] = isoly.Currency.add(currency, amount[type], change);
|
|
38
|
+
amount[type] = isoly.Currency.add(currency, amount[type] ?? 0, change);
|
|
26
39
|
amount.total = isoly.Currency.add(currency, amount.total, change);
|
|
27
40
|
return amount;
|
|
28
41
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Amount.js","sourceRoot":"","sources":["../../../Transaction/Amount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAE3B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"Amount.js","sourceRoot":"","sources":["../../../Transaction/Amount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAE3B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AASrC,MAAM,KAAW,MAAM,CA4CtB;AA5CD,WAAiB,MAAM;IAMtB,IAAiB,MAAM,CAStB;IATD,WAAiB,MAAM;QACT,WAAI,GAAG,IAAI,CAAC,MAAM,CAAS;YACvC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE;YACrB,IAAI,EAAE,IAAI,CAAC,MA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