@riocrypto/common-server 1.0.1430 → 1.0.1432

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;
26
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
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);
@@ -38,6 +38,32 @@ class InvopopClient {
38
38
  const issueMonth = String(issueDate.getMonth() + 1).padStart(2, "0"); // Month is zero-indexed
39
39
  const issueDay = String(issueDate.getDate()).padStart(2, "0");
40
40
  const issueDateFormatted = `${issueYear}-${issueMonth}-${issueDay}`;
41
+ let customerName;
42
+ let postalCode;
43
+ let rfc;
44
+ 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
+ if (!((_e = (_d = user.invoicing) === null || _d === void 0 ? void 0 : _d.MX) === null || _e === void 0 ? void 0 : _e.shouldInvoice)) {
46
+ customerName = "PÚBLICO EN GENERAL";
47
+ postalCode = "66260";
48
+ rfc = "XAXX010101000";
49
+ }
50
+ else if ((_g = (_f = user.invoicing) === null || _f === void 0 ? void 0 : _f.MX) === null || _g === void 0 ? void 0 : _g.fiscalName) {
51
+ customerName = (_h = user.invoicing) === null || _h === void 0 ? void 0 : _h.MX.fiscalName.toLocaleUpperCase();
52
+ 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
+ rfc = (_o = (_m = user.onboarding) === null || _m === void 0 ? void 0 : _m.MX) === null || _o === void 0 ? void 0 : _o.taxId;
54
+ }
55
+ }
56
+ else {
57
+ customerName = (0, common_1.getUserName)(user).toLocaleUpperCase();
58
+ postalCode = (_r = (_q = (_p = user.onboarding) === null || _p === void 0 ? void 0 : _p.MX) === null || _q === void 0 ? void 0 : _q.address) === null || _r === void 0 ? void 0 : _r.postalCode;
59
+ rfc = "XEXX010101000";
60
+ }
61
+ if (!customerName) {
62
+ throw new Error("Customer name not found");
63
+ }
64
+ if (!postalCode) {
65
+ throw new Error("Postal code not found");
66
+ }
41
67
  const { data } = yield axios_1.default.put(`${this.baseUrl}/transform/v1/jobs/${uuid}`, {
42
68
  workflow_id: "5b123900-1035-4c8c-a97a-36b940d7a21e",
43
69
  data: {
@@ -62,24 +88,20 @@ class InvopopClient {
62
88
  ],
63
89
  },
64
90
  customer: {
65
- name: ((_b = (_a = user.invoicing) === null || _a === void 0 ? void 0 : _a.MX) === null || _b === void 0 ? void 0 : _b.fiscalName)
66
- ? (_c = user.invoicing) === null || _c === void 0 ? void 0 : _c.MX.fiscalName.toLocaleUpperCase()
67
- : (0, common_1.getUserName)(user).toLocaleUpperCase(),
91
+ name: customerName,
68
92
  tax_id: {
69
93
  country: "MX",
70
- zone: ((_e = (_d = user.invoicing) === null || _d === void 0 ? void 0 : _d.MX) === null || _e === void 0 ? void 0 : _e.shouldInvoice)
71
- ? (_h = (_g = (_f = user.onboarding) === null || _f === void 0 ? void 0 : _f.MX) === null || _g === void 0 ? void 0 : _g.address) === null || _h === void 0 ? void 0 : _h.postalCode
72
- : "66260",
73
- code: ((_k = (_j = user.onboarding) === null || _j === void 0 ? void 0 : _j.MX) === null || _k === void 0 ? void 0 : _k.taxId) || "XAXX010101000",
94
+ zone: postalCode,
95
+ code: rfc,
74
96
  },
75
97
  identities: [
76
98
  {
77
99
  key: "mx-cfdi-fiscal-regime",
78
- code: ((_o = (_m = (_l = user.invoicing) === null || _l === void 0 ? void 0 : _l.MX) === null || _m === void 0 ? void 0 : _m.fiscalRegimenCode) === null || _o === void 0 ? void 0 : _o.toString()) || "616",
100
+ code: ((_u = (_t = (_s = user.invoicing) === null || _s === void 0 ? void 0 : _s.MX) === null || _t === void 0 ? void 0 : _t.fiscalRegimenCode) === null || _u === void 0 ? void 0 : _u.toString()) || "616",
79
101
  },
80
102
  {
81
103
  key: "mx-cfdi-use",
82
- code: ((_q = (_p = user.invoicing) === null || _p === void 0 ? void 0 : _p.MX) === null || _q === void 0 ? void 0 : _q.shouldInvoice) ? "G03" : "S01",
104
+ code: ((_w = (_v = user.invoicing) === null || _v === void 0 ? void 0 : _v.MX) === null || _w === void 0 ? void 0 : _w.shouldInvoice) ? "G03" : "S01",
83
105
  },
84
106
  ],
85
107
  },
@@ -90,7 +112,7 @@ class InvopopClient {
90
112
  item: {
91
113
  name: "Facilitación de Compra-Venta de Activos Virtuales",
92
114
  identities: [{ key: "mx-cfdi-prod-serv", code: "80151500" }],
93
- price: (_r = order.actualFees.platformFeeFiat) === null || _r === void 0 ? void 0 : _r.toFixed(2),
115
+ price: (_x = order.actualFees.platformFeeFiat) === null || _x === void 0 ? void 0 : _x.toFixed(2),
94
116
  },
95
117
  taxes: [
96
118
  {
@@ -229,6 +229,7 @@ interface UserDoc extends Document {
229
229
  personalId?: string;
230
230
  taxId?: string;
231
231
  isResident?: boolean;
232
+ hasAcceptedTerms?: boolean;
232
233
  individualIdentityVerification?: {
233
234
  status?: "passed" | "failed" | "review";
234
235
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.1430",
3
+ "version": "1.0.1432",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",