@pax2pay/model-banking 0.1.418 → 0.1.419
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.
|
@@ -42,7 +42,8 @@ export namespace Statistics {
|
|
|
42
42
|
statistics: Statistics,
|
|
43
43
|
transaction: Transaction,
|
|
44
44
|
domestic: isoly.CountryCode.Alpha2[],
|
|
45
|
-
intraRegion: isoly.CountryCode.Alpha2[]
|
|
45
|
+
intraRegion: isoly.CountryCode.Alpha2[],
|
|
46
|
+
currency: isoly.Currency
|
|
46
47
|
): Statistics {
|
|
47
48
|
const state = transaction.state
|
|
48
49
|
const authorization = state?.authorization
|
|
@@ -53,24 +54,29 @@ export namespace Statistics {
|
|
|
53
54
|
? "intraRegion"
|
|
54
55
|
: "extraRegion"
|
|
55
56
|
statistics[state.transaction.kind][region].count++
|
|
56
|
-
statistics[state.transaction.kind][region].amount
|
|
57
|
+
statistics[state.transaction.kind][region].amount = isoly.Currency.add(
|
|
58
|
+
currency,
|
|
59
|
+
statistics[state.transaction.kind][region].amount,
|
|
60
|
+
state.transaction.amount
|
|
61
|
+
)
|
|
57
62
|
}
|
|
58
63
|
return statistics
|
|
59
64
|
}
|
|
60
|
-
export function combine(accumulation: Statistics, incoming: Statistics): Statistics {
|
|
61
|
-
Object.entries(
|
|
62
|
-
|
|
63
|
-
(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
export function combine(accumulation: Statistics, incoming: Statistics, currency: isoly.Currency): Statistics {
|
|
66
|
+
Object.entries((({ cursor, ...rest }) => rest)(incoming)).forEach(
|
|
67
|
+
([kind, statistic]: [TransactionType, Statistics[TransactionType]]) =>
|
|
68
|
+
Object.entries(statistic).forEach(
|
|
69
|
+
([region, { count, amount }]: [
|
|
70
|
+
Region,
|
|
71
|
+
{
|
|
72
|
+
count: number
|
|
73
|
+
amount: number
|
|
74
|
+
}
|
|
75
|
+
]) => {
|
|
76
|
+
accumulation[kind][region].count += count
|
|
77
|
+
accumulation[kind][region].amount = isoly.Currency.add(currency, accumulation[kind][region].amount, amount)
|
|
68
78
|
}
|
|
69
|
-
|
|
70
|
-
accumulation[kind][region].count += count
|
|
71
|
-
accumulation[kind][region].amount += amount
|
|
72
|
-
}
|
|
73
|
-
)
|
|
79
|
+
)
|
|
74
80
|
)
|
|
75
81
|
return accumulation
|
|
76
82
|
}
|
|
@@ -27,6 +27,6 @@ export declare namespace Statistics {
|
|
|
27
27
|
}>;
|
|
28
28
|
}
|
|
29
29
|
const type: isly.object.ExtendableType<Transaction.Statistics>;
|
|
30
|
-
function append(statistics: Statistics, transaction: Transaction, domestic: isoly.CountryCode.Alpha2[], intraRegion: isoly.CountryCode.Alpha2[]): Statistics;
|
|
31
|
-
function combine(accumulation: Statistics, incoming: Statistics): Statistics;
|
|
30
|
+
function append(statistics: Statistics, transaction: Transaction, domestic: isoly.CountryCode.Alpha2[], intraRegion: isoly.CountryCode.Alpha2[], currency: isoly.Currency): Statistics;
|
|
31
|
+
function combine(accumulation: Statistics, incoming: Statistics, currency: isoly.Currency): Statistics;
|
|
32
32
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isoly } from "isoly";
|
|
1
2
|
import { isly } from "isly";
|
|
2
3
|
export var Statistics;
|
|
3
4
|
(function (Statistics) {
|
|
@@ -21,7 +22,7 @@ export var Statistics;
|
|
|
21
22
|
refund: Regional.type,
|
|
22
23
|
cursor: isly.string().optional(),
|
|
23
24
|
});
|
|
24
|
-
function append(statistics, transaction, domestic, intraRegion) {
|
|
25
|
+
function append(statistics, transaction, domestic, intraRegion, currency) {
|
|
25
26
|
const state = transaction.state;
|
|
26
27
|
const authorization = state?.authorization;
|
|
27
28
|
if (state && authorization && (state.transaction.kind == "capture" || state.transaction.kind == "refund")) {
|
|
@@ -31,15 +32,15 @@ export var Statistics;
|
|
|
31
32
|
? "intraRegion"
|
|
32
33
|
: "extraRegion";
|
|
33
34
|
statistics[state.transaction.kind][region].count++;
|
|
34
|
-
statistics[state.transaction.kind][region].amount
|
|
35
|
+
statistics[state.transaction.kind][region].amount = isoly.Currency.add(currency, statistics[state.transaction.kind][region].amount, state.transaction.amount);
|
|
35
36
|
}
|
|
36
37
|
return statistics;
|
|
37
38
|
}
|
|
38
39
|
Statistics.append = append;
|
|
39
|
-
function combine(accumulation, incoming) {
|
|
40
|
-
Object.entries(incoming).forEach(([kind, statistic]) => Object.entries(statistic).forEach(([region, { count, amount }]) => {
|
|
40
|
+
function combine(accumulation, incoming, currency) {
|
|
41
|
+
Object.entries((({ cursor, ...rest }) => rest)(incoming)).forEach(([kind, statistic]) => Object.entries(statistic).forEach(([region, { count, amount }]) => {
|
|
41
42
|
accumulation[kind][region].count += count;
|
|
42
|
-
accumulation[kind][region].amount
|
|
43
|
+
accumulation[kind][region].amount = isoly.Currency.add(currency, accumulation[kind][region].amount, amount);
|
|
43
44
|
}));
|
|
44
45
|
return accumulation;
|
|
45
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Statistics.js","sourceRoot":"../","sources":["Transaction/Statistics.ts"],"names":[],"mappings":"
|
|
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;AAS3B,MAAM,KAAW,UAAU,CAwE1B;AAxED,WAAiB,UAAU;IAE1B,IAAiB,eAAe,CAE/B;IAFD,WAAiB,eAAe;QAClB,sBAAM,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAU,CAAA;IACrD,CAAC,EAFgB,eAAe,GAAf,0BAAe,KAAf,0BAAe,QAE/B;IAED,IAAiB,MAAM,CAEtB;IAFD,WAAiB,MAAM;QACT,aAAM,GAAG,CAAC,UAAU,EAAE,aAAa,EAAE,aAAa,CAAU,CAAA;IAC1E,CAAC,EAFgB,MAAM,G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