@pax2pay/model-banking 0.1.339 → 0.1.341
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/.github/workflows/ci.yml +1 -1
- package/Treasury/Snapshot/Warning/Buffer.ts +35 -0
- package/Treasury/Snapshot/Warning/Unguarded.ts +29 -0
- package/Treasury/Snapshot/Warning/index.ts +4 -2
- package/dist/Treasury/Snapshot/Warning/Buffer.d.ts +14 -0
- package/dist/Treasury/Snapshot/Warning/Buffer.js +28 -0
- package/dist/Treasury/Snapshot/Warning/Buffer.js.map +1 -0
- package/dist/Treasury/Snapshot/Warning/Unguarded.d.ts +3 -0
- package/dist/Treasury/Snapshot/Warning/Unguarded.js +30 -0
- package/dist/Treasury/Snapshot/Warning/Unguarded.js.map +1 -1
- package/dist/Treasury/Snapshot/Warning/index.d.ts +3 -1
- package/dist/Treasury/Snapshot/Warning/index.js +3 -1
- package/dist/Treasury/Snapshot/Warning/index.js.map +1 -1
- package/package.json +1 -1
package/.github/workflows/ci.yml
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { isoly } from "isoly"
|
|
2
|
+
import { isly } from "isly"
|
|
3
|
+
import { Account } from "../../Account"
|
|
4
|
+
|
|
5
|
+
export interface Buffer {
|
|
6
|
+
type: "buffer"
|
|
7
|
+
account: string
|
|
8
|
+
currency: isoly.Currency
|
|
9
|
+
minimum: number
|
|
10
|
+
balance: number
|
|
11
|
+
}
|
|
12
|
+
export namespace Buffer {
|
|
13
|
+
export const type = isly.object<Buffer>({
|
|
14
|
+
type: isly.string("buffer"),
|
|
15
|
+
account: isly.string(),
|
|
16
|
+
currency: isly.string(),
|
|
17
|
+
minimum: isly.number(),
|
|
18
|
+
balance: isly.number(),
|
|
19
|
+
})
|
|
20
|
+
export function create(account: Account): Buffer[] {
|
|
21
|
+
const result: Buffer[] = []
|
|
22
|
+
for (const [currency, amount] of Object.entries(account.balance)) {
|
|
23
|
+
const minimum = account.conditions?.minimum?.[currency as isoly.Currency]
|
|
24
|
+
if (typeof minimum != "undefined" && minimum > amount)
|
|
25
|
+
result.push({
|
|
26
|
+
type: "buffer",
|
|
27
|
+
account: account.id,
|
|
28
|
+
currency: currency as isoly.Currency,
|
|
29
|
+
minimum,
|
|
30
|
+
balance: amount,
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
return result
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { isoly } from "isoly"
|
|
2
2
|
import { isly } from "isly"
|
|
3
|
+
import { Holidays } from "../../../Holidays"
|
|
4
|
+
import { Account } from "../../Account"
|
|
5
|
+
import { Transaction } from "../../Transaction"
|
|
3
6
|
|
|
4
7
|
export interface Unguarded {
|
|
5
8
|
type: "unguarded"
|
|
@@ -14,4 +17,30 @@ export namespace Unguarded {
|
|
|
14
17
|
currency: isly.string(),
|
|
15
18
|
transaction: isly.object<Unguarded["transaction"]>({ id: isly.string(), created: isly.string() }),
|
|
16
19
|
})
|
|
20
|
+
export function create(account: Account, transactions: Transaction[]): Unguarded[] {
|
|
21
|
+
const result: Unguarded[] = []
|
|
22
|
+
for (const [currency, amount] of Object.entries(account.balance)) {
|
|
23
|
+
let oldest: { id: string; date: isoly.Date; created: isoly.DateTime } | undefined = undefined
|
|
24
|
+
let remainder = amount
|
|
25
|
+
for (const transaction of transactions) {
|
|
26
|
+
if (transaction.amount > 0 && transaction.currency == currency && remainder > 0) {
|
|
27
|
+
remainder = isoly.Currency.subtract(currency, remainder, transaction.amount)
|
|
28
|
+
oldest = {
|
|
29
|
+
id: transaction.id,
|
|
30
|
+
date: isoly.DateTime.getDate(transaction.created),
|
|
31
|
+
created: transaction.created,
|
|
32
|
+
}
|
|
33
|
+
} else if (remainder < 0)
|
|
34
|
+
break
|
|
35
|
+
}
|
|
36
|
+
if (oldest && isoly.Date.now() > isoly.Date.nextBusinessDay(oldest.date, 3, Holidays.dates["England"]))
|
|
37
|
+
result.push({
|
|
38
|
+
type: "unguarded",
|
|
39
|
+
currency: currency as isoly.Currency,
|
|
40
|
+
date: oldest.date,
|
|
41
|
+
transaction: { id: oldest.id, created: oldest.created },
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
return result
|
|
45
|
+
}
|
|
17
46
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { isly } from "isly"
|
|
2
|
+
import { Buffer as WarningBuffer } from "./Buffer"
|
|
2
3
|
import { Overdraft as WarningOverdraft } from "./Overdraft"
|
|
3
4
|
import { Unguarded as WarningUnguarded } from "./Unguarded"
|
|
4
5
|
|
|
5
|
-
export type Warning = Warning.Overdraft | Warning.Unguarded
|
|
6
|
+
export type Warning = Warning.Overdraft | Warning.Unguarded | Warning.Buffer
|
|
6
7
|
|
|
7
8
|
export namespace Warning {
|
|
8
9
|
export import Overdraft = WarningOverdraft
|
|
9
10
|
export import Unguarded = WarningUnguarded
|
|
10
|
-
export
|
|
11
|
+
export import Buffer = WarningBuffer
|
|
12
|
+
export const type = isly.union<Warning, Overdraft, Unguarded, Buffer>(Overdraft.type, Unguarded.type, Buffer.type)
|
|
11
13
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { isoly } from "isoly";
|
|
2
|
+
import { isly } from "isly";
|
|
3
|
+
import { Account } from "../../Account";
|
|
4
|
+
export interface Buffer {
|
|
5
|
+
type: "buffer";
|
|
6
|
+
account: string;
|
|
7
|
+
currency: isoly.Currency;
|
|
8
|
+
minimum: number;
|
|
9
|
+
balance: number;
|
|
10
|
+
}
|
|
11
|
+
export declare namespace Buffer {
|
|
12
|
+
const type: isly.object.ExtendableType<Buffer>;
|
|
13
|
+
function create(account: Account): Buffer[];
|
|
14
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { isly } from "isly";
|
|
2
|
+
export var Buffer;
|
|
3
|
+
(function (Buffer) {
|
|
4
|
+
Buffer.type = isly.object({
|
|
5
|
+
type: isly.string("buffer"),
|
|
6
|
+
account: isly.string(),
|
|
7
|
+
currency: isly.string(),
|
|
8
|
+
minimum: isly.number(),
|
|
9
|
+
balance: isly.number(),
|
|
10
|
+
});
|
|
11
|
+
function create(account) {
|
|
12
|
+
const result = [];
|
|
13
|
+
for (const [currency, amount] of Object.entries(account.balance)) {
|
|
14
|
+
const minimum = account.conditions?.minimum?.[currency];
|
|
15
|
+
if (typeof minimum != "undefined" && minimum > amount)
|
|
16
|
+
result.push({
|
|
17
|
+
type: "buffer",
|
|
18
|
+
account: account.id,
|
|
19
|
+
currency: currency,
|
|
20
|
+
minimum,
|
|
21
|
+
balance: amount,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
Buffer.create = create;
|
|
27
|
+
})(Buffer || (Buffer = {}));
|
|
28
|
+
//# sourceMappingURL=Buffer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Buffer.js","sourceRoot":"../","sources":["Treasury/Snapshot/Warning/Buffer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAU3B,MAAM,KAAW,MAAM,CAuBtB;AAvBD,WAAiB,MAAM;IACT,WAAI,GAAG,IAAI,CAAC,MAAM,CAAS;QACvC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;QAC3B,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE;QACtB,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE;QACvB,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE;QACtB,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE;KACtB,CAAC,CAAA;IACF,SAAgB,MAAM,CAAC,OAAgB;QACtC,MAAM,MAAM,GAAa,EAAE,CAAA;QAC3B,KAAK,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YAClE,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,EAAE,OAAO,EAAE,CAAC,QAA0B,CAAC,CAAA;YACzE,IAAI,OAAO,OAAO,IAAI,WAAW,IAAI,OAAO,GAAG,MAAM;gBACpD,MAAM,CAAC,IAAI,CAAC;oBACX,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE,OAAO,CAAC,EAAE;oBACnB,QAAQ,EAAE,QAA0B;oBACpC,OAAO;oBACP,OAAO,EAAE,MAAM;iBACf,CAAC,CAAA;QACJ,CAAC;QACD,OAAO,MAAM,CAAA;IACd,CAAC;IAde,aAAM,SAcrB,CAAA;AACF,CAAC,EAvBgB,MAAM,KAAN,MAAM,QAuBtB"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { isoly } from "isoly";
|
|
2
2
|
import { isly } from "isly";
|
|
3
|
+
import { Account } from "../../Account";
|
|
4
|
+
import { Transaction } from "../../Transaction";
|
|
3
5
|
export interface Unguarded {
|
|
4
6
|
type: "unguarded";
|
|
5
7
|
date: isoly.Date;
|
|
@@ -11,4 +13,5 @@ export interface Unguarded {
|
|
|
11
13
|
}
|
|
12
14
|
export declare namespace Unguarded {
|
|
13
15
|
const type: isly.object.ExtendableType<Unguarded>;
|
|
16
|
+
function create(account: Account, transactions: Transaction[]): Unguarded[];
|
|
14
17
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { isoly } from "isoly";
|
|
1
2
|
import { isly } from "isly";
|
|
3
|
+
import { Holidays } from "../../../Holidays";
|
|
2
4
|
export var Unguarded;
|
|
3
5
|
(function (Unguarded) {
|
|
4
6
|
Unguarded.type = isly.object({
|
|
@@ -7,5 +9,33 @@ export var Unguarded;
|
|
|
7
9
|
currency: isly.string(),
|
|
8
10
|
transaction: isly.object({ id: isly.string(), created: isly.string() }),
|
|
9
11
|
});
|
|
12
|
+
function create(account, transactions) {
|
|
13
|
+
const result = [];
|
|
14
|
+
for (const [currency, amount] of Object.entries(account.balance)) {
|
|
15
|
+
let oldest = undefined;
|
|
16
|
+
let remainder = amount;
|
|
17
|
+
for (const transaction of transactions) {
|
|
18
|
+
if (transaction.amount > 0 && transaction.currency == currency && remainder > 0) {
|
|
19
|
+
remainder = isoly.Currency.subtract(currency, remainder, transaction.amount);
|
|
20
|
+
oldest = {
|
|
21
|
+
id: transaction.id,
|
|
22
|
+
date: isoly.DateTime.getDate(transaction.created),
|
|
23
|
+
created: transaction.created,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
else if (remainder < 0)
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
if (oldest && isoly.Date.now() > isoly.Date.nextBusinessDay(oldest.date, 3, Holidays.dates["England"]))
|
|
30
|
+
result.push({
|
|
31
|
+
type: "unguarded",
|
|
32
|
+
currency: currency,
|
|
33
|
+
date: oldest.date,
|
|
34
|
+
transaction: { id: oldest.id, created: oldest.created },
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
Unguarded.create = create;
|
|
10
40
|
})(Unguarded || (Unguarded = {}));
|
|
11
41
|
//# sourceMappingURL=Unguarded.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Unguarded.js","sourceRoot":"../","sources":["Treasury/Snapshot/Warning/Unguarded.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Unguarded.js","sourceRoot":"../","sources":["Treasury/Snapshot/Warning/Unguarded.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAU5C,MAAM,KAAW,SAAS,CAiCzB;AAjCD,WAAiB,SAAS;IACZ,cAAI,GAAG,IAAI,CAAC,MAAM,CAAY;QAC1C,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QAC9B,IAAI,E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CAAC,IAAI,CAAC;oBACX,IAAI,EAAE,WAAW;oBACjB,QAAQ,EAAE,QAA0B;oBACpC,IAAI,EAAE,MAAM,CAAC,IAAI;oBACjB,WAAW,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE;iBACvD,CAAC,CAAA;QACJ,CAAC;QACD,OAAO,MAAM,CAAA;IACd,CAAC;IAzBe,gBAAM,SAyBrB,CAAA;AACF,CAAC,EAjCgB,SAAS,KAAT,SAAS,QAiCzB"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { isly } from "isly";
|
|
2
|
+
import { Buffer as WarningBuffer } from "./Buffer";
|
|
2
3
|
import { Overdraft as WarningOverdraft } from "./Overdraft";
|
|
3
4
|
import { Unguarded as WarningUnguarded } from "./Unguarded";
|
|
4
|
-
export type Warning = Warning.Overdraft | Warning.Unguarded;
|
|
5
|
+
export type Warning = Warning.Overdraft | Warning.Unguarded | Warning.Buffer;
|
|
5
6
|
export declare namespace Warning {
|
|
6
7
|
export import Overdraft = WarningOverdraft;
|
|
7
8
|
export import Unguarded = WarningUnguarded;
|
|
9
|
+
export import Buffer = WarningBuffer;
|
|
8
10
|
const type: isly.Type<Warning>;
|
|
9
11
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { isly } from "isly";
|
|
2
|
+
import { Buffer as WarningBuffer } from "./Buffer";
|
|
2
3
|
import { Overdraft as WarningOverdraft } from "./Overdraft";
|
|
3
4
|
import { Unguarded as WarningUnguarded } from "./Unguarded";
|
|
4
5
|
export var Warning;
|
|
5
6
|
(function (Warning) {
|
|
6
7
|
Warning.Overdraft = WarningOverdraft;
|
|
7
8
|
Warning.Unguarded = WarningUnguarded;
|
|
8
|
-
Warning.
|
|
9
|
+
Warning.Buffer = WarningBuffer;
|
|
10
|
+
Warning.type = isly.union(Warning.Overdraft.type, Warning.Unguarded.type, Warning.Buffer.type);
|
|
9
11
|
})(Warning || (Warning = {}));
|
|
10
12
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"../","sources":["Treasury/Snapshot/Warning/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,SAAS,IAAI,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC3D,OAAO,EAAE,SAAS,IAAI,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAI3D,MAAM,KAAW,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../","sources":["Treasury/Snapshot/Warning/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,UAAU,CAAA;AAClD,OAAO,EAAE,SAAS,IAAI,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC3D,OAAO,EAAE,SAAS,IAAI,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAI3D,MAAM,KAAW,OAAO,CAKvB;AALD,WAAiB,OAAO;IACT,iBAAS,GAAG,gBAAgB,CAAA;IAC5B,iBAAS,GAAG,gBAAgB,CAAA;IAC5B,cAAM,GAAG,aAAa,CAAA;IACvB,YAAI,GAAG,IAAI,CAAC,KAAK,CAAwC,QAAA,SAAS,CAAC,IAAI,EAAE,QAAA,SAAS,CAAC,IAAI,EAAE,QAAA,MAAM,CAAC,IAAI,CAAC,CAAA;AACnH,CAAC,EALgB,OAAO,KAAP,OAAO,QAKvB"}
|