@riocrypto/common-server 1.0.1431 → 1.0.1433
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.
- package/build/clients/invopop-client.js +33 -11
- package/package.json +1 -1
|
@@ -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;
|
|
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 = "66260";
|
|
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:
|
|
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:
|
|
71
|
-
|
|
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: ((
|
|
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",
|
|
79
101
|
},
|
|
80
102
|
{
|
|
81
103
|
key: "mx-cfdi-use",
|
|
82
|
-
code: ((
|
|
104
|
+
code: ((_t = (_s = user.invoicing) === null || _s === void 0 ? void 0 : _s.MX) === null || _t === void 0 ? void 0 : _t.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: (
|
|
115
|
+
price: (_u = order.actualFees.platformFeeFiat) === null || _u === void 0 ? void 0 : _u.toFixed(2),
|
|
94
116
|
},
|
|
95
117
|
taxes: [
|
|
96
118
|
{
|