@pax2pay/model-banking 0.1.448 → 0.1.449
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isoly } from "isoly"
|
|
2
2
|
import { isly } from "isly"
|
|
3
|
-
import {
|
|
3
|
+
import { Card } from "../Card"
|
|
4
4
|
import { Transaction } from "."
|
|
5
5
|
|
|
6
6
|
export interface Statistics {
|
|
@@ -41,34 +41,48 @@ export namespace Statistics {
|
|
|
41
41
|
cards: isly.string().array(),
|
|
42
42
|
cursor: isly.string().optional(),
|
|
43
43
|
})
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
) {
|
|
58
|
-
const region = domestic.includes(transaction.counterpart.merchant.country)
|
|
59
|
-
? "domestic"
|
|
60
|
-
: intraRegion.includes(transaction.counterpart.merchant.country)
|
|
61
|
-
? "intraRegion"
|
|
62
|
-
: "extraRegion"
|
|
63
|
-
statistics[state.transaction.kind][region].count++
|
|
64
|
-
statistics[state.transaction.kind][region].amount = isoly.Currency.add(
|
|
65
|
-
currency,
|
|
66
|
-
statistics[state.transaction.kind][region].amount,
|
|
67
|
-
state.transaction.amount
|
|
68
|
-
)
|
|
69
|
-
statistics.cards.includes(transaction.account.id) || statistics.cards.push(transaction.account.id)
|
|
44
|
+
function empty(): Statistics {
|
|
45
|
+
return {
|
|
46
|
+
capture: {
|
|
47
|
+
domestic: { count: 0, amount: 0 },
|
|
48
|
+
intraRegion: { count: 0, amount: 0 },
|
|
49
|
+
extraRegion: { count: 0, amount: 0 },
|
|
50
|
+
},
|
|
51
|
+
refund: {
|
|
52
|
+
domestic: { count: 0, amount: 0 },
|
|
53
|
+
intraRegion: { count: 0, amount: 0 },
|
|
54
|
+
extraRegion: { count: 0, amount: 0 },
|
|
55
|
+
},
|
|
56
|
+
cards: [],
|
|
70
57
|
}
|
|
71
|
-
|
|
58
|
+
}
|
|
59
|
+
export function compile(
|
|
60
|
+
transactions: Transaction[],
|
|
61
|
+
scheme: Card.Scheme,
|
|
62
|
+
regions: Record<"domestic" | "intraRegion", isoly.CountryCode.Alpha2[]>
|
|
63
|
+
): Statistics {
|
|
64
|
+
const result: Statistics = empty()
|
|
65
|
+
for (const transaction of transactions)
|
|
66
|
+
if (
|
|
67
|
+
Transaction.CardTransaction.type.is(transaction) &&
|
|
68
|
+
transaction.status == "finalized" &&
|
|
69
|
+
transaction.account.scheme == scheme
|
|
70
|
+
) {
|
|
71
|
+
const region = regions.domestic.includes(transaction.counterpart.merchant.country)
|
|
72
|
+
? "domestic"
|
|
73
|
+
: regions.intraRegion.includes(transaction.counterpart.merchant.country)
|
|
74
|
+
? "intraRegion"
|
|
75
|
+
: "extraRegion"
|
|
76
|
+
const kind = transaction.direction == "outbound" ? "capture" : "refund"
|
|
77
|
+
result[kind][region].count++
|
|
78
|
+
result[kind][region].amount = isoly.Currency.add(
|
|
79
|
+
transaction.currency,
|
|
80
|
+
result[kind][region].amount,
|
|
81
|
+
Math.abs(transaction.amount.original)
|
|
82
|
+
)
|
|
83
|
+
result.cards.includes(transaction.account.id) || result.cards.push(transaction.account.id)
|
|
84
|
+
}
|
|
85
|
+
return result
|
|
72
86
|
}
|
|
73
87
|
export function combine(accumulation: Statistics, incoming: Statistics, currency: isoly.Currency): Statistics {
|
|
74
88
|
const [statistics, cards] = (({ cursor, cards, ...rest }) => [rest, cards])(incoming)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isoly } from "isoly";
|
|
2
2
|
import { isly } from "isly";
|
|
3
|
+
import { Card } from "../Card";
|
|
3
4
|
import { Transaction } from ".";
|
|
4
5
|
export interface Statistics {
|
|
5
6
|
capture: Statistics.Regional;
|
|
@@ -28,6 +29,6 @@ export declare namespace Statistics {
|
|
|
28
29
|
}>;
|
|
29
30
|
}
|
|
30
31
|
const type: import("isly/dist/cjs/object").IslyObject<Transaction.Statistics, object>;
|
|
31
|
-
function
|
|
32
|
+
function compile(transactions: Transaction[], scheme: Card.Scheme, regions: Record<"domestic" | "intraRegion", isoly.CountryCode.Alpha2[]>): Statistics;
|
|
32
33
|
function combine(accumulation: Statistics, incoming: Statistics, currency: isoly.Currency): Statistics;
|
|
33
34
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isoly } from "isoly";
|
|
2
2
|
import { isly } from "isly";
|
|
3
|
-
import {
|
|
3
|
+
import { Transaction } from ".";
|
|
4
4
|
export var Statistics;
|
|
5
5
|
(function (Statistics) {
|
|
6
6
|
let TransactionType;
|
|
@@ -24,24 +24,40 @@ export var Statistics;
|
|
|
24
24
|
cards: isly.string().array(),
|
|
25
25
|
cursor: isly.string().optional(),
|
|
26
26
|
});
|
|
27
|
-
function
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
:
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
return statistics;
|
|
27
|
+
function empty() {
|
|
28
|
+
return {
|
|
29
|
+
capture: {
|
|
30
|
+
domestic: { count: 0, amount: 0 },
|
|
31
|
+
intraRegion: { count: 0, amount: 0 },
|
|
32
|
+
extraRegion: { count: 0, amount: 0 },
|
|
33
|
+
},
|
|
34
|
+
refund: {
|
|
35
|
+
domestic: { count: 0, amount: 0 },
|
|
36
|
+
intraRegion: { count: 0, amount: 0 },
|
|
37
|
+
extraRegion: { count: 0, amount: 0 },
|
|
38
|
+
},
|
|
39
|
+
cards: [],
|
|
40
|
+
};
|
|
43
41
|
}
|
|
44
|
-
|
|
42
|
+
function compile(transactions, scheme, regions) {
|
|
43
|
+
const result = empty();
|
|
44
|
+
for (const transaction of transactions)
|
|
45
|
+
if (Transaction.CardTransaction.type.is(transaction) &&
|
|
46
|
+
transaction.status == "finalized" &&
|
|
47
|
+
transaction.account.scheme == scheme) {
|
|
48
|
+
const region = regions.domestic.includes(transaction.counterpart.merchant.country)
|
|
49
|
+
? "domestic"
|
|
50
|
+
: regions.intraRegion.includes(transaction.counterpart.merchant.country)
|
|
51
|
+
? "intraRegion"
|
|
52
|
+
: "extraRegion";
|
|
53
|
+
const kind = transaction.direction == "outbound" ? "capture" : "refund";
|
|
54
|
+
result[kind][region].count++;
|
|
55
|
+
result[kind][region].amount = isoly.Currency.add(transaction.currency, result[kind][region].amount, Math.abs(transaction.amount.original));
|
|
56
|
+
result.cards.includes(transaction.account.id) || result.cards.push(transaction.account.id);
|
|
57
|
+
}
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
Statistics.compile = compile;
|
|
45
61
|
function combine(accumulation, incoming, currency) {
|
|
46
62
|
const [statistics, cards] = (({ cursor, cards, ...rest }) => [rest, cards])(incoming);
|
|
47
63
|
Object.entries(statistics).forEach(([kind, statistic]) => Object.entries(statistic).forEach(([region, { count, amount }]) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Statistics.js","sourceRoot":"../","sources":["Transaction/Statistics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"Statistics.js","sourceRoot":"../","sources":["Transaction/Statistics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAE3B,OAAO,EAAE,WAAW,EAAE,MAAM,GAAG,CAAA;AAS/B,MAAM,KAAW,UAAU,CA6F1B;AA7FD,WAAiB,UAAU;IAE1B,IAAiB,eAAe,CAE/B;IAFD,WAAiB,eAAe;QAClB,sBA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