@riocrypto/common-server 1.0.1437 → 1.0.1439

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.
@@ -23,7 +23,7 @@ class InvopopClient {
23
23
  this.baseUrl = "https://api.invopop.com";
24
24
  }
25
25
  createJob(order, user) {
26
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
26
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
27
27
  return __awaiter(this, void 0, void 0, function* () {
28
28
  const uuid = (0, uuid_1.v1)();
29
29
  const operationDate = new Date(order.createdAt);
@@ -55,7 +55,7 @@ class InvopopClient {
55
55
  customerName = (_h = user.invoicing) === null || _h === void 0 ? void 0 : _h.MX.fiscalName.toLocaleUpperCase();
56
56
  postalCode = (_l = (_k = (_j = user.onboarding) === null || _j === void 0 ? void 0 : _j.MX) === null || _k === void 0 ? void 0 : _k.address) === null || _l === void 0 ? void 0 : _l.postalCode;
57
57
  rfc = (_o = (_m = user.onboarding) === null || _m === void 0 ? void 0 : _m.MX) === null || _o === void 0 ? void 0 : _o.taxId;
58
- fiscalRegimenCode = (_p = user.invoicing) === null || _p === void 0 ? void 0 : _p.MX.fiscalRegimenCode;
58
+ fiscalRegimenCode = (_q = (_p = user.invoicing) === null || _p === void 0 ? void 0 : _p.MX.fiscalRegimenCode) === null || _q === void 0 ? void 0 : _q.toString();
59
59
  cfdiUseCode = "G03";
60
60
  }
61
61
  }
@@ -129,7 +129,7 @@ class InvopopClient {
129
129
  item: {
130
130
  name: "Facilitación de Compra-Venta de Activos Virtuales",
131
131
  identities: [{ key: "mx-cfdi-prod-serv", code: "80151500" }],
132
- price: (_q = order.actualFees.platformFeeFiat) === null || _q === void 0 ? void 0 : _q.toFixed(2),
132
+ price: (_r = order.actualFees.platformFeeFiat) === null || _r === void 0 ? void 0 : _r.toFixed(2),
133
133
  },
134
134
  taxes: [
135
135
  {
@@ -1,5 +1,6 @@
1
1
  import { Fiat } from "@riocrypto/common";
2
- export declare const getExchangeRates: (fiat: Fiat) => Promise<{
2
+ import { Mongoose } from "mongoose";
3
+ export declare const getExchangeRates: (mongoose: Mongoose, fiat: Fiat) => Promise<{
3
4
  conversionRateToUSD: number;
4
5
  conversionRateToUSDWithMarkups?: number | undefined;
5
6
  conversionRateFromUSD: number;
@@ -12,7 +12,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.getExchangeRates = void 0;
13
13
  const common_1 = require("@riocrypto/common");
14
14
  const polygon_client_1 = require("../clients/polygon-client");
15
- const getExchangeRates = (fiat) => __awaiter(void 0, void 0, void 0, function* () {
15
+ const rio_settings_1 = require("../models/rio-settings");
16
+ const getExchangeRates = (mongoose, fiat) => __awaiter(void 0, void 0, void 0, function* () {
17
+ const RioSettings = (0, rio_settings_1.buildRioSettings)(mongoose);
18
+ const rioSettings = yield RioSettings.findOne();
19
+ if (!rioSettings) {
20
+ throw new Error("Rio settings not found");
21
+ }
22
+ const afterHoursExchangeRateMarkup = rioSettings.afterHoursExchangeRateMarkup;
16
23
  const polygonClient = yield (0, polygon_client_1.buildPolygonClient)();
17
24
  const conversionRateToUSD = fiat === common_1.Fiat.PEN
18
25
  ? (yield polygonClient.getExchangeRateData(fiat, common_1.Fiat.USD)).bid
@@ -30,8 +37,10 @@ const getExchangeRates = (fiat) => __awaiter(void 0, void 0, void 0, function* (
30
37
  const minutes = peruTime.getMinutes();
31
38
  // Check if it's between 2:10 PM and 12:00 AM
32
39
  if ((hours === 14 && minutes >= 10) || hours > 14 || hours === 0) {
33
- conversionRateToUSDWithMarkups = conversionRateToUSD * 0.9975;
34
- conversionRateFromUSDWithMarkups = conversionRateFromUSD * 0.9975;
40
+ conversionRateToUSDWithMarkups =
41
+ conversionRateToUSD * (1 - afterHoursExchangeRateMarkup);
42
+ conversionRateFromUSDWithMarkups =
43
+ conversionRateFromUSD * (1 - afterHoursExchangeRateMarkup);
35
44
  }
36
45
  }
37
46
  if (fiat === common_1.Fiat.MXN) {
@@ -42,12 +51,16 @@ const getExchangeRates = (fiat) => __awaiter(void 0, void 0, void 0, function* (
42
51
  if ((hours === 15 && minutes >= 45) ||
43
52
  (hours > 15 && hours < 24) ||
44
53
  (hours === 0 && minutes === 0)) {
45
- conversionRateToUSDWithMarkups = conversionRateToUSD * 0.9975;
46
- conversionRateFromUSDWithMarkups = conversionRateFromUSD * 0.9975;
54
+ conversionRateToUSDWithMarkups =
55
+ conversionRateToUSD * (1 - afterHoursExchangeRateMarkup);
56
+ conversionRateFromUSDWithMarkups =
57
+ conversionRateFromUSD * (1 - afterHoursExchangeRateMarkup);
47
58
  }
48
59
  else if (hours >= 0 && hours < 7) {
49
- conversionRateToUSDWithMarkups = conversionRateToUSD * 0.9975;
50
- conversionRateFromUSDWithMarkups = conversionRateFromUSD * 0.9975;
60
+ conversionRateToUSDWithMarkups =
61
+ conversionRateToUSD * (1 - afterHoursExchangeRateMarkup);
62
+ conversionRateFromUSDWithMarkups =
63
+ conversionRateFromUSD * (1 - afterHoursExchangeRateMarkup);
51
64
  }
52
65
  }
53
66
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.1437",
3
+ "version": "1.0.1439",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -27,7 +27,7 @@
27
27
  "@everapi/currencyapi-js": "^1.0.6",
28
28
  "@google-cloud/storage": "^6.9.5",
29
29
  "@google-cloud/vision": "^4.0.2",
30
- "@riocrypto/common": "^1.0.1274",
30
+ "@riocrypto/common": "^1.0.1275",
31
31
  "@types/express": "^4.17.13",
32
32
  "axios": "^0.27.2",
33
33
  "ccxt": "^3.0.30",