@riocrypto/common 1.0.2735 → 1.0.2737

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.
@@ -10,25 +10,27 @@ const formatLocalDate = (date) => {
10
10
  return `${year}-${month}-${day}`;
11
11
  };
12
12
  const getDaysBetweenAgreedTwoWaySettlementDateAndPaymentDate = ({ country, holidays, twoWaySettlementDate, deferredPaymentType, }) => {
13
- if (deferredPaymentType !== deferred_payment_type_1.DeferredPaymentType.OneDayAfter) {
13
+ const businessDaysToAdd = (0, deferred_payment_type_1.getDeferredPaymentBusinessDays)(deferredPaymentType);
14
+ if (businessDaysToAdd === 0) {
14
15
  return 0;
15
16
  }
16
17
  const timezone = (0, get_country_timezone_1.getCountryTimezone)(country);
17
18
  // Convert the two way settlement date to the country's timezone
18
19
  const settlementDateInCountryTZ = new Date(twoWaySettlementDate.toLocaleString("en-US", { timeZone: timezone }));
19
- // Find the next business day after the settlement date
20
- const nextBusinessDay = new Date(settlementDateInCountryTZ);
21
- nextBusinessDay.setDate(settlementDateInCountryTZ.getDate() + 1);
22
- while (true) {
23
- const isWeekend = nextBusinessDay.getDay() === 0 || nextBusinessDay.getDay() === 6;
24
- const isHoliday = holidays.dates.includes(formatLocalDate(nextBusinessDay));
20
+ // Walk forward one calendar day at a time, counting only business days,
21
+ // until the requested number of business days has been reached
22
+ const paymentDate = new Date(settlementDateInCountryTZ);
23
+ let businessDaysFound = 0;
24
+ while (businessDaysFound < businessDaysToAdd) {
25
+ paymentDate.setDate(paymentDate.getDate() + 1);
26
+ const isWeekend = paymentDate.getDay() === 0 || paymentDate.getDay() === 6;
27
+ const isHoliday = holidays.dates.includes(formatLocalDate(paymentDate));
25
28
  if (!isWeekend && !isHoliday) {
26
- break; // Found the next business day
29
+ businessDaysFound++;
27
30
  }
28
- nextBusinessDay.setDate(nextBusinessDay.getDate() + 1);
29
31
  }
30
- // Calculate the calendar days difference between settlement date and next business day
31
- const timeDifference = nextBusinessDay.getTime() - settlementDateInCountryTZ.getTime();
32
+ // Calculate the calendar days difference between settlement date and payment date
33
+ const timeDifference = paymentDate.getTime() - settlementDateInCountryTZ.getTime();
32
34
  const daysDifference = Math.ceil(timeDifference / (1000 * 3600 * 24));
33
35
  return daysDifference;
34
36
  };
package/build/index.d.ts CHANGED
@@ -353,6 +353,7 @@ export * from "./types/bridge-transfer";
353
353
  export * from "./types/bridge-external-account";
354
354
  export * from "./types/bridge-liquidation-address";
355
355
  export * from "./types/admin-task-type";
356
+ export * from "./types/transaction-monitoring";
356
357
  export * from "./types/admin-task-status";
357
358
  export * from "./types/admin-task";
358
359
  export * from "./types/import-order-input";
package/build/index.js CHANGED
@@ -369,6 +369,7 @@ __exportStar(require("./types/bridge-transfer"), exports);
369
369
  __exportStar(require("./types/bridge-external-account"), exports);
370
370
  __exportStar(require("./types/bridge-liquidation-address"), exports);
371
371
  __exportStar(require("./types/admin-task-type"), exports);
372
+ __exportStar(require("./types/transaction-monitoring"), exports);
372
373
  __exportStar(require("./types/admin-task-status"), exports);
373
374
  __exportStar(require("./types/admin-task"), exports);
374
375
  __exportStar(require("./types/import-order-input"), exports);
@@ -1,5 +1,7 @@
1
1
  export declare enum DeferredPaymentType {
2
2
  None = "none",
3
3
  EndOfDay = "endOfDay",
4
- OneDayAfter = "oneDayAfter"
4
+ OneDayAfter = "oneDayAfter",
5
+ TwoDaysAfter = "twoDaysAfter"
5
6
  }
7
+ export declare const getDeferredPaymentBusinessDays: (deferredPaymentType: DeferredPaymentType) => number;
@@ -1,9 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DeferredPaymentType = void 0;
3
+ exports.getDeferredPaymentBusinessDays = exports.DeferredPaymentType = void 0;
4
4
  var DeferredPaymentType;
5
5
  (function (DeferredPaymentType) {
6
6
  DeferredPaymentType["None"] = "none";
7
7
  DeferredPaymentType["EndOfDay"] = "endOfDay";
8
8
  DeferredPaymentType["OneDayAfter"] = "oneDayAfter";
9
+ DeferredPaymentType["TwoDaysAfter"] = "twoDaysAfter";
9
10
  })(DeferredPaymentType = exports.DeferredPaymentType || (exports.DeferredPaymentType = {}));
11
+ const getDeferredPaymentBusinessDays = (deferredPaymentType) => {
12
+ switch (deferredPaymentType) {
13
+ case DeferredPaymentType.OneDayAfter:
14
+ return 1;
15
+ case DeferredPaymentType.TwoDaysAfter:
16
+ return 2;
17
+ default:
18
+ return 0;
19
+ }
20
+ };
21
+ exports.getDeferredPaymentBusinessDays = getDeferredPaymentBusinessDays;
@@ -0,0 +1,22 @@
1
+ export declare enum TransactionMonitoringRule {
2
+ Structuring = "structuring",
3
+ HighVolumeMonthly = "highVolumeMonthly",
4
+ HighVolumeSingleTransaction = "highVolumeSingleTransaction",
5
+ DormantAccount = "dormantAccount",
6
+ ChangeOfBehaviorVolumeUp = "changeOfBehaviorVolumeUp",
7
+ ChangeOfBehaviorVolumeDown = "changeOfBehaviorVolumeDown",
8
+ ChangeOfBehaviorTransactionCountUp = "changeOfBehaviorTransactionCountUp",
9
+ ChangeOfBehaviorTransactionCountDown = "changeOfBehaviorTransactionCountDown",
10
+ HighRiskBankCounterparty = "highRiskBankCounterparty",
11
+ WatchedBankCounterparty = "watchedBankCounterparty"
12
+ }
13
+ export declare enum TransactionMonitoringAlertSeverity {
14
+ SoftStop = "softStop",
15
+ HardStop = "hardStop",
16
+ UrgentReview = "urgentReview",
17
+ HighRiskActivity = "highRiskActivity"
18
+ }
19
+ export declare enum TransactionMonitoringDirection {
20
+ Inbound = "inbound",
21
+ Outbound = "outbound"
22
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TransactionMonitoringDirection = exports.TransactionMonitoringAlertSeverity = exports.TransactionMonitoringRule = void 0;
4
+ // Scenarios from the "Rio x Artu TM" alerting matrix. Each value is stored on
5
+ // persisted alerts, so renaming one changes the dedup key for that scenario.
6
+ var TransactionMonitoringRule;
7
+ (function (TransactionMonitoringRule) {
8
+ TransactionMonitoringRule["Structuring"] = "structuring";
9
+ TransactionMonitoringRule["HighVolumeMonthly"] = "highVolumeMonthly";
10
+ TransactionMonitoringRule["HighVolumeSingleTransaction"] = "highVolumeSingleTransaction";
11
+ TransactionMonitoringRule["DormantAccount"] = "dormantAccount";
12
+ TransactionMonitoringRule["ChangeOfBehaviorVolumeUp"] = "changeOfBehaviorVolumeUp";
13
+ TransactionMonitoringRule["ChangeOfBehaviorVolumeDown"] = "changeOfBehaviorVolumeDown";
14
+ TransactionMonitoringRule["ChangeOfBehaviorTransactionCountUp"] = "changeOfBehaviorTransactionCountUp";
15
+ TransactionMonitoringRule["ChangeOfBehaviorTransactionCountDown"] = "changeOfBehaviorTransactionCountDown";
16
+ TransactionMonitoringRule["HighRiskBankCounterparty"] = "highRiskBankCounterparty";
17
+ TransactionMonitoringRule["WatchedBankCounterparty"] = "watchedBankCounterparty";
18
+ })(TransactionMonitoringRule = exports.TransactionMonitoringRule || (exports.TransactionMonitoringRule = {}));
19
+ var TransactionMonitoringAlertSeverity;
20
+ (function (TransactionMonitoringAlertSeverity) {
21
+ TransactionMonitoringAlertSeverity["SoftStop"] = "softStop";
22
+ TransactionMonitoringAlertSeverity["HardStop"] = "hardStop";
23
+ TransactionMonitoringAlertSeverity["UrgentReview"] = "urgentReview";
24
+ TransactionMonitoringAlertSeverity["HighRiskActivity"] = "highRiskActivity";
25
+ })(TransactionMonitoringAlertSeverity = exports.TransactionMonitoringAlertSeverity || (exports.TransactionMonitoringAlertSeverity = {}));
26
+ var TransactionMonitoringDirection;
27
+ (function (TransactionMonitoringDirection) {
28
+ TransactionMonitoringDirection["Inbound"] = "inbound";
29
+ TransactionMonitoringDirection["Outbound"] = "outbound";
30
+ })(TransactionMonitoringDirection = exports.TransactionMonitoringDirection || (exports.TransactionMonitoringDirection = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common",
3
- "version": "1.0.2735",
3
+ "version": "1.0.2737",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",