@pax2pay/model-banking 0.1.338 → 0.1.340
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/Treasury/Snapshot/Fiat.ts +13 -0
- package/Treasury/Snapshot/Warning/Unguarded.ts +46 -0
- package/Treasury/Snapshot/Warning/index.ts +7 -3
- package/Treasury/Snapshot/index.ts +2 -0
- package/dist/Treasury/Snapshot/Fiat.d.ts +12 -0
- package/dist/Treasury/Snapshot/Fiat.js +2 -0
- package/dist/Treasury/Snapshot/Fiat.js.map +1 -0
- package/dist/Treasury/Snapshot/Warning/Unguarded.d.ts +17 -0
- package/dist/Treasury/Snapshot/Warning/Unguarded.js +41 -0
- package/dist/Treasury/Snapshot/Warning/Unguarded.js.map +1 -0
- package/dist/Treasury/Snapshot/Warning/index.d.ts +7 -3
- package/dist/Treasury/Snapshot/Warning/index.js +6 -2
- package/dist/Treasury/Snapshot/Warning/index.js.map +1 -1
- package/dist/Treasury/Snapshot/index.d.ts +2 -0
- package/dist/Treasury/Snapshot/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { isoly } from "isoly"
|
|
2
|
+
import { Supplier } from "../../Supplier"
|
|
3
|
+
import { Balance } from "../Balance"
|
|
4
|
+
import { Warning } from "./Warning"
|
|
5
|
+
|
|
6
|
+
export interface Fiat {
|
|
7
|
+
supplier: Supplier | "total"
|
|
8
|
+
account: string
|
|
9
|
+
timestamp: isoly.DateTime
|
|
10
|
+
type: "safeguarded" | "unsafe" | "other" | "buffer"
|
|
11
|
+
balances: Balance
|
|
12
|
+
warnings?: Warning[]
|
|
13
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { isoly } from "isoly"
|
|
2
|
+
import { isly } from "isly"
|
|
3
|
+
import { Holidays } from "../../../Holidays"
|
|
4
|
+
import { Account } from "../../Account"
|
|
5
|
+
import { Transaction } from "../../Transaction"
|
|
6
|
+
|
|
7
|
+
export interface Unguarded {
|
|
8
|
+
type: "unguarded"
|
|
9
|
+
date: isoly.Date
|
|
10
|
+
currency: isoly.Currency
|
|
11
|
+
transaction: { id: string; created: isoly.DateTime }
|
|
12
|
+
}
|
|
13
|
+
export namespace Unguarded {
|
|
14
|
+
export const type = isly.object<Unguarded>({
|
|
15
|
+
type: isly.string("unguarded"),
|
|
16
|
+
date: isly.string(),
|
|
17
|
+
currency: isly.string(),
|
|
18
|
+
transaction: isly.object<Unguarded["transaction"]>({ id: isly.string(), created: isly.string() }),
|
|
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
|
+
}
|
|
46
|
+
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isly } from "isly"
|
|
2
|
+
import { Overdraft as WarningOverdraft } from "./Overdraft"
|
|
3
|
+
import { Unguarded as WarningUnguarded } from "./Unguarded"
|
|
2
4
|
|
|
3
|
-
export type Warning = Overdraft
|
|
5
|
+
export type Warning = Warning.Overdraft | Warning.Unguarded
|
|
4
6
|
|
|
5
7
|
export namespace Warning {
|
|
6
|
-
export
|
|
8
|
+
export import Overdraft = WarningOverdraft
|
|
9
|
+
export import Unguarded = WarningUnguarded
|
|
10
|
+
export const type = isly.union<Warning, Overdraft, Unguarded>(Overdraft.type, Unguarded.type)
|
|
7
11
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isoly } from "isoly"
|
|
2
2
|
import { isly } from "isly"
|
|
3
3
|
import { Emoney as SnapshotEmoney } from "./Emoney"
|
|
4
|
+
import { Fiat as SnapshotFiat } from "./Fiat"
|
|
4
5
|
import { Fragment as SnapshotFragment } from "./Fragment"
|
|
5
6
|
import { funding as snapshotFunding } from "./funding"
|
|
6
7
|
import { Warning as SnapshotWarning } from "./Warning"
|
|
@@ -12,5 +13,6 @@ export namespace Snapshot {
|
|
|
12
13
|
export import Warning = SnapshotWarning
|
|
13
14
|
export import funding = snapshotFunding
|
|
14
15
|
export type Emoney = SnapshotEmoney
|
|
16
|
+
export type Fiat = SnapshotFiat
|
|
15
17
|
export const type = isly.record(isly.fromIs("Currency", isoly.Currency.is), Fragment.type)
|
|
16
18
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { isoly } from "isoly";
|
|
2
|
+
import { Supplier } from "../../Supplier";
|
|
3
|
+
import { Balance } from "../Balance";
|
|
4
|
+
import { Warning } from "./Warning";
|
|
5
|
+
export interface Fiat {
|
|
6
|
+
supplier: Supplier | "total";
|
|
7
|
+
account: string;
|
|
8
|
+
timestamp: isoly.DateTime;
|
|
9
|
+
type: "safeguarded" | "unsafe" | "other" | "buffer";
|
|
10
|
+
balances: Balance;
|
|
11
|
+
warnings?: Warning[];
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Fiat.js","sourceRoot":"../","sources":["Treasury/Snapshot/Fiat.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { isoly } from "isoly";
|
|
2
|
+
import { isly } from "isly";
|
|
3
|
+
import { Account } from "../../Account";
|
|
4
|
+
import { Transaction } from "../../Transaction";
|
|
5
|
+
export interface Unguarded {
|
|
6
|
+
type: "unguarded";
|
|
7
|
+
date: isoly.Date;
|
|
8
|
+
currency: isoly.Currency;
|
|
9
|
+
transaction: {
|
|
10
|
+
id: string;
|
|
11
|
+
created: isoly.DateTime;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export declare namespace Unguarded {
|
|
15
|
+
const type: isly.object.ExtendableType<Unguarded>;
|
|
16
|
+
function create(account: Account, transactions: Transaction[]): Unguarded[];
|
|
17
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { isoly } from "isoly";
|
|
2
|
+
import { isly } from "isly";
|
|
3
|
+
import { Holidays } from "../../../Holidays";
|
|
4
|
+
export var Unguarded;
|
|
5
|
+
(function (Unguarded) {
|
|
6
|
+
Unguarded.type = isly.object({
|
|
7
|
+
type: isly.string("unguarded"),
|
|
8
|
+
date: isly.string(),
|
|
9
|
+
currency: isly.string(),
|
|
10
|
+
transaction: isly.object({ id: isly.string(), created: isly.string() }),
|
|
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;
|
|
40
|
+
})(Unguarded || (Unguarded = {}));
|
|
41
|
+
//# sourceMappingURL=Unguarded.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,EAAE,IAAI,CAAC,MAAM,EAAE;QACnB,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE;QACvB,WAAW,EAAE,IAAI,CAAC,MAAM,CAA2B,EAAE,EAAE,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;KACjG,CAAC,CAAA;IACF,SAAgB,MAAM,CAAC,OAAgB,EAAE,YAA2B;QACnE,MAAM,MAAM,GAAgB,EAAE,CAAA;QAC9B,KAAK,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,IAA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 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { isly } from "isly";
|
|
2
|
+
import { Overdraft as WarningOverdraft } from "./Overdraft";
|
|
3
|
+
import { Unguarded as WarningUnguarded } from "./Unguarded";
|
|
4
|
+
export type Warning = Warning.Overdraft | Warning.Unguarded;
|
|
3
5
|
export declare namespace Warning {
|
|
4
|
-
|
|
6
|
+
export import Overdraft = WarningOverdraft;
|
|
7
|
+
export import Unguarded = WarningUnguarded;
|
|
8
|
+
const type: isly.Type<Warning>;
|
|
5
9
|
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isly } from "isly";
|
|
2
|
+
import { Overdraft as WarningOverdraft } from "./Overdraft";
|
|
3
|
+
import { Unguarded as WarningUnguarded } from "./Unguarded";
|
|
2
4
|
export var Warning;
|
|
3
5
|
(function (Warning) {
|
|
4
|
-
Warning.
|
|
6
|
+
Warning.Overdraft = WarningOverdraft;
|
|
7
|
+
Warning.Unguarded = WarningUnguarded;
|
|
8
|
+
Warning.type = isly.union(Warning.Overdraft.type, Warning.Unguarded.type);
|
|
5
9
|
})(Warning || (Warning = {}));
|
|
6
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"../","sources":["Treasury/Snapshot/Warning/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;
|
|
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,CAIvB;AAJD,WAAiB,OAAO;IACT,iBAAS,GAAG,gBAAgB,CAAA;IAC5B,iBAAS,GAAG,gBAAgB,CAAA;IAC7B,YAAI,GAAG,IAAI,CAAC,KAAK,CAAgC,QAAA,SAAS,CAAC,IAAI,EAAE,QAAA,SAAS,CAAC,IAAI,CAAC,CAAA;AAC9F,CAAC,EAJgB,OAAO,KAAP,OAAO,QAIvB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isoly } from "isoly";
|
|
2
2
|
import { isly } from "isly";
|
|
3
3
|
import { Emoney as SnapshotEmoney } from "./Emoney";
|
|
4
|
+
import { Fiat as SnapshotFiat } from "./Fiat";
|
|
4
5
|
import { Fragment as SnapshotFragment } from "./Fragment";
|
|
5
6
|
import { funding as snapshotFunding } from "./funding";
|
|
6
7
|
import { Warning as SnapshotWarning } from "./Warning";
|
|
@@ -10,6 +11,7 @@ export declare namespace Snapshot {
|
|
|
10
11
|
export import Warning = SnapshotWarning;
|
|
11
12
|
export import funding = snapshotFunding;
|
|
12
13
|
type Emoney = SnapshotEmoney;
|
|
14
|
+
type Fiat = SnapshotFiat;
|
|
13
15
|
const type: isly.Type<{
|
|
14
16
|
BTN: any;
|
|
15
17
|
CHE: any;
|
|
@@ -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;
|
|
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;AAG3B,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,CAOxB;AAPD,WAAiB,QAAQ;IACV,iBAAQ,GAAG,gBAAgB,CAAA;IAC3B,gBAAO,GAAG,eAAe,CAAA;IACzB,gBAAO,GAAG,eAAe,CAAA;IAG1B,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,EAPgB,QAAQ,KAAR,QAAQ,QAOxB"}
|