@pax2pay/model-banking 0.1.317 → 0.1.318
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/Card/index.ts +35 -0
- package/dist/Card/index.d.ts +1 -0
- package/dist/Card/index.js +26 -0
- package/dist/Card/index.js.map +1 -1
- package/package.json +1 -1
package/Card/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { isoly } from "isoly"
|
|
|
2
2
|
import { isly } from "isly"
|
|
3
3
|
import { Amount } from "../Amount"
|
|
4
4
|
import { Realm } from "../Realm"
|
|
5
|
+
import { Report } from "../Report"
|
|
5
6
|
import { Rule, type as ruleType } from "../Rule/Rule"
|
|
6
7
|
import { Changeable as CardChangeable } from "./Changeable"
|
|
7
8
|
import { Creatable as CardCreatable } from "./Creatable"
|
|
@@ -71,4 +72,38 @@ export namespace Card {
|
|
|
71
72
|
export import Operation = CardOperation
|
|
72
73
|
export import Scheme = CardScheme
|
|
73
74
|
export import Stack = CardStack
|
|
75
|
+
|
|
76
|
+
const csvMap: Record<string, (card: Card) => string | number | undefined> = {
|
|
77
|
+
id: card => card.id,
|
|
78
|
+
created: card => readableDate(card.created),
|
|
79
|
+
cancelled: card => readableDate(card.history.find(o => o.type == "card" && o.status == "cancelled")?.created),
|
|
80
|
+
"organization.code": card => card.organization,
|
|
81
|
+
realm: card => card.realm,
|
|
82
|
+
account: card => card.account,
|
|
83
|
+
preset: card => card.preset,
|
|
84
|
+
scheme: card => card.scheme,
|
|
85
|
+
reference: card => card.reference,
|
|
86
|
+
currency: card => card.limit[0],
|
|
87
|
+
limit: card => card.limit[1],
|
|
88
|
+
spent: card => card.spent[1],
|
|
89
|
+
status: card => card.status,
|
|
90
|
+
expiry: card => readableDate(Expiry.toDateTime(card.details.expiry)),
|
|
91
|
+
iin: card => card.details.iin,
|
|
92
|
+
holder: card => card.details.holder,
|
|
93
|
+
}
|
|
94
|
+
function readableDate(date: isoly.DateTime | undefined): string | undefined {
|
|
95
|
+
return date && date.slice(0, 10) + " " + (date.endsWith("Z") ? date.slice(11, -1) : date.slice(11))
|
|
96
|
+
}
|
|
97
|
+
export function toCsv(transactions: Card[]): string {
|
|
98
|
+
return Report.toCsv(
|
|
99
|
+
Object.keys(csvMap),
|
|
100
|
+
transactions.map(card =>
|
|
101
|
+
Report.Row.toCsv(
|
|
102
|
+
Object.values(csvMap).map(c => c(card)),
|
|
103
|
+
","
|
|
104
|
+
)
|
|
105
|
+
),
|
|
106
|
+
","
|
|
107
|
+
)
|
|
108
|
+
}
|
|
74
109
|
}
|
package/dist/Card/index.d.ts
CHANGED
package/dist/Card/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isoly } from "isoly";
|
|
2
2
|
import { isly } from "isly";
|
|
3
3
|
import { Realm } from "../Realm";
|
|
4
|
+
import { Report } from "../Report";
|
|
4
5
|
import { type as ruleType } from "../Rule/Rule";
|
|
5
6
|
import { Changeable as CardChangeable } from "./Changeable";
|
|
6
7
|
import { Creatable as CardCreatable } from "./Creatable";
|
|
@@ -45,5 +46,30 @@ export var Card;
|
|
|
45
46
|
Card.Operation = CardOperation;
|
|
46
47
|
Card.Scheme = CardScheme;
|
|
47
48
|
Card.Stack = CardStack;
|
|
49
|
+
const csvMap = {
|
|
50
|
+
id: card => card.id,
|
|
51
|
+
created: card => readableDate(card.created),
|
|
52
|
+
cancelled: card => readableDate(card.history.find(o => o.type == "card" && o.status == "cancelled")?.created),
|
|
53
|
+
"organization.code": card => card.organization,
|
|
54
|
+
realm: card => card.realm,
|
|
55
|
+
account: card => card.account,
|
|
56
|
+
preset: card => card.preset,
|
|
57
|
+
scheme: card => card.scheme,
|
|
58
|
+
reference: card => card.reference,
|
|
59
|
+
currency: card => card.limit[0],
|
|
60
|
+
limit: card => card.limit[1],
|
|
61
|
+
spent: card => card.spent[1],
|
|
62
|
+
status: card => card.status,
|
|
63
|
+
expiry: card => readableDate(Card.Expiry.toDateTime(card.details.expiry)),
|
|
64
|
+
iin: card => card.details.iin,
|
|
65
|
+
holder: card => card.details.holder,
|
|
66
|
+
};
|
|
67
|
+
function readableDate(date) {
|
|
68
|
+
return date && date.slice(0, 10) + " " + (date.endsWith("Z") ? date.slice(11, -1) : date.slice(11));
|
|
69
|
+
}
|
|
70
|
+
function toCsv(transactions) {
|
|
71
|
+
return Report.toCsv(Object.keys(csvMap), transactions.map(card => Report.Row.toCsv(Object.values(csvMap).map(c => c(card)), ",")), ",");
|
|
72
|
+
}
|
|
73
|
+
Card.toCsv = toCsv;
|
|
48
74
|
})(Card || (Card = {}));
|
|
49
75
|
//# sourceMappingURL=index.js.map
|
package/dist/Card/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"../","sources":["Card/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAE3B,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAChC,OAAO,EAAQ,IAAI,IAAI,QAAQ,EAAE,MAAM,cAAc,CAAA;AACrD,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,cAAc,CAAA;AAC3D,OAAO,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,aAAa,CAAA;AACxD,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,UAAU,CAAA;AAC/C,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,QAAQ,CAAA;AACzC,OAAO,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,aAAa,CAAA;AACxD,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,UAAU,CAAA;AAC/C,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,UAAU,CAAA;AAC/C,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,SAAS,CAAA;AA2B5C,MAAM,KAAW,IAAI,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