@pax2pay/model-banking 0.1.339 → 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.
@@ -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,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":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAQ3B,MAAM,KAAW,SAAS,CAOzB;AAPD,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;Q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AAG,CAAC,IAAI,WAAW,CAAC,QAAQ,IAAI,QAAQ,IAAI,SAAS,GAAG,CAAC,EAAE,CAAC;oBACjF,SAAS,GAAG,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;oBAC5E,MAAM,GAAG;wBACR,EAAE,EAAE,WAAW,CAAC,EAAE;wBAClB,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC;wBACjD,OAAO,EAAE,WAAW,CAAC,OAAO;qBAC5B,CAAA;gBACF,CAAC;qBAAM,IAAI,SAAS,GAAG,CAAC;oBACvB,MAAK;YACP,CAAC;YACD,IAAI,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;gBACrG,MAAM,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pax2pay/model-banking",
3
- "version": "0.1.339",
3
+ "version": "0.1.340",
4
4
  "description": "Library containing data model types and functions for the Pax2Pay Banking API.",
5
5
  "author": "Pax2Pay Ltd",
6
6
  "license": "MIT",