n8n-nodes-centum 0.2.45 → 0.2.47
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/LICENSE.md +19 -19
- package/README.md +126 -126
- package/dist/nodes/Centum/Centum.node.js +316 -1
- package/dist/nodes/Centum/Centum.node.js.map +1 -1
- package/dist/nodes/Centum/CentumDescription.js +77 -14
- package/dist/nodes/Centum/CentumDescription.js.map +1 -1
- package/dist/nodes/Centum/centum.svg +565 -565
- package/dist/package.json +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +56 -56
package/LICENSE.md
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
Copyright 2022 n8n
|
|
2
|
-
|
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
4
|
-
this software and associated documentation files (the "Software"), to deal in
|
|
5
|
-
the Software without restriction, including without limitation the rights to
|
|
6
|
-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
7
|
-
of the Software, and to permit persons to whom the Software is furnished to do
|
|
8
|
-
so, subject to the following conditions:
|
|
9
|
-
|
|
10
|
-
The above copyright notice and this permission notice shall be included in all
|
|
11
|
-
copies or substantial portions of the Software.
|
|
12
|
-
|
|
13
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
-
SOFTWARE.
|
|
1
|
+
Copyright 2022 n8n
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
4
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
5
|
+
the Software without restriction, including without limitation the rights to
|
|
6
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
7
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
|
8
|
+
so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,126 +1,126 @@
|
|
|
1
|
-
# n8n-nodes-centum
|
|
2
|
-
|
|
3
|
-

|
|
4
|
-
|
|
5
|
-
This is a custom node for [n8n](https://n8n.io/), an open-source workflow automation platform, designed to integrate with the **Centum API**, a system for managing customers, payments, and other business resources.
|
|
6
|
-
The `Centum` node simplifies interaction with the Centum API endpoints, allowing operations such as customer search, payment creation, and more directly inside your n8n workflows.
|
|
7
|
-
|
|
8
|
-
The node is built to be extensible, making it easy to add new operations for specific integration needs with Centum.
|
|
9
|
-
|
|
10
|
-
## Requires 3 parameters in the **Centum API** credential:
|
|
11
|
-
|
|
12
|
-
| Field | Type | Example | Required |
|
|
13
|
-
|-----------------------------------|------------|-------------------------------------------------------------|----------|
|
|
14
|
-
| Public Access Key | Password | a1b2c3d4e5f6g7h8i9j0... | Yes |
|
|
15
|
-
| CentumSuiteConsumidorApiPublicaId | Number | 12345 | Yes |
|
|
16
|
-
| Centum URL | Text (URL) | https://plataformaX.centum.com.ar:23990/BLX | Yes |
|
|
17
|
-
|-----------------------------------|------------|-------------------------------------------------------------|----------|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
## Available Operations
|
|
22
|
-
|
|
23
|
-
**55 endpoints organized into 5 categories:**
|
|
24
|
-
|
|
25
|
-
### 📦 Articles
|
|
26
|
-
- `articulo`: Search articles with filters (categories, dates, stock)
|
|
27
|
-
- `articuloPorId`: Query by exact ID or code
|
|
28
|
-
- `articuloPorNombre`: Query by article name
|
|
29
|
-
- `articulosDatosGenerales`: Retrieve general article data
|
|
30
|
-
- `articulosExistencia`: Stock availability by branch
|
|
31
|
-
- `articulosImagenes`: Download and process article images
|
|
32
|
-
- `articulosPrecioPorLista`: Prices by price list
|
|
33
|
-
- `articulosSucursalesFisicas`: Articles grouped by branch
|
|
34
|
-
- `articuloSucursalFisica`: Specific article in branch
|
|
35
|
-
- `buscarArticulo`: Search article by name or code
|
|
36
|
-
- `categoriasObtener`: List categories
|
|
37
|
-
- `marcasObtener`: List brands
|
|
38
|
-
- `rubrosObtener`: List product groups
|
|
39
|
-
|
|
40
|
-
### 👤 Customers
|
|
41
|
-
- `clienteNuevo`: Create a new customer
|
|
42
|
-
- `nuevoContribuyente`: Register a taxpayer with CUIT
|
|
43
|
-
- `clientes`: Paginated customer list
|
|
44
|
-
- `clientesActualizar`: Update customer data
|
|
45
|
-
- `clientesBusqueda`: Search by email or DNI
|
|
46
|
-
- `clientesBusquedaPorCuit`: Search by CUIT
|
|
47
|
-
- `buscarContribuyente`: Search taxpayer
|
|
48
|
-
- `composicionSaldoCliente`: Detailed account status
|
|
49
|
-
- `obtenerSaldoCliente`: Current account balance
|
|
50
|
-
|
|
51
|
-
### 💳 Orders and Payments
|
|
52
|
-
- `cobros`: Register a payment
|
|
53
|
-
- `obtenerCobros`: Filter payments
|
|
54
|
-
- `obtenerFacturasCobros`: Payment invoice history
|
|
55
|
-
- `crearPedidoVenta`: Create a sales order
|
|
56
|
-
- `obtenerPedidosDeVenta`: List sales orders
|
|
57
|
-
- `obtenerFacturasPedidosVentas`: Sales order invoice history
|
|
58
|
-
- `obtenerFacturasPedidosVentasPorID`: Sales order invoice history by ID
|
|
59
|
-
- `obtenerEstadosPedidosDeVenta`: Available sales order statuses
|
|
60
|
-
- `pedidoVentaActividad`: Check sales order activity
|
|
61
|
-
- `generarVentas`: Generate a sale
|
|
62
|
-
- `generarCompras`: Generate a purchase
|
|
63
|
-
- `obtenerCompras`: Filter purchases
|
|
64
|
-
- `generarOrdenCompra`: Generate a purchase order
|
|
65
|
-
- `obtenerOrdenCompra`: Get purchase order by ID
|
|
66
|
-
- `obtenerOrdenesCompras`: Filter purchase orders
|
|
67
|
-
- `obtenerBonificaciones`: Get available discounts
|
|
68
|
-
|
|
69
|
-
### 🌍 Catalogs
|
|
70
|
-
- `provinciasLista`: List of provinces (Argentina)
|
|
71
|
-
- `departamentosLista`: Departments by province
|
|
72
|
-
- `sucursalesFisicas`: Physical branches
|
|
73
|
-
- `listaPrecios`: Available price lists
|
|
74
|
-
- `promocionesCliente`: Commercial promotions for customers
|
|
75
|
-
- `regimenesEspecialesLista`: Special tax regimes
|
|
76
|
-
- `regimenesEspecialesPorId`: Special regime by ID
|
|
77
|
-
- `tipoComprobante`: Voucher types
|
|
78
|
-
- `obtenerTurnoEntrega`: Get delivery time slots
|
|
79
|
-
- `obtenerVendedores`: Get sales representatives
|
|
80
|
-
|
|
81
|
-
### ⚙️ Utilities
|
|
82
|
-
- `generarProductosWoo`: Transform data to WooCommerce format
|
|
83
|
-
- `procesarImagenes`: Image processing and synchronization
|
|
84
|
-
- `generarToken`: Authentication token generation
|
|
85
|
-
- `operadoresMoviles`: Retrieve mobile operator data based on credentials
|
|
86
|
-
- `proveedorBuscar`: Search supplier by ID
|
|
87
|
-
- `proveedorCrear`: Create a new supplier
|
|
88
|
-
|
|
89
|
-
## Prerequisites
|
|
90
|
-
|
|
91
|
-
To use this node, make sure you have the following installed in your development environment:
|
|
92
|
-
|
|
93
|
-
- **n8n**: Version 1.75.2 or higher (latest recommended for compatibility).
|
|
94
|
-
- **Node.js**: Version 20.x or higher.
|
|
95
|
-
- **npm**: Required to install and build the plugin.
|
|
96
|
-
- **Git**: To clone the repository.
|
|
97
|
-
- **Centum API access**: Valid credentials (`centumUrl`, `consumerApiPublicId`, `publicAccessKey`) provided by your Centum provider.
|
|
98
|
-
|
|
99
|
-
Recommended: Follow the n8n guide to [set up your development environment](https://docs.n8n.io/integrations/creating-nodes/build/node-development-environment/).
|
|
100
|
-
|
|
101
|
-
## Using this Starter
|
|
102
|
-
|
|
103
|
-
Basic steps to work with this starter. For a detailed guide on creating and publishing nodes, see the [documentation](https://docs.n8n.io/integrations/creating-nodes/).
|
|
104
|
-
|
|
105
|
-
1. [Generate a new repository](https://github.com/n8n-io/n8n-nodes-starter/generate) from this template.
|
|
106
|
-
2. `git clone https://github.com/<your-username>/<your-repo>.git`
|
|
107
|
-
3. Run `npm i` to install dependencies.
|
|
108
|
-
4. Open the project in your editor.
|
|
109
|
-
5. Explore the examples in `/nodes` and `/credentials`. Modify or replace them with your own nodes.
|
|
110
|
-
6. Update `package.json` with your details.
|
|
111
|
-
7. Run `npm run lint` to check for errors or `npm run lintfix` to fix them automatically.
|
|
112
|
-
8. Test your node locally. See [Running your node locally](https://docs.n8n.io/integrations/creating-nodes/test/run-node-locally/).
|
|
113
|
-
9. Replace this README with your node documentation. Use the [README TEMPLATE](/broobe/n8n/n8n-nodes-blocky-nodes/-/blob/main/README_TEMPLATE.md) as a base.
|
|
114
|
-
10. Update the LICENSE file with your details.
|
|
115
|
-
11. [Publish](https://docs.npmjs.com/packages-and-modules/contributing-packages-to-the-registry) your package to npm.
|
|
116
|
-
|
|
117
|
-
## Support
|
|
118
|
-
|
|
119
|
-
For issues or questions:
|
|
120
|
-
- Open an **issue** in the [GitHub repository](https://github.com/your-username/n8n-nodes-centum).
|
|
121
|
-
- Contact your Centum provider for API-related support.
|
|
122
|
-
- Check the [n8n documentation](https://docs.n8n.io/) for help with workflow integration.
|
|
123
|
-
|
|
124
|
-
## License
|
|
125
|
-
|
|
126
|
-
This project is licensed under the [MIT License](LICENSE). See the `LICENSE` file for details.
|
|
1
|
+
# n8n-nodes-centum
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
This is a custom node for [n8n](https://n8n.io/), an open-source workflow automation platform, designed to integrate with the **Centum API**, a system for managing customers, payments, and other business resources.
|
|
6
|
+
The `Centum` node simplifies interaction with the Centum API endpoints, allowing operations such as customer search, payment creation, and more directly inside your n8n workflows.
|
|
7
|
+
|
|
8
|
+
The node is built to be extensible, making it easy to add new operations for specific integration needs with Centum.
|
|
9
|
+
|
|
10
|
+
## Requires 3 parameters in the **Centum API** credential:
|
|
11
|
+
|
|
12
|
+
| Field | Type | Example | Required |
|
|
13
|
+
|-----------------------------------|------------|-------------------------------------------------------------|----------|
|
|
14
|
+
| Public Access Key | Password | a1b2c3d4e5f6g7h8i9j0... | Yes |
|
|
15
|
+
| CentumSuiteConsumidorApiPublicaId | Number | 12345 | Yes |
|
|
16
|
+
| Centum URL | Text (URL) | https://plataformaX.centum.com.ar:23990/BLX | Yes |
|
|
17
|
+
|-----------------------------------|------------|-------------------------------------------------------------|----------|
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## Available Operations
|
|
22
|
+
|
|
23
|
+
**55 endpoints organized into 5 categories:**
|
|
24
|
+
|
|
25
|
+
### 📦 Articles
|
|
26
|
+
- `articulo`: Search articles with filters (categories, dates, stock)
|
|
27
|
+
- `articuloPorId`: Query by exact ID or code
|
|
28
|
+
- `articuloPorNombre`: Query by article name
|
|
29
|
+
- `articulosDatosGenerales`: Retrieve general article data
|
|
30
|
+
- `articulosExistencia`: Stock availability by branch
|
|
31
|
+
- `articulosImagenes`: Download and process article images
|
|
32
|
+
- `articulosPrecioPorLista`: Prices by price list
|
|
33
|
+
- `articulosSucursalesFisicas`: Articles grouped by branch
|
|
34
|
+
- `articuloSucursalFisica`: Specific article in branch
|
|
35
|
+
- `buscarArticulo`: Search article by name or code
|
|
36
|
+
- `categoriasObtener`: List categories
|
|
37
|
+
- `marcasObtener`: List brands
|
|
38
|
+
- `rubrosObtener`: List product groups
|
|
39
|
+
|
|
40
|
+
### 👤 Customers
|
|
41
|
+
- `clienteNuevo`: Create a new customer
|
|
42
|
+
- `nuevoContribuyente`: Register a taxpayer with CUIT
|
|
43
|
+
- `clientes`: Paginated customer list
|
|
44
|
+
- `clientesActualizar`: Update customer data
|
|
45
|
+
- `clientesBusqueda`: Search by email or DNI
|
|
46
|
+
- `clientesBusquedaPorCuit`: Search by CUIT
|
|
47
|
+
- `buscarContribuyente`: Search taxpayer
|
|
48
|
+
- `composicionSaldoCliente`: Detailed account status
|
|
49
|
+
- `obtenerSaldoCliente`: Current account balance
|
|
50
|
+
|
|
51
|
+
### 💳 Orders and Payments
|
|
52
|
+
- `cobros`: Register a payment
|
|
53
|
+
- `obtenerCobros`: Filter payments
|
|
54
|
+
- `obtenerFacturasCobros`: Payment invoice history
|
|
55
|
+
- `crearPedidoVenta`: Create a sales order
|
|
56
|
+
- `obtenerPedidosDeVenta`: List sales orders
|
|
57
|
+
- `obtenerFacturasPedidosVentas`: Sales order invoice history
|
|
58
|
+
- `obtenerFacturasPedidosVentasPorID`: Sales order invoice history by ID
|
|
59
|
+
- `obtenerEstadosPedidosDeVenta`: Available sales order statuses
|
|
60
|
+
- `pedidoVentaActividad`: Check sales order activity
|
|
61
|
+
- `generarVentas`: Generate a sale
|
|
62
|
+
- `generarCompras`: Generate a purchase
|
|
63
|
+
- `obtenerCompras`: Filter purchases
|
|
64
|
+
- `generarOrdenCompra`: Generate a purchase order
|
|
65
|
+
- `obtenerOrdenCompra`: Get purchase order by ID
|
|
66
|
+
- `obtenerOrdenesCompras`: Filter purchase orders
|
|
67
|
+
- `obtenerBonificaciones`: Get available discounts
|
|
68
|
+
|
|
69
|
+
### 🌍 Catalogs
|
|
70
|
+
- `provinciasLista`: List of provinces (Argentina)
|
|
71
|
+
- `departamentosLista`: Departments by province
|
|
72
|
+
- `sucursalesFisicas`: Physical branches
|
|
73
|
+
- `listaPrecios`: Available price lists
|
|
74
|
+
- `promocionesCliente`: Commercial promotions for customers
|
|
75
|
+
- `regimenesEspecialesLista`: Special tax regimes
|
|
76
|
+
- `regimenesEspecialesPorId`: Special regime by ID
|
|
77
|
+
- `tipoComprobante`: Voucher types
|
|
78
|
+
- `obtenerTurnoEntrega`: Get delivery time slots
|
|
79
|
+
- `obtenerVendedores`: Get sales representatives
|
|
80
|
+
|
|
81
|
+
### ⚙️ Utilities
|
|
82
|
+
- `generarProductosWoo`: Transform data to WooCommerce format
|
|
83
|
+
- `procesarImagenes`: Image processing and synchronization
|
|
84
|
+
- `generarToken`: Authentication token generation
|
|
85
|
+
- `operadoresMoviles`: Retrieve mobile operator data based on credentials
|
|
86
|
+
- `proveedorBuscar`: Search supplier by ID
|
|
87
|
+
- `proveedorCrear`: Create a new supplier
|
|
88
|
+
|
|
89
|
+
## Prerequisites
|
|
90
|
+
|
|
91
|
+
To use this node, make sure you have the following installed in your development environment:
|
|
92
|
+
|
|
93
|
+
- **n8n**: Version 1.75.2 or higher (latest recommended for compatibility).
|
|
94
|
+
- **Node.js**: Version 20.x or higher.
|
|
95
|
+
- **npm**: Required to install and build the plugin.
|
|
96
|
+
- **Git**: To clone the repository.
|
|
97
|
+
- **Centum API access**: Valid credentials (`centumUrl`, `consumerApiPublicId`, `publicAccessKey`) provided by your Centum provider.
|
|
98
|
+
|
|
99
|
+
Recommended: Follow the n8n guide to [set up your development environment](https://docs.n8n.io/integrations/creating-nodes/build/node-development-environment/).
|
|
100
|
+
|
|
101
|
+
## Using this Starter
|
|
102
|
+
|
|
103
|
+
Basic steps to work with this starter. For a detailed guide on creating and publishing nodes, see the [documentation](https://docs.n8n.io/integrations/creating-nodes/).
|
|
104
|
+
|
|
105
|
+
1. [Generate a new repository](https://github.com/n8n-io/n8n-nodes-starter/generate) from this template.
|
|
106
|
+
2. `git clone https://github.com/<your-username>/<your-repo>.git`
|
|
107
|
+
3. Run `npm i` to install dependencies.
|
|
108
|
+
4. Open the project in your editor.
|
|
109
|
+
5. Explore the examples in `/nodes` and `/credentials`. Modify or replace them with your own nodes.
|
|
110
|
+
6. Update `package.json` with your details.
|
|
111
|
+
7. Run `npm run lint` to check for errors or `npm run lintfix` to fix them automatically.
|
|
112
|
+
8. Test your node locally. See [Running your node locally](https://docs.n8n.io/integrations/creating-nodes/test/run-node-locally/).
|
|
113
|
+
9. Replace this README with your node documentation. Use the [README TEMPLATE](/broobe/n8n/n8n-nodes-blocky-nodes/-/blob/main/README_TEMPLATE.md) as a base.
|
|
114
|
+
10. Update the LICENSE file with your details.
|
|
115
|
+
11. [Publish](https://docs.npmjs.com/packages-and-modules/contributing-packages-to-the-registry) your package to npm.
|
|
116
|
+
|
|
117
|
+
## Support
|
|
118
|
+
|
|
119
|
+
For issues or questions:
|
|
120
|
+
- Open an **issue** in the [GitHub repository](https://github.com/your-username/n8n-nodes-centum).
|
|
121
|
+
- Contact your Centum provider for API-related support.
|
|
122
|
+
- Check the [n8n documentation](https://docs.n8n.io/) for help with workflow integration.
|
|
123
|
+
|
|
124
|
+
## License
|
|
125
|
+
|
|
126
|
+
This project is licensed under the [MIT License](LICENSE). See the `LICENSE` file for details.
|
|
@@ -816,6 +816,260 @@ class Centum {
|
|
|
816
816
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage);
|
|
817
817
|
}
|
|
818
818
|
}
|
|
819
|
+
case "crearRemitoCompra": {
|
|
820
|
+
const idCliente = (this.getNodeParameter('clienteId', 0)) ?? '';
|
|
821
|
+
const letraDocumento = this.getNodeParameter('letraDocumento', 0) ?? '';
|
|
822
|
+
const puntoDeVenta = this.getNodeParameter('puntoDeVenta', 0) ?? '';
|
|
823
|
+
const numero = this.getNodeParameter('numeroFactura', 0) ?? '';
|
|
824
|
+
const articulosRaw = this.getNodeParameter('articulo', 0);
|
|
825
|
+
const fechaDocumento = this.getNodeParameter('documentDate', 0);
|
|
826
|
+
const formattedDocumentDate = String(fechaDocumento).split('T')[0];
|
|
827
|
+
const fechaDelivery = this.getNodeParameter('deliveryDate', 0);
|
|
828
|
+
const formattedDeliveryDate = String(fechaDelivery).split('T')[0];
|
|
829
|
+
const fechaVencimiento = this.getNodeParameter('dueDate', 0);
|
|
830
|
+
const formattedDueDate = String(fechaVencimiento).split('T')[0];
|
|
831
|
+
const proveedorIdRaw = this.getNodeParameter('proveedorId', 0);
|
|
832
|
+
const proveedorId = String(proveedorIdRaw ?? '').trim();
|
|
833
|
+
const turnoEntregaId = this.getNodeParameter('turnoEntrega', 0);
|
|
834
|
+
const sucursalId = this.getNodeParameter('idSucursalFisica', 0);
|
|
835
|
+
if (!proveedorId) {
|
|
836
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Debe especificarse idProveedor.');
|
|
837
|
+
}
|
|
838
|
+
let articulos = [];
|
|
839
|
+
const parseInvalidMsg = 'Formato de artículos inválido. Ej: {"ID": 1271, "Cantidad": 10} o {"Codigo": "ABC123", "Cantidad": 10} o arrays de estos objetos';
|
|
840
|
+
const toArticuloInput = (x) => ({
|
|
841
|
+
ID: typeof x?.ID === 'number' ? x.ID : undefined,
|
|
842
|
+
Codigo: typeof x?.Codigo === 'string' ? x.Codigo : undefined,
|
|
843
|
+
Cantidad: Number(x?.Cantidad),
|
|
844
|
+
});
|
|
845
|
+
const isArticuloInput = (x) => {
|
|
846
|
+
if (!x || typeof x !== 'object')
|
|
847
|
+
return false;
|
|
848
|
+
const hasIdOrCodigo = typeof x.ID === 'number' || (typeof x.Codigo === 'string' && x.Codigo.trim().length > 0);
|
|
849
|
+
const cant = x.Cantidad;
|
|
850
|
+
const cantOk = typeof cant === 'number' && Number.isFinite(cant) && cant > 0;
|
|
851
|
+
return hasIdOrCodigo && cantOk;
|
|
852
|
+
};
|
|
853
|
+
if (typeof articulosRaw === 'string') {
|
|
854
|
+
try {
|
|
855
|
+
const parsed = JSON.parse(articulosRaw);
|
|
856
|
+
const arr = Array.isArray(parsed) ? parsed : [parsed];
|
|
857
|
+
articulos = arr.map(toArticuloInput).filter(isArticuloInput);
|
|
858
|
+
}
|
|
859
|
+
catch {
|
|
860
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), parseInvalidMsg);
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
else if (Array.isArray(articulosRaw)) {
|
|
864
|
+
articulos = articulosRaw.map(toArticuloInput).filter(isArticuloInput);
|
|
865
|
+
}
|
|
866
|
+
else if (typeof articulosRaw === 'object' && articulosRaw !== null) {
|
|
867
|
+
const one = toArticuloInput(articulosRaw);
|
|
868
|
+
articulos = isArticuloInput(one) ? [one] : [];
|
|
869
|
+
}
|
|
870
|
+
else {
|
|
871
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Tipo de dato inesperado: ${typeof articulosRaw}`);
|
|
872
|
+
}
|
|
873
|
+
if (!idCliente) {
|
|
874
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'El ID del cliente es obligatorio.');
|
|
875
|
+
}
|
|
876
|
+
if (!articulos.length) {
|
|
877
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Debe enviarse al menos un artículo válido con Cantidad > 0.');
|
|
878
|
+
}
|
|
879
|
+
try {
|
|
880
|
+
const dataCliente = await (0, functions_1.apiRequest)(`${centumUrl}/Clientes/${idCliente}`, { method: 'GET', headers });
|
|
881
|
+
const cliente = dataCliente;
|
|
882
|
+
if (!cliente)
|
|
883
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Cliente no encontrado');
|
|
884
|
+
}
|
|
885
|
+
catch (error) {
|
|
886
|
+
const msg = error?.response?.data?.Message || error?.message || 'Error obteniendo cliente';
|
|
887
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), msg);
|
|
888
|
+
}
|
|
889
|
+
const RemitoCompraArticulos = [];
|
|
890
|
+
for (const articuloInput of articulos) {
|
|
891
|
+
try {
|
|
892
|
+
const bodyArticulo = {
|
|
893
|
+
IdCliente: idCliente,
|
|
894
|
+
FechaDocumento: formattedDocumentDate,
|
|
895
|
+
};
|
|
896
|
+
if (articuloInput.ID)
|
|
897
|
+
bodyArticulo.Ids = [articuloInput.ID];
|
|
898
|
+
else
|
|
899
|
+
bodyArticulo.Codigo = articuloInput.Codigo;
|
|
900
|
+
const dataArticulo = await (0, functions_1.apiRequest)(`${centumUrl}/Articulos/Venta`, {
|
|
901
|
+
method: 'POST',
|
|
902
|
+
headers,
|
|
903
|
+
body: bodyArticulo,
|
|
904
|
+
});
|
|
905
|
+
const items = dataArticulo?.Articulos?.Items ?? [];
|
|
906
|
+
if (!Array.isArray(items) || items.length === 0)
|
|
907
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Artículo no encontrado');
|
|
908
|
+
for (const item of items) {
|
|
909
|
+
RemitoCompraArticulos.push({
|
|
910
|
+
...item,
|
|
911
|
+
Cantidad: articuloInput.Cantidad,
|
|
912
|
+
});
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
catch (error) {
|
|
916
|
+
const msg = error?.response?.data?.Message || error?.message || 'Error resolviendo artículo';
|
|
917
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), msg);
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
let proveedorInfo;
|
|
921
|
+
try {
|
|
922
|
+
const response = await (0, functions_1.apiRequest)(`${centumUrl}/Proveedores/${encodeURIComponent(proveedorId)}`, { method: 'GET', headers });
|
|
923
|
+
if (!response?.IdProveedor)
|
|
924
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Proveedor no encontrado');
|
|
925
|
+
proveedorInfo = response;
|
|
926
|
+
}
|
|
927
|
+
catch (error) {
|
|
928
|
+
const msg = error?.response?.data?.Message || error?.message || 'Error obteniendo proveedor';
|
|
929
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), msg);
|
|
930
|
+
}
|
|
931
|
+
const bodyRemitoCompra = {
|
|
932
|
+
SucursalFisica: {
|
|
933
|
+
IdSucursalFisica: sucursalId
|
|
934
|
+
},
|
|
935
|
+
NumeroDocumento: {
|
|
936
|
+
LetraDocumento: letraDocumento,
|
|
937
|
+
PuntoVenta: puntoDeVenta,
|
|
938
|
+
Numero: numero
|
|
939
|
+
},
|
|
940
|
+
TurnoEntrega: {
|
|
941
|
+
IdTurnoEntrega: turnoEntregaId
|
|
942
|
+
},
|
|
943
|
+
FechaDocumento: formattedDocumentDate,
|
|
944
|
+
FechaEntrega: formattedDeliveryDate,
|
|
945
|
+
Proveedor: proveedorInfo,
|
|
946
|
+
RemitoCompraArticulos,
|
|
947
|
+
FechaVencimiento: formattedDueDate,
|
|
948
|
+
OperadorCompra: {
|
|
949
|
+
IdOperadorCompra: 1,
|
|
950
|
+
Codigo: "1",
|
|
951
|
+
Nombre: "Operador de Compras Defecto",
|
|
952
|
+
EsSupervisor: false
|
|
953
|
+
},
|
|
954
|
+
IdChofer: 1,
|
|
955
|
+
};
|
|
956
|
+
try {
|
|
957
|
+
const response = await (0, functions_1.apiRequest)(`${centumUrl}/RemitosCompra`, {
|
|
958
|
+
method: "POST",
|
|
959
|
+
headers,
|
|
960
|
+
body: bodyRemitoCompra,
|
|
961
|
+
});
|
|
962
|
+
return [this.helpers.returnJsonArray(response)];
|
|
963
|
+
}
|
|
964
|
+
catch (error) {
|
|
965
|
+
const msg = error?.response?.data?.Message || error?.message || 'Error creando la orden de compra';
|
|
966
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), msg);
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
case "crearRemitoVenta": {
|
|
970
|
+
const idSucursalFisica = this.getNodeParameter('idSucursalFisica', 0);
|
|
971
|
+
const puntoDeVenta = this.getNodeParameter('puntoDeVenta', 0);
|
|
972
|
+
const letraDocumento = this.getNodeParameter('letraDocumento', 0);
|
|
973
|
+
const numeroDocumento = this.getNodeParameter('numeroFactura', 0);
|
|
974
|
+
const turnoDeEntrega = this.getNodeParameter('turnoEntrega', 0);
|
|
975
|
+
const fechaDocumento = this.getNodeParameter('documentDate', 0);
|
|
976
|
+
const fechaDocumentoFormateada = fechaDocumento.replace(/\..+/, "");
|
|
977
|
+
const fechaEmbarque = this.getNodeParameter('shipmentDate', 0);
|
|
978
|
+
const fechaEmbarqueFormateada = fechaEmbarque.replace(/\..+/, "");
|
|
979
|
+
const fechaImputacion = this.getNodeParameter('indictmentDate', 0);
|
|
980
|
+
;
|
|
981
|
+
const fechaImputacionFormateada = fechaImputacion.replace(/\..+/, "");
|
|
982
|
+
const fechaEntrega = this.getNodeParameter('deliveryDate', 0);
|
|
983
|
+
const fechaEntregaFormateada = fechaEntrega.replace(/\..+/, "");
|
|
984
|
+
const idVendedor = this.getNodeParameter('idVendedor', 0);
|
|
985
|
+
const idCliente = this.getNodeParameter('clienteId', 0);
|
|
986
|
+
const rawArticles = this.getNodeParameter("articlesCollection", 0);
|
|
987
|
+
let articulosArray = [];
|
|
988
|
+
if (typeof rawArticles === "string") {
|
|
989
|
+
articulosArray = JSON.parse(rawArticles);
|
|
990
|
+
}
|
|
991
|
+
else {
|
|
992
|
+
articulosArray = rawArticles;
|
|
993
|
+
}
|
|
994
|
+
const ids = articulosArray.map((a) => a.ID);
|
|
995
|
+
const qtyById = Object.fromEntries(articulosArray.map((a) => [a.ID, a.Cantidad]));
|
|
996
|
+
const bodyCompraArticulos = {
|
|
997
|
+
IdCliente: idCliente,
|
|
998
|
+
FechaDocumento: fechaDocumentoFormateada,
|
|
999
|
+
Ids: ids,
|
|
1000
|
+
};
|
|
1001
|
+
let articulosVenta;
|
|
1002
|
+
try {
|
|
1003
|
+
articulosVenta = await (0, functions_1.apiRequest)(`${centumUrl}/Articulos/Venta`, {
|
|
1004
|
+
method: "POST",
|
|
1005
|
+
body: bodyCompraArticulos,
|
|
1006
|
+
headers,
|
|
1007
|
+
});
|
|
1008
|
+
}
|
|
1009
|
+
catch (error) {
|
|
1010
|
+
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
1011
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Error al obtener la informacion de los articulos ${errorMessage}`);
|
|
1012
|
+
}
|
|
1013
|
+
const ventaObj = typeof articulosVenta === "string" ? JSON.parse(articulosVenta) : articulosVenta;
|
|
1014
|
+
const itemsRespuesta = ventaObj?.Articulos?.Items ?? ventaObj?.CompraArticulos ?? ventaObj?.Items ?? [];
|
|
1015
|
+
const compraConCantidad = itemsRespuesta.map((art) => ({
|
|
1016
|
+
...art,
|
|
1017
|
+
Cantidad: qtyById[String(art.IdArticulo)] ?? 0,
|
|
1018
|
+
}));
|
|
1019
|
+
let clientInfo;
|
|
1020
|
+
try {
|
|
1021
|
+
const dataCliente = await (0, functions_1.apiRequest)(`${centumUrl}/Clientes/${idCliente}`, {
|
|
1022
|
+
method: "GET",
|
|
1023
|
+
headers
|
|
1024
|
+
});
|
|
1025
|
+
const cliente = dataCliente;
|
|
1026
|
+
if (!cliente?.IdCliente) {
|
|
1027
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'El cliente no fue encontrado');
|
|
1028
|
+
}
|
|
1029
|
+
clientInfo = cliente;
|
|
1030
|
+
}
|
|
1031
|
+
catch (error) {
|
|
1032
|
+
console.log("Error creating sales order:", error);
|
|
1033
|
+
const errorMessage = error?.response?.data?.Message || error.message || "Error al obtener el cliente.";
|
|
1034
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage);
|
|
1035
|
+
}
|
|
1036
|
+
try {
|
|
1037
|
+
const response = await (0, functions_1.apiRequest)(`${centumUrl}/RemitosVenta`, {
|
|
1038
|
+
headers,
|
|
1039
|
+
method: "POST",
|
|
1040
|
+
body: {
|
|
1041
|
+
SucursalFisica: {
|
|
1042
|
+
IdSucursalFisica: idSucursalFisica,
|
|
1043
|
+
},
|
|
1044
|
+
NumeroDocumento: {
|
|
1045
|
+
LetraDocumento: letraDocumento,
|
|
1046
|
+
PuntoVenta: puntoDeVenta,
|
|
1047
|
+
Numero: numeroDocumento,
|
|
1048
|
+
},
|
|
1049
|
+
FechaDocumento: fechaDocumentoFormateada,
|
|
1050
|
+
FechaEmbarque: fechaEmbarqueFormateada,
|
|
1051
|
+
FechaImputacion: fechaImputacionFormateada,
|
|
1052
|
+
FechaEntrega: fechaEntregaFormateada,
|
|
1053
|
+
TurnoEntrega: {
|
|
1054
|
+
IdTurnoEntrega: turnoDeEntrega,
|
|
1055
|
+
},
|
|
1056
|
+
Cliente: clientInfo,
|
|
1057
|
+
Vendedor: {
|
|
1058
|
+
IdVendedor: idVendedor
|
|
1059
|
+
},
|
|
1060
|
+
IdChofer: 1,
|
|
1061
|
+
PorcentajeDescuento: 0.0,
|
|
1062
|
+
Observaciones: "Remito creado desde n8n.",
|
|
1063
|
+
RemitoVentaArticulos: compraConCantidad
|
|
1064
|
+
},
|
|
1065
|
+
});
|
|
1066
|
+
return [this.helpers.returnJsonArray(response)];
|
|
1067
|
+
}
|
|
1068
|
+
catch (error) {
|
|
1069
|
+
const msg = error?.response?.data?.Message || error?.message || 'Error creando el Remito De Venta';
|
|
1070
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), msg);
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
819
1073
|
case "crearVenta": {
|
|
820
1074
|
const numeroPuntoDeVenta = this.getNodeParameter("puntoDeVenta", 0);
|
|
821
1075
|
const bonificacion = this.getNodeParameter("bonificacion", 0, "");
|
|
@@ -927,6 +1181,42 @@ class Centum {
|
|
|
927
1181
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Error creando la venta.\n${errorMessage}`);
|
|
928
1182
|
}
|
|
929
1183
|
}
|
|
1184
|
+
case "crearMovimientoStock": {
|
|
1185
|
+
const idSucursalFisica = this.getNodeParameter('idSucursalFisica', 0);
|
|
1186
|
+
const articleId = this.getNodeParameter('articleId', 0);
|
|
1187
|
+
const fechaImputacion = this.getNodeParameter('indictmentDate', 0);
|
|
1188
|
+
const fechaImputacionFormateada = fechaImputacion.replace(/\..+/, "");
|
|
1189
|
+
if (!articleId) {
|
|
1190
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "El ID del articulo es obligatorio.");
|
|
1191
|
+
}
|
|
1192
|
+
try {
|
|
1193
|
+
const response = await (0, functions_1.apiRequest)(`${centumUrl}/AjustesMovimientoStock?bAjustePrevioACero=false`, {
|
|
1194
|
+
method: "POST",
|
|
1195
|
+
headers,
|
|
1196
|
+
body: {
|
|
1197
|
+
AjusteMovimientoStockItems: [
|
|
1198
|
+
{
|
|
1199
|
+
Articulo: {
|
|
1200
|
+
IdArticulo: articleId,
|
|
1201
|
+
},
|
|
1202
|
+
},
|
|
1203
|
+
],
|
|
1204
|
+
SucursalFisica: {
|
|
1205
|
+
IdSucursalFisica: idSucursalFisica
|
|
1206
|
+
},
|
|
1207
|
+
ConceptoVarios: {
|
|
1208
|
+
IdConceptoVarios: 1
|
|
1209
|
+
},
|
|
1210
|
+
FechaImputacion: fechaImputacionFormateada,
|
|
1211
|
+
},
|
|
1212
|
+
});
|
|
1213
|
+
return [this.helpers.returnJsonArray(response)];
|
|
1214
|
+
}
|
|
1215
|
+
catch (error) {
|
|
1216
|
+
const msg = error?.response?.data?.Message || error?.message || 'Error creando el ajuste de stock';
|
|
1217
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), msg);
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
930
1220
|
case "descargarImagenesProductos": {
|
|
931
1221
|
const arrResult = [];
|
|
932
1222
|
const inputData = this.getInputData();
|
|
@@ -1089,6 +1379,18 @@ class Centum {
|
|
|
1089
1379
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Hubo un error al obtener el listado de categorias. Error: ${error}`);
|
|
1090
1380
|
}
|
|
1091
1381
|
}
|
|
1382
|
+
case "listarChoferes": {
|
|
1383
|
+
try {
|
|
1384
|
+
const response = await (0, functions_1.apiRequest)(`${centumUrl}/GuiaLogisticaChoferes`, {
|
|
1385
|
+
method: 'GET',
|
|
1386
|
+
headers
|
|
1387
|
+
});
|
|
1388
|
+
return [this.helpers.returnJsonArray(response)];
|
|
1389
|
+
}
|
|
1390
|
+
catch (error) {
|
|
1391
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Hubo un error al obtener el listado de choferes. Error: ${error}`);
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1092
1394
|
case "listarClientes": {
|
|
1093
1395
|
try {
|
|
1094
1396
|
const ajustesHTTP = functions_1.getHttpSettings.call(this);
|
|
@@ -1894,6 +2196,19 @@ class Centum {
|
|
|
1894
2196
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Error obteniendo los turnos de entrega: ${errorMessage}`);
|
|
1895
2197
|
}
|
|
1896
2198
|
}
|
|
2199
|
+
case 'listarUbicacionArticulos': {
|
|
2200
|
+
try {
|
|
2201
|
+
const ubicacionArticulos = await (0, functions_1.apiRequest)(`${centumUrl}/UbicacionesArticulos`, {
|
|
2202
|
+
method: 'GET',
|
|
2203
|
+
headers
|
|
2204
|
+
});
|
|
2205
|
+
return [this.helpers.returnJsonArray(ubicacionArticulos)];
|
|
2206
|
+
}
|
|
2207
|
+
catch (error) {
|
|
2208
|
+
const errorMessage = error?.response?.data?.Message || error.message || "Error desconocido";
|
|
2209
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Error obteniendo las ubicaciones de los articulos: ${errorMessage}`);
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
1897
2212
|
case 'listarVendedores': {
|
|
1898
2213
|
try {
|
|
1899
2214
|
const turnoEntrega = await (0, functions_1.apiRequest)(`${centumUrl}/Vendedores`, {
|
|
@@ -2037,7 +2352,7 @@ class Centum {
|
|
|
2037
2352
|
case "verificarCredencialesOperador": {
|
|
2038
2353
|
const username = this.getNodeParameter("username", 0, "");
|
|
2039
2354
|
try {
|
|
2040
|
-
const operadoresActividad = await (0, functions_1.apiRequest)(`
|
|
2355
|
+
const operadoresActividad = await (0, functions_1.apiRequest)(`
|
|
2041
2356
|
${centumUrl}/OperadoresMoviles?Usuario=${username}`, {
|
|
2042
2357
|
method: "GET",
|
|
2043
2358
|
headers,
|