@riocrypto/common 1.0.1925 → 1.0.1926

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,3 @@
1
+ import { Order } from "../types/order";
2
+ import { User } from "../types/user";
3
+ export declare const getCanDisburseWithoutCosigner: (user: User, order: Order) => boolean | undefined;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCanDisburseWithoutCosigner = void 0;
4
+ const side_1 = require("../types/side");
5
+ const user_attribute_1 = require("../types/user-attribute");
6
+ const getCanDisburseWithoutCosigner = (user, order) => {
7
+ var _a, _b, _c, _d;
8
+ // If between 8am and 3:40pm Mexico City time, check if user has disburseMorningBuyOrdersWithoutCosigner or disburseMorningSellOrdersWithoutCosigner
9
+ // If between 3:40pm and 8am Mexico City time, check if user has disburseEveningBuyOrdersWithoutCosigner or disburseEveningSellOrdersWithoutCosigner
10
+ // Else return false
11
+ const now = new Date();
12
+ const mexicoCityTime = new Date(now.toLocaleString("en-US", { timeZone: "America/Mexico_City" }));
13
+ const currentTime = mexicoCityTime.getTime();
14
+ // Create time boundaries for morning and evening periods
15
+ const morningStart = new Date(mexicoCityTime);
16
+ morningStart.setHours(8, 0, 0, 0);
17
+ const morningEnd = new Date(mexicoCityTime);
18
+ morningEnd.setHours(15, 40, 0, 0);
19
+ const eveningStart = new Date(mexicoCityTime);
20
+ eveningStart.setHours(15, 40, 0, 0);
21
+ const eveningEnd = new Date(mexicoCityTime);
22
+ eveningEnd.setHours(8, 0, 0, 0);
23
+ // Check if current time is in morning period (8:00 AM - 3:40 PM)
24
+ if (currentTime >= morningStart.getTime() &&
25
+ currentTime < morningEnd.getTime()) {
26
+ return order.side === side_1.Side.Buy
27
+ ? (_a = user.attributes) === null || _a === void 0 ? void 0 : _a.includes(user_attribute_1.UserAttribute.disburseMorningBuyOrdersWithoutCosigner)
28
+ : (_b = user.attributes) === null || _b === void 0 ? void 0 : _b.includes(user_attribute_1.UserAttribute.disburseMorningSellOrdersWithoutCosigner);
29
+ }
30
+ // Check if current time is in evening period (3:40 PM - 8:00 AM next day)
31
+ // For evening period, we need to handle the case where it spans across midnight
32
+ const isEveningPeriod = currentTime >= eveningStart.getTime() || currentTime < eveningEnd.getTime();
33
+ if (isEveningPeriod) {
34
+ return order.side === side_1.Side.Buy
35
+ ? (_c = user.attributes) === null || _c === void 0 ? void 0 : _c.includes(user_attribute_1.UserAttribute.disburseEveningBuyOrdersWithoutCosigner)
36
+ : (_d = user.attributes) === null || _d === void 0 ? void 0 : _d.includes(user_attribute_1.UserAttribute.disburseEveningSellOrdersWithoutCosigner);
37
+ }
38
+ return false;
39
+ };
40
+ exports.getCanDisburseWithoutCosigner = getCanDisburseWithoutCosigner;
package/build/index.d.ts CHANGED
@@ -374,6 +374,7 @@ export * from "./helpers/humanize-admin-auth-role";
374
374
  export * from "./helpers/humanize-auth-role";
375
375
  export * from "./helpers/get-base-url";
376
376
  export * from "./helpers/get-currency-with-country";
377
+ export * from "./helpers/get-can-disburse-without-cosigner";
377
378
  export * from "./helpers/is-bitso-bank-account";
378
379
  export * from "./constants/mexico-fiscal-regimens";
379
380
  export * from "./constants/mexican-banks";
package/build/index.js CHANGED
@@ -390,6 +390,7 @@ __exportStar(require("./helpers/humanize-admin-auth-role"), exports);
390
390
  __exportStar(require("./helpers/humanize-auth-role"), exports);
391
391
  __exportStar(require("./helpers/get-base-url"), exports);
392
392
  __exportStar(require("./helpers/get-currency-with-country"), exports);
393
+ __exportStar(require("./helpers/get-can-disburse-without-cosigner"), exports);
393
394
  __exportStar(require("./helpers/is-bitso-bank-account"), exports);
394
395
  __exportStar(require("./constants/mexico-fiscal-regimens"), exports);
395
396
  __exportStar(require("./constants/mexican-banks"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common",
3
- "version": "1.0.1925",
3
+ "version": "1.0.1926",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",