@pax2pay/model-banking 0.1.538 → 0.1.540
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 +39 -29
- package/dist/cjs/Account/Charge.d.ts +18 -12
- package/dist/cjs/Account/Charge.js +27 -17
- package/dist/cjs/Account/Charge.js.map +1 -1
- package/dist/mjs/Account/Charge.d.ts +18 -12
- package/dist/mjs/Account/Charge.js +27 -17
- package/dist/mjs/Account/Charge.js.map +1 -1
- package/package.json +1 -1
package/Account/Charge.ts
CHANGED
|
@@ -1,47 +1,57 @@
|
|
|
1
|
+
import { cryptly } from "cryptly"
|
|
1
2
|
import { isoly } from "isoly"
|
|
2
3
|
import { isly } from "isly"
|
|
3
4
|
import { Card } from "../Card"
|
|
4
5
|
import { Transaction } from "../Transaction"
|
|
5
6
|
|
|
6
|
-
export
|
|
7
|
+
export interface Charge extends Charge.Creatable {
|
|
7
8
|
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
9
|
}
|
|
16
10
|
export namespace Charge {
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
11
|
+
export interface Creatable {
|
|
12
|
+
destination: { account: string }
|
|
13
|
+
rate: number // rate: 0.01 for 1%
|
|
14
|
+
applies: {
|
|
15
|
+
to: {
|
|
16
|
+
merchants: Card.Restriction.Merchant[]
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export namespace Creatable {
|
|
21
|
+
export const type = isly.object<Creatable>({
|
|
22
|
+
destination: isly.object({ account: isly.string() }),
|
|
23
|
+
rate: isly.number(),
|
|
24
|
+
applies: isly.object({
|
|
25
|
+
to: isly.object<Creatable["applies"]["to"]>({
|
|
26
|
+
merchants: Card.Restriction.Merchant.type.array(),
|
|
27
|
+
}),
|
|
24
28
|
}),
|
|
25
|
-
})
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
export const type = Creatable.type.extend<Charge>({
|
|
32
|
+
id: isly.string(),
|
|
26
33
|
})
|
|
34
|
+
export function fromCreatable(creatable: Creatable): Charge {
|
|
35
|
+
return { ...creatable, id: cryptly.Identifier.generate(16) }
|
|
36
|
+
}
|
|
27
37
|
export function evaluate(
|
|
28
38
|
charges: Charge[] = [],
|
|
29
39
|
transaction: Transaction.Creatable.Resolved | Transaction
|
|
30
40
|
): Transaction.Amount.Charge[] {
|
|
31
41
|
const result: Transaction.Amount.Charge[] = []
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
const counterpart = "merchant" in transaction.counterpart ? transaction.counterpart : undefined
|
|
43
|
+
if (counterpart)
|
|
44
|
+
for (const charge of charges)
|
|
45
|
+
if (charge.applies.to.merchants.some(merchant => Card.Restriction.Merchant.check(merchant, counterpart)))
|
|
46
|
+
result.push({
|
|
47
|
+
destination: charge.destination,
|
|
48
|
+
type: "merchant",
|
|
49
|
+
amount: isoly.Currency.multiply(
|
|
50
|
+
transaction.currency,
|
|
51
|
+
typeof transaction.amount == "number" ? transaction.amount : -transaction.amount.original,
|
|
52
|
+
charge.rate
|
|
53
|
+
),
|
|
54
|
+
})
|
|
45
55
|
return result
|
|
46
56
|
}
|
|
47
57
|
export function sum(charges: Transaction.Amount.Charge[], currency: isoly.Currency): number {
|
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
import { isoly } from "isoly";
|
|
2
2
|
import { Card } from "../Card";
|
|
3
3
|
import { Transaction } from "../Transaction";
|
|
4
|
-
export
|
|
4
|
+
export interface Charge extends Charge.Creatable {
|
|
5
5
|
id: string;
|
|
6
|
-
|
|
7
|
-
account: string;
|
|
8
|
-
};
|
|
9
|
-
rate: number;
|
|
10
|
-
applies: {
|
|
11
|
-
to: {
|
|
12
|
-
merchants: Card.Restriction.Merchant[];
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
};
|
|
6
|
+
}
|
|
16
7
|
export declare namespace Charge {
|
|
17
|
-
|
|
8
|
+
interface Creatable {
|
|
9
|
+
destination: {
|
|
10
|
+
account: string;
|
|
11
|
+
};
|
|
12
|
+
rate: number;
|
|
13
|
+
applies: {
|
|
14
|
+
to: {
|
|
15
|
+
merchants: Card.Restriction.Merchant[];
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
namespace Creatable {
|
|
20
|
+
const type: import("isly/dist/cjs/object").IslyObject<Creatable, object>;
|
|
21
|
+
}
|
|
22
|
+
const type: import("isly/dist/cjs/object").IslyObject<Charge, Creatable>;
|
|
23
|
+
function fromCreatable(creatable: Creatable): Charge;
|
|
18
24
|
function evaluate(charges: Charge[] | undefined, transaction: Transaction.Creatable.Resolved | Transaction): Transaction.Amount.Charge[];
|
|
19
25
|
function sum(charges: Transaction.Amount.Charge[], currency: isoly.Currency): number;
|
|
20
26
|
}
|
|
@@ -1,32 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Charge = void 0;
|
|
4
|
+
const cryptly_1 = require("cryptly");
|
|
4
5
|
const isoly_1 = require("isoly");
|
|
5
6
|
const isly_1 = require("isly");
|
|
6
7
|
const Card_1 = require("../Card");
|
|
7
8
|
var Charge;
|
|
8
9
|
(function (Charge) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
let Creatable;
|
|
11
|
+
(function (Creatable) {
|
|
12
|
+
Creatable.type = isly_1.isly.object({
|
|
13
|
+
destination: isly_1.isly.object({ account: isly_1.isly.string() }),
|
|
14
|
+
rate: isly_1.isly.number(),
|
|
15
|
+
applies: isly_1.isly.object({
|
|
16
|
+
to: isly_1.isly.object({
|
|
17
|
+
merchants: Card_1.Card.Restriction.Merchant.type.array(),
|
|
18
|
+
}),
|
|
16
19
|
}),
|
|
17
|
-
})
|
|
20
|
+
});
|
|
21
|
+
})(Creatable = Charge.Creatable || (Charge.Creatable = {}));
|
|
22
|
+
Charge.type = Creatable.type.extend({
|
|
23
|
+
id: isly_1.isly.string(),
|
|
18
24
|
});
|
|
25
|
+
function fromCreatable(creatable) {
|
|
26
|
+
return { ...creatable, id: cryptly_1.cryptly.Identifier.generate(16) };
|
|
27
|
+
}
|
|
28
|
+
Charge.fromCreatable = fromCreatable;
|
|
19
29
|
function evaluate(charges = [], transaction) {
|
|
20
30
|
const result = [];
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
31
|
+
const counterpart = "merchant" in transaction.counterpart ? transaction.counterpart : undefined;
|
|
32
|
+
if (counterpart)
|
|
33
|
+
for (const charge of charges)
|
|
34
|
+
if (charge.applies.to.merchants.some(merchant => Card_1.Card.Restriction.Merchant.check(merchant, counterpart)))
|
|
35
|
+
result.push({
|
|
36
|
+
destination: charge.destination,
|
|
37
|
+
type: "merchant",
|
|
38
|
+
amount: isoly_1.isoly.Currency.multiply(transaction.currency, typeof transaction.amount == "number" ? transaction.amount : -transaction.amount.original, charge.rate),
|
|
39
|
+
});
|
|
30
40
|
return result;
|
|
31
41
|
}
|
|
32
42
|
Charge.evaluate = evaluate;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Charge.js","sourceRoot":"","sources":["../../../Account/Charge.ts"],"names":[],"mappings":";;;AAAA,iCAA6B;AAC7B,+BAA2B;AAC3B,kCAA8B;
|
|
1
|
+
{"version":3,"file":"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AAI,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,WAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;oBACvG,MAAM,CAAC,IAAI,CAAC;wBACX,WAAW,EAAE,MAAM,CAAC,WAAW;wBAC/B,IAAI,EAAE,UAAU;wBAChB,MAAM,EAAE,aAAK,CAAC,QAAQ,CAAC,QAAQ,CAC9B,WAAW,CAAC,QAAQ,EACpB,OAAO,WAAW,CAAC,MAAM,IAAI,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,QAAQ,EACzF,MAAM,CAAC,IAAI,CACX;qBACD,CAAC,CAAA;QACL,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,aAAK,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,EAlDgB,MAAM,sBAAN,MAAM,QAkDtB"}
|
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
import { isoly } from "isoly";
|
|
2
2
|
import { Card } from "../Card";
|
|
3
3
|
import { Transaction } from "../Transaction";
|
|
4
|
-
export
|
|
4
|
+
export interface Charge extends Charge.Creatable {
|
|
5
5
|
id: string;
|
|
6
|
-
|
|
7
|
-
account: string;
|
|
8
|
-
};
|
|
9
|
-
rate: number;
|
|
10
|
-
applies: {
|
|
11
|
-
to: {
|
|
12
|
-
merchants: Card.Restriction.Merchant[];
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
};
|
|
6
|
+
}
|
|
16
7
|
export declare namespace Charge {
|
|
17
|
-
|
|
8
|
+
interface Creatable {
|
|
9
|
+
destination: {
|
|
10
|
+
account: string;
|
|
11
|
+
};
|
|
12
|
+
rate: number;
|
|
13
|
+
applies: {
|
|
14
|
+
to: {
|
|
15
|
+
merchants: Card.Restriction.Merchant[];
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
namespace Creatable {
|
|
20
|
+
const type: import("isly/dist/cjs/object").IslyObject<Creatable, object>;
|
|
21
|
+
}
|
|
22
|
+
const type: import("isly/dist/cjs/object").IslyObject<Charge, Creatable>;
|
|
23
|
+
function fromCreatable(creatable: Creatable): Charge;
|
|
18
24
|
function evaluate(charges: Charge[] | undefined, transaction: Transaction.Creatable.Resolved | Transaction): Transaction.Amount.Charge[];
|
|
19
25
|
function sum(charges: Transaction.Amount.Charge[], currency: isoly.Currency): number;
|
|
20
26
|
}
|
|
@@ -1,29 +1,39 @@
|
|
|
1
|
+
import { cryptly } from "cryptly";
|
|
1
2
|
import { isoly } from "isoly";
|
|
2
3
|
import { isly } from "isly";
|
|
3
4
|
import { Card } from "../Card";
|
|
4
5
|
export var Charge;
|
|
5
6
|
(function (Charge) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
let Creatable;
|
|
8
|
+
(function (Creatable) {
|
|
9
|
+
Creatable.type = isly.object({
|
|
10
|
+
destination: isly.object({ account: isly.string() }),
|
|
11
|
+
rate: isly.number(),
|
|
12
|
+
applies: isly.object({
|
|
13
|
+
to: isly.object({
|
|
14
|
+
merchants: Card.Restriction.Merchant.type.array(),
|
|
15
|
+
}),
|
|
13
16
|
}),
|
|
14
|
-
})
|
|
17
|
+
});
|
|
18
|
+
})(Creatable = Charge.Creatable || (Charge.Creatable = {}));
|
|
19
|
+
Charge.type = Creatable.type.extend({
|
|
20
|
+
id: isly.string(),
|
|
15
21
|
});
|
|
22
|
+
function fromCreatable(creatable) {
|
|
23
|
+
return { ...creatable, id: cryptly.Identifier.generate(16) };
|
|
24
|
+
}
|
|
25
|
+
Charge.fromCreatable = fromCreatable;
|
|
16
26
|
function evaluate(charges = [], transaction) {
|
|
17
27
|
const result = [];
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
const counterpart = "merchant" in transaction.counterpart ? transaction.counterpart : undefined;
|
|
29
|
+
if (counterpart)
|
|
30
|
+
for (const charge of charges)
|
|
31
|
+
if (charge.applies.to.merchants.some(merchant => Card.Restriction.Merchant.check(merchant, counterpart)))
|
|
32
|
+
result.push({
|
|
33
|
+
destination: charge.destination,
|
|
34
|
+
type: "merchant",
|
|
35
|
+
amount: isoly.Currency.multiply(transaction.currency, typeof transaction.amount == "number" ? transaction.amount : -transaction.amount.original, charge.rate),
|
|
36
|
+
});
|
|
27
37
|
return result;
|
|
28
38
|
}
|
|
29
39
|
Charge.evaluate = evaluate;
|
|
@@ -1 +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;
|
|
1
|
+
{"version":3,"file":"Charge.js","sourceRoot":"","sources":["../../../Account/Charge.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,EAAE,IAAI,EAAE,MAAM,SAAS,CA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