@pax2pay/model-banking 0.1.301 → 0.1.303

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.
@@ -0,0 +1,90 @@
1
+ export namespace Dates {
2
+ // Source for British holidays: https://www.gov.uk/bank-holidays.json
3
+ export const englandAndWales = [
4
+ "2024-01-01",
5
+ "2024-03-29",
6
+ "2024-04-01",
7
+ "2024-05-06",
8
+ "2024-05-27",
9
+ "2024-08-26",
10
+ "2024-12-25",
11
+ "2024-12-26",
12
+ "2025-01-01",
13
+ "2025-04-18",
14
+ "2025-04-21",
15
+ "2025-05-05",
16
+ "2025-05-26",
17
+ "2025-08-25",
18
+ "2025-12-25",
19
+ "2025-12-26",
20
+ "2026-01-01",
21
+ "2026-04-03",
22
+ "2026-04-06",
23
+ "2026-05-04",
24
+ "2026-05-25",
25
+ "2026-08-31",
26
+ "2026-12-25",
27
+ "2026-12-28",
28
+ ]
29
+ export const scotland = [
30
+ "2024-01-01",
31
+ "2024-01-02",
32
+ "2024-03-29",
33
+ "2024-05-06",
34
+ "2024-05-27",
35
+ "2024-08-05",
36
+ "2024-12-02",
37
+ "2024-12-25",
38
+ "2024-12-26",
39
+ "2025-01-01",
40
+ "2025-01-02",
41
+ "2025-04-18",
42
+ "2025-05-05",
43
+ "2025-05-26",
44
+ "2025-08-04",
45
+ "2025-12-01",
46
+ "2025-12-25",
47
+ "2025-12-26",
48
+ "2026-01-01",
49
+ "2026-01-02",
50
+ "2026-04-03",
51
+ "2026-05-04",
52
+ "2026-05-25",
53
+ "2026-08-03",
54
+ "2026-11-30",
55
+ "2026-12-25",
56
+ "2026-12-28",
57
+ ]
58
+ export const northernIreland = [
59
+ "2024-01-01",
60
+ "2024-03-18",
61
+ "2024-03-29",
62
+ "2024-04-01",
63
+ "2024-05-06",
64
+ "2024-05-27",
65
+ "2024-07-12",
66
+ "2024-08-26",
67
+ "2024-12-25",
68
+ "2024-12-26",
69
+ "2025-01-01",
70
+ "2025-03-17",
71
+ "2025-04-18",
72
+ "2025-04-21",
73
+ "2025-05-05",
74
+ "2025-05-26",
75
+ "2025-07-14",
76
+ "2025-08-25",
77
+ "2025-12-25",
78
+ "2025-12-26",
79
+ "2026-01-01",
80
+ "2026-03-17",
81
+ "2026-04-03",
82
+ "2026-04-06",
83
+ "2026-05-04",
84
+ "2026-05-25",
85
+ "2026-07-13",
86
+ "2026-08-31",
87
+ "2026-12-25",
88
+ "2026-12-28",
89
+ ]
90
+ }
@@ -0,0 +1,17 @@
1
+ import { isoly } from "isoly"
2
+ import { isly } from "isly"
3
+ import { Dates } from "./Dates"
4
+
5
+ export namespace Holidays {
6
+ export type Regions = typeof Regions.values[number]
7
+ export namespace Regions {
8
+ export const values = ["England", "Wales", "Scotland", "Northern Ireland"] as const
9
+ export const type = isly.string<Regions>(values)
10
+ }
11
+ export const dates: Record<Regions, Readonly<isoly.Date>[]> = {
12
+ England: Dates.englandAndWales,
13
+ Wales: Dates.englandAndWales,
14
+ Scotland: Dates.scotland,
15
+ "Northern Ireland": Dates.northernIreland,
16
+ }
17
+ }
@@ -3,7 +3,12 @@ import { isly } from "isly"
3
3
  export interface PaxgiroCredit {
4
4
  type: "paxgiro-credit"
5
5
  reference: string
6
+ justInTime?: boolean
6
7
  }
7
8
  export namespace PaxgiroCredit {
8
- export const type = isly.object<PaxgiroCredit>({ type: isly.string("paxgiro-credit"), reference: isly.string() })
9
+ export const type = isly.object<PaxgiroCredit>({
10
+ type: isly.string("paxgiro-credit"),
11
+ reference: isly.string(),
12
+ justInTime: isly.boolean().optional(),
13
+ })
9
14
  }
@@ -0,0 +1,60 @@
1
+ import { isoly } from "isoly"
2
+ import { isly } from "isly"
3
+ import { Transaction } from "../Transaction"
4
+
5
+ export namespace funding {
6
+ export type Cursor = { cursor: string; amount: number }
7
+ export namespace Cursor {
8
+ export const type = isly.object<Cursor>({
9
+ cursor: isly.string(),
10
+ amount: isly.number(),
11
+ })
12
+ export function fromTransaction(transaction: Transaction): string {
13
+ return `${transaction.currency}|${isoly.DateTime.invert(transaction.created)}|${transaction.id}`
14
+ }
15
+ export function toTimestamp(cursor: string): isoly.DateTime {
16
+ return isoly.DateTime.invert(cursor.split("|")[1])
17
+ }
18
+ }
19
+ export type Cursors = Partial<Record<isoly.Currency, Cursor>>
20
+ export namespace Cursors {
21
+ export const type = isly.record<Cursors>(isly.fromIs("isoly.Currency", isoly.Currency.is), Cursor.type)
22
+ export function updateAmount(settlement: Transaction, cursors: Cursors): Cursors {
23
+ const cursor = cursors[settlement.currency]
24
+ if (!cursor)
25
+ cursors[settlement.currency] = {
26
+ cursor: Cursor.fromTransaction(settlement),
27
+ amount: Math.abs(settlement.amount),
28
+ }
29
+ else {
30
+ cursor.amount += Math.abs(settlement.amount)
31
+ }
32
+ return cursors
33
+ }
34
+ export function updateCursors(funding: Transaction, cursors: Cursors): Cursors {
35
+ const cursor = cursors[funding.currency]
36
+ if (!cursor)
37
+ cursors[funding.currency] = {
38
+ cursor: Cursor.fromTransaction(funding),
39
+ amount: -Math.abs(funding.amount),
40
+ }
41
+ else if (cursor.amount > 0) {
42
+ cursor.amount -= Math.abs(funding.amount)
43
+ cursor.cursor = Cursor.fromTransaction(funding)
44
+ }
45
+ return cursors
46
+ }
47
+ }
48
+ export function settle(transactions: Transaction[], amountsUpdated: Cursors): Cursors {
49
+ for (let i = transactions.length - 1; i >= 0; i--) {
50
+ Cursors.updateCursors(transactions[i], amountsUpdated)
51
+ }
52
+ return amountsUpdated
53
+ }
54
+ export function isStale(cursor: Cursor, bankingDays?: number, holidays?: isoly.Date[]): boolean {
55
+ return (
56
+ isoly.Date.now() >
57
+ isoly.Date.nextBusinessDay(isoly.DateTime.getDate(Cursor.toTimestamp(cursor.cursor)), bankingDays, holidays)
58
+ )
59
+ }
60
+ }
@@ -2,14 +2,15 @@ import { isoly } from "isoly"
2
2
  import { isly } from "isly"
3
3
  import { Emoney as SnapshotEmoney } from "./Emoney"
4
4
  import { Fragment as SnapshotFragment } from "./Fragment"
5
+ import { funding as snapshotFunding } from "./funding"
5
6
  import { Warning as SnapshotWarning } from "./Warning"
6
7
 
7
8
  export type Snapshot = Partial<Record<isoly.Currency, Snapshot.Fragment>>
8
9
 
9
10
  export namespace Snapshot {
10
11
  export import Fragment = SnapshotFragment
11
- export type Warning = SnapshotWarning
12
- export const Warning = SnapshotWarning
12
+ export import Warning = SnapshotWarning
13
+ export import funding = snapshotFunding
13
14
  export type Emoney = SnapshotEmoney
14
15
  export const type = isly.record(isly.fromIs("Currency", isoly.Currency.is), Fragment.type)
15
16
  }
package/Treasury/index.ts CHANGED
@@ -16,6 +16,5 @@ export namespace Treasury {
16
16
  export import Transaction = TreasuryTransaction
17
17
  export import Snapshot = TreasurySnapshot
18
18
  export import Account = TreasuryAccount
19
- export type Balance = TreasuryBalance
20
- export const Balance = TreasuryBalance
19
+ export import Balance = TreasuryBalance
21
20
  }
@@ -0,0 +1,5 @@
1
+ export declare namespace Dates {
2
+ const englandAndWales: string[];
3
+ const scotland: string[];
4
+ const northernIreland: string[];
5
+ }
@@ -0,0 +1,91 @@
1
+ export var Dates;
2
+ (function (Dates) {
3
+ Dates.englandAndWales = [
4
+ "2024-01-01",
5
+ "2024-03-29",
6
+ "2024-04-01",
7
+ "2024-05-06",
8
+ "2024-05-27",
9
+ "2024-08-26",
10
+ "2024-12-25",
11
+ "2024-12-26",
12
+ "2025-01-01",
13
+ "2025-04-18",
14
+ "2025-04-21",
15
+ "2025-05-05",
16
+ "2025-05-26",
17
+ "2025-08-25",
18
+ "2025-12-25",
19
+ "2025-12-26",
20
+ "2026-01-01",
21
+ "2026-04-03",
22
+ "2026-04-06",
23
+ "2026-05-04",
24
+ "2026-05-25",
25
+ "2026-08-31",
26
+ "2026-12-25",
27
+ "2026-12-28",
28
+ ];
29
+ Dates.scotland = [
30
+ "2024-01-01",
31
+ "2024-01-02",
32
+ "2024-03-29",
33
+ "2024-05-06",
34
+ "2024-05-27",
35
+ "2024-08-05",
36
+ "2024-12-02",
37
+ "2024-12-25",
38
+ "2024-12-26",
39
+ "2025-01-01",
40
+ "2025-01-02",
41
+ "2025-04-18",
42
+ "2025-05-05",
43
+ "2025-05-26",
44
+ "2025-08-04",
45
+ "2025-12-01",
46
+ "2025-12-25",
47
+ "2025-12-26",
48
+ "2026-01-01",
49
+ "2026-01-02",
50
+ "2026-04-03",
51
+ "2026-05-04",
52
+ "2026-05-25",
53
+ "2026-08-03",
54
+ "2026-11-30",
55
+ "2026-12-25",
56
+ "2026-12-28",
57
+ ];
58
+ Dates.northernIreland = [
59
+ "2024-01-01",
60
+ "2024-03-18",
61
+ "2024-03-29",
62
+ "2024-04-01",
63
+ "2024-05-06",
64
+ "2024-05-27",
65
+ "2024-07-12",
66
+ "2024-08-26",
67
+ "2024-12-25",
68
+ "2024-12-26",
69
+ "2025-01-01",
70
+ "2025-03-17",
71
+ "2025-04-18",
72
+ "2025-04-21",
73
+ "2025-05-05",
74
+ "2025-05-26",
75
+ "2025-07-14",
76
+ "2025-08-25",
77
+ "2025-12-25",
78
+ "2025-12-26",
79
+ "2026-01-01",
80
+ "2026-03-17",
81
+ "2026-04-03",
82
+ "2026-04-06",
83
+ "2026-05-04",
84
+ "2026-05-25",
85
+ "2026-07-13",
86
+ "2026-08-31",
87
+ "2026-12-25",
88
+ "2026-12-28",
89
+ ];
90
+ })(Dates || (Dates = {}));
91
+ //# sourceMappingURL=Dates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Dates.js","sourceRoot":"../","sources":["Holidays/Dates.ts"],"names":[],"mappings":"AAAA,MAAM,KAAW,KAAK,CAyFrB;AAzFD,WAAiB,KAAK;IAER,qBAAe,GAAG;QAC9B,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;KACZ,CAAA;IACY,cAAQ,GAAG;QACvB,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;KACZ,CAAA;IACY,qBAAe,GAAG;QAC9B,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;KACZ,CAAA;AACF,CAAC,EAzFgB,KAAK,KAAL,KAAK,QAyFrB"}
@@ -0,0 +1,10 @@
1
+ import { isoly } from "isoly";
2
+ import { isly } from "isly";
3
+ export declare namespace Holidays {
4
+ type Regions = typeof Regions.values[number];
5
+ namespace Regions {
6
+ const values: readonly ["England", "Wales", "Scotland", "Northern Ireland"];
7
+ const type: isly.Type<"England" | "Wales" | "Scotland" | "Northern Ireland">;
8
+ }
9
+ const dates: Record<Regions, Readonly<isoly.Date>[]>;
10
+ }
@@ -0,0 +1,17 @@
1
+ import { isly } from "isly";
2
+ import { Dates } from "./Dates";
3
+ export var Holidays;
4
+ (function (Holidays) {
5
+ let Regions;
6
+ (function (Regions) {
7
+ Regions.values = ["England", "Wales", "Scotland", "Northern Ireland"];
8
+ Regions.type = isly.string(Regions.values);
9
+ })(Regions = Holidays.Regions || (Holidays.Regions = {}));
10
+ Holidays.dates = {
11
+ England: Dates.englandAndWales,
12
+ Wales: Dates.englandAndWales,
13
+ Scotland: Dates.scotland,
14
+ "Northern Ireland": Dates.northernIreland,
15
+ };
16
+ })(Holidays || (Holidays = {}));
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"../","sources":["Holidays/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAE/B,MAAM,KAAW,QAAQ,CAYxB;AAZD,WAAiB,QAAQ;IAExB,IAAiB,OAAO,CAGvB;IAHD,WAAiB,OAAO;QACV,cAAM,GAAG,CAAC,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,kBAAkB,CAAU,CAAA;QACtE,YAAI,GAAG,IAAI,CAAC,MAAM,CAAU,QAAA,MAAM,CAAC,CAAA;IACjD,CAAC,EAHgB,OAAO,GAAP,gBAAO,KAAP,gBAAO,QAGvB;IACY,cAAK,GAA4C;QAC7D,OAAO,EAAE,KAAK,CAAC,eAAe;QAC9B,KAAK,EAAE,KAAK,CAAC,eAAe;QAC5B,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,kBAAkB,EAAE,KAAK,CAAC,eAAe;KACzC,CAAA;AACF,CAAC,EAZgB,QAAQ,KAAR,QAAQ,QAYxB"}
@@ -2,6 +2,7 @@ import { isly } from "isly";
2
2
  export interface PaxgiroCredit {
3
3
  type: "paxgiro-credit";
4
4
  reference: string;
5
+ justInTime?: boolean;
5
6
  }
6
7
  export declare namespace PaxgiroCredit {
7
8
  const type: isly.object.ExtendableType<PaxgiroCredit>;
@@ -1,6 +1,10 @@
1
1
  import { isly } from "isly";
2
2
  export var PaxgiroCredit;
3
3
  (function (PaxgiroCredit) {
4
- PaxgiroCredit.type = isly.object({ type: isly.string("paxgiro-credit"), reference: isly.string() });
4
+ PaxgiroCredit.type = isly.object({
5
+ type: isly.string("paxgiro-credit"),
6
+ reference: isly.string(),
7
+ justInTime: isly.boolean().optional(),
8
+ });
5
9
  })(PaxgiroCredit || (PaxgiroCredit = {}));
6
10
  //# sourceMappingURL=PaxgiroCredit.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PaxgiroCredit.js","sourceRoot":"../","sources":["Rail/Address/PaxgiroCredit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAM3B,MAAM,KAAW,aAAa,CAE7B;AAFD,WAAiB,aAAa;IAChB,kBAAI,GAAG,IAAI,CAAC,MAAM,CAAgB,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;AAClH,CAAC,EAFgB,aAAa,KAAb,aAAa,QAE7B"}
1
+ {"version":3,"file":"PaxgiroCredit.js","sourceRoot":"../","sources":["Rail/Address/PaxgiroCredit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAO3B,MAAM,KAAW,aAAa,CAM7B;AAND,WAAiB,aAAa;IAChB,kBAAI,GAAG,IAAI,CAAC,MAAM,CAAgB;QAC9C,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC;QACnC,SAAS,EAAE,IAAI,CAAC,MAAM,EAAE;QACxB,UAAU,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;KACrC,CAAC,CAAA;AACH,CAAC,EANgB,aAAa,KAAb,aAAa,QAM7B"}
@@ -0,0 +1,22 @@
1
+ import { isoly } from "isoly";
2
+ import { isly } from "isly";
3
+ import { Transaction } from "../Transaction";
4
+ export declare namespace funding {
5
+ type Cursor = {
6
+ cursor: string;
7
+ amount: number;
8
+ };
9
+ namespace Cursor {
10
+ const type: isly.object.ExtendableType<Cursor>;
11
+ function fromTransaction(transaction: Transaction): string;
12
+ function toTimestamp(cursor: string): isoly.DateTime;
13
+ }
14
+ type Cursors = Partial<Record<isoly.Currency, Cursor>>;
15
+ namespace Cursors {
16
+ const type: isly.Type<Partial<Record<"BTN" | "CHE" | "MKD" | "AED" | "AFN" | "ALL" | "AMD" | "ANG" | "AOA" | "ARS" | "AUD" | "AWG" | "AZN" | "BAM" | "BBD" | "BDT" | "BGN" | "BHD" | "BIF" | "BMD" | "BND" | "BOB" | "BOV" | "BRL" | "BSD" | "BWP" | "BYN" | "BZD" | "CAD" | "CDF" | "CHF" | "CHW" | "CLF" | "CLP" | "CNY" | "COP" | "COU" | "CRC" | "CUC" | "CUP" | "CVE" | "CZK" | "DJF" | "DKK" | "DOP" | "DZD" | "EGP" | "ERN" | "ETB" | "EUR" | "FJD" | "FKP" | "GBP" | "GEL" | "GHS" | "GIP" | "GMD" | "GNF" | "GTQ" | "GYD" | "HKD" | "HNL" | "HRK" | "HTG" | "HUF" | "IDR" | "ILS" | "INR" | "IQD" | "IRR" | "ISK" | "JMD" | "JOD" | "JPY" | "KES" | "KGS" | "KHR" | "KMF" | "KPW" | "KRW" | "KWD" | "KYD" | "KZT" | "LAK" | "LBP" | "LKR" | "LRD" | "LSL" | "LYD" | "MAD" | "MDL" | "MGA" | "MMK" | "MNT" | "MOP" | "MRU" | "MUR" | "MVR" | "MWK" | "MXN" | "MXV" | "MYR" | "MZN" | "NAD" | "NGN" | "NIO" | "NOK" | "NPR" | "NZD" | "OMR" | "PAB" | "PEN" | "PGK" | "PHP" | "PKR" | "PLN" | "PYG" | "QAR" | "RON" | "RSD" | "RUB" | "RWF" | "SAR" | "SBD" | "SCR" | "SDG" | "SEK" | "SGD" | "SHP" | "SLL" | "SOS" | "SRD" | "SSP" | "STN" | "SVC" | "SYP" | "SZL" | "THB" | "TJS" | "TMT" | "TND" | "TOP" | "TRY" | "TTD" | "TWD" | "TZS" | "UAH" | "UGX" | "USD" | "USN" | "UYI" | "UYU" | "UYW" | "UZS" | "VES" | "VND" | "VUV" | "WST" | "XAF" | "XAG" | "XAU" | "XBA" | "XBB" | "XBC" | "XBD" | "XCD" | "XDR" | "XOF" | "XPD" | "XPF" | "XPT" | "XSU" | "XTS" | "XUA" | "XXX" | "YER" | "ZAR" | "ZMW" | "ZWL", Cursor>>>;
17
+ function updateAmount(settlement: Transaction, cursors: Cursors): Cursors;
18
+ function updateCursors(funding: Transaction, cursors: Cursors): Cursors;
19
+ }
20
+ function settle(transactions: Transaction[], amountsUpdated: Cursors): Cursors;
21
+ function isStale(cursor: Cursor, bankingDays?: number, holidays?: isoly.Date[]): boolean;
22
+ }
@@ -0,0 +1,64 @@
1
+ import { isoly } from "isoly";
2
+ import { isly } from "isly";
3
+ export var funding;
4
+ (function (funding_1) {
5
+ let Cursor;
6
+ (function (Cursor) {
7
+ Cursor.type = isly.object({
8
+ cursor: isly.string(),
9
+ amount: isly.number(),
10
+ });
11
+ function fromTransaction(transaction) {
12
+ return `${transaction.currency}|${isoly.DateTime.invert(transaction.created)}|${transaction.id}`;
13
+ }
14
+ Cursor.fromTransaction = fromTransaction;
15
+ function toTimestamp(cursor) {
16
+ return isoly.DateTime.invert(cursor.split("|")[1]);
17
+ }
18
+ Cursor.toTimestamp = toTimestamp;
19
+ })(Cursor = funding_1.Cursor || (funding_1.Cursor = {}));
20
+ let Cursors;
21
+ (function (Cursors) {
22
+ Cursors.type = isly.record(isly.fromIs("isoly.Currency", isoly.Currency.is), Cursor.type);
23
+ function updateAmount(settlement, cursors) {
24
+ const cursor = cursors[settlement.currency];
25
+ if (!cursor)
26
+ cursors[settlement.currency] = {
27
+ cursor: Cursor.fromTransaction(settlement),
28
+ amount: Math.abs(settlement.amount),
29
+ };
30
+ else {
31
+ cursor.amount += Math.abs(settlement.amount);
32
+ }
33
+ return cursors;
34
+ }
35
+ Cursors.updateAmount = updateAmount;
36
+ function updateCursors(funding, cursors) {
37
+ const cursor = cursors[funding.currency];
38
+ if (!cursor)
39
+ cursors[funding.currency] = {
40
+ cursor: Cursor.fromTransaction(funding),
41
+ amount: -Math.abs(funding.amount),
42
+ };
43
+ else if (cursor.amount > 0) {
44
+ cursor.amount -= Math.abs(funding.amount);
45
+ cursor.cursor = Cursor.fromTransaction(funding);
46
+ }
47
+ return cursors;
48
+ }
49
+ Cursors.updateCursors = updateCursors;
50
+ })(Cursors = funding_1.Cursors || (funding_1.Cursors = {}));
51
+ function settle(transactions, amountsUpdated) {
52
+ for (let i = transactions.length - 1; i >= 0; i--) {
53
+ Cursors.updateCursors(transactions[i], amountsUpdated);
54
+ }
55
+ return amountsUpdated;
56
+ }
57
+ funding_1.settle = settle;
58
+ function isStale(cursor, bankingDays, holidays) {
59
+ return (isoly.Date.now() >
60
+ isoly.Date.nextBusinessDay(isoly.DateTime.getDate(Cursor.toTimestamp(cursor.cursor)), bankingDays, holidays));
61
+ }
62
+ funding_1.isStale = isStale;
63
+ })(funding || (funding = {}));
64
+ //# sourceMappingURL=funding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"funding.js","sourceRoot":"../","sources":["Treasury/Snapshot/funding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAG3B,MAAM,KAAW,OAAO,CAuDvB;AAvDD,WAAiB,SAAO;IAEvB,IAAiB,MAAM,CAWtB;IAXD,WAAiB,MAAM;QACT,WAAI,GAAG,IAAI,CAAC,MAAM,CAAS;YACvC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE;YACrB,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE;SACrB,CAAC,CAAA;QACF,SAAgB,eAAe,CAAC,WAAwB;YACvD,OAAO,GAAG,WAAW,CAAC,QAAQ,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} from "isoly";
2
2
  import { isly } from "isly";
3
3
  import { Emoney as SnapshotEmoney } from "./Emoney";
4
4
  import { Fragment as SnapshotFragment } from "./Fragment";
5
+ import { funding as snapshotFunding } from "./funding";
5
6
  import { Warning as SnapshotWarning } from "./Warning";
6
7
  export type Snapshot = Partial<Record<isoly.Currency, Snapshot.Fragment>>;
7
8
  export declare namespace Snapshot {
8
9
  export import Fragment = SnapshotFragment;
9
- type Warning = SnapshotWarning;
10
- const Warning: typeof SnapshotWarning;
10
+ export import Warning = SnapshotWarning;
11
+ export import funding = snapshotFunding;
11
12
  type Emoney = SnapshotEmoney;
12
13
  const type: isly.Type<{
13
14
  BTN: any;
@@ -1,11 +1,13 @@
1
1
  import { isoly } from "isoly";
2
2
  import { isly } from "isly";
3
3
  import { Fragment as SnapshotFragment } from "./Fragment";
4
+ import { funding as snapshotFunding } from "./funding";
4
5
  import { Warning as SnapshotWarning } from "./Warning";
5
6
  export var Snapshot;
6
7
  (function (Snapshot) {
7
8
  Snapshot.Fragment = SnapshotFragment;
8
9
  Snapshot.Warning = SnapshotWarning;
10
+ Snapshot.funding = snapshotFunding;
9
11
  Snapshot.type = isly.record(isly.fromIs("Currency", isoly.Currency.is), Snapshot.Fragment.type);
10
12
  })(Snapshot || (Snapshot = {}));
11
13
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../","sources":["Treasury/Snapshot/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAE3B,OAAO,EAAE,QAAQ,IAAI,gBAAgB,EAAE,MAAM,YAAY,CAAA;AACzD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,WAAW,CAAA;AAItD,MAAM,KAAW,QAAQ,CAMxB;AAND,WAAiB,QAAQ;IACV,iBAAQ,GAAG,gBAAgB,CAAA;IAE5B,gBAAO,GAAG,eAAe,CAAA;IAEzB,aAAI,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,SAAA,QAAQ,CAAC,IAAI,CAAC,CAAA;AAC3F,CAAC,EANgB,QAAQ,KAAR,QAAQ,QAMxB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"../","sources":["Treasury/Snapshot/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAE3B,OAAO,EAAE,QAAQ,IAAI,gBAAgB,EAAE,MAAM,YAAY,CAAA;AACzD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,WAAW,CAAA;AACtD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,WAAW,CAAA;AAItD,MAAM,KAAW,QAAQ,CAMxB;AAND,WAAiB,QAAQ;IACV,iBAAQ,GAAG,gBAAgB,CAAA;IAC3B,gBAAO,GAAG,eAAe,CAAA;IACzB,gBAAO,GAAG,eAAe,CAAA;IAE1B,aAAI,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,SAAA,QAAQ,CAAC,IAAI,CAAC,CAAA;AAC3F,CAAC,EANgB,QAAQ,KAAR,QAAQ,QAMxB"}
@@ -8,6 +8,5 @@ export declare namespace Treasury {
8
8
  export import Transaction = TreasuryTransaction;
9
9
  export import Snapshot = TreasurySnapshot;
10
10
  export import Account = TreasuryAccount;
11
- type Balance = TreasuryBalance;
12
- const Balance: typeof TreasuryBalance;
11
+ export import Balance = TreasuryBalance;
13
12
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../","sources":["Treasury/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,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AO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,WAAW,CAAA;AACtD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,WAAW,CAAA;AACtD,OAAO,EAAE,QAAQ,IAAI,gBAAgB,EAAE,MAAM,YAAY,CAAA;AACzD,OAAO,EAAE,WAAW,IAAI,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAElE,MAAM,KAAW,QAAQ,CAaxB;AAbD,WAAiB,QAAQ;IACxB,SAAgB,GAAG,CAAC,IAAqB;QACxC,MAAM,GAAG,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAA;QAChC,MAAM,MAAM,GAAG,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,CAAA;QAC1F,OAAO,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAC7B,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,EACxG,OAAO,CACP,CAAA;IACF,CAAC;IAPe,YAAG,MAOlB,CAAA;IACa,oBAAW,GAAG,mBAAmB,CAAA;IACjC,iBAAQ,GAAG,gBAAgB,CAAA;IAC3B,gBAAO,GAAG,eAAe,CAAA;IACzB,gBAAO,GAAG,eAAe,CAAA;AACxC,CAAC,EAbgB,QAAQ,KAAR,QAAQ,QAaxB"}
package/dist/pax2pay.d.ts CHANGED
@@ -3,6 +3,7 @@ export { Acquirer } from "./Acquirer";
3
3
  export { Balances } from "./Balances";
4
4
  export { Card } from "./Card";
5
5
  export { Event } from "./Event";
6
+ export { Holidays } from "./Holidays";
6
7
  export { Operation } from "./Operation";
7
8
  export { Organization } from "./Organization";
8
9
  export { Rail } from "./Rail";
package/dist/pax2pay.js CHANGED
@@ -3,6 +3,7 @@ export { Acquirer } from "./Acquirer";
3
3
  export { Balances } from "./Balances";
4
4
  export { Card } from "./Card";
5
5
  export { Event } from "./Event";
6
+ export { Holidays } from "./Holidays";
6
7
  export { Operation } from "./Operation";
7
8
  export { Organization } from "./Organization";
8
9
  export { Rail } from "./Rail";
@@ -1 +1 @@
1
- {"version":3,"file":"pax2pay.js","sourceRoot":"../","sources":["pax2pay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,eAAe,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ACrC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEnD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pax2pay/model-banking",
3
- "version": "0.1.301",
3
+ "version": "0.1.303",
4
4
  "description": "Library containing data model types and functions for the Pax2Pay Banking API.",
5
5
  "author": "Pax2Pay Ltd",
6
6
  "license": "MIT",
package/pax2pay.ts CHANGED
@@ -3,6 +3,7 @@ export { Acquirer } from "./Acquirer"
3
3
  export { Balances } from "./Balances"
4
4
  export { Card } from "./Card"
5
5
  export { Event } from "./Event"
6
+ export { Holidays } from "./Holidays"
6
7
  export { Operation } from "./Operation"
7
8
  export { Organization } from "./Organization"
8
9
  export { Rail } from "./Rail"