@pax2pay/model-banking 0.1.417 → 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.
|
@@ -2,16 +2,11 @@ import { isoly } from "isoly"
|
|
|
2
2
|
import { isly } from "isly"
|
|
3
3
|
import { Transaction } from "."
|
|
4
4
|
|
|
5
|
-
export
|
|
6
|
-
Statistics.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
count: number
|
|
11
|
-
amount: number
|
|
12
|
-
}
|
|
13
|
-
>
|
|
14
|
-
>
|
|
5
|
+
export interface Statistics {
|
|
6
|
+
capture: Statistics.Regional
|
|
7
|
+
refund: Statistics.Regional
|
|
8
|
+
cursor?: string
|
|
9
|
+
}
|
|
15
10
|
|
|
16
11
|
export namespace Statistics {
|
|
17
12
|
export type TransactionType = typeof TransactionType.values[number]
|
|
@@ -22,21 +17,33 @@ export namespace Statistics {
|
|
|
22
17
|
export namespace Region {
|
|
23
18
|
export const values = ["domestic", "intraRegion", "extraRegion"] as const
|
|
24
19
|
}
|
|
25
|
-
export
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
export type Regional = Record<
|
|
21
|
+
Statistics.Region,
|
|
22
|
+
{
|
|
23
|
+
count: number
|
|
24
|
+
amount: number
|
|
25
|
+
}
|
|
26
|
+
>
|
|
27
|
+
export namespace Regional {
|
|
28
|
+
export const type = isly.record(
|
|
28
29
|
isly.string<Region>(Region.values),
|
|
29
30
|
isly.object({
|
|
30
31
|
count: isly.number(),
|
|
31
32
|
amount: isly.number(),
|
|
32
33
|
})
|
|
33
34
|
)
|
|
34
|
-
|
|
35
|
+
}
|
|
36
|
+
export const type = isly.object<Statistics>({
|
|
37
|
+
capture: Regional.type,
|
|
38
|
+
refund: Regional.type,
|
|
39
|
+
cursor: isly.string().optional(),
|
|
40
|
+
})
|
|
35
41
|
export function append(
|
|
36
42
|
statistics: Statistics,
|
|
37
43
|
transaction: Transaction,
|
|
38
44
|
domestic: isoly.CountryCode.Alpha2[],
|
|
39
|
-
intraRegion: isoly.CountryCode.Alpha2[]
|
|
45
|
+
intraRegion: isoly.CountryCode.Alpha2[],
|
|
46
|
+
currency: isoly.Currency
|
|
40
47
|
): Statistics {
|
|
41
48
|
const state = transaction.state
|
|
42
49
|
const authorization = state?.authorization
|
|
@@ -47,24 +54,29 @@ export namespace Statistics {
|
|
|
47
54
|
? "intraRegion"
|
|
48
55
|
: "extraRegion"
|
|
49
56
|
statistics[state.transaction.kind][region].count++
|
|
50
|
-
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
|
+
)
|
|
51
62
|
}
|
|
52
63
|
return statistics
|
|
53
64
|
}
|
|
54
|
-
export function combine(accumulation: Statistics, incoming: Statistics): Statistics {
|
|
55
|
-
Object.entries(
|
|
56
|
-
|
|
57
|
-
(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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)
|
|
62
78
|
}
|
|
63
|
-
|
|
64
|
-
accumulation[kind][region].count += count
|
|
65
|
-
accumulation[kind][region].amount += amount
|
|
66
|
-
}
|
|
67
|
-
)
|
|
79
|
+
)
|
|
68
80
|
)
|
|
69
81
|
return accumulation
|
|
70
82
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { isoly } from "isoly";
|
|
2
2
|
import { isly } from "isly";
|
|
3
3
|
import { Transaction } from ".";
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
export interface Statistics {
|
|
5
|
+
capture: Statistics.Regional;
|
|
6
|
+
refund: Statistics.Regional;
|
|
7
|
+
cursor?: string;
|
|
8
|
+
}
|
|
8
9
|
export declare namespace Statistics {
|
|
9
10
|
type TransactionType = typeof TransactionType.values[number];
|
|
10
11
|
namespace TransactionType {
|
|
@@ -14,7 +15,18 @@ export declare namespace Statistics {
|
|
|
14
15
|
namespace Region {
|
|
15
16
|
const values: readonly ["domestic", "intraRegion", "extraRegion"];
|
|
16
17
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
type Regional = Record<Statistics.Region, {
|
|
19
|
+
count: number;
|
|
20
|
+
amount: number;
|
|
21
|
+
}>;
|
|
22
|
+
namespace Regional {
|
|
23
|
+
const type: isly.Type<{
|
|
24
|
+
domestic: any;
|
|
25
|
+
intraRegion: any;
|
|
26
|
+
extraRegion: any;
|
|
27
|
+
}>;
|
|
28
|
+
}
|
|
29
|
+
const type: isly.object.ExtendableType<Transaction.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;
|
|
20
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) {
|
|
@@ -9,11 +10,19 @@ export var Statistics;
|
|
|
9
10
|
(function (Region) {
|
|
10
11
|
Region.values = ["domestic", "intraRegion", "extraRegion"];
|
|
11
12
|
})(Region = Statistics.Region || (Statistics.Region = {}));
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
let Regional;
|
|
14
|
+
(function (Regional) {
|
|
15
|
+
Regional.type = isly.record(isly.string(Region.values), isly.object({
|
|
16
|
+
count: isly.number(),
|
|
17
|
+
amount: isly.number(),
|
|
18
|
+
}));
|
|
19
|
+
})(Regional = Statistics.Regional || (Statistics.Regional = {}));
|
|
20
|
+
Statistics.type = isly.object({
|
|
21
|
+
capture: Regional.type,
|
|
22
|
+
refund: Regional.type,
|
|
23
|
+
cursor: isly.string().optional(),
|
|
24
|
+
});
|
|
25
|
+
function append(statistics, transaction, domestic, intraRegion, currency) {
|
|
17
26
|
const state = transaction.state;
|
|
18
27
|
const authorization = state?.authorization;
|
|
19
28
|
if (state && authorization && (state.transaction.kind == "capture" || state.transaction.kind == "refund")) {
|
|
@@ -23,15 +32,15 @@ export var Statistics;
|
|
|
23
32
|
? "intraRegion"
|
|
24
33
|
: "extraRegion";
|
|
25
34
|
statistics[state.transaction.kind][region].count++;
|
|
26
|
-
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);
|
|
27
36
|
}
|
|
28
37
|
return statistics;
|
|
29
38
|
}
|
|
30
39
|
Statistics.append = append;
|
|
31
|
-
function combine(accumulation, incoming) {
|
|
32
|
-
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 }]) => {
|
|
33
42
|
accumulation[kind][region].count += count;
|
|
34
|
-
accumulation[kind][region].amount
|
|
43
|
+
accumulation[kind][region].amount = isoly.Currency.add(currency, accumulation[kind][region].amount, amount);
|
|
35
44
|
}));
|
|
36
45
|
return accumulation;
|
|
37
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,GAAN,iBAAM,KAAN,iBAAM,QAEtB;IAQD,IAAiB,QAAQ,CAQxB;IARD,WAAiB,QAAQ;QACX,aAAI,GAAG,IAAI,CAAC,MAAM,CAC9B,IAAI,CAAC,MAAM,CAAS,MAAM,CAAC,MAAM,CAAC,EAClC,IAAI,CAAC,MAAM,CAAC;YACX,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE;YACpB,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE;SACrB,CAAC,CACF,CAAA;IACF,CAAC,EARgB,QAAQ,GAAR,mBAAQ,KAAR,mBAAQ,QAQxB;IACY,eAAI,GAAG,IAAI,CAAC,MAAM,CAAa;QAC3C,OAAO,EAAE,QAAQ,CAAC,IAAI;QACtB,MAAM,EAAE,QAAQ,CAAC,IAAI;QACrB,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,QA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