n8n-nodes-centum 0.2.28 → 0.2.29
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/README.md +12 -1
- package/dist/nodes/Centum/Centum.node.js +1124 -1051
- package/dist/nodes/Centum/Centum.node.js.map +1 -1
- package/dist/nodes/Centum/CentumDescription.js +251 -160
- package/dist/nodes/Centum/CentumDescription.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -38,92 +38,139 @@ class Centum {
|
|
|
38
38
|
};
|
|
39
39
|
const resource = this.getNodeParameter("resource", 0);
|
|
40
40
|
switch (resource) {
|
|
41
|
-
case "
|
|
42
|
-
const
|
|
43
|
-
const documentDate = this.getNodeParameter("documentDate", 0);
|
|
44
|
-
const IdsRubro = this.getNodeParameter("idsRubros", 0);
|
|
45
|
-
const completeMigration = this.getNodeParameter("migracionCompleta", 0);
|
|
46
|
-
const IdsSubRubro = this.getNodeParameter("idsSubRubros", 0);
|
|
47
|
-
const formattedDocumentDate = documentDate.replace(/\..+/, "");
|
|
48
|
-
const dateModified = this.getNodeParameter("dateModified", 0);
|
|
49
|
-
const dateModifiedImage = this.getNodeParameter("dateModifiedImage", 0);
|
|
50
|
-
const priceDateModified = this.getNodeParameter("priceDateModified", 0);
|
|
51
|
-
const numeroPagina = this.getNodeParameter("numeroPagina", 0);
|
|
52
|
-
const cantidadPorPagina = this.getNodeParameter("cantidadPorPagina", 0);
|
|
53
|
-
const bodyToSend = {
|
|
54
|
-
idCliente: clientId,
|
|
55
|
-
FechaDocumento: formattedDocumentDate,
|
|
56
|
-
incluirAtributosArticulos: true,
|
|
57
|
-
IdsRubro: IdsRubro ? [IdsRubro] : [],
|
|
58
|
-
IdsSubRubro: IdsSubRubro ? [IdsSubRubro] : [""],
|
|
59
|
-
fechaModificacionDesde: dateModified ? dateModified : "",
|
|
60
|
-
fechaModificacionImagenesDesde: dateModifiedImage ? dateModifiedImage : "",
|
|
61
|
-
fechaPrecioActualizadoDesde: priceDateModified,
|
|
62
|
-
numeroPagina,
|
|
63
|
-
cantidadPorPagina,
|
|
64
|
-
};
|
|
41
|
+
case "actualizarCliente": {
|
|
42
|
+
const nuevosDatos = this.getNodeParameter("cuerpoHTTP", 0);
|
|
65
43
|
try {
|
|
66
|
-
const
|
|
44
|
+
const updateCustomer = await (0, functions_1.apiRequest)(`${centumUrl}/Clientes/Actualizar`, {
|
|
67
45
|
method: "POST",
|
|
68
|
-
body:
|
|
46
|
+
body: nuevosDatos,
|
|
69
47
|
headers,
|
|
70
|
-
queryParams: { tipoOrdenArticulos: "Codigo" },
|
|
71
48
|
});
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
49
|
+
return [this.helpers.returnJsonArray(updateCustomer)];
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
console.log(error);
|
|
53
|
+
return [this.helpers.returnJsonArray([])];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
case "buscarClientePorCuit": {
|
|
57
|
+
const cuit = this.getNodeParameter("cuit", 0, "");
|
|
58
|
+
if (!cuit) {
|
|
59
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Debe proporcionar CUIT para buscar clientes.");
|
|
60
|
+
}
|
|
61
|
+
const queryParams = { Cuit: cuit };
|
|
62
|
+
try {
|
|
63
|
+
const response = await (0, functions_1.apiRequest)(`${centumUrl}/Clientes`, {
|
|
64
|
+
method: "GET",
|
|
65
|
+
headers,
|
|
66
|
+
queryParams,
|
|
67
|
+
});
|
|
68
|
+
return [this.helpers.returnJsonArray(response.Items)];
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
console.log(`[ClientesBusquedaPorCuit] Error:`, error);
|
|
72
|
+
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
73
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
case "buscarClientes": {
|
|
77
|
+
const codigo = this.getNodeParameter("codigoCliente", 0, "");
|
|
78
|
+
const cuit = this.getNodeParameter("cuit", 0, "");
|
|
79
|
+
const razonSocial = this.getNodeParameter("razonSocial", 0, "");
|
|
80
|
+
if (!codigo && !cuit && !razonSocial) {
|
|
81
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Debe proporcionar al menos un campo para la búsqueda (CUIT, Codigo o Razón Social).");
|
|
82
|
+
}
|
|
83
|
+
const queryParams = {};
|
|
84
|
+
if (cuit)
|
|
85
|
+
queryParams.Cuit = cuit;
|
|
86
|
+
if (codigo)
|
|
87
|
+
queryParams.codigo = codigo;
|
|
88
|
+
if (razonSocial)
|
|
89
|
+
queryParams.RazonSocial = razonSocial;
|
|
90
|
+
try {
|
|
91
|
+
const response = await (0, functions_1.apiRequest)(`${centumUrl}/Clientes`, {
|
|
92
|
+
method: "GET",
|
|
93
|
+
headers,
|
|
94
|
+
queryParams,
|
|
95
|
+
});
|
|
96
|
+
console.log(response);
|
|
97
|
+
return [this.helpers.returnJsonArray(response.Items)];
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
console.log(`[ClientesBusqueda] Error:`, error);
|
|
101
|
+
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
102
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
case "buscarContribuyente": {
|
|
106
|
+
const cuit = this.getNodeParameter("cuit", 0, "");
|
|
107
|
+
const razonSocial = this.getNodeParameter("razonSocial", 0, "");
|
|
108
|
+
if (!cuit && !razonSocial) {
|
|
109
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Debe proporcionar al menos CUIT o Razón Social para buscar contribuyentes.");
|
|
110
|
+
}
|
|
111
|
+
let url = `${centumUrl}/Clientes/BuscarContribuyente`;
|
|
112
|
+
const queryParams = {};
|
|
113
|
+
if (cuit && !razonSocial) {
|
|
114
|
+
url += `/${cuit}`;
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
if (cuit)
|
|
118
|
+
queryParams.Cuit = cuit;
|
|
119
|
+
if (razonSocial)
|
|
120
|
+
queryParams.razonSocial = razonSocial;
|
|
121
|
+
}
|
|
122
|
+
const requestDetails = {
|
|
123
|
+
url,
|
|
124
|
+
headers,
|
|
125
|
+
queryParams,
|
|
126
|
+
};
|
|
127
|
+
try {
|
|
128
|
+
console.log(`[BuscarContribuyente] Request:`, JSON.stringify(requestDetails, null, 2));
|
|
129
|
+
const response = await (0, functions_1.apiRequest)(requestDetails.url, {
|
|
130
|
+
method: "GET",
|
|
131
|
+
headers: requestDetails.headers,
|
|
132
|
+
queryParams: requestDetails.queryParams,
|
|
133
|
+
});
|
|
134
|
+
console.log(`[BuscarContribuyente] Response:`, JSON.stringify(response, null, 2));
|
|
135
|
+
if (response.CantidadTotalItems === 1) {
|
|
136
|
+
return [this.helpers.returnJsonArray(response.Items)];
|
|
118
137
|
}
|
|
138
|
+
return [this.helpers.returnJsonArray(response)];
|
|
119
139
|
}
|
|
120
140
|
catch (error) {
|
|
121
|
-
console.log(
|
|
141
|
+
console.log(`[BuscarContribuyente] Error:`, error);
|
|
142
|
+
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
143
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
case "buscarProductoEnSucursal": {
|
|
147
|
+
const IdSucursalFisica = this.getNodeParameter("idSucursalFisica", 0);
|
|
148
|
+
const idArticulo = this.getNodeParameter("articleId", 0);
|
|
149
|
+
const codigo = this.getNodeParameter("codigoArticulo", 0);
|
|
150
|
+
const nombre = this.getNodeParameter("nombreArticulo", 0);
|
|
151
|
+
const queryParams = {
|
|
152
|
+
IdSucursalFisica: IdSucursalFisica,
|
|
153
|
+
codigoExacto: codigo,
|
|
154
|
+
idsArticulos: idArticulo,
|
|
155
|
+
nombre
|
|
156
|
+
};
|
|
157
|
+
if (!IdSucursalFisica || (!idArticulo && !codigo && !nombre)) {
|
|
158
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "El id de la sucursal fisica y el id del articulo o el codigo son obligatorios");
|
|
159
|
+
}
|
|
160
|
+
try {
|
|
161
|
+
const dataArticulosExistencias = await (0, functions_1.apiRequest)(`${centumUrl}/ArticulosSucursalesFisicas`, {
|
|
162
|
+
headers,
|
|
163
|
+
queryParams,
|
|
164
|
+
});
|
|
165
|
+
return [this.helpers.returnJsonArray(dataArticulosExistencias.Items)];
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
console.log(error);
|
|
122
169
|
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
123
170
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage);
|
|
124
171
|
}
|
|
125
172
|
}
|
|
126
|
-
case "
|
|
173
|
+
case "buscarProductoPorCodigo": {
|
|
127
174
|
const codigo = this.getNodeParameter("codigoArticulo", 0);
|
|
128
175
|
const articleId = this.getNodeParameter("articleId", 0);
|
|
129
176
|
const fechaCreacionDesde = this.getNodeParameter("startDate", 0);
|
|
@@ -145,7 +192,7 @@ class Centum {
|
|
|
145
192
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage);
|
|
146
193
|
}
|
|
147
194
|
}
|
|
148
|
-
case "
|
|
195
|
+
case "buscarProductoPorNombre": {
|
|
149
196
|
const nombre = this.getNodeParameter("nombre", 0);
|
|
150
197
|
if (!nombre) {
|
|
151
198
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "El nombre del artículo es obligatorio");
|
|
@@ -166,226 +213,100 @@ class Centum {
|
|
|
166
213
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage);
|
|
167
214
|
}
|
|
168
215
|
}
|
|
169
|
-
case
|
|
216
|
+
case 'buscarProductos': {
|
|
217
|
+
const nombreArticulo = this.getNodeParameter('nombreArticulo', 0, '');
|
|
218
|
+
const codigoArticulo = this.getNodeParameter('codigoArticulo', 0, '');
|
|
170
219
|
try {
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
const fetchOptions = {
|
|
174
|
-
method: "POST",
|
|
220
|
+
const response = await (0, functions_1.apiRequest)(`${centumUrl}/Articulos/DatosGenerales`, {
|
|
221
|
+
method: 'POST',
|
|
175
222
|
headers,
|
|
176
|
-
body: {},
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
|
|
223
|
+
body: { Nombre: nombreArticulo, Codigo: codigoArticulo },
|
|
224
|
+
});
|
|
225
|
+
return [this.helpers.returnJsonArray(response)];
|
|
226
|
+
}
|
|
227
|
+
catch (error) {
|
|
228
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Hubo un error al buscar el articulo. Error: ${error}`);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
case 'buscarProveedor': {
|
|
232
|
+
const proveedorId = this.getNodeParameter('proveedorId', 0);
|
|
233
|
+
try {
|
|
234
|
+
const response = await (0, functions_1.apiRequest)(`${centumUrl}/Proveedores/${proveedorId}`, {
|
|
235
|
+
method: 'GET',
|
|
236
|
+
headers
|
|
237
|
+
});
|
|
238
|
+
return [this.helpers.returnJsonArray(response)];
|
|
184
239
|
}
|
|
185
240
|
catch (error) {
|
|
186
|
-
console.log("Error en solicitud de artículos", error);
|
|
187
241
|
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
188
242
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage);
|
|
189
243
|
}
|
|
190
244
|
}
|
|
191
|
-
case "
|
|
192
|
-
const
|
|
245
|
+
case "consultarPrecioProducto": {
|
|
246
|
+
const idArticulos = this.getNodeParameter("codigoArticulo", 0);
|
|
247
|
+
const idLista = this.getNodeParameter("idList", 0);
|
|
248
|
+
if (!idLista || !idArticulos) {
|
|
249
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "El id de la lista y el artículo son obligatorios.");
|
|
250
|
+
}
|
|
193
251
|
try {
|
|
194
|
-
const
|
|
252
|
+
const articulo = await (0, functions_1.apiRequest)(`${centumUrl}/Articulos/FiltrosPrecios`, {
|
|
253
|
+
method: "POST",
|
|
195
254
|
headers,
|
|
196
|
-
|
|
197
|
-
idsSucursalesFisicas: branchOfficeIds,
|
|
198
|
-
},
|
|
255
|
+
body: { IdsArticulos: idArticulos, IdLista: idLista },
|
|
199
256
|
});
|
|
200
|
-
return [this.helpers.returnJsonArray(
|
|
257
|
+
return [this.helpers.returnJsonArray(articulo)];
|
|
201
258
|
}
|
|
202
259
|
catch (error) {
|
|
203
|
-
console.log("
|
|
204
|
-
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
205
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage);
|
|
260
|
+
console.log("Error en solicitud de artículo por ID:", error);
|
|
206
261
|
}
|
|
207
262
|
}
|
|
208
|
-
case "
|
|
209
|
-
const
|
|
210
|
-
const
|
|
211
|
-
const
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
idArticulo: element.json.IdArticulo,
|
|
216
|
-
images: [],
|
|
217
|
-
infoImages: [],
|
|
218
|
-
};
|
|
219
|
-
const allArticleImages = await (0, functions_1.centumGetArticleImages)(1, element.json.IdArticulo, {
|
|
220
|
-
consumerApiPublicId,
|
|
221
|
-
publicAccessKey: String(centumApiCredentials.publicAccessKey),
|
|
222
|
-
}, requestUrl);
|
|
223
|
-
if (allArticleImages instanceof Error) {
|
|
224
|
-
console.error(`Failed to download images for article ${element.json.IdArticulo}`, allArticleImages);
|
|
225
|
-
continue;
|
|
226
|
-
}
|
|
227
|
-
if (allArticleImages.length > 0) {
|
|
228
|
-
for (let j = 0; j < allArticleImages.length; j++) {
|
|
229
|
-
const binary = {};
|
|
230
|
-
const dataImage = allArticleImages[j];
|
|
231
|
-
const buffer = Buffer.from(dataImage.buffer);
|
|
232
|
-
binary["data"] = await this.helpers.prepareBinaryData(buffer);
|
|
233
|
-
binary.data.fileName = `${element.json.Codigo}_${j + 1}.${binary.data.fileExtension}`;
|
|
234
|
-
dataObj.images.push(binary);
|
|
235
|
-
dataObj.infoImages.push({
|
|
236
|
-
lastModified: dataImage.lastModified,
|
|
237
|
-
orderNumber: dataImage.orderNumber,
|
|
238
|
-
});
|
|
239
|
-
const existObj = arrResult.find((obj) => obj.idArticulo === element.json.IdArticulo);
|
|
240
|
-
if (!existObj) {
|
|
241
|
-
arrResult.push(dataObj);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
else {
|
|
246
|
-
dataObj.images = null;
|
|
247
|
-
arrResult.push(dataObj);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
return [this.helpers.returnJsonArray(arrResult)];
|
|
251
|
-
}
|
|
252
|
-
case "articulosPrecioPorLista": {
|
|
253
|
-
const idArticulos = this.getNodeParameter("codigoArticulo", 0);
|
|
254
|
-
const idLista = this.getNodeParameter("idList", 0);
|
|
255
|
-
if (!idLista || !idArticulos) {
|
|
256
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "El id de la lista y el artículo son obligatorios.");
|
|
257
|
-
}
|
|
258
|
-
try {
|
|
259
|
-
const articulo = await (0, functions_1.apiRequest)(`${centumUrl}/Articulos/FiltrosPrecios`, {
|
|
260
|
-
method: "POST",
|
|
261
|
-
headers,
|
|
262
|
-
body: { IdsArticulos: idArticulos, IdLista: idLista },
|
|
263
|
-
});
|
|
264
|
-
return [this.helpers.returnJsonArray(articulo)];
|
|
265
|
-
}
|
|
266
|
-
catch (error) {
|
|
267
|
-
console.log("Error en solicitud de artículo por ID:", error);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
case "articulosSucursalesFisicas": {
|
|
271
|
-
const IdSucursalFisica = this.getNodeParameter("IdSucursalFisica", 0);
|
|
272
|
-
const queryParams = {
|
|
273
|
-
idsSucursalesFisicas: IdSucursalFisica,
|
|
274
|
-
};
|
|
275
|
-
if (!IdSucursalFisica) {
|
|
276
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "El id de la sucursal fisica es obligatorio");
|
|
277
|
-
}
|
|
278
|
-
try {
|
|
279
|
-
const dataArticulosExistencias = await (0, functions_1.apiRequest)(`${centumUrl}/ArticulosSucursalesFisicas`, {
|
|
280
|
-
headers,
|
|
281
|
-
queryParams,
|
|
282
|
-
});
|
|
283
|
-
return [this.helpers.returnJsonArray(dataArticulosExistencias.Items)];
|
|
284
|
-
}
|
|
285
|
-
catch (error) {
|
|
286
|
-
console.log(error);
|
|
287
|
-
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
288
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage);
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
case "articuloSucursalFisica": {
|
|
292
|
-
const IdSucursalFisica = this.getNodeParameter("idSucursalFisica", 0);
|
|
293
|
-
const idArticulo = this.getNodeParameter("articleId", 0);
|
|
294
|
-
const codigo = this.getNodeParameter("codigoArticulo", 0);
|
|
295
|
-
const nombre = this.getNodeParameter("nombreArticulo", 0);
|
|
296
|
-
const queryParams = {
|
|
297
|
-
IdSucursalFisica: IdSucursalFisica,
|
|
298
|
-
codigoExacto: codigo,
|
|
299
|
-
idsArticulos: idArticulo,
|
|
300
|
-
nombre
|
|
301
|
-
};
|
|
302
|
-
if (!IdSucursalFisica || (!idArticulo && !codigo && !nombre)) {
|
|
303
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "El id de la sucursal fisica y el id del articulo o el codigo son obligatorios");
|
|
263
|
+
case "consultarSaldoCliente": {
|
|
264
|
+
const clientIdParam = this.getNodeParameter("clienteId", 0);
|
|
265
|
+
const desdeSaldoFecha = this.getNodeParameter("priceDateModified", 0);
|
|
266
|
+
const soloFecha = String(desdeSaldoFecha).split("T")[0];
|
|
267
|
+
const clientId = Number(clientIdParam);
|
|
268
|
+
if (isNaN(clientId) || clientId <= 0) {
|
|
269
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "clienteId debe ser un número positivo");
|
|
304
270
|
}
|
|
305
271
|
try {
|
|
306
|
-
|
|
272
|
+
let url = `${centumUrl}/SaldosCuentasCorrientes/${clientId}`;
|
|
273
|
+
if (soloFecha) {
|
|
274
|
+
url += `?fechaVencimientoHasta=${soloFecha}`;
|
|
275
|
+
}
|
|
276
|
+
const response = await (0, functions_1.apiRequest)(url, {
|
|
277
|
+
method: "GET",
|
|
307
278
|
headers,
|
|
308
|
-
queryParams,
|
|
309
279
|
});
|
|
310
|
-
return [this.helpers.returnJsonArray(
|
|
280
|
+
return [this.helpers.returnJsonArray(response)];
|
|
311
281
|
}
|
|
312
282
|
catch (error) {
|
|
313
|
-
console.log(error);
|
|
314
283
|
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
315
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage);
|
|
284
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Error obteniendo saldo para cliente ${clientId}: ${errorMessage}`);
|
|
316
285
|
}
|
|
317
286
|
}
|
|
318
|
-
case
|
|
319
|
-
const
|
|
320
|
-
const codigoArticulo = this.getNodeParameter('codigoArticulo', 0, '');
|
|
287
|
+
case "consultarStock": {
|
|
288
|
+
const branchOfficeIds = String(this.getNodeParameter("branchOfficeIds", 0));
|
|
321
289
|
try {
|
|
322
|
-
const
|
|
323
|
-
method: 'POST',
|
|
290
|
+
const dataArticulosExistencia = await (0, functions_1.apiRequest)(`${centumUrl}/ArticulosExistencias`, {
|
|
324
291
|
headers,
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
}
|
|
329
|
-
catch (error) {
|
|
330
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Hubo un error al buscar el articulo. Error: ${error}`);
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
case "buscarContribuyente": {
|
|
334
|
-
const cuit = this.getNodeParameter("cuit", 0, "");
|
|
335
|
-
const razonSocial = this.getNodeParameter("razonSocial", 0, "");
|
|
336
|
-
if (!cuit && !razonSocial) {
|
|
337
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Debe proporcionar al menos CUIT o Razón Social para buscar contribuyentes.");
|
|
338
|
-
}
|
|
339
|
-
let url = `${centumUrl}/Clientes/BuscarContribuyente`;
|
|
340
|
-
const queryParams = {};
|
|
341
|
-
if (cuit && !razonSocial) {
|
|
342
|
-
url += `/${cuit}`;
|
|
343
|
-
}
|
|
344
|
-
else {
|
|
345
|
-
if (cuit)
|
|
346
|
-
queryParams.Cuit = cuit;
|
|
347
|
-
if (razonSocial)
|
|
348
|
-
queryParams.razonSocial = razonSocial;
|
|
349
|
-
}
|
|
350
|
-
const requestDetails = {
|
|
351
|
-
url,
|
|
352
|
-
headers,
|
|
353
|
-
queryParams,
|
|
354
|
-
};
|
|
355
|
-
try {
|
|
356
|
-
console.log(`[BuscarContribuyente] Request:`, JSON.stringify(requestDetails, null, 2));
|
|
357
|
-
const response = await (0, functions_1.apiRequest)(requestDetails.url, {
|
|
358
|
-
method: "GET",
|
|
359
|
-
headers: requestDetails.headers,
|
|
360
|
-
queryParams: requestDetails.queryParams,
|
|
292
|
+
queryParams: {
|
|
293
|
+
idsSucursalesFisicas: branchOfficeIds,
|
|
294
|
+
},
|
|
361
295
|
});
|
|
362
|
-
|
|
363
|
-
if (response.CantidadTotalItems === 1) {
|
|
364
|
-
return [this.helpers.returnJsonArray(response.Items)];
|
|
365
|
-
}
|
|
366
|
-
return [this.helpers.returnJsonArray(response)];
|
|
296
|
+
return [this.helpers.returnJsonArray(dataArticulosExistencia.Items)];
|
|
367
297
|
}
|
|
368
298
|
catch (error) {
|
|
369
|
-
console.log(
|
|
299
|
+
console.log("ArticulosExistencias error: ", error);
|
|
370
300
|
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
371
301
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage);
|
|
372
302
|
}
|
|
373
303
|
}
|
|
374
|
-
case "
|
|
375
|
-
const
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
url = `${url}?idSubRubro=${subRubro}`;
|
|
379
|
-
}
|
|
380
|
-
try {
|
|
381
|
-
const response = await (0, functions_1.apiRequest)(url);
|
|
382
|
-
return [this.helpers.returnJsonArray(response)];
|
|
383
|
-
}
|
|
384
|
-
catch (error) {
|
|
385
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Hubo un error al obtener el listado de categorias. Error: ${error}`);
|
|
386
|
-
}
|
|
304
|
+
case "convertirProductosParaWooCommerce": {
|
|
305
|
+
const data = this.getInputData();
|
|
306
|
+
const json = (0, functions_1.createJsonProducts)(data);
|
|
307
|
+
return [this.helpers.returnJsonArray(json)];
|
|
387
308
|
}
|
|
388
|
-
case "
|
|
309
|
+
case "crearCliente": {
|
|
389
310
|
const datosCliente = this.getNodeParameter("cuerpoHTTP", 0);
|
|
390
311
|
const clienteDNI = this.getNodeParameter("dni", 0);
|
|
391
312
|
const datosJSON = (0, functions_1.createCustomerJson)(datosCliente, clienteDNI);
|
|
@@ -406,137 +327,250 @@ class Centum {
|
|
|
406
327
|
return [this.helpers.returnJsonArray(obj)];
|
|
407
328
|
}
|
|
408
329
|
}
|
|
409
|
-
case "
|
|
330
|
+
case "crearCompra": {
|
|
331
|
+
const nombreTipoComprobante = this.getNodeParameter("nombreTipoComprobante", 0, "");
|
|
332
|
+
const codigoComprobante = this.getNodeParameter("codigoComprobante", 0, "");
|
|
333
|
+
const idTipoComprobante = this.getNodeParameter("idTipoComprobante", 0);
|
|
334
|
+
const numeroDocumento = this.getNodeParameter("numeroFactura", 0);
|
|
335
|
+
const puntoVenta = this.getNodeParameter("puntoDeVenta", 0);
|
|
336
|
+
const letraDocumento = this.getNodeParameter("letraDocumento", 0, "");
|
|
337
|
+
const fechaDocumento = this.getNodeParameter("fechaFactura", 0, "");
|
|
338
|
+
const sucursalFisica = this.getNodeParameter("idSucursalFisica", 0);
|
|
339
|
+
const articulosArray = this.getNodeParameter("articlesCollection", 0);
|
|
340
|
+
const idCliente = this.getNodeParameter("clienteId", 0);
|
|
341
|
+
const idProveedor = this.getNodeParameter("idProveedor", 0);
|
|
342
|
+
const fechaProducto = this.getNodeParameter("startDate", 0);
|
|
343
|
+
const separarFecha = String(fechaProducto).split("T")[0];
|
|
344
|
+
const ids = articulosArray.map((a) => a.ID);
|
|
345
|
+
const qtyById = Object.fromEntries(articulosArray.map((a) => [a.ID, a.Cantidad]));
|
|
346
|
+
let bodyProveedor;
|
|
347
|
+
const bodyCompraArticulos = {
|
|
348
|
+
IdCliente: idCliente,
|
|
349
|
+
FechaDocumento: separarFecha,
|
|
350
|
+
Ids: ids,
|
|
351
|
+
};
|
|
410
352
|
try {
|
|
411
|
-
const
|
|
412
|
-
const clientesURL = `${centumUrl}/Clientes`;
|
|
413
|
-
const fetchOptions = {
|
|
353
|
+
const fetchProveedor = await (0, functions_1.apiRequest)(`${centumUrl}/Proveedores/${idProveedor}`, {
|
|
414
354
|
method: "GET",
|
|
415
|
-
pagination: ajustesHTTP.pagination,
|
|
416
|
-
cantidadItemsPorPagina: ajustesHTTP.cantidadItemsPorPagina,
|
|
417
|
-
intervaloPagina: ajustesHTTP.intervaloPagina,
|
|
418
|
-
itemsField: "Items",
|
|
419
|
-
context: this,
|
|
420
355
|
headers,
|
|
421
|
-
};
|
|
422
|
-
|
|
423
|
-
const paginated = await (0, functions_1.apiGetRequest)(clientesURL, fetchOptions);
|
|
424
|
-
clientes = paginated;
|
|
425
|
-
return [this.helpers.returnJsonArray(clientes)];
|
|
356
|
+
});
|
|
357
|
+
bodyProveedor = fetchProveedor;
|
|
426
358
|
}
|
|
427
359
|
catch (error) {
|
|
428
360
|
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
429
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage);
|
|
361
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Error obteniendo el proveedor.\n ${errorMessage}`);
|
|
430
362
|
}
|
|
431
|
-
|
|
432
|
-
case "clientesActualizar": {
|
|
433
|
-
const nuevosDatos = this.getNodeParameter("cuerpoHTTP", 0);
|
|
363
|
+
let articulosVenta;
|
|
434
364
|
try {
|
|
435
|
-
|
|
365
|
+
articulosVenta = await (0, functions_1.apiRequest)(`${centumUrl}/Articulos/Venta`, {
|
|
436
366
|
method: "POST",
|
|
437
|
-
body:
|
|
438
|
-
headers,
|
|
439
|
-
});
|
|
440
|
-
return [this.helpers.returnJsonArray(updateCustomer)];
|
|
441
|
-
}
|
|
442
|
-
catch (error) {
|
|
443
|
-
console.log(error);
|
|
444
|
-
return [this.helpers.returnJsonArray([])];
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
case "clientesBusqueda": {
|
|
448
|
-
const codigo = this.getNodeParameter("codigoCliente", 0, "");
|
|
449
|
-
const cuit = this.getNodeParameter("cuit", 0, "");
|
|
450
|
-
const razonSocial = this.getNodeParameter("razonSocial", 0, "");
|
|
451
|
-
if (!codigo && !cuit && !razonSocial) {
|
|
452
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Debe proporcionar al menos un campo para la búsqueda (CUIT, Codigo o Razón Social).");
|
|
453
|
-
}
|
|
454
|
-
const queryParams = {};
|
|
455
|
-
if (cuit)
|
|
456
|
-
queryParams.Cuit = cuit;
|
|
457
|
-
if (codigo)
|
|
458
|
-
queryParams.codigo = codigo;
|
|
459
|
-
if (razonSocial)
|
|
460
|
-
queryParams.RazonSocial = razonSocial;
|
|
461
|
-
try {
|
|
462
|
-
const response = await (0, functions_1.apiRequest)(`${centumUrl}/Clientes`, {
|
|
463
|
-
method: "GET",
|
|
367
|
+
body: bodyCompraArticulos,
|
|
464
368
|
headers,
|
|
465
|
-
queryParams,
|
|
466
369
|
});
|
|
467
|
-
console.log(response);
|
|
468
|
-
return [this.helpers.returnJsonArray(response.Items)];
|
|
469
370
|
}
|
|
470
371
|
catch (error) {
|
|
471
|
-
console.log(`[ClientesBusqueda] Error:`, error);
|
|
472
372
|
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
473
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage);
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
case "clientesBusquedaPorCuit": {
|
|
477
|
-
const cuit = this.getNodeParameter("cuit", 0, "");
|
|
478
|
-
if (!cuit) {
|
|
479
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Debe proporcionar CUIT para buscar clientes.");
|
|
480
|
-
}
|
|
481
|
-
const queryParams = { Cuit: cuit };
|
|
482
|
-
try {
|
|
483
|
-
const response = await (0, functions_1.apiRequest)(`${centumUrl}/Clientes`, {
|
|
484
|
-
method: "GET",
|
|
485
|
-
headers,
|
|
486
|
-
queryParams,
|
|
487
|
-
});
|
|
488
|
-
return [this.helpers.returnJsonArray(response.Items)];
|
|
373
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Error al obtener la informacion de los articulos ${errorMessage}`);
|
|
489
374
|
}
|
|
490
|
-
|
|
491
|
-
|
|
375
|
+
const ventaObj = typeof articulosVenta === "string" ? JSON.parse(articulosVenta) : articulosVenta;
|
|
376
|
+
const itemsRespuesta = ventaObj?.Articulos?.Items ?? ventaObj?.CompraArticulos ?? ventaObj?.Items ?? [];
|
|
377
|
+
const compraConCantidad = itemsRespuesta.map((art) => ({
|
|
378
|
+
...art,
|
|
379
|
+
Cantidad: qtyById[String(art.IdArticulo)] ?? 0,
|
|
380
|
+
}));
|
|
381
|
+
const finalBody = {
|
|
382
|
+
TipoComprobanteCompra: {
|
|
383
|
+
IdTipoComprobanteCompra: idTipoComprobante,
|
|
384
|
+
Codigo: codigoComprobante,
|
|
385
|
+
Nombre: nombreTipoComprobante,
|
|
386
|
+
},
|
|
387
|
+
SucursalFisica: {
|
|
388
|
+
IdSucursalFisica: sucursalFisica,
|
|
389
|
+
},
|
|
390
|
+
NumeroDocumento: {
|
|
391
|
+
LetraDocumento: letraDocumento,
|
|
392
|
+
PuntoVenta: puntoVenta,
|
|
393
|
+
Numero: numeroDocumento,
|
|
394
|
+
},
|
|
395
|
+
FechaDocumento: fechaDocumento,
|
|
396
|
+
Proveedor: bodyProveedor,
|
|
397
|
+
CompraArticulos: compraConCantidad,
|
|
398
|
+
};
|
|
399
|
+
try {
|
|
400
|
+
const response = await (0, functions_1.apiRequest)(`${centumUrl}/Compras`, {
|
|
401
|
+
method: "POST",
|
|
402
|
+
headers,
|
|
403
|
+
body: finalBody,
|
|
404
|
+
});
|
|
405
|
+
return [this.helpers.returnJsonArray(response)];
|
|
406
|
+
}
|
|
407
|
+
catch (error) {
|
|
492
408
|
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
493
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage);
|
|
409
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Error creando la compra.\n ${errorMessage}`);
|
|
494
410
|
}
|
|
495
411
|
}
|
|
496
|
-
case "
|
|
497
|
-
const
|
|
498
|
-
const
|
|
499
|
-
|
|
500
|
-
|
|
412
|
+
case "crearContribuyente": {
|
|
413
|
+
const bodyJson = this.getNodeParameter("cuerpoHTTP", 0);
|
|
414
|
+
const cuit = this.getNodeParameter("cuit", 0);
|
|
415
|
+
console.log(bodyJson);
|
|
416
|
+
if (typeof cuit !== "string" || !/^\d{11}$/.test(cuit)) {
|
|
417
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "El CUIT debe ser una cadena de 11 dígitos numéricos.");
|
|
418
|
+
}
|
|
419
|
+
const contribuyenteJSON = (0, functions_1.createContribuyenteJson)(bodyJson, cuit);
|
|
501
420
|
try {
|
|
502
|
-
const
|
|
421
|
+
const crearCliente = await (0, functions_1.apiRequest)(`${centumUrl}/Clientes`, {
|
|
503
422
|
method: "POST",
|
|
504
|
-
body:
|
|
423
|
+
body: contribuyenteJSON,
|
|
505
424
|
headers,
|
|
506
425
|
});
|
|
507
|
-
|
|
426
|
+
console.log("Contribuyente creado:", crearCliente);
|
|
427
|
+
return [this.helpers.returnJsonArray([crearCliente])];
|
|
508
428
|
}
|
|
509
429
|
catch (error) {
|
|
510
|
-
console.
|
|
511
|
-
const
|
|
512
|
-
|
|
430
|
+
console.error("Error al crear contribuyente:", error);
|
|
431
|
+
const statusCode = error?.response?.status;
|
|
432
|
+
const responseData = error?.response?.data;
|
|
433
|
+
const errorMessage = responseData?.Message || responseData?.message || error?.message || "Error desconocido al crear el contribuyente.";
|
|
434
|
+
const fullMessage = statusCode ? `Error ${statusCode}: ${errorMessage}` : errorMessage;
|
|
435
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), fullMessage, {
|
|
436
|
+
description: responseData?.Detail || "Ocurrió un error inesperado al llamar a la API de Centum.",
|
|
437
|
+
});
|
|
513
438
|
}
|
|
514
439
|
}
|
|
515
|
-
case "
|
|
516
|
-
const clientIdParam = this.getNodeParameter("clienteId", 0);
|
|
517
|
-
const desdeSaldoFecha = this.getNodeParameter("priceDateModified", 0);
|
|
518
|
-
const separarFecha = String(desdeSaldoFecha).split("T")[0];
|
|
519
|
-
const clientId = Number(clientIdParam);
|
|
520
|
-
if (isNaN(clientId) || clientId <= 0) {
|
|
521
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "clienteId debe ser un número positivo");
|
|
522
|
-
}
|
|
440
|
+
case "crearOrdenCompra": {
|
|
523
441
|
try {
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
url += `?fechaVencimientoHasta=${separarFecha}`;
|
|
527
|
-
}
|
|
528
|
-
const response = await (0, functions_1.apiRequest)(url, {
|
|
529
|
-
method: "GET",
|
|
442
|
+
const response = await (0, functions_1.apiRequest)(`${centumUrl}/OrdenesCompra`, {
|
|
443
|
+
method: "POST",
|
|
530
444
|
headers,
|
|
445
|
+
body: {
|
|
446
|
+
"SucursalFisica": {
|
|
447
|
+
"IdSucursalFisica": 6084
|
|
448
|
+
},
|
|
449
|
+
"NumeroDocumento": {
|
|
450
|
+
"LetraDocumento": "O",
|
|
451
|
+
"PuntoVenta": 1,
|
|
452
|
+
"Numero": 6
|
|
453
|
+
},
|
|
454
|
+
"FechaDocumento": "2025-11-07T00:00:00",
|
|
455
|
+
"FechaEntrega": "2026-06-02T00:00:00",
|
|
456
|
+
"Proveedor": {
|
|
457
|
+
"IdProveedor": 6283,
|
|
458
|
+
"Codigo": "006283",
|
|
459
|
+
"RazonSocial": "Proveedores Río 240 EIRL",
|
|
460
|
+
"CUIT": "27260404100",
|
|
461
|
+
"Direccion": null,
|
|
462
|
+
"Localidad": "CONCEPCION ARENAL 7350",
|
|
463
|
+
"CodigoPostal": "7600",
|
|
464
|
+
"Provincia": {
|
|
465
|
+
"IdProvincia": 4876,
|
|
466
|
+
"Codigo": "BSAS",
|
|
467
|
+
"Nombre": "Buenos Aires"
|
|
468
|
+
},
|
|
469
|
+
"Pais": {
|
|
470
|
+
"IdPais": 4657,
|
|
471
|
+
"Codigo": "ARG",
|
|
472
|
+
"Nombre": "Argentina"
|
|
473
|
+
},
|
|
474
|
+
"Telefono": "541166778899",
|
|
475
|
+
"TelefonoAlternativo": "541166778899",
|
|
476
|
+
"Fax": null,
|
|
477
|
+
"Interno": null,
|
|
478
|
+
"Email": "matjul.mdq@hotmail.com",
|
|
479
|
+
"OperadorCompra": {
|
|
480
|
+
"IdOperadorCompra": 1,
|
|
481
|
+
"Codigo": "Operador de Compras Defecto",
|
|
482
|
+
"Nombre": "Operador de Compras Defecto",
|
|
483
|
+
"EsSupervisor": true
|
|
484
|
+
},
|
|
485
|
+
"CondicionIVA": {
|
|
486
|
+
"IdCondicionIVA": 1895,
|
|
487
|
+
"Codigo": "RI",
|
|
488
|
+
"Nombre": "Responsable Inscripto"
|
|
489
|
+
},
|
|
490
|
+
"CondicionIIBB": {
|
|
491
|
+
"IdCondicionIIBB": 6051,
|
|
492
|
+
"Codigo": "Responsable Inscript"
|
|
493
|
+
},
|
|
494
|
+
"NumeroIIBB": "30716828820",
|
|
495
|
+
"FormaPagoProveedor": {
|
|
496
|
+
"IdFormaPagoProveedor": 6091,
|
|
497
|
+
"Nombre": "Efectivo"
|
|
498
|
+
},
|
|
499
|
+
"DiasMorosidad": null,
|
|
500
|
+
"DiasIncobrables": null,
|
|
501
|
+
"CondicionPago": {
|
|
502
|
+
"IdCondicionPago": 4,
|
|
503
|
+
"Codigo": "CC1",
|
|
504
|
+
"Nombre": "7 Dias"
|
|
505
|
+
},
|
|
506
|
+
"CategoriaImpuestoGanancias": {
|
|
507
|
+
"IdCategoriaImpuestoGanancia": 6065,
|
|
508
|
+
"Nombre": "Exento"
|
|
509
|
+
},
|
|
510
|
+
"CategoriaRetencionIVA": null,
|
|
511
|
+
"CategoriaRetencionSUSS": null,
|
|
512
|
+
"ClaseProveedor": {
|
|
513
|
+
"IdClaseProveedor": 8609,
|
|
514
|
+
"Codigo": "02",
|
|
515
|
+
"Nombre": "DISTRIBUIDOR"
|
|
516
|
+
},
|
|
517
|
+
"Zona": {
|
|
518
|
+
"IdZona": 6095,
|
|
519
|
+
"Codigo": "Zona Defecto",
|
|
520
|
+
"Nombre": "Zona Defecto",
|
|
521
|
+
"Activo": true,
|
|
522
|
+
"EntregaLunes": false,
|
|
523
|
+
"EntregaMartes": false,
|
|
524
|
+
"EntregaMiercoles": false,
|
|
525
|
+
"EntregaJueves": false,
|
|
526
|
+
"EntregaViernes": false,
|
|
527
|
+
"EntregaSabado": false,
|
|
528
|
+
"EntregaDomingo": false,
|
|
529
|
+
"DemoraEnHorasFechaEntrega": 24,
|
|
530
|
+
"CostoEntrega": 10000
|
|
531
|
+
},
|
|
532
|
+
"DescuentoProveedor": null,
|
|
533
|
+
"DiasEntrega": 0,
|
|
534
|
+
"Activo": true
|
|
535
|
+
},
|
|
536
|
+
"PorcentajeDescuento": 0.000000,
|
|
537
|
+
"Observaciones": "",
|
|
538
|
+
"OrdenCompraArticulos": [
|
|
539
|
+
{
|
|
540
|
+
"IdArticulo": 2757,
|
|
541
|
+
"Codigo": "00002757",
|
|
542
|
+
"Nombre": "GALL MARYSOL MARINERAS 300gr",
|
|
543
|
+
"Cantidad": 1.000,
|
|
544
|
+
"SegundoControlStock": 0.000,
|
|
545
|
+
"Precio": 7.0,
|
|
546
|
+
"PorcentajeDescuento1": 0.000,
|
|
547
|
+
"PorcentajeDescuento2": 0.000,
|
|
548
|
+
"PorcentajeDescuento3": 0.000,
|
|
549
|
+
"DescuentoCalculado": 0.000000,
|
|
550
|
+
"CategoriaImpuestoIVA": {
|
|
551
|
+
"IdCategoriaImpuestoIVA": 4,
|
|
552
|
+
"Codigo": "5",
|
|
553
|
+
"Nombre": "IVA 21.00",
|
|
554
|
+
"Tasa": 21.000
|
|
555
|
+
},
|
|
556
|
+
"ImpuestoInterno": 0.000,
|
|
557
|
+
"Observaciones": ""
|
|
558
|
+
}
|
|
559
|
+
],
|
|
560
|
+
"FechaVencimiento": "2029-11-07T00:00:00",
|
|
561
|
+
"OperadorCompra": {
|
|
562
|
+
"IdOperadorCompra": 1,
|
|
563
|
+
"Codigo": "1",
|
|
564
|
+
"Nombre": "Operador de Compras Defecto",
|
|
565
|
+
"EsSupervisor": false
|
|
566
|
+
},
|
|
567
|
+
}
|
|
531
568
|
});
|
|
532
|
-
if (!response || typeof response !== "object") {
|
|
533
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Respuesta inválida del servidor");
|
|
534
|
-
}
|
|
535
569
|
return [this.helpers.returnJsonArray(response)];
|
|
536
570
|
}
|
|
537
571
|
catch (error) {
|
|
538
572
|
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
539
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Error
|
|
573
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Error creando la compra.\n ${errorMessage}`);
|
|
540
574
|
}
|
|
541
575
|
}
|
|
542
576
|
case "crearPedidoVenta": {
|
|
@@ -676,261 +710,71 @@ class Centum {
|
|
|
676
710
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage);
|
|
677
711
|
}
|
|
678
712
|
}
|
|
679
|
-
case
|
|
680
|
-
const
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
const data = this.getInputData();
|
|
701
|
-
const json = (0, functions_1.createJsonProducts)(data);
|
|
702
|
-
return [this.helpers.returnJsonArray(json)];
|
|
703
|
-
}
|
|
704
|
-
case "generarCompras": {
|
|
705
|
-
const nombreTipoComprobante = this.getNodeParameter("nombreTipoComprobante", 0, "");
|
|
706
|
-
const codigoComprobante = this.getNodeParameter("codigoComprobante", 0, "");
|
|
707
|
-
const idTipoComprobante = this.getNodeParameter("idTipoComprobante", 0);
|
|
708
|
-
const numeroDocumento = this.getNodeParameter("numeroFactura", 0);
|
|
709
|
-
const puntoVenta = this.getNodeParameter("puntoDeVenta", 0);
|
|
710
|
-
const letraDocumento = this.getNodeParameter("letraDocumento", 0, "");
|
|
711
|
-
const fechaDocumento = this.getNodeParameter("fechaFactura", 0, "");
|
|
712
|
-
const sucursalFisica = this.getNodeParameter("idSucursalFisica", 0);
|
|
713
|
-
const articulosArray = this.getNodeParameter("articlesCollection", 0);
|
|
714
|
-
const idCliente = this.getNodeParameter("clienteId", 0);
|
|
715
|
-
const idProveedor = this.getNodeParameter("idProveedor", 0);
|
|
716
|
-
const fechaProducto = this.getNodeParameter("startDate", 0);
|
|
717
|
-
const separarFecha = String(fechaProducto).split("T")[0];
|
|
718
|
-
const ids = articulosArray.map((a) => a.ID);
|
|
719
|
-
const qtyById = Object.fromEntries(articulosArray.map((a) => [a.ID, a.Cantidad]));
|
|
720
|
-
let bodyProveedor;
|
|
721
|
-
const bodyCompraArticulos = {
|
|
722
|
-
IdCliente: idCliente,
|
|
723
|
-
FechaDocumento: separarFecha,
|
|
724
|
-
Ids: ids,
|
|
725
|
-
};
|
|
726
|
-
try {
|
|
727
|
-
const fetchProveedor = await (0, functions_1.apiRequest)(`${centumUrl}/Proveedores/${idProveedor}`, {
|
|
728
|
-
method: "GET",
|
|
729
|
-
headers,
|
|
730
|
-
});
|
|
731
|
-
bodyProveedor = fetchProveedor;
|
|
732
|
-
}
|
|
733
|
-
catch (error) {
|
|
734
|
-
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
735
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Error obteniendo el proveedor.\n ${errorMessage}`);
|
|
736
|
-
}
|
|
737
|
-
let articulosVenta;
|
|
738
|
-
try {
|
|
739
|
-
articulosVenta = await (0, functions_1.apiRequest)(`${centumUrl}/Articulos/Venta`, {
|
|
740
|
-
method: "POST",
|
|
741
|
-
body: bodyCompraArticulos,
|
|
742
|
-
headers,
|
|
743
|
-
});
|
|
744
|
-
}
|
|
745
|
-
catch (error) {
|
|
746
|
-
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
747
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Error al obtener la informacion de los articulos ${errorMessage}`);
|
|
748
|
-
}
|
|
749
|
-
const ventaObj = typeof articulosVenta === "string" ? JSON.parse(articulosVenta) : articulosVenta;
|
|
750
|
-
const itemsRespuesta = ventaObj?.Articulos?.Items ?? ventaObj?.CompraArticulos ?? ventaObj?.Items ?? [];
|
|
751
|
-
const compraConCantidad = itemsRespuesta.map((art) => ({
|
|
752
|
-
...art,
|
|
753
|
-
Cantidad: qtyById[String(art.IdArticulo)] ?? 0,
|
|
754
|
-
}));
|
|
755
|
-
const finalBody = {
|
|
756
|
-
TipoComprobanteCompra: {
|
|
757
|
-
IdTipoComprobanteCompra: idTipoComprobante,
|
|
758
|
-
Codigo: codigoComprobante,
|
|
759
|
-
Nombre: nombreTipoComprobante,
|
|
713
|
+
case 'crearProveedor': {
|
|
714
|
+
const codigo = this.getNodeParameter('codigoArticulo', 0, '');
|
|
715
|
+
const razonSocial = this.getNodeParameter('razonSocial', 0, '');
|
|
716
|
+
const cuit = this.getNodeParameter('cuit', 0);
|
|
717
|
+
const provincia = this.getNodeParameter('idProvincia', 0);
|
|
718
|
+
const pais = this.getNodeParameter('idPais', 0);
|
|
719
|
+
const condicionIVA = this.getNodeParameter('condicionIVA', 0, '');
|
|
720
|
+
const formaPagoProveedor = this.getNodeParameter('formaPagoProveedor', 0);
|
|
721
|
+
const condicionPago = this.getNodeParameter('condicionDePago', 0);
|
|
722
|
+
const categoriaImpuestoGanancias = this.getNodeParameter('categoriaImpuestosGanancias', 0);
|
|
723
|
+
const claseProveedor = this.getNodeParameter('claseProveedor', 0);
|
|
724
|
+
const activo = this.getNodeParameter('active', 0);
|
|
725
|
+
const idOperadorCompra = this.getNodeParameter('idOperadorCompra', 0);
|
|
726
|
+
const idZona = this.getNodeParameter('idZona', 0);
|
|
727
|
+
const idDescuentoProveedor = this.getNodeParameter('idDescuentoProveedor', 0);
|
|
728
|
+
const body = {
|
|
729
|
+
Codigo: codigo,
|
|
730
|
+
RazonSocial: razonSocial,
|
|
731
|
+
CUIT: cuit,
|
|
732
|
+
Provincia: {
|
|
733
|
+
IdProvincia: provincia
|
|
760
734
|
},
|
|
761
|
-
|
|
762
|
-
|
|
735
|
+
Pais: {
|
|
736
|
+
IdPais: pais
|
|
763
737
|
},
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
PuntoVenta: puntoVenta,
|
|
767
|
-
Numero: numeroDocumento,
|
|
738
|
+
CondicionIVA: {
|
|
739
|
+
IdCondicionIVA: condicionIVA
|
|
768
740
|
},
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
741
|
+
FormaPagoProveedor: {
|
|
742
|
+
IdFormaPagoProveedor: formaPagoProveedor
|
|
743
|
+
},
|
|
744
|
+
CondicionPago: {
|
|
745
|
+
IdCondicionPago: condicionPago
|
|
746
|
+
},
|
|
747
|
+
CategoriaImpuestoGanancias: {
|
|
748
|
+
IdCategoriaImpuestoGanancia: categoriaImpuestoGanancias
|
|
749
|
+
},
|
|
750
|
+
ClaseProveedor: {
|
|
751
|
+
IdClaseProveedor: claseProveedor
|
|
752
|
+
},
|
|
753
|
+
OperadorCompra: {
|
|
754
|
+
IdOperadorCompra: idOperadorCompra
|
|
755
|
+
},
|
|
756
|
+
Activo: activo,
|
|
757
|
+
Zona: {
|
|
758
|
+
IdZona: idZona
|
|
759
|
+
},
|
|
760
|
+
DescuentoProveedor: {
|
|
761
|
+
IdDescuentoProveedor: idDescuentoProveedor
|
|
762
|
+
}
|
|
772
763
|
};
|
|
773
764
|
try {
|
|
774
|
-
const response = await (0, functions_1.apiRequest)(`${centumUrl}/
|
|
775
|
-
method:
|
|
776
|
-
headers,
|
|
777
|
-
body: finalBody,
|
|
778
|
-
});
|
|
779
|
-
return [this.helpers.returnJsonArray(response)];
|
|
780
|
-
}
|
|
781
|
-
catch (error) {
|
|
782
|
-
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
783
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Error creando la compra.\n ${errorMessage}`);
|
|
784
|
-
}
|
|
785
|
-
}
|
|
786
|
-
case "generarOrdenCompra": {
|
|
787
|
-
try {
|
|
788
|
-
const response = await (0, functions_1.apiRequest)(`${centumUrl}/OrdenesCompra`, {
|
|
789
|
-
method: "POST",
|
|
765
|
+
const response = await (0, functions_1.apiRequest)(`${centumUrl}/Proveedores/`, {
|
|
766
|
+
method: 'POST',
|
|
790
767
|
headers,
|
|
791
|
-
body
|
|
792
|
-
"SucursalFisica": {
|
|
793
|
-
"IdSucursalFisica": 6084
|
|
794
|
-
},
|
|
795
|
-
"NumeroDocumento": {
|
|
796
|
-
"LetraDocumento": "O",
|
|
797
|
-
"PuntoVenta": 1,
|
|
798
|
-
"Numero": 6
|
|
799
|
-
},
|
|
800
|
-
"FechaDocumento": "2025-11-07T00:00:00",
|
|
801
|
-
"FechaEntrega": "2026-06-02T00:00:00",
|
|
802
|
-
"Proveedor": {
|
|
803
|
-
"IdProveedor": 6283,
|
|
804
|
-
"Codigo": "006283",
|
|
805
|
-
"RazonSocial": "Proveedores Río 240 EIRL",
|
|
806
|
-
"CUIT": "27260404100",
|
|
807
|
-
"Direccion": null,
|
|
808
|
-
"Localidad": "CONCEPCION ARENAL 7350",
|
|
809
|
-
"CodigoPostal": "7600",
|
|
810
|
-
"Provincia": {
|
|
811
|
-
"IdProvincia": 4876,
|
|
812
|
-
"Codigo": "BSAS",
|
|
813
|
-
"Nombre": "Buenos Aires"
|
|
814
|
-
},
|
|
815
|
-
"Pais": {
|
|
816
|
-
"IdPais": 4657,
|
|
817
|
-
"Codigo": "ARG",
|
|
818
|
-
"Nombre": "Argentina"
|
|
819
|
-
},
|
|
820
|
-
"Telefono": "541166778899",
|
|
821
|
-
"TelefonoAlternativo": "541166778899",
|
|
822
|
-
"Fax": null,
|
|
823
|
-
"Interno": null,
|
|
824
|
-
"Email": "matjul.mdq@hotmail.com",
|
|
825
|
-
"OperadorCompra": {
|
|
826
|
-
"IdOperadorCompra": 1,
|
|
827
|
-
"Codigo": "Operador de Compras Defecto",
|
|
828
|
-
"Nombre": "Operador de Compras Defecto",
|
|
829
|
-
"EsSupervisor": true
|
|
830
|
-
},
|
|
831
|
-
"CondicionIVA": {
|
|
832
|
-
"IdCondicionIVA": 1895,
|
|
833
|
-
"Codigo": "RI",
|
|
834
|
-
"Nombre": "Responsable Inscripto"
|
|
835
|
-
},
|
|
836
|
-
"CondicionIIBB": {
|
|
837
|
-
"IdCondicionIIBB": 6051,
|
|
838
|
-
"Codigo": "Responsable Inscript"
|
|
839
|
-
},
|
|
840
|
-
"NumeroIIBB": "30716828820",
|
|
841
|
-
"FormaPagoProveedor": {
|
|
842
|
-
"IdFormaPagoProveedor": 6091,
|
|
843
|
-
"Nombre": "Efectivo"
|
|
844
|
-
},
|
|
845
|
-
"DiasMorosidad": null,
|
|
846
|
-
"DiasIncobrables": null,
|
|
847
|
-
"CondicionPago": {
|
|
848
|
-
"IdCondicionPago": 4,
|
|
849
|
-
"Codigo": "CC1",
|
|
850
|
-
"Nombre": "7 Dias"
|
|
851
|
-
},
|
|
852
|
-
"CategoriaImpuestoGanancias": {
|
|
853
|
-
"IdCategoriaImpuestoGanancia": 6065,
|
|
854
|
-
"Nombre": "Exento"
|
|
855
|
-
},
|
|
856
|
-
"CategoriaRetencionIVA": null,
|
|
857
|
-
"CategoriaRetencionSUSS": null,
|
|
858
|
-
"ClaseProveedor": {
|
|
859
|
-
"IdClaseProveedor": 8609,
|
|
860
|
-
"Codigo": "02",
|
|
861
|
-
"Nombre": "DISTRIBUIDOR"
|
|
862
|
-
},
|
|
863
|
-
"Zona": {
|
|
864
|
-
"IdZona": 6095,
|
|
865
|
-
"Codigo": "Zona Defecto",
|
|
866
|
-
"Nombre": "Zona Defecto",
|
|
867
|
-
"Activo": true,
|
|
868
|
-
"EntregaLunes": false,
|
|
869
|
-
"EntregaMartes": false,
|
|
870
|
-
"EntregaMiercoles": false,
|
|
871
|
-
"EntregaJueves": false,
|
|
872
|
-
"EntregaViernes": false,
|
|
873
|
-
"EntregaSabado": false,
|
|
874
|
-
"EntregaDomingo": false,
|
|
875
|
-
"DemoraEnHorasFechaEntrega": 24,
|
|
876
|
-
"CostoEntrega": 10000
|
|
877
|
-
},
|
|
878
|
-
"DescuentoProveedor": null,
|
|
879
|
-
"DiasEntrega": 0,
|
|
880
|
-
"Activo": true
|
|
881
|
-
},
|
|
882
|
-
"PorcentajeDescuento": 0.000000,
|
|
883
|
-
"Observaciones": "",
|
|
884
|
-
"OrdenCompraArticulos": [
|
|
885
|
-
{
|
|
886
|
-
"IdArticulo": 2757,
|
|
887
|
-
"Codigo": "00002757",
|
|
888
|
-
"Nombre": "GALL MARYSOL MARINERAS 300gr",
|
|
889
|
-
"Cantidad": 1.000,
|
|
890
|
-
"SegundoControlStock": 0.000,
|
|
891
|
-
"Precio": 7.0,
|
|
892
|
-
"PorcentajeDescuento1": 0.000,
|
|
893
|
-
"PorcentajeDescuento2": 0.000,
|
|
894
|
-
"PorcentajeDescuento3": 0.000,
|
|
895
|
-
"DescuentoCalculado": 0.000000,
|
|
896
|
-
"CategoriaImpuestoIVA": {
|
|
897
|
-
"IdCategoriaImpuestoIVA": 4,
|
|
898
|
-
"Codigo": "5",
|
|
899
|
-
"Nombre": "IVA 21.00",
|
|
900
|
-
"Tasa": 21.000
|
|
901
|
-
},
|
|
902
|
-
"ImpuestoInterno": 0.000,
|
|
903
|
-
"Observaciones": ""
|
|
904
|
-
}
|
|
905
|
-
],
|
|
906
|
-
"FechaVencimiento": "2029-11-07T00:00:00",
|
|
907
|
-
"OperadorCompra": {
|
|
908
|
-
"IdOperadorCompra": 1,
|
|
909
|
-
"Codigo": "1",
|
|
910
|
-
"Nombre": "Operador de Compras Defecto",
|
|
911
|
-
"EsSupervisor": false
|
|
912
|
-
},
|
|
913
|
-
}
|
|
768
|
+
body
|
|
914
769
|
});
|
|
915
770
|
return [this.helpers.returnJsonArray(response)];
|
|
916
771
|
}
|
|
917
772
|
catch (error) {
|
|
918
|
-
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
919
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Error creando la compra.\n ${errorMessage}`);
|
|
920
|
-
}
|
|
921
|
-
}
|
|
922
|
-
case "generarToken": {
|
|
923
|
-
try {
|
|
924
|
-
const tokenGenerado = (0, functions_1.createHash)(headers.publicAccessKey);
|
|
925
|
-
return [this.helpers.returnJsonArray(tokenGenerado)];
|
|
926
|
-
}
|
|
927
|
-
catch (error) {
|
|
928
|
-
console.log(error);
|
|
929
773
|
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
930
774
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage);
|
|
931
775
|
}
|
|
932
776
|
}
|
|
933
|
-
case "
|
|
777
|
+
case "crearVenta": {
|
|
934
778
|
const numeroPuntoDeVenta = this.getNodeParameter("puntoDeVenta", 0);
|
|
935
779
|
const bonificacion = this.getNodeParameter("bonificacion", 0, "");
|
|
936
780
|
const esContado = this.getNodeParameter("esContado", 0);
|
|
@@ -1028,34 +872,416 @@ class Centum {
|
|
|
1028
872
|
];
|
|
1029
873
|
}
|
|
1030
874
|
try {
|
|
1031
|
-
const url = `${centumUrl}/Ventas?verificaLimiteCreditoCliente=false&verificaStockNegativo=false&verificaCuotificador=false`;
|
|
1032
|
-
const response = await (0, functions_1.apiRequest)(url, {
|
|
875
|
+
const url = `${centumUrl}/Ventas?verificaLimiteCreditoCliente=false&verificaStockNegativo=false&verificaCuotificador=false`;
|
|
876
|
+
const response = await (0, functions_1.apiRequest)(url, {
|
|
877
|
+
method: "POST",
|
|
878
|
+
headers,
|
|
879
|
+
body: bodyVenta,
|
|
880
|
+
});
|
|
881
|
+
return [this.helpers.returnJsonArray(response)];
|
|
882
|
+
}
|
|
883
|
+
catch (error) {
|
|
884
|
+
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
885
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Error creando la venta.\n${errorMessage}`);
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
case "descargarImagenesProductos": {
|
|
889
|
+
const arrResult = [];
|
|
890
|
+
const inputData = this.getInputData();
|
|
891
|
+
const requestUrl = `${centumUrl}/ArticulosImagenes`;
|
|
892
|
+
for (let i = 0; i < inputData.length; i++) {
|
|
893
|
+
const element = inputData[i];
|
|
894
|
+
const dataObj = {
|
|
895
|
+
idArticulo: element.json.IdArticulo,
|
|
896
|
+
images: [],
|
|
897
|
+
infoImages: [],
|
|
898
|
+
};
|
|
899
|
+
const allArticleImages = await (0, functions_1.centumGetArticleImages)(1, element.json.IdArticulo, {
|
|
900
|
+
consumerApiPublicId,
|
|
901
|
+
publicAccessKey: String(centumApiCredentials.publicAccessKey),
|
|
902
|
+
}, requestUrl);
|
|
903
|
+
if (allArticleImages instanceof Error) {
|
|
904
|
+
console.error(`Failed to download images for article ${element.json.IdArticulo}`, allArticleImages);
|
|
905
|
+
continue;
|
|
906
|
+
}
|
|
907
|
+
if (allArticleImages.length > 0) {
|
|
908
|
+
for (let j = 0; j < allArticleImages.length; j++) {
|
|
909
|
+
const binary = {};
|
|
910
|
+
const dataImage = allArticleImages[j];
|
|
911
|
+
const buffer = Buffer.from(dataImage.buffer);
|
|
912
|
+
binary["data"] = await this.helpers.prepareBinaryData(buffer);
|
|
913
|
+
binary.data.fileName = `${element.json.Codigo}_${j + 1}.${binary.data.fileExtension}`;
|
|
914
|
+
dataObj.images.push(binary);
|
|
915
|
+
dataObj.infoImages.push({
|
|
916
|
+
lastModified: dataImage.lastModified,
|
|
917
|
+
orderNumber: dataImage.orderNumber,
|
|
918
|
+
});
|
|
919
|
+
const existObj = arrResult.find((obj) => obj.idArticulo === element.json.IdArticulo);
|
|
920
|
+
if (!existObj) {
|
|
921
|
+
arrResult.push(dataObj);
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
else {
|
|
926
|
+
dataObj.images = null;
|
|
927
|
+
arrResult.push(dataObj);
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
return [this.helpers.returnJsonArray(arrResult)];
|
|
931
|
+
}
|
|
932
|
+
case "estadisticaVentaRanking": {
|
|
933
|
+
const fechaDesdeString = this.getNodeParameter('startDate', 0);
|
|
934
|
+
const fechaHastaString = this.getNodeParameter('endDate', 0);
|
|
935
|
+
const tipoDeRanking = this.getNodeParameter('tipoDeRanking', 0);
|
|
936
|
+
const orderByRanking = this.getNodeParameter('ventaRankingOrderBy', 0);
|
|
937
|
+
const orderAsc = this.getNodeParameter('orderAsc', 0);
|
|
938
|
+
const cantItems = this.getNodeParameter('cantidadDeItems', 0);
|
|
939
|
+
const fechaDesde = String(fechaDesdeString).split("T")[0];
|
|
940
|
+
const fechaHasta = String(fechaHastaString).split("T")[0];
|
|
941
|
+
let url = `${centumUrl}/EstadisticaVentaRanking/${cantItems}`;
|
|
942
|
+
if (fechaDesde && fechaHasta) {
|
|
943
|
+
url += `?fechaDocumentoDesde=${fechaDesde}&fechaDocumentoHasta=${fechaHasta}`;
|
|
944
|
+
}
|
|
945
|
+
else {
|
|
946
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Ambos periodos de fecha son necesarios.');
|
|
947
|
+
}
|
|
948
|
+
if (tipoDeRanking) {
|
|
949
|
+
if (tipoDeRanking === 'esRankingClientes') {
|
|
950
|
+
url += `&${tipoDeRanking}=true`;
|
|
951
|
+
}
|
|
952
|
+
if (tipoDeRanking === 'esRankingArticulos') {
|
|
953
|
+
url += `&${tipoDeRanking}=true`;
|
|
954
|
+
}
|
|
955
|
+
if (tipoDeRanking === 'esRankingVendedores') {
|
|
956
|
+
url += `&${tipoDeRanking}=true`;
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
if (orderByRanking) {
|
|
960
|
+
if (orderByRanking === 'CantidadUnidadNivel0') {
|
|
961
|
+
url += `&tipoOrdenEstadisticaVentaRanking=${orderByRanking}`;
|
|
962
|
+
}
|
|
963
|
+
if (orderByRanking === 'CantidadUnidadNivel1') {
|
|
964
|
+
url += `&tipoOrdenEstadisticaVentaRanking=${orderByRanking}`;
|
|
965
|
+
}
|
|
966
|
+
if (orderByRanking === 'CantidadUnidadNivel2') {
|
|
967
|
+
url += `&tipoOrdenEstadisticaVentaRanking=${orderByRanking}`;
|
|
968
|
+
}
|
|
969
|
+
if (orderByRanking === 'ImporteTotalNeto') {
|
|
970
|
+
url += `&tipoOrdenEstadisticaVentaRanking=${orderByRanking}`;
|
|
971
|
+
}
|
|
972
|
+
if (orderByRanking === 'ImporteTotalFinal') {
|
|
973
|
+
url += `&tipoOrdenEstadisticaVentaRanking=${orderByRanking}`;
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
if (orderAsc !== null) {
|
|
977
|
+
url += `&ordenEstadisticaVentaRankingAscendente=${orderAsc}`;
|
|
978
|
+
}
|
|
979
|
+
try {
|
|
980
|
+
const response = await (0, functions_1.apiRequest)(`${url}`, {
|
|
981
|
+
method: "GET",
|
|
982
|
+
headers,
|
|
983
|
+
});
|
|
984
|
+
return [this.helpers.returnJsonArray(response)];
|
|
985
|
+
}
|
|
986
|
+
catch (error) {
|
|
987
|
+
console.log("Error en solicitud de promociones para el cliente:", error);
|
|
988
|
+
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
989
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Error obteniendo el listado de precios. \n ${errorMessage}`);
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
case "generarTokenSeguridad": {
|
|
993
|
+
try {
|
|
994
|
+
const tokenGenerado = (0, functions_1.createHash)(headers.publicAccessKey);
|
|
995
|
+
return [this.helpers.returnJsonArray(tokenGenerado)];
|
|
996
|
+
}
|
|
997
|
+
catch (error) {
|
|
998
|
+
console.log(error);
|
|
999
|
+
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
1000
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage);
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
case 'listarBonificaciones': {
|
|
1004
|
+
try {
|
|
1005
|
+
const bonificaciones = await (0, functions_1.apiRequest)(`${centumUrl}/Bonificaciones`, {
|
|
1006
|
+
method: "GET",
|
|
1007
|
+
headers
|
|
1008
|
+
});
|
|
1009
|
+
return [this.helpers.returnJsonArray([bonificaciones])];
|
|
1010
|
+
}
|
|
1011
|
+
catch (error) {
|
|
1012
|
+
console.error("Error al obtener las bonificaciones:", error);
|
|
1013
|
+
const statusCode = error?.response?.status;
|
|
1014
|
+
const responseData = error?.response?.data;
|
|
1015
|
+
const errorMessage = responseData?.Message || responseData?.message || error?.message || "Error desconocido al crear el contribuyente.";
|
|
1016
|
+
const fullMessage = statusCode ? `Error ${statusCode}: ${errorMessage}` : errorMessage;
|
|
1017
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), fullMessage, {
|
|
1018
|
+
description: responseData?.Detail || "Ocurrió un error inesperado al llamar a la API de Centum.",
|
|
1019
|
+
});
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
case "listarCategorias": {
|
|
1023
|
+
const subRubro = this.getNodeParameter('idsSubRubros', 0);
|
|
1024
|
+
let url = `${centumUrl}/CategoriasArticulo`;
|
|
1025
|
+
if (subRubro) {
|
|
1026
|
+
url = `${url}?idSubRubro=${subRubro}`;
|
|
1027
|
+
}
|
|
1028
|
+
try {
|
|
1029
|
+
const response = await (0, functions_1.apiRequest)(url);
|
|
1030
|
+
return [this.helpers.returnJsonArray(response)];
|
|
1031
|
+
}
|
|
1032
|
+
catch (error) {
|
|
1033
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Hubo un error al obtener el listado de categorias. Error: ${error}`);
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
case "listarClientes": {
|
|
1037
|
+
try {
|
|
1038
|
+
const ajustesHTTP = functions_1.getHttpSettings.call(this);
|
|
1039
|
+
const clientesURL = `${centumUrl}/Clientes`;
|
|
1040
|
+
const fetchOptions = {
|
|
1041
|
+
method: "GET",
|
|
1042
|
+
pagination: ajustesHTTP.pagination,
|
|
1043
|
+
cantidadItemsPorPagina: ajustesHTTP.cantidadItemsPorPagina,
|
|
1044
|
+
intervaloPagina: ajustesHTTP.intervaloPagina,
|
|
1045
|
+
itemsField: "Items",
|
|
1046
|
+
context: this,
|
|
1047
|
+
headers,
|
|
1048
|
+
};
|
|
1049
|
+
let clientes = [];
|
|
1050
|
+
const paginated = await (0, functions_1.apiGetRequest)(clientesURL, fetchOptions);
|
|
1051
|
+
clientes = paginated;
|
|
1052
|
+
return [this.helpers.returnJsonArray(clientes)];
|
|
1053
|
+
}
|
|
1054
|
+
catch (error) {
|
|
1055
|
+
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
1056
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage);
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
case "listarCobros": {
|
|
1060
|
+
const idCliente = this.getNodeParameter("clienteId", 0);
|
|
1061
|
+
const idCobro = this.getNodeParameter("idCobro", 0);
|
|
1062
|
+
const fechaDesde = this.getNodeParameter("startDate", 0, "");
|
|
1063
|
+
const fechaHasta = this.getNodeParameter("endDate", 0, "");
|
|
1064
|
+
const separarFechaDesde = String(fechaDesde).split("T")[0];
|
|
1065
|
+
const separarFechaHasta = String(fechaHasta).split("T")[0];
|
|
1066
|
+
if (!idCliente && !separarFechaDesde && !separarFechaHasta && !idCobro) {
|
|
1067
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Debes ingresar almenos un parametro para realizar la búsqueda.");
|
|
1068
|
+
}
|
|
1069
|
+
const body = {
|
|
1070
|
+
idCliente,
|
|
1071
|
+
fechaDocumentoDesde: separarFechaDesde,
|
|
1072
|
+
fechaDocumentoHasta: separarFechaHasta,
|
|
1073
|
+
idCobro,
|
|
1074
|
+
};
|
|
1075
|
+
try {
|
|
1076
|
+
const response = await (0, functions_1.apiRequest)(`${centumUrl}/Cobros/FiltrosCobro`, {
|
|
1077
|
+
method: "POST",
|
|
1078
|
+
headers,
|
|
1079
|
+
body,
|
|
1080
|
+
});
|
|
1081
|
+
return [this.helpers.returnJsonArray(response)];
|
|
1082
|
+
}
|
|
1083
|
+
catch (error) {
|
|
1084
|
+
console.log("Error en obtener el listado de cobros:", error);
|
|
1085
|
+
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
1086
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Error en obtener el listado de cobros para cliente ${idCliente}: ${errorMessage}`);
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
case "listarCompras": {
|
|
1090
|
+
const idCliente = this.getNodeParameter("clienteId", 0);
|
|
1091
|
+
const idCompra = this.getNodeParameter("idCompra", 0);
|
|
1092
|
+
const fechaDesde = this.getNodeParameter("startDate", 0, "");
|
|
1093
|
+
const fechaHasta = this.getNodeParameter("endDate", 0, "");
|
|
1094
|
+
const separarFechaDesde = String(fechaDesde).split("T")[0];
|
|
1095
|
+
const separarFechaHasta = String(fechaHasta).split("T")[0];
|
|
1096
|
+
if (!idCliente && !separarFechaDesde && !separarFechaHasta && !idCompra) {
|
|
1097
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Debes ingresar almenos un parametro para realizar la búsqueda.");
|
|
1098
|
+
}
|
|
1099
|
+
const body = {
|
|
1100
|
+
idCliente,
|
|
1101
|
+
fechaDocumentoDesde: separarFechaDesde,
|
|
1102
|
+
fechaDocumentoHasta: separarFechaHasta,
|
|
1103
|
+
idCompra,
|
|
1104
|
+
};
|
|
1105
|
+
try {
|
|
1106
|
+
const response = await (0, functions_1.apiRequest)(`${centumUrl}/Compras/FiltrosCompra`, {
|
|
1107
|
+
method: "POST",
|
|
1108
|
+
headers,
|
|
1109
|
+
body,
|
|
1110
|
+
});
|
|
1111
|
+
return [this.helpers.returnJsonArray(response)];
|
|
1112
|
+
}
|
|
1113
|
+
catch (error) {
|
|
1114
|
+
console.log("Error en obtener el listado de cobros:", error);
|
|
1115
|
+
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
1116
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Error en obtener el listado de cobros para cliente ${idCliente}: ${errorMessage}`);
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
case "listarConceptos": {
|
|
1120
|
+
let url = `${centumUrl}/Conceptos`;
|
|
1121
|
+
try {
|
|
1122
|
+
const response = await (0, functions_1.apiRequest)(url, {
|
|
1123
|
+
method: "GET",
|
|
1124
|
+
headers
|
|
1125
|
+
});
|
|
1126
|
+
return [this.helpers.returnJsonArray(response)];
|
|
1127
|
+
}
|
|
1128
|
+
catch (error) {
|
|
1129
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Hubo un error al obtener el listado de conceptos. Error: ${error}`);
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
case "listarDepartamentos": {
|
|
1133
|
+
const idProvincia = this.getNodeParameter("idProvincia", 0, "");
|
|
1134
|
+
try {
|
|
1135
|
+
const queryParams = {};
|
|
1136
|
+
if (idProvincia) {
|
|
1137
|
+
queryParams.idProvincia = idProvincia;
|
|
1138
|
+
}
|
|
1139
|
+
const departamentos = await (0, functions_1.apiRequest)(`${centumUrl}/Departamentos`, {
|
|
1140
|
+
method: "GET",
|
|
1141
|
+
headers,
|
|
1142
|
+
queryParams,
|
|
1143
|
+
});
|
|
1144
|
+
return [this.helpers.returnJsonArray(departamentos.map((d) => ({ ...d })))];
|
|
1145
|
+
}
|
|
1146
|
+
catch (error) {
|
|
1147
|
+
console.log(error);
|
|
1148
|
+
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
1149
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage);
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
case "listarEstadosPedidosVenta": {
|
|
1153
|
+
try {
|
|
1154
|
+
const response = await (0, functions_1.apiRequest)(`${centumUrl}/EstadosPedidoVenta?bIncluirTodosEstados=true`, {
|
|
1155
|
+
method: "GET",
|
|
1156
|
+
headers,
|
|
1157
|
+
});
|
|
1158
|
+
return [this.helpers.returnJsonArray(response)];
|
|
1159
|
+
}
|
|
1160
|
+
catch (error) {
|
|
1161
|
+
console.log(error);
|
|
1162
|
+
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
1163
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage);
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
case "listarFacturasCobros": {
|
|
1167
|
+
const clientIdParam = this.getNodeParameter("clienteId", 0);
|
|
1168
|
+
const desdeSaldoFecha = this.getNodeParameter("startDate", 0);
|
|
1169
|
+
const hastaSaldoFecha = this.getNodeParameter("endDate", 0);
|
|
1170
|
+
const separarFechaDesde = String(desdeSaldoFecha).split("T")[0];
|
|
1171
|
+
const separarFechaHasta = String(hastaSaldoFecha).split("T")[0];
|
|
1172
|
+
const clientId = Number(clientIdParam);
|
|
1173
|
+
if (isNaN(clientId) || clientId <= 0) {
|
|
1174
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "clienteId debe ser un número positivo");
|
|
1175
|
+
}
|
|
1176
|
+
if (!desdeSaldoFecha) {
|
|
1177
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "priceDateModified (fecha desde) es requerido");
|
|
1178
|
+
}
|
|
1179
|
+
if (!hastaSaldoFecha) {
|
|
1180
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "priceDateModifiedSince (fecha hasta) es requerido");
|
|
1181
|
+
}
|
|
1182
|
+
try {
|
|
1183
|
+
const body = {
|
|
1184
|
+
fechaDocumentoDesde: separarFechaDesde,
|
|
1185
|
+
fechaDocumentoHasta: separarFechaHasta,
|
|
1186
|
+
IdCliente: clientId,
|
|
1187
|
+
};
|
|
1188
|
+
const response = await (0, functions_1.apiRequest)(`${centumUrl}/Cobros/FiltrosCobro`, {
|
|
1033
1189
|
method: "POST",
|
|
1034
1190
|
headers,
|
|
1035
|
-
body
|
|
1191
|
+
body,
|
|
1036
1192
|
});
|
|
1193
|
+
if (!response || typeof response !== "object") {
|
|
1194
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Respuesta inválida del servidor");
|
|
1195
|
+
}
|
|
1037
1196
|
return [this.helpers.returnJsonArray(response)];
|
|
1038
1197
|
}
|
|
1039
1198
|
catch (error) {
|
|
1199
|
+
console.log("Error en solicitud de facturas pedidos ventas:", error);
|
|
1040
1200
|
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
1041
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Error
|
|
1201
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Error obteniendo facturas pedidos ventas para cliente ${clientId}: ${errorMessage}`);
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
case "listarFacturasVenta": {
|
|
1205
|
+
const idCliente = this.getNodeParameter('clienteId', 0);
|
|
1206
|
+
const idVenta = this.getNodeParameter('ventaId', 0);
|
|
1207
|
+
const idSucursal = this.getNodeParameter('sucursalId', 0);
|
|
1208
|
+
const idDivisionEmpresa = this.getNodeParameter('divisionEmpresaId', 0);
|
|
1209
|
+
const incluirAnulados = this.getNodeParameter('incluirAnulados', 0);
|
|
1210
|
+
const idUsuarioCreador = this.getNodeParameter('usuarioCreadorId', 0);
|
|
1211
|
+
const idTransporte = this.getNodeParameter('transporteId', 0);
|
|
1212
|
+
const idTipoComprobante = this.getNodeParameter('idTipoComprobante', 0);
|
|
1213
|
+
const idClienteCuentaCorriente = this.getNodeParameter('cuentaCorrienteId', 0);
|
|
1214
|
+
const idVendedor = this.getNodeParameter('idVendedor', 0);
|
|
1215
|
+
const idCanalVenta = this.getNodeParameter('canalVentaId', 0);
|
|
1216
|
+
const desdeSaldoFecha = this.getNodeParameter("startDate", 0);
|
|
1217
|
+
const hastaSaldoFecha = this.getNodeParameter("endDate", 0);
|
|
1218
|
+
if (!desdeSaldoFecha || !hastaSaldoFecha) {
|
|
1219
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Las fechas desde y hasta son requeridas");
|
|
1220
|
+
}
|
|
1221
|
+
const body = {
|
|
1222
|
+
fechaDocumentoDesde: String(desdeSaldoFecha).split("T")[0],
|
|
1223
|
+
fechaDocumentoHasta: String(hastaSaldoFecha).split("T")[0],
|
|
1224
|
+
};
|
|
1225
|
+
idCliente && (body.idCliente = idCliente);
|
|
1226
|
+
idVenta && (body.idVenta = idVenta);
|
|
1227
|
+
idSucursal && (body.idSucursal = idSucursal);
|
|
1228
|
+
idDivisionEmpresa && (body.idDivisionEmpresa = idDivisionEmpresa);
|
|
1229
|
+
idUsuarioCreador && (body.idUsuarioCreador = idUsuarioCreador);
|
|
1230
|
+
idTransporte && (body.idTransporte = idTransporte);
|
|
1231
|
+
idTipoComprobante && (body.idTipoComprobante = idTipoComprobante);
|
|
1232
|
+
idClienteCuentaCorriente && (body.idClienteCuentaCorriente = idClienteCuentaCorriente);
|
|
1233
|
+
idVendedor && (body.idVendedor = idVendedor);
|
|
1234
|
+
idCanalVenta && (body.idCanalVenta = idCanalVenta);
|
|
1235
|
+
incluirAnulados && (body.incluirAnulados = incluirAnulados);
|
|
1236
|
+
const response = await (0, functions_1.apiRequest)(`${centumUrl}/Ventas/FiltrosVentaConsulta`, {
|
|
1237
|
+
method: "POST",
|
|
1238
|
+
headers,
|
|
1239
|
+
body,
|
|
1240
|
+
});
|
|
1241
|
+
if (!response || typeof response !== "object") {
|
|
1242
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Respuesta inválida del servidor");
|
|
1042
1243
|
}
|
|
1244
|
+
return [this.helpers.returnJsonArray(response)];
|
|
1043
1245
|
}
|
|
1044
|
-
case "
|
|
1246
|
+
case "listarFacturasVentasPorCliente": {
|
|
1247
|
+
const clientIdParam = this.getNodeParameter("clienteId", 0);
|
|
1248
|
+
const desdeSaldoFecha = this.getNodeParameter("startDate", 0);
|
|
1249
|
+
const hastaSaldoFecha = this.getNodeParameter("endDate", 0);
|
|
1250
|
+
const separarFechaDesde = String(desdeSaldoFecha).split("T")[0];
|
|
1251
|
+
const separarFechaHasta = String(hastaSaldoFecha).split("T")[0];
|
|
1252
|
+
const clientId = Number(clientIdParam);
|
|
1253
|
+
if (isNaN(clientId) || clientId <= 0) {
|
|
1254
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "clienteId debe ser un número positivo");
|
|
1255
|
+
}
|
|
1256
|
+
if (!desdeSaldoFecha) {
|
|
1257
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "priceDateModified (fecha desde) es requerido");
|
|
1258
|
+
}
|
|
1259
|
+
if (!hastaSaldoFecha) {
|
|
1260
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "priceDateModifiedSince (fecha hasta) es requerido");
|
|
1261
|
+
}
|
|
1045
1262
|
try {
|
|
1046
|
-
const
|
|
1047
|
-
|
|
1263
|
+
const body = {
|
|
1264
|
+
fechaDocumentoDesde: separarFechaDesde,
|
|
1265
|
+
fechaDocumentoHasta: separarFechaHasta,
|
|
1266
|
+
IdCliente: clientId,
|
|
1267
|
+
};
|
|
1268
|
+
const response = await (0, functions_1.apiRequest)(`${centumUrl}/Ventas/FiltrosVenta`, {
|
|
1269
|
+
method: "POST",
|
|
1048
1270
|
headers,
|
|
1271
|
+
body,
|
|
1049
1272
|
});
|
|
1273
|
+
if (!response || typeof response !== "object") {
|
|
1274
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Respuesta inválida del servidor");
|
|
1275
|
+
}
|
|
1050
1276
|
return [this.helpers.returnJsonArray(response)];
|
|
1051
1277
|
}
|
|
1052
1278
|
catch (error) {
|
|
1053
|
-
console.log("Error en solicitud de
|
|
1279
|
+
console.log("Error en solicitud de facturas pedidos ventas:", error);
|
|
1054
1280
|
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
1055
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Error obteniendo
|
|
1281
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Error obteniendo facturas pedidos ventas para cliente ${clientId}: ${errorMessage}`);
|
|
1056
1282
|
}
|
|
1057
1283
|
}
|
|
1058
|
-
case "
|
|
1284
|
+
case "listarMarcas": {
|
|
1059
1285
|
try {
|
|
1060
1286
|
const response = await (0, functions_1.apiRequest)(`${centumUrl}/MarcasArticulo`, {
|
|
1061
1287
|
method: 'GET',
|
|
@@ -1069,71 +1295,88 @@ class Centum {
|
|
|
1069
1295
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Error en obtener el listado de marcas. \n ${errorMessage}`);
|
|
1070
1296
|
}
|
|
1071
1297
|
}
|
|
1072
|
-
case "
|
|
1073
|
-
const
|
|
1074
|
-
const
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1298
|
+
case "listarOrdenesCompra": {
|
|
1299
|
+
const idProveedor = this.getNodeParameter("proveedorId", 0);
|
|
1300
|
+
const desdeSaldoFecha = this.getNodeParameter("startDate", 0);
|
|
1301
|
+
const hastaSaldoFecha = this.getNodeParameter("endDate", 0);
|
|
1302
|
+
const separarFechaDesde = String(desdeSaldoFecha).split("T")[0];
|
|
1303
|
+
const separarFechaHasta = String(hastaSaldoFecha).split("T")[0];
|
|
1304
|
+
if (!desdeSaldoFecha) {
|
|
1305
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "priceDateModified (fecha desde) es requerido");
|
|
1306
|
+
}
|
|
1307
|
+
if (!hastaSaldoFecha) {
|
|
1308
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "priceDateModifiedSince (fecha hasta) es requerido");
|
|
1078
1309
|
}
|
|
1079
|
-
const contribuyenteJSON = (0, functions_1.createContribuyenteJson)(bodyJson, cuit);
|
|
1080
1310
|
try {
|
|
1081
|
-
const
|
|
1311
|
+
const body = {
|
|
1312
|
+
fechaDocumentoDesde: separarFechaDesde,
|
|
1313
|
+
fechaDocumentoHasta: separarFechaHasta,
|
|
1314
|
+
idProveedor
|
|
1315
|
+
};
|
|
1316
|
+
const response = await (0, functions_1.apiRequest)(`${centumUrl}/OrdenesCompra/FiltrosOrdenCompra`, {
|
|
1082
1317
|
method: "POST",
|
|
1083
|
-
body: contribuyenteJSON,
|
|
1084
1318
|
headers,
|
|
1319
|
+
body,
|
|
1085
1320
|
});
|
|
1086
|
-
|
|
1087
|
-
|
|
1321
|
+
if (!response || typeof response !== "object") {
|
|
1322
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Respuesta inválida del servidor");
|
|
1323
|
+
}
|
|
1324
|
+
return [this.helpers.returnJsonArray(response)];
|
|
1088
1325
|
}
|
|
1089
1326
|
catch (error) {
|
|
1090
|
-
console.
|
|
1091
|
-
const
|
|
1092
|
-
|
|
1093
|
-
const errorMessage = responseData?.Message || responseData?.message || error?.message || "Error desconocido al crear el contribuyente.";
|
|
1094
|
-
const fullMessage = statusCode ? `Error ${statusCode}: ${errorMessage}` : errorMessage;
|
|
1095
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), fullMessage, {
|
|
1096
|
-
description: responseData?.Detail || "Ocurrió un error inesperado al llamar a la API de Centum.",
|
|
1097
|
-
});
|
|
1327
|
+
console.log("Error en solicitud de facturas pedidos ventas:", error);
|
|
1328
|
+
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
1329
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Error obteniendo ordenes de compra del proveedor ${idProveedor}: ${errorMessage}`);
|
|
1098
1330
|
}
|
|
1099
1331
|
}
|
|
1100
|
-
case
|
|
1332
|
+
case "listarPedidosVenta": {
|
|
1333
|
+
const idCliente = this.getNodeParameter("clienteId", 0);
|
|
1334
|
+
const idsEstado = this.getNodeParameter("statusId", 0);
|
|
1335
|
+
const fechaDesde = this.getNodeParameter("startDate", 0, "");
|
|
1336
|
+
const fechaHasta = this.getNodeParameter("endDate", 0, "");
|
|
1337
|
+
const separarFechaDesde = String(fechaDesde).split("T")[0];
|
|
1338
|
+
const separarFechaHasta = String(fechaHasta).split("T")[0];
|
|
1339
|
+
if (!idCliente && !idsEstado && !separarFechaDesde && !separarFechaHasta) {
|
|
1340
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Debes ingresar almenos un parametro para realizar la búsqueda.");
|
|
1341
|
+
}
|
|
1342
|
+
const body = {
|
|
1343
|
+
idCliente,
|
|
1344
|
+
fechaDocumentoDesde: separarFechaDesde,
|
|
1345
|
+
fechaDocumentoHasta: separarFechaHasta,
|
|
1346
|
+
idsEstado,
|
|
1347
|
+
};
|
|
1101
1348
|
try {
|
|
1102
|
-
const
|
|
1103
|
-
method: "
|
|
1104
|
-
headers
|
|
1349
|
+
const response = await (0, functions_1.apiRequest)(`${centumUrl}/PedidosVenta/FiltrosPedidoVenta`, {
|
|
1350
|
+
method: "POST",
|
|
1351
|
+
headers,
|
|
1352
|
+
body,
|
|
1105
1353
|
});
|
|
1106
|
-
return [this.helpers.returnJsonArray(
|
|
1354
|
+
return [this.helpers.returnJsonArray(response)];
|
|
1107
1355
|
}
|
|
1108
1356
|
catch (error) {
|
|
1109
|
-
console.
|
|
1110
|
-
const
|
|
1111
|
-
|
|
1112
|
-
const errorMessage = responseData?.Message || responseData?.message || error?.message || "Error desconocido al crear el contribuyente.";
|
|
1113
|
-
const fullMessage = statusCode ? `Error ${statusCode}: ${errorMessage}` : errorMessage;
|
|
1114
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), fullMessage, {
|
|
1115
|
-
description: responseData?.Detail || "Ocurrió un error inesperado al llamar a la API de Centum.",
|
|
1116
|
-
});
|
|
1357
|
+
console.log("Error en solicitud de facturas pedidos ventas:", error);
|
|
1358
|
+
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
1359
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Error obteniendo los pedidos ventas para cliente ${idCliente}: ${errorMessage}`);
|
|
1117
1360
|
}
|
|
1118
1361
|
}
|
|
1119
|
-
case "
|
|
1362
|
+
case "listarPedidosVentaFiltrados": {
|
|
1120
1363
|
const idCliente = this.getNodeParameter("clienteId", 0);
|
|
1121
|
-
const
|
|
1364
|
+
const idsEstado = this.getNodeParameter("statusId", 0);
|
|
1122
1365
|
const fechaDesde = this.getNodeParameter("startDate", 0, "");
|
|
1123
1366
|
const fechaHasta = this.getNodeParameter("endDate", 0, "");
|
|
1124
1367
|
const separarFechaDesde = String(fechaDesde).split("T")[0];
|
|
1125
1368
|
const separarFechaHasta = String(fechaHasta).split("T")[0];
|
|
1126
|
-
if (!idCliente && !
|
|
1369
|
+
if (!idCliente && !idsEstado && !separarFechaDesde && !separarFechaHasta) {
|
|
1127
1370
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Debes ingresar almenos un parametro para realizar la búsqueda.");
|
|
1128
1371
|
}
|
|
1129
1372
|
const body = {
|
|
1130
1373
|
idCliente,
|
|
1131
1374
|
fechaDocumentoDesde: separarFechaDesde,
|
|
1132
1375
|
fechaDocumentoHasta: separarFechaHasta,
|
|
1133
|
-
|
|
1376
|
+
idsEstado,
|
|
1134
1377
|
};
|
|
1135
1378
|
try {
|
|
1136
|
-
const response = await (0, functions_1.apiRequest)(`${centumUrl}/
|
|
1379
|
+
const response = await (0, functions_1.apiRequest)(`${centumUrl}/PedidosVenta/FiltrosPedidoVentaConsulta`, {
|
|
1137
1380
|
method: "POST",
|
|
1138
1381
|
headers,
|
|
1139
1382
|
body,
|
|
@@ -1141,48 +1384,124 @@ class Centum {
|
|
|
1141
1384
|
return [this.helpers.returnJsonArray(response)];
|
|
1142
1385
|
}
|
|
1143
1386
|
catch (error) {
|
|
1144
|
-
console.log("Error en
|
|
1387
|
+
console.log("Error en solicitud de facturas pedidos ventas:", error);
|
|
1388
|
+
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
1389
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Error obteniendo los pedidos ventas para cliente ${idCliente}: ${errorMessage}`);
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
case "listarPrecios": {
|
|
1393
|
+
try {
|
|
1394
|
+
const response = await (0, functions_1.apiRequest)(`${centumUrl}/ListasPrecios`, {
|
|
1395
|
+
method: "GET",
|
|
1396
|
+
headers,
|
|
1397
|
+
});
|
|
1398
|
+
return [this.helpers.returnJsonArray(response)];
|
|
1399
|
+
}
|
|
1400
|
+
catch (error) {
|
|
1401
|
+
console.log("Error en solicitud de promociones para el cliente:", error);
|
|
1402
|
+
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
1403
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Error obteniendo el listado de precios. \n ${errorMessage}`);
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
case "listarProductosDisponibles": {
|
|
1407
|
+
const clientId = this.getNodeParameter("clienteId", 0);
|
|
1408
|
+
const documentDate = this.getNodeParameter("documentDate", 0);
|
|
1409
|
+
const IdsRubro = this.getNodeParameter("idsRubros", 0);
|
|
1410
|
+
const completeMigration = this.getNodeParameter("migracionCompleta", 0);
|
|
1411
|
+
const IdsSubRubro = this.getNodeParameter("idsSubRubros", 0);
|
|
1412
|
+
const formattedDocumentDate = documentDate.replace(/\..+/, "");
|
|
1413
|
+
const dateModified = this.getNodeParameter("dateModified", 0);
|
|
1414
|
+
const dateModifiedImage = this.getNodeParameter("dateModifiedImage", 0);
|
|
1415
|
+
const priceDateModified = this.getNodeParameter("priceDateModified", 0);
|
|
1416
|
+
const numeroPagina = this.getNodeParameter("numeroPagina", 0);
|
|
1417
|
+
const cantidadPorPagina = this.getNodeParameter("cantidadPorPagina", 0);
|
|
1418
|
+
const bodyToSend = {
|
|
1419
|
+
idCliente: clientId,
|
|
1420
|
+
FechaDocumento: formattedDocumentDate,
|
|
1421
|
+
incluirAtributosArticulos: true,
|
|
1422
|
+
IdsRubro: IdsRubro ? [IdsRubro] : [],
|
|
1423
|
+
IdsSubRubro: IdsSubRubro ? [IdsSubRubro] : [""],
|
|
1424
|
+
fechaModificacionDesde: dateModified ? dateModified : "",
|
|
1425
|
+
fechaModificacionImagenesDesde: dateModifiedImage ? dateModifiedImage : "",
|
|
1426
|
+
fechaPrecioActualizadoDesde: priceDateModified,
|
|
1427
|
+
numeroPagina,
|
|
1428
|
+
cantidadPorPagina,
|
|
1429
|
+
};
|
|
1430
|
+
try {
|
|
1431
|
+
const response = await (0, functions_1.apiRequest)(`${centumUrl}/Articulos/Venta`, {
|
|
1432
|
+
method: "POST",
|
|
1433
|
+
body: bodyToSend,
|
|
1434
|
+
headers,
|
|
1435
|
+
queryParams: { tipoOrdenArticulos: "Codigo" },
|
|
1436
|
+
});
|
|
1437
|
+
if (response.Articulos.Items.length > 0) {
|
|
1438
|
+
const items = response.Articulos.Items;
|
|
1439
|
+
if (!completeMigration) {
|
|
1440
|
+
const acc = [];
|
|
1441
|
+
for (const item of items) {
|
|
1442
|
+
const groupArticle = item.GrupoArticulo;
|
|
1443
|
+
if (!groupArticle)
|
|
1444
|
+
continue;
|
|
1445
|
+
const body = {
|
|
1446
|
+
idCliente: clientId,
|
|
1447
|
+
FechaDocumento: formattedDocumentDate,
|
|
1448
|
+
incluirAtributosArticulos: true,
|
|
1449
|
+
IdsRubro: IdsRubro ? [IdsRubro] : [],
|
|
1450
|
+
IdsSubRubro: IdsSubRubro ? [IdsSubRubro] : [""],
|
|
1451
|
+
NombreGrupoArticulo: groupArticle.Nombre,
|
|
1452
|
+
IdGrupoArticulo: groupArticle.IdGrupoArticulo,
|
|
1453
|
+
};
|
|
1454
|
+
try {
|
|
1455
|
+
const response = await (0, functions_1.apiRequest)(`${centumUrl}/Articulos/Venta`, {
|
|
1456
|
+
method: "POST",
|
|
1457
|
+
headers: { ...headers },
|
|
1458
|
+
body,
|
|
1459
|
+
queryParams: { tipoOrdenArticulos: "Codigo" },
|
|
1460
|
+
});
|
|
1461
|
+
if (response.Articulos.Items.length > 0) {
|
|
1462
|
+
acc.push(...response.Articulos.Items);
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
catch (error) {
|
|
1466
|
+
console.log("Error en solicitud de grupo de artículos", { error });
|
|
1467
|
+
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
1468
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage);
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
const combinedArrays = [...acc, ...items];
|
|
1472
|
+
const filteredArray = Array.from(new Map(combinedArrays.map((obj) => [obj.IdArticulo, obj])).values());
|
|
1473
|
+
const itemsArray = filteredArray.map((item) => ({
|
|
1474
|
+
...item,
|
|
1475
|
+
AtributosArticulo: item.Habilitado && item.ActivoWeb ? item.AtributosArticulo : [],
|
|
1476
|
+
}));
|
|
1477
|
+
return [this.helpers.returnJsonArray(itemsArray)];
|
|
1478
|
+
}
|
|
1479
|
+
return [this.helpers.returnJsonArray(items)];
|
|
1480
|
+
}
|
|
1481
|
+
else {
|
|
1482
|
+
return [this.helpers.returnJsonArray({ json: {} })];
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
catch (error) {
|
|
1486
|
+
console.log("Error en solicitud de artículos", error);
|
|
1145
1487
|
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
1146
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(),
|
|
1488
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage);
|
|
1147
1489
|
}
|
|
1148
1490
|
}
|
|
1149
|
-
case "
|
|
1150
|
-
const
|
|
1151
|
-
const
|
|
1152
|
-
|
|
1153
|
-
const fechaHasta = this.getNodeParameter("endDate", 0, "");
|
|
1154
|
-
const separarFechaDesde = String(fechaDesde).split("T")[0];
|
|
1155
|
-
const separarFechaHasta = String(fechaHasta).split("T")[0];
|
|
1156
|
-
if (!idCliente && !separarFechaDesde && !separarFechaHasta && !idCompra) {
|
|
1157
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Debes ingresar almenos un parametro para realizar la búsqueda.");
|
|
1158
|
-
}
|
|
1159
|
-
const body = {
|
|
1160
|
-
idCliente,
|
|
1161
|
-
fechaDocumentoDesde: separarFechaDesde,
|
|
1162
|
-
fechaDocumentoHasta: separarFechaHasta,
|
|
1163
|
-
idCompra,
|
|
1491
|
+
case "listarProductosPorSucursal": {
|
|
1492
|
+
const IdSucursalFisica = this.getNodeParameter("IdSucursalFisica", 0);
|
|
1493
|
+
const queryParams = {
|
|
1494
|
+
idsSucursalesFisicas: IdSucursalFisica,
|
|
1164
1495
|
};
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
method: "POST",
|
|
1168
|
-
headers,
|
|
1169
|
-
body,
|
|
1170
|
-
});
|
|
1171
|
-
return [this.helpers.returnJsonArray(response)];
|
|
1172
|
-
}
|
|
1173
|
-
catch (error) {
|
|
1174
|
-
console.log("Error en obtener el listado de cobros:", error);
|
|
1175
|
-
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
1176
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Error en obtener el listado de cobros para cliente ${idCliente}: ${errorMessage}`);
|
|
1496
|
+
if (!IdSucursalFisica) {
|
|
1497
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "El id de la sucursal fisica es obligatorio");
|
|
1177
1498
|
}
|
|
1178
|
-
}
|
|
1179
|
-
case "obtenerEstadosPedidosDeVenta": {
|
|
1180
1499
|
try {
|
|
1181
|
-
const
|
|
1182
|
-
method: "GET",
|
|
1500
|
+
const dataArticulosExistencias = await (0, functions_1.apiRequest)(`${centumUrl}/ArticulosSucursalesFisicas`, {
|
|
1183
1501
|
headers,
|
|
1502
|
+
queryParams,
|
|
1184
1503
|
});
|
|
1185
|
-
return [this.helpers.returnJsonArray(
|
|
1504
|
+
return [this.helpers.returnJsonArray(dataArticulosExistencias.Items)];
|
|
1186
1505
|
}
|
|
1187
1506
|
catch (error) {
|
|
1188
1507
|
console.log(error);
|
|
@@ -1190,29 +1509,22 @@ class Centum {
|
|
|
1190
1509
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage);
|
|
1191
1510
|
}
|
|
1192
1511
|
}
|
|
1193
|
-
case "
|
|
1512
|
+
case "listarPromocionesCliente": {
|
|
1194
1513
|
const clientIdParam = this.getNodeParameter("clienteId", 0);
|
|
1195
|
-
const
|
|
1196
|
-
const
|
|
1197
|
-
const separarFechaDesde = String(desdeSaldoFecha).split("T")[0];
|
|
1198
|
-
const separarFechaHasta = String(hastaSaldoFecha).split("T")[0];
|
|
1514
|
+
const documentDate = this.getNodeParameter("documentDate", 0);
|
|
1515
|
+
const diaSemana = this.getNodeParameter("diaSemana", 0);
|
|
1199
1516
|
const clientId = Number(clientIdParam);
|
|
1200
|
-
if (
|
|
1201
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "
|
|
1202
|
-
}
|
|
1203
|
-
if (!desdeSaldoFecha) {
|
|
1204
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "priceDateModified (fecha desde) es requerido");
|
|
1205
|
-
}
|
|
1206
|
-
if (!hastaSaldoFecha) {
|
|
1207
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "priceDateModifiedSince (fecha hasta) es requerido");
|
|
1517
|
+
if (!documentDate) {
|
|
1518
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "documentDate es requerido");
|
|
1208
1519
|
}
|
|
1520
|
+
const formattedDocumentDate = String(documentDate).split("T")[0];
|
|
1209
1521
|
try {
|
|
1210
1522
|
const body = {
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1523
|
+
FechaDocumento: formattedDocumentDate,
|
|
1524
|
+
IdsCliente: clientId,
|
|
1525
|
+
DiaSemana: diaSemana || "",
|
|
1214
1526
|
};
|
|
1215
|
-
const response = await (0, functions_1.apiRequest)(`${centumUrl}/
|
|
1527
|
+
const response = await (0, functions_1.apiRequest)(`${centumUrl}/PromocionesComerciales/FiltrosPromocionComercial`, {
|
|
1216
1528
|
method: "POST",
|
|
1217
1529
|
headers,
|
|
1218
1530
|
body,
|
|
@@ -1220,235 +1532,116 @@ class Centum {
|
|
|
1220
1532
|
if (!response || typeof response !== "object") {
|
|
1221
1533
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Respuesta inválida del servidor");
|
|
1222
1534
|
}
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
catch (error) {
|
|
1226
|
-
console.log("Error en solicitud de facturas pedidos ventas:", error);
|
|
1227
|
-
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
1228
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Error obteniendo facturas pedidos ventas para cliente ${clientId}: ${errorMessage}`);
|
|
1229
|
-
}
|
|
1230
|
-
}
|
|
1231
|
-
case "obtenerOrdenesCompras": {
|
|
1232
|
-
const idProveedor = this.getNodeParameter("proveedorId", 0);
|
|
1233
|
-
const desdeSaldoFecha = this.getNodeParameter("startDate", 0);
|
|
1234
|
-
const hastaSaldoFecha = this.getNodeParameter("endDate", 0);
|
|
1235
|
-
const separarFechaDesde = String(desdeSaldoFecha).split("T")[0];
|
|
1236
|
-
const separarFechaHasta = String(hastaSaldoFecha).split("T")[0];
|
|
1237
|
-
if (!desdeSaldoFecha) {
|
|
1238
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "priceDateModified (fecha desde) es requerido");
|
|
1239
|
-
}
|
|
1240
|
-
if (!hastaSaldoFecha) {
|
|
1241
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "priceDateModifiedSince (fecha hasta) es requerido");
|
|
1242
|
-
}
|
|
1243
|
-
try {
|
|
1244
|
-
const body = {
|
|
1245
|
-
fechaDocumentoDesde: separarFechaDesde,
|
|
1246
|
-
fechaDocumentoHasta: separarFechaHasta,
|
|
1247
|
-
idProveedor
|
|
1248
|
-
};
|
|
1249
|
-
const response = await (0, functions_1.apiRequest)(`${centumUrl}/OrdenesCompra/FiltrosOrdenCompra`, {
|
|
1250
|
-
method: "POST",
|
|
1251
|
-
headers,
|
|
1252
|
-
body,
|
|
1253
|
-
});
|
|
1254
|
-
if (!response || typeof response !== "object") {
|
|
1255
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Respuesta inválida del servidor");
|
|
1535
|
+
if (response.Items && Array.isArray(response.Items)) {
|
|
1536
|
+
return [this.helpers.returnJsonArray(response.Items)];
|
|
1256
1537
|
}
|
|
1257
1538
|
return [this.helpers.returnJsonArray(response)];
|
|
1258
1539
|
}
|
|
1259
1540
|
catch (error) {
|
|
1260
|
-
console.log("Error en solicitud de
|
|
1541
|
+
console.log("Error en solicitud de promociones para el cliente:", error);
|
|
1261
1542
|
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
1262
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Error obteniendo
|
|
1543
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Error obteniendo promociones para el cliente ${clientId}: \n ${errorMessage}`);
|
|
1263
1544
|
}
|
|
1264
1545
|
}
|
|
1265
|
-
case "
|
|
1266
|
-
const
|
|
1267
|
-
if (!ordenCompraId) {
|
|
1268
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "El id de la compra es requerido");
|
|
1269
|
-
}
|
|
1546
|
+
case "listarProvincias": {
|
|
1547
|
+
const idPais = this.getNodeParameter("idPais", 0, "");
|
|
1270
1548
|
try {
|
|
1271
|
-
|
|
1272
|
-
|
|
1549
|
+
const queryParams = {};
|
|
1550
|
+
if (idPais) {
|
|
1551
|
+
queryParams.idPais = idPais;
|
|
1552
|
+
}
|
|
1553
|
+
const provincias = await (0, functions_1.apiRequest)(`${centumUrl}/Provincias`, {
|
|
1273
1554
|
method: "GET",
|
|
1274
|
-
headers
|
|
1555
|
+
headers,
|
|
1556
|
+
queryParams,
|
|
1275
1557
|
});
|
|
1276
|
-
|
|
1277
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Respuesta inválida del servidor");
|
|
1278
|
-
}
|
|
1279
|
-
return [this.helpers.returnJsonArray(response)];
|
|
1558
|
+
return [this.helpers.returnJsonArray(provincias.map((p) => ({ ...p })))];
|
|
1280
1559
|
}
|
|
1281
1560
|
catch (error) {
|
|
1282
|
-
console.log(
|
|
1561
|
+
console.log(error);
|
|
1283
1562
|
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
1284
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(),
|
|
1563
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage);
|
|
1285
1564
|
}
|
|
1286
1565
|
}
|
|
1287
|
-
case "
|
|
1288
|
-
const clientIdParam = this.getNodeParameter("clienteId", 0);
|
|
1289
|
-
const desdeSaldoFecha = this.getNodeParameter("startDate", 0);
|
|
1290
|
-
const hastaSaldoFecha = this.getNodeParameter("endDate", 0);
|
|
1291
|
-
const separarFechaDesde = String(desdeSaldoFecha).split("T")[0];
|
|
1292
|
-
const separarFechaHasta = String(hastaSaldoFecha).split("T")[0];
|
|
1293
|
-
const clientId = Number(clientIdParam);
|
|
1294
|
-
if (isNaN(clientId) || clientId <= 0) {
|
|
1295
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "clienteId debe ser un número positivo");
|
|
1296
|
-
}
|
|
1297
|
-
if (!desdeSaldoFecha) {
|
|
1298
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "priceDateModified (fecha desde) es requerido");
|
|
1299
|
-
}
|
|
1300
|
-
if (!hastaSaldoFecha) {
|
|
1301
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "priceDateModifiedSince (fecha hasta) es requerido");
|
|
1302
|
-
}
|
|
1566
|
+
case "listarRegimenesEspeciales": {
|
|
1303
1567
|
try {
|
|
1304
|
-
const
|
|
1305
|
-
|
|
1306
|
-
fechaDocumentoHasta: separarFechaHasta,
|
|
1307
|
-
IdCliente: clientId,
|
|
1308
|
-
};
|
|
1309
|
-
const response = await (0, functions_1.apiRequest)(`${centumUrl}/Ventas/FiltrosVenta`, {
|
|
1310
|
-
method: "POST",
|
|
1568
|
+
const dataRegimenesList = await (0, functions_1.apiRequest)(`${centumUrl}/RegimenesEspeciales`, {
|
|
1569
|
+
method: "GET",
|
|
1311
1570
|
headers,
|
|
1312
|
-
body,
|
|
1313
1571
|
});
|
|
1314
|
-
|
|
1315
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Respuesta inválida del servidor");
|
|
1316
|
-
}
|
|
1317
|
-
return [this.helpers.returnJsonArray(response)];
|
|
1572
|
+
return [this.helpers.returnJsonArray(dataRegimenesList)];
|
|
1318
1573
|
}
|
|
1319
1574
|
catch (error) {
|
|
1320
|
-
console.log(
|
|
1575
|
+
console.log(error);
|
|
1321
1576
|
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
1322
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(),
|
|
1323
|
-
}
|
|
1324
|
-
}
|
|
1325
|
-
case "obtenerFacturasPedidosVentas": {
|
|
1326
|
-
const idCliente = this.getNodeParameter('clienteId', 0);
|
|
1327
|
-
const idVenta = this.getNodeParameter('ventaId', 0);
|
|
1328
|
-
const idSucursal = this.getNodeParameter('sucursalId', 0);
|
|
1329
|
-
const idDivisionEmpresa = this.getNodeParameter('divisionEmpresaId', 0);
|
|
1330
|
-
const incluirAnulados = this.getNodeParameter('incluirAnulados', 0);
|
|
1331
|
-
const idUsuarioCreador = this.getNodeParameter('usuarioCreadorId', 0);
|
|
1332
|
-
const idTransporte = this.getNodeParameter('transporteId', 0);
|
|
1333
|
-
const idTipoComprobante = this.getNodeParameter('idTipoComprobante', 0);
|
|
1334
|
-
const idClienteCuentaCorriente = this.getNodeParameter('cuentaCorrienteId', 0);
|
|
1335
|
-
const idVendedor = this.getNodeParameter('idVendedor', 0);
|
|
1336
|
-
const idCanalVenta = this.getNodeParameter('canalVentaId', 0);
|
|
1337
|
-
const desdeSaldoFecha = this.getNodeParameter("startDate", 0);
|
|
1338
|
-
const hastaSaldoFecha = this.getNodeParameter("endDate", 0);
|
|
1339
|
-
if (!desdeSaldoFecha || !hastaSaldoFecha) {
|
|
1340
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Las fechas desde y hasta son requeridas");
|
|
1341
|
-
}
|
|
1342
|
-
const body = {
|
|
1343
|
-
fechaDocumentoDesde: String(desdeSaldoFecha).split("T")[0],
|
|
1344
|
-
fechaDocumentoHasta: String(hastaSaldoFecha).split("T")[0],
|
|
1345
|
-
};
|
|
1346
|
-
idCliente && (body.idCliente = idCliente);
|
|
1347
|
-
idVenta && (body.idVenta = idVenta);
|
|
1348
|
-
idSucursal && (body.idSucursal = idSucursal);
|
|
1349
|
-
idDivisionEmpresa && (body.idDivisionEmpresa = idDivisionEmpresa);
|
|
1350
|
-
idUsuarioCreador && (body.idUsuarioCreador = idUsuarioCreador);
|
|
1351
|
-
idTransporte && (body.idTransporte = idTransporte);
|
|
1352
|
-
idTipoComprobante && (body.idTipoComprobante = idTipoComprobante);
|
|
1353
|
-
idClienteCuentaCorriente && (body.idClienteCuentaCorriente = idClienteCuentaCorriente);
|
|
1354
|
-
idVendedor && (body.idVendedor = idVendedor);
|
|
1355
|
-
idCanalVenta && (body.idCanalVenta = idCanalVenta);
|
|
1356
|
-
incluirAnulados && (body.incluirAnulados = incluirAnulados);
|
|
1357
|
-
const response = await (0, functions_1.apiRequest)(`${centumUrl}/Ventas/FiltrosVentaConsulta`, {
|
|
1358
|
-
method: "POST",
|
|
1359
|
-
headers,
|
|
1360
|
-
body,
|
|
1361
|
-
});
|
|
1362
|
-
if (!response || typeof response !== "object") {
|
|
1363
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Respuesta inválida del servidor");
|
|
1577
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage);
|
|
1364
1578
|
}
|
|
1365
|
-
return [this.helpers.returnJsonArray(response)];
|
|
1366
1579
|
}
|
|
1367
|
-
case "
|
|
1368
|
-
const idCliente = this.getNodeParameter("clienteId", 0);
|
|
1369
|
-
const idsEstado = this.getNodeParameter("statusId", 0);
|
|
1370
|
-
const fechaDesde = this.getNodeParameter("startDate", 0, "");
|
|
1371
|
-
const fechaHasta = this.getNodeParameter("endDate", 0, "");
|
|
1372
|
-
const separarFechaDesde = String(fechaDesde).split("T")[0];
|
|
1373
|
-
const separarFechaHasta = String(fechaHasta).split("T")[0];
|
|
1374
|
-
if (!idCliente && !idsEstado && !separarFechaDesde && !separarFechaHasta) {
|
|
1375
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Debes ingresar almenos un parametro para realizar la búsqueda.");
|
|
1376
|
-
}
|
|
1377
|
-
const body = {
|
|
1378
|
-
idCliente,
|
|
1379
|
-
fechaDocumentoDesde: separarFechaDesde,
|
|
1380
|
-
fechaDocumentoHasta: separarFechaHasta,
|
|
1381
|
-
idsEstado,
|
|
1382
|
-
};
|
|
1580
|
+
case "listarRubros": {
|
|
1383
1581
|
try {
|
|
1384
|
-
const response = await (0, functions_1.apiRequest)(`${centumUrl}/
|
|
1385
|
-
method:
|
|
1386
|
-
headers
|
|
1387
|
-
body,
|
|
1582
|
+
const response = await (0, functions_1.apiRequest)(`${centumUrl}/Rubros`, {
|
|
1583
|
+
method: 'GET',
|
|
1584
|
+
headers
|
|
1388
1585
|
});
|
|
1389
1586
|
return [this.helpers.returnJsonArray(response)];
|
|
1390
1587
|
}
|
|
1391
1588
|
catch (error) {
|
|
1392
|
-
console.log(
|
|
1393
|
-
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
1394
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(),
|
|
1395
|
-
}
|
|
1396
|
-
}
|
|
1397
|
-
case "obtenerPedidosDeVentaFiltrados": {
|
|
1398
|
-
const idCliente = this.getNodeParameter("clienteId", 0);
|
|
1399
|
-
const idsEstado = this.getNodeParameter("statusId", 0);
|
|
1400
|
-
const fechaDesde = this.getNodeParameter("startDate", 0, "");
|
|
1401
|
-
const fechaHasta = this.getNodeParameter("endDate", 0, "");
|
|
1402
|
-
const separarFechaDesde = String(fechaDesde).split("T")[0];
|
|
1403
|
-
const separarFechaHasta = String(fechaHasta).split("T")[0];
|
|
1404
|
-
if (!idCliente && !idsEstado && !separarFechaDesde && !separarFechaHasta) {
|
|
1405
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Debes ingresar almenos un parametro para realizar la búsqueda.");
|
|
1589
|
+
console.log(error);
|
|
1590
|
+
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
1591
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage);
|
|
1406
1592
|
}
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
fechaDocumentoDesde: separarFechaDesde,
|
|
1410
|
-
fechaDocumentoHasta: separarFechaHasta,
|
|
1411
|
-
idsEstado,
|
|
1412
|
-
};
|
|
1593
|
+
}
|
|
1594
|
+
case "listarSucursales": {
|
|
1413
1595
|
try {
|
|
1414
|
-
const
|
|
1415
|
-
method: "
|
|
1596
|
+
const dataListBranches = await (0, functions_1.apiRequest)(`${centumUrl}/SucursalesFisicas`, {
|
|
1597
|
+
method: "GET",
|
|
1416
1598
|
headers,
|
|
1417
|
-
body,
|
|
1418
1599
|
});
|
|
1419
|
-
return [this.helpers.returnJsonArray(
|
|
1600
|
+
return [this.helpers.returnJsonArray(dataListBranches)];
|
|
1420
1601
|
}
|
|
1421
1602
|
catch (error) {
|
|
1422
|
-
console.log(
|
|
1603
|
+
console.log(error);
|
|
1423
1604
|
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
1424
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(),
|
|
1605
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage);
|
|
1425
1606
|
}
|
|
1426
1607
|
}
|
|
1427
|
-
case "
|
|
1428
|
-
const clientIdParam = this.getNodeParameter("clienteId", 0);
|
|
1429
|
-
const desdeSaldoFecha = this.getNodeParameter("priceDateModified", 0);
|
|
1430
|
-
const soloFecha = String(desdeSaldoFecha).split("T")[0];
|
|
1431
|
-
const clientId = Number(clientIdParam);
|
|
1432
|
-
if (isNaN(clientId) || clientId <= 0) {
|
|
1433
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "clienteId debe ser un número positivo");
|
|
1434
|
-
}
|
|
1608
|
+
case "listarTiposComprobante": {
|
|
1435
1609
|
try {
|
|
1436
|
-
|
|
1437
|
-
if (soloFecha) {
|
|
1438
|
-
url += `?fechaVencimientoHasta=${soloFecha}`;
|
|
1439
|
-
}
|
|
1440
|
-
const response = await (0, functions_1.apiRequest)(url, {
|
|
1610
|
+
const comprobanteList = await (0, functions_1.apiRequest)(`${centumUrl}/TiposComprobante`, {
|
|
1441
1611
|
method: "GET",
|
|
1442
1612
|
headers,
|
|
1443
1613
|
});
|
|
1444
|
-
return [this.helpers.returnJsonArray(
|
|
1614
|
+
return [this.helpers.returnJsonArray(comprobanteList)];
|
|
1445
1615
|
}
|
|
1446
1616
|
catch (error) {
|
|
1617
|
+
console.log(error);
|
|
1447
1618
|
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
1448
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(),
|
|
1619
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage);
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1622
|
+
case "listarTodosLosProductos": {
|
|
1623
|
+
try {
|
|
1624
|
+
const ajustesHTTP = functions_1.getHttpSettings.call(this);
|
|
1625
|
+
const articulosURL = `${centumUrl}/Articulos/DatosGenerales`;
|
|
1626
|
+
const fetchOptions = {
|
|
1627
|
+
method: "POST",
|
|
1628
|
+
headers,
|
|
1629
|
+
body: {},
|
|
1630
|
+
queryParams: { tipoOrdenArticulos: "Nombre" },
|
|
1631
|
+
pagination: ajustesHTTP.pagination,
|
|
1632
|
+
cantidadItemsPorPagina: ajustesHTTP.cantidadItemsPorPagina,
|
|
1633
|
+
intervaloPagina: ajustesHTTP.intervaloPagina,
|
|
1634
|
+
};
|
|
1635
|
+
const paginated = await (0, functions_1.apiPostRequestPaginated)(articulosURL, fetchOptions);
|
|
1636
|
+
return [this.helpers.returnJsonArray(paginated)];
|
|
1637
|
+
}
|
|
1638
|
+
catch (error) {
|
|
1639
|
+
console.log("Error en solicitud de artículos", error);
|
|
1640
|
+
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
1641
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage);
|
|
1449
1642
|
}
|
|
1450
1643
|
}
|
|
1451
|
-
case '
|
|
1644
|
+
case 'listarTurnosEntrega': {
|
|
1452
1645
|
try {
|
|
1453
1646
|
const turnoEntrega = await (0, functions_1.apiRequest)(`${centumUrl}/TurnosEntrega`, {
|
|
1454
1647
|
method: 'GET',
|
|
@@ -1461,7 +1654,7 @@ class Centum {
|
|
|
1461
1654
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Error obteniendo los turnos de entrega: ${errorMessage}`);
|
|
1462
1655
|
}
|
|
1463
1656
|
}
|
|
1464
|
-
case '
|
|
1657
|
+
case 'listarVendedores': {
|
|
1465
1658
|
try {
|
|
1466
1659
|
const turnoEntrega = await (0, functions_1.apiRequest)(`${centumUrl}/Vendedores`, {
|
|
1467
1660
|
method: 'GET',
|
|
@@ -1474,30 +1667,18 @@ class Centum {
|
|
|
1474
1667
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Error obteniendo los vendedores: ${errorMessage}`);
|
|
1475
1668
|
}
|
|
1476
1669
|
}
|
|
1477
|
-
case "
|
|
1478
|
-
const
|
|
1479
|
-
const
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
${centumUrl}/OperadoresMoviles/Credenciales?Usuario=${username}&Contrasena=${password}`, {
|
|
1483
|
-
method: "GET",
|
|
1484
|
-
headers,
|
|
1485
|
-
});
|
|
1486
|
-
return [this.helpers.returnJsonArray(operadoresActividad)];
|
|
1487
|
-
}
|
|
1488
|
-
catch (error) {
|
|
1489
|
-
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
1490
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage);
|
|
1491
|
-
}
|
|
1492
|
-
}
|
|
1493
|
-
case "pedidoVentaActividad": {
|
|
1494
|
-
const pedidoID = this.getNodeParameter("id", 0);
|
|
1670
|
+
case "registrarCobro": {
|
|
1671
|
+
const ordenCliente = this.getNodeParameter("cliente", 0);
|
|
1672
|
+
const ordenArticulo = this.getNodeParameter("articulo", 0);
|
|
1673
|
+
const ordenEnvio = this.getNodeParameter("envio", 0);
|
|
1674
|
+
const bodyCharge = (0, functions_1.createChargeJson)(ordenCliente, ordenArticulo, ordenEnvio);
|
|
1495
1675
|
try {
|
|
1496
|
-
const
|
|
1497
|
-
method: "
|
|
1676
|
+
const dataCobros = await (0, functions_1.apiRequest)(`${centumUrl}/Cobros`, {
|
|
1677
|
+
method: "POST",
|
|
1678
|
+
body: bodyCharge,
|
|
1498
1679
|
headers,
|
|
1499
1680
|
});
|
|
1500
|
-
return [this.helpers.returnJsonArray(
|
|
1681
|
+
return [this.helpers.returnJsonArray(dataCobros)];
|
|
1501
1682
|
}
|
|
1502
1683
|
catch (error) {
|
|
1503
1684
|
console.log(error);
|
|
@@ -1505,7 +1686,7 @@ class Centum {
|
|
|
1505
1686
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage);
|
|
1506
1687
|
}
|
|
1507
1688
|
}
|
|
1508
|
-
case "
|
|
1689
|
+
case "sincronizarImagenes": {
|
|
1509
1690
|
const dataImages = this.getNodeParameter("dataImg", 0);
|
|
1510
1691
|
const db = this.getNodeParameter("lastModifiedImg", 0);
|
|
1511
1692
|
const result = [];
|
|
@@ -1531,145 +1712,36 @@ class Centum {
|
|
|
1531
1712
|
}
|
|
1532
1713
|
return [this.helpers.returnJsonArray(result)];
|
|
1533
1714
|
}
|
|
1534
|
-
case "
|
|
1535
|
-
const
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
const clientId = Number(clientIdParam);
|
|
1539
|
-
if (!documentDate) {
|
|
1540
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "documentDate es requerido");
|
|
1715
|
+
case "verDetalleOrdenCompra": {
|
|
1716
|
+
const ordenCompraId = this.getNodeParameter("idCompra", 0);
|
|
1717
|
+
if (!ordenCompraId) {
|
|
1718
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "El id de la compra es requerido");
|
|
1541
1719
|
}
|
|
1542
|
-
const formattedDocumentDate = String(documentDate).split("T")[0];
|
|
1543
1720
|
try {
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
};
|
|
1549
|
-
const response = await (0, functions_1.apiRequest)(`${centumUrl}/PromocionesComerciales/FiltrosPromocionComercial`, {
|
|
1550
|
-
method: "POST",
|
|
1551
|
-
headers,
|
|
1552
|
-
body,
|
|
1721
|
+
let url = `${centumUrl}/OrdenesCompra/${ordenCompraId}`;
|
|
1722
|
+
const response = await (0, functions_1.apiRequest)(`${url}`, {
|
|
1723
|
+
method: "GET",
|
|
1724
|
+
headers
|
|
1553
1725
|
});
|
|
1554
1726
|
if (!response || typeof response !== "object") {
|
|
1555
1727
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Respuesta inválida del servidor");
|
|
1556
1728
|
}
|
|
1557
|
-
if (response.Items && Array.isArray(response.Items)) {
|
|
1558
|
-
return [this.helpers.returnJsonArray(response.Items)];
|
|
1559
|
-
}
|
|
1560
|
-
return [this.helpers.returnJsonArray(response)];
|
|
1561
|
-
}
|
|
1562
|
-
catch (error) {
|
|
1563
|
-
console.log("Error en solicitud de promociones para el cliente:", error);
|
|
1564
|
-
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
1565
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Error obteniendo promociones para el cliente ${clientId}: \n ${errorMessage}`);
|
|
1566
|
-
}
|
|
1567
|
-
}
|
|
1568
|
-
case 'proveedorBuscar': {
|
|
1569
|
-
const proveedorId = this.getNodeParameter('proveedorId', 0);
|
|
1570
|
-
try {
|
|
1571
|
-
const response = await (0, functions_1.apiRequest)(`${centumUrl}/Proveedores/${proveedorId}`, {
|
|
1572
|
-
method: 'GET',
|
|
1573
|
-
headers
|
|
1574
|
-
});
|
|
1575
|
-
return [this.helpers.returnJsonArray(response)];
|
|
1576
|
-
}
|
|
1577
|
-
catch (error) {
|
|
1578
|
-
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
1579
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage);
|
|
1580
|
-
}
|
|
1581
|
-
}
|
|
1582
|
-
case 'proveedorCrear': {
|
|
1583
|
-
const codigo = this.getNodeParameter('codigoArticulo', 0, '');
|
|
1584
|
-
const razonSocial = this.getNodeParameter('razonSocial', 0, '');
|
|
1585
|
-
const cuit = this.getNodeParameter('cuit', 0);
|
|
1586
|
-
const provincia = this.getNodeParameter('idProvincia', 0);
|
|
1587
|
-
const pais = this.getNodeParameter('idPais', 0);
|
|
1588
|
-
const condicionIVA = this.getNodeParameter('condicionIVA', 0, '');
|
|
1589
|
-
const formaPagoProveedor = this.getNodeParameter('formaPagoProveedor', 0);
|
|
1590
|
-
const condicionPago = this.getNodeParameter('condicionDePago', 0);
|
|
1591
|
-
const categoriaImpuestoGanancias = this.getNodeParameter('categoriaImpuestosGanancias', 0);
|
|
1592
|
-
const claseProveedor = this.getNodeParameter('claseProveedor', 0);
|
|
1593
|
-
const activo = this.getNodeParameter('active', 0);
|
|
1594
|
-
const idOperadorCompra = this.getNodeParameter('idOperadorCompra', 0);
|
|
1595
|
-
const idZona = this.getNodeParameter('idZona', 0);
|
|
1596
|
-
const idDescuentoProveedor = this.getNodeParameter('idDescuentoProveedor', 0);
|
|
1597
|
-
const body = {
|
|
1598
|
-
Codigo: codigo,
|
|
1599
|
-
RazonSocial: razonSocial,
|
|
1600
|
-
CUIT: cuit,
|
|
1601
|
-
Provincia: {
|
|
1602
|
-
IdProvincia: provincia
|
|
1603
|
-
},
|
|
1604
|
-
Pais: {
|
|
1605
|
-
IdPais: pais
|
|
1606
|
-
},
|
|
1607
|
-
CondicionIVA: {
|
|
1608
|
-
IdCondicionIVA: condicionIVA
|
|
1609
|
-
},
|
|
1610
|
-
FormaPagoProveedor: {
|
|
1611
|
-
IdFormaPagoProveedor: formaPagoProveedor
|
|
1612
|
-
},
|
|
1613
|
-
CondicionPago: {
|
|
1614
|
-
IdCondicionPago: condicionPago
|
|
1615
|
-
},
|
|
1616
|
-
CategoriaImpuestoGanancias: {
|
|
1617
|
-
IdCategoriaImpuestoGanancia: categoriaImpuestoGanancias
|
|
1618
|
-
},
|
|
1619
|
-
ClaseProveedor: {
|
|
1620
|
-
IdClaseProveedor: claseProveedor
|
|
1621
|
-
},
|
|
1622
|
-
OperadorCompra: {
|
|
1623
|
-
IdOperadorCompra: idOperadorCompra
|
|
1624
|
-
},
|
|
1625
|
-
Activo: activo,
|
|
1626
|
-
Zona: {
|
|
1627
|
-
IdZona: idZona
|
|
1628
|
-
},
|
|
1629
|
-
DescuentoProveedor: {
|
|
1630
|
-
IdDescuentoProveedor: idDescuentoProveedor
|
|
1631
|
-
}
|
|
1632
|
-
};
|
|
1633
|
-
try {
|
|
1634
|
-
const response = await (0, functions_1.apiRequest)(`${centumUrl}/Proveedores/`, {
|
|
1635
|
-
method: 'POST',
|
|
1636
|
-
headers,
|
|
1637
|
-
body
|
|
1638
|
-
});
|
|
1639
1729
|
return [this.helpers.returnJsonArray(response)];
|
|
1640
1730
|
}
|
|
1641
1731
|
catch (error) {
|
|
1732
|
+
console.log("Error en solicitud de facturas pedidos ventas:", error);
|
|
1642
1733
|
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
1643
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage);
|
|
1644
|
-
}
|
|
1645
|
-
}
|
|
1646
|
-
case "provinciasLista": {
|
|
1647
|
-
const idPais = this.getNodeParameter("idPais", 0, "");
|
|
1648
|
-
try {
|
|
1649
|
-
const queryParams = {};
|
|
1650
|
-
if (idPais) {
|
|
1651
|
-
queryParams.idPais = idPais;
|
|
1652
|
-
}
|
|
1653
|
-
const provincias = await (0, functions_1.apiRequest)(`${centumUrl}/Provincias`, {
|
|
1654
|
-
method: "GET",
|
|
1655
|
-
headers,
|
|
1656
|
-
queryParams,
|
|
1657
|
-
});
|
|
1658
|
-
return [this.helpers.returnJsonArray(provincias.map((p) => ({ ...p })))];
|
|
1659
|
-
}
|
|
1660
|
-
catch (error) {
|
|
1661
|
-
console.log(error);
|
|
1662
|
-
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
1663
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage);
|
|
1734
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Error obteniendo la orden de compra con el id ${ordenCompraId}: ${errorMessage}`);
|
|
1664
1735
|
}
|
|
1665
1736
|
}
|
|
1666
|
-
case "
|
|
1737
|
+
case "verDetallePedidoVenta": {
|
|
1738
|
+
const pedidoID = this.getNodeParameter("id", 0);
|
|
1667
1739
|
try {
|
|
1668
|
-
const
|
|
1740
|
+
const dataActividad = await (0, functions_1.apiRequest)(`${centumUrl}/PedidosVenta/${pedidoID}`, {
|
|
1669
1741
|
method: "GET",
|
|
1670
1742
|
headers,
|
|
1671
1743
|
});
|
|
1672
|
-
return [this.helpers.returnJsonArray(
|
|
1744
|
+
return [this.helpers.returnJsonArray(dataActividad)];
|
|
1673
1745
|
}
|
|
1674
1746
|
catch (error) {
|
|
1675
1747
|
console.log(error);
|
|
@@ -1677,7 +1749,7 @@ class Centum {
|
|
|
1677
1749
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage);
|
|
1678
1750
|
}
|
|
1679
1751
|
}
|
|
1680
|
-
case "
|
|
1752
|
+
case "verDetalleRegimenEspecial": {
|
|
1681
1753
|
const regimenId = this.getNodeParameter("id", 0);
|
|
1682
1754
|
if (!regimenId) {
|
|
1683
1755
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "El ID del regimen es requerido");
|
|
@@ -1695,44 +1767,45 @@ class Centum {
|
|
|
1695
1767
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage);
|
|
1696
1768
|
}
|
|
1697
1769
|
}
|
|
1698
|
-
case "
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
}
|
|
1706
|
-
catch (error) {
|
|
1707
|
-
console.log(error);
|
|
1708
|
-
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
1709
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage);
|
|
1770
|
+
case "verDetalleSaldoCliente": {
|
|
1771
|
+
const clientIdParam = this.getNodeParameter("clienteId", 0);
|
|
1772
|
+
const desdeSaldoFecha = this.getNodeParameter("priceDateModified", 0);
|
|
1773
|
+
const separarFecha = String(desdeSaldoFecha).split("T")[0];
|
|
1774
|
+
const clientId = Number(clientIdParam);
|
|
1775
|
+
if (isNaN(clientId) || clientId <= 0) {
|
|
1776
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "clienteId debe ser un número positivo");
|
|
1710
1777
|
}
|
|
1711
|
-
}
|
|
1712
|
-
case "sucursalesFisicas": {
|
|
1713
1778
|
try {
|
|
1714
|
-
|
|
1779
|
+
let url = `${centumUrl}/SaldosCuentasCorrientes/Composicion/${clientId}`;
|
|
1780
|
+
if (separarFecha) {
|
|
1781
|
+
url += `?fechaVencimientoHasta=${separarFecha}`;
|
|
1782
|
+
}
|
|
1783
|
+
const response = await (0, functions_1.apiRequest)(url, {
|
|
1715
1784
|
method: "GET",
|
|
1716
1785
|
headers,
|
|
1717
1786
|
});
|
|
1718
|
-
|
|
1787
|
+
if (!response || typeof response !== "object") {
|
|
1788
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Respuesta inválida del servidor");
|
|
1789
|
+
}
|
|
1790
|
+
return [this.helpers.returnJsonArray(response)];
|
|
1719
1791
|
}
|
|
1720
1792
|
catch (error) {
|
|
1721
|
-
console.log(error);
|
|
1722
1793
|
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
1723
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage);
|
|
1794
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Error obteniendo composición de saldo para cliente ${clientId}: ${errorMessage}`);
|
|
1724
1795
|
}
|
|
1725
1796
|
}
|
|
1726
|
-
case "
|
|
1797
|
+
case "verificarCredencialesOperador": {
|
|
1798
|
+
const username = this.getNodeParameter("username", 0, "");
|
|
1799
|
+
const password = this.getNodeParameter("password", 0, "");
|
|
1727
1800
|
try {
|
|
1728
|
-
const
|
|
1801
|
+
const operadoresActividad = await (0, functions_1.apiRequest)(`
|
|
1802
|
+
${centumUrl}/OperadoresMoviles/Credenciales?Usuario=${username}&Contrasena=${password}`, {
|
|
1729
1803
|
method: "GET",
|
|
1730
1804
|
headers,
|
|
1731
1805
|
});
|
|
1732
|
-
return [this.helpers.returnJsonArray(
|
|
1806
|
+
return [this.helpers.returnJsonArray(operadoresActividad)];
|
|
1733
1807
|
}
|
|
1734
1808
|
catch (error) {
|
|
1735
|
-
console.log(error);
|
|
1736
1809
|
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
1737
1810
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage);
|
|
1738
1811
|
}
|