@riocrypto/common-server 1.0.1433 → 1.0.1435

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, _r, _s, _t, _u;
26
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
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);
@@ -41,22 +41,30 @@ class InvopopClient {
41
41
  let customerName;
42
42
  let postalCode;
43
43
  let rfc;
44
+ let fiscalRegimenCode;
45
+ let cfdiUseCode;
44
46
  if (((_c = (_b = (_a = user.onboarding) === null || _a === void 0 ? void 0 : _a.MX) === null || _b === void 0 ? void 0 : _b.address) === null || _c === void 0 ? void 0 : _c.country) === common_1.CountryOfOrigin.Mexico) {
45
47
  if (!((_e = (_d = user.invoicing) === null || _d === void 0 ? void 0 : _d.MX) === null || _e === void 0 ? void 0 : _e.shouldInvoice)) {
46
48
  customerName = "PÚBLICO EN GENERAL";
47
49
  postalCode = "66260";
48
50
  rfc = "XAXX010101000";
51
+ fiscalRegimenCode = "616";
52
+ cfdiUseCode = "S01";
49
53
  }
50
54
  else if ((_g = (_f = user.invoicing) === null || _f === void 0 ? void 0 : _f.MX) === null || _g === void 0 ? void 0 : _g.fiscalName) {
51
55
  customerName = (_h = user.invoicing) === null || _h === void 0 ? void 0 : _h.MX.fiscalName.toLocaleUpperCase();
52
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;
53
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;
59
+ cfdiUseCode = "G03";
54
60
  }
55
61
  }
56
62
  else {
57
63
  customerName = (0, common_1.getUserName)(user).toLocaleUpperCase();
58
64
  postalCode = "66260";
59
65
  rfc = "XEXX010101000";
66
+ fiscalRegimenCode = "616";
67
+ cfdiUseCode = "S01";
60
68
  }
61
69
  if (!customerName) {
62
70
  throw new Error("Customer name not found");
@@ -64,6 +72,15 @@ class InvopopClient {
64
72
  if (!postalCode) {
65
73
  throw new Error("Postal code not found");
66
74
  }
75
+ if (!rfc) {
76
+ throw new Error("RFC not found");
77
+ }
78
+ if (!fiscalRegimenCode) {
79
+ throw new Error("Fiscal regimen code not found");
80
+ }
81
+ if (!cfdiUseCode) {
82
+ throw new Error("CFDI use code not found");
83
+ }
67
84
  const { data } = yield axios_1.default.put(`${this.baseUrl}/transform/v1/jobs/${uuid}`, {
68
85
  workflow_id: "5b123900-1035-4c8c-a97a-36b940d7a21e",
69
86
  data: {
@@ -97,11 +114,11 @@ class InvopopClient {
97
114
  identities: [
98
115
  {
99
116
  key: "mx-cfdi-fiscal-regime",
100
- code: ((_r = (_q = (_p = user.invoicing) === null || _p === void 0 ? void 0 : _p.MX) === null || _q === void 0 ? void 0 : _q.fiscalRegimenCode) === null || _r === void 0 ? void 0 : _r.toString()) || "616",
117
+ code: fiscalRegimenCode,
101
118
  },
102
119
  {
103
120
  key: "mx-cfdi-use",
104
- code: ((_t = (_s = user.invoicing) === null || _s === void 0 ? void 0 : _s.MX) === null || _t === void 0 ? void 0 : _t.shouldInvoice) ? "G03" : "S01",
121
+ code: cfdiUseCode,
105
122
  },
106
123
  ],
107
124
  },
@@ -112,7 +129,7 @@ class InvopopClient {
112
129
  item: {
113
130
  name: "Facilitación de Compra-Venta de Activos Virtuales",
114
131
  identities: [{ key: "mx-cfdi-prod-serv", code: "80151500" }],
115
- price: (_u = order.actualFees.platformFeeFiat) === null || _u === void 0 ? void 0 : _u.toFixed(2),
132
+ price: (_q = order.actualFees.platformFeeFiat) === null || _q === void 0 ? void 0 : _q.toFixed(2),
116
133
  },
117
134
  taxes: [
118
135
  {
@@ -30,8 +30,8 @@ const getExchangeRates = (fiat) => __awaiter(void 0, void 0, void 0, function* (
30
30
  const minutes = peruTime.getMinutes();
31
31
  // Check if it's between 2:10 PM and 12:00 AM
32
32
  if ((hours === 14 && minutes >= 10) || hours > 14 || hours === 0) {
33
- conversionRateToUSDWithMarkups = conversionRateToUSD * 0.992;
34
- conversionRateFromUSDWithMarkups = conversionRateFromUSD * 0.992;
33
+ conversionRateToUSDWithMarkups = conversionRateToUSD * 0.9975;
34
+ conversionRateFromUSDWithMarkups = conversionRateFromUSD * 0.9975;
35
35
  }
36
36
  }
37
37
  if (fiat === common_1.Fiat.MXN) {
@@ -42,12 +42,12 @@ const getExchangeRates = (fiat) => __awaiter(void 0, void 0, void 0, function* (
42
42
  if ((hours === 15 && minutes >= 45) ||
43
43
  (hours > 15 && hours < 24) ||
44
44
  (hours === 0 && minutes === 0)) {
45
- conversionRateToUSDWithMarkups = conversionRateToUSD * 0.992;
46
- conversionRateFromUSDWithMarkups = conversionRateFromUSD * 0.992;
45
+ conversionRateToUSDWithMarkups = conversionRateToUSD * 0.9975;
46
+ conversionRateFromUSDWithMarkups = conversionRateFromUSD * 0.9975;
47
47
  }
48
48
  else if (hours >= 0 && hours < 7) {
49
- conversionRateToUSDWithMarkups = conversionRateToUSD * 0.991;
50
- conversionRateFromUSDWithMarkups = conversionRateFromUSD * 0.991;
49
+ conversionRateToUSDWithMarkups = conversionRateToUSD * 0.9975;
50
+ conversionRateFromUSDWithMarkups = conversionRateFromUSD * 0.9975;
51
51
  }
52
52
  }
53
53
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.1433",
3
+ "version": "1.0.1435",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",