n8n-nodes-sunat-peru 0.1.0 → 2.0.0
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
CHANGED
|
@@ -1,98 +1,133 @@
|
|
|
1
|
-
# n8n-nodes-sunat-peru
|
|
1
|
+
# n8n-nodes-sunat-peru 🇵🇪
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-

|
|
5
|
-

|
|
3
|
+
**Peru Electronic Invoicing for n8n** - RUC/DNI validation, exchange rate, UIT.
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## ✨ Features
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
- ✅ **
|
|
13
|
-
- ✅ **
|
|
14
|
-
- ✅ **
|
|
15
|
-
- ✅ **
|
|
11
|
+
- ✅ **Issue Invoices** to SUNAT (Invoice, Sales Receipt, Credit Note)
|
|
12
|
+
- ✅ **RUC/DNI Validation** - Verify, format, query SUNAT
|
|
13
|
+
- ✅ **Exchange Rate** - Dollar buy/sell from SBS (live data)
|
|
14
|
+
- ✅ **UIT Value** - Tax Unit
|
|
15
|
+
- ✅ **UIT ↔ Soles Conversion** automatic
|
|
16
|
+
- ✅ **Supports Nubefact and Efact**
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
- 💵 **Tipo de Cambio** - Dólar compra/venta SBS
|
|
19
|
-
- 📊 **Valor UIT** - Unidad Impositiva Tributaria
|
|
20
|
-
- 🔄 **Convertir UIT ↔ Soles**
|
|
18
|
+
## 🚀 Installation
|
|
21
19
|
|
|
22
|
-
###
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
- 📄 **Nota de Débito** - 08
|
|
20
|
+
### n8n Cloud / Desktop
|
|
21
|
+
1. Settings → Community Nodes
|
|
22
|
+
2. Search `n8n-nodes-sunat-peru`
|
|
23
|
+
3. Install
|
|
27
24
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
### En n8n (recomendado)
|
|
31
|
-
1. Ve a **Settings** → **Community Nodes**
|
|
32
|
-
2. Clic en **Install**
|
|
33
|
-
3. Escribe: `n8n-nodes-sunat-peru`
|
|
34
|
-
4. Clic en **Install**
|
|
35
|
-
|
|
36
|
-
### Via npm
|
|
25
|
+
### Self-hosted
|
|
37
26
|
```bash
|
|
38
27
|
npm install n8n-nodes-sunat-peru
|
|
39
28
|
```
|
|
40
29
|
|
|
41
|
-
## ⚙️
|
|
30
|
+
## ⚙️ Configuration
|
|
42
31
|
|
|
43
|
-
###
|
|
44
|
-
Las siguientes funciones NO requieren credenciales:
|
|
45
|
-
- Validar/formatear RUC/DNI
|
|
46
|
-
- Tipo de cambio (API pública)
|
|
47
|
-
- Valor UIT
|
|
48
|
-
- Conversiones
|
|
32
|
+
### To issue invoices you need:
|
|
49
33
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
34
|
+
| Provider | Free Plan | Link |
|
|
35
|
+
|----------|-----------|------|
|
|
36
|
+
| **Nubefact** | Yes (demo) | [nubefact.com](https://nubefact.com) |
|
|
37
|
+
| **Efact** | Yes (testing) | [efact.pe](https://efact.pe) |
|
|
54
38
|
|
|
55
|
-
|
|
39
|
+
1. Create an account with one of the providers
|
|
40
|
+
2. Get your API Key
|
|
41
|
+
3. Configure credentials in n8n
|
|
56
42
|
|
|
57
|
-
###
|
|
58
|
-
|
|
59
|
-
Recurso: RUC/DNI
|
|
60
|
-
Operación: Validar RUC
|
|
61
|
-
RUC: 20123456789
|
|
62
|
-
```
|
|
43
|
+
### For local functions (RUC, Indicators):
|
|
44
|
+
No credentials needed - works without configuration.
|
|
63
45
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
46
|
+
## 📖 Usage
|
|
47
|
+
|
|
48
|
+
### Validate RUC
|
|
49
|
+
|
|
50
|
+
```javascript
|
|
51
|
+
// Input: "20123456789"
|
|
52
|
+
// Output:
|
|
53
|
+
{
|
|
54
|
+
"valid": true,
|
|
55
|
+
"ruc": "20123456789",
|
|
56
|
+
"tipo": "Company",
|
|
57
|
+
"message": "Valid RUC"
|
|
58
|
+
}
|
|
68
59
|
```
|
|
69
60
|
|
|
70
|
-
###
|
|
61
|
+
### Get Exchange Rate
|
|
62
|
+
|
|
63
|
+
```javascript
|
|
64
|
+
// Output:
|
|
65
|
+
{
|
|
66
|
+
"indicator": "Exchange Rate",
|
|
67
|
+
"buy": 3.73,
|
|
68
|
+
"sell": 3.77,
|
|
69
|
+
"date": "2024-01-15",
|
|
70
|
+
"source": "SUNAT/SBS"
|
|
71
|
+
}
|
|
71
72
|
```
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
|
|
74
|
+
### Get UIT Value
|
|
75
|
+
|
|
76
|
+
```javascript
|
|
77
|
+
// Output:
|
|
78
|
+
{
|
|
79
|
+
"indicator": "UIT",
|
|
80
|
+
"value": 5350,
|
|
81
|
+
"year": 2025,
|
|
82
|
+
"source": "SUNAT"
|
|
83
|
+
}
|
|
75
84
|
```
|
|
76
85
|
|
|
77
|
-
##
|
|
86
|
+
## 🔧 Available Operations
|
|
87
|
+
|
|
88
|
+
### 🔢 RUC/DNI
|
|
89
|
+
- Validate RUC
|
|
90
|
+
- Validate DNI
|
|
91
|
+
- Format RUC
|
|
92
|
+
- Query RUC (from SUNAT)
|
|
93
|
+
|
|
94
|
+
### 💰 Indicators (live data)
|
|
95
|
+
- Exchange Rate (Dollar)
|
|
96
|
+
- UIT Value
|
|
97
|
+
- Convert UIT to Soles
|
|
98
|
+
- Convert Soles to UIT
|
|
99
|
+
|
|
100
|
+
### 📄 Issue Invoice
|
|
101
|
+
- Invoice (Type 01)
|
|
102
|
+
- Sales Receipt (Type 03)
|
|
103
|
+
- Credit Note (Type 07)
|
|
104
|
+
|
|
105
|
+
## 🌐 Supported Providers
|
|
106
|
+
|
|
107
|
+
### Nubefact
|
|
108
|
+
- Popular in Peru
|
|
109
|
+
- Easy to use API
|
|
110
|
+
- [Documentation](https://nubefact.com/documentacion)
|
|
111
|
+
|
|
112
|
+
### Efact
|
|
113
|
+
- Low cost plans
|
|
114
|
+
- Full SUNAT compliance
|
|
115
|
+
- [Documentation](https://efact.pe/docs)
|
|
78
116
|
|
|
79
|
-
|
|
80
|
-
|--------|------|-------------|
|
|
81
|
-
| 01 | Factura | Para empresas con RUC |
|
|
82
|
-
| 03 | Boleta | Para consumidor final |
|
|
83
|
-
| 07 | Nota Crédito | Anula/modifica factura |
|
|
84
|
-
| 08 | Nota Débito | Cargo adicional |
|
|
117
|
+
## 💡 Use Cases
|
|
85
118
|
|
|
86
|
-
|
|
119
|
+
- **E-commerce**: Automatically issue invoices
|
|
120
|
+
- **SaaS**: Generate automatic monthly invoices
|
|
121
|
+
- **Validation**: Verify customer RUC in forms
|
|
122
|
+
- **Accounting**: Get live exchange rates
|
|
123
|
+
- **Tax**: Calculate UIT amounts
|
|
87
124
|
|
|
88
|
-
|
|
89
|
-
- **SBS** - Tipo de cambio oficial
|
|
90
|
-
- **Nubefact / Efact** - Emisión facturas (requiere cuenta)
|
|
125
|
+
## 📄 License
|
|
91
126
|
|
|
92
|
-
|
|
127
|
+
MIT License - see [LICENSE](LICENSE)
|
|
93
128
|
|
|
94
|
-
|
|
129
|
+
## 👨💻 Author
|
|
95
130
|
|
|
96
|
-
|
|
131
|
+
**Manu** - [LatamFlows](https://latamflows.com)
|
|
97
132
|
|
|
98
|
-
|
|
133
|
+
Automation for LATAM 🚀
|
|
@@ -4,22 +4,22 @@ exports.SunatPeruApi = void 0;
|
|
|
4
4
|
class SunatPeruApi {
|
|
5
5
|
constructor() {
|
|
6
6
|
this.name = 'sunatPeruApi';
|
|
7
|
-
this.displayName = 'SUNAT
|
|
7
|
+
this.displayName = 'SUNAT Peru / Electronic Invoicing';
|
|
8
8
|
this.documentationUrl = 'https://nubefact.com/documentacion';
|
|
9
9
|
this.properties = [
|
|
10
10
|
{
|
|
11
|
-
displayName: '
|
|
11
|
+
displayName: 'Invoicing Provider',
|
|
12
12
|
name: 'provider',
|
|
13
13
|
type: 'options',
|
|
14
14
|
options: [
|
|
15
15
|
{ name: 'Nubefact', value: 'nubefact' },
|
|
16
16
|
{ name: 'Efact', value: 'efact' },
|
|
17
|
-
{ name: '
|
|
17
|
+
{ name: 'Local Functions Only (no issuing)', value: 'none' },
|
|
18
18
|
],
|
|
19
19
|
default: 'none',
|
|
20
20
|
},
|
|
21
21
|
{
|
|
22
|
-
displayName: 'API Key
|
|
22
|
+
displayName: 'Nubefact API Key',
|
|
23
23
|
name: 'nubefactApiKey',
|
|
24
24
|
type: 'string',
|
|
25
25
|
typeOptions: { password: true },
|
|
@@ -27,18 +27,18 @@ class SunatPeruApi {
|
|
|
27
27
|
displayOptions: { show: { provider: ['nubefact'] } },
|
|
28
28
|
},
|
|
29
29
|
{
|
|
30
|
-
displayName: '
|
|
30
|
+
displayName: 'Nubefact Environment',
|
|
31
31
|
name: 'nubefactEnvironment',
|
|
32
32
|
type: 'options',
|
|
33
33
|
options: [
|
|
34
|
-
{ name: 'Demo (
|
|
35
|
-
{ name: '
|
|
34
|
+
{ name: 'Demo (Testing)', value: 'demo' },
|
|
35
|
+
{ name: 'Production', value: 'production' },
|
|
36
36
|
],
|
|
37
37
|
default: 'demo',
|
|
38
38
|
displayOptions: { show: { provider: ['nubefact'] } },
|
|
39
39
|
},
|
|
40
40
|
{
|
|
41
|
-
displayName: 'API Key
|
|
41
|
+
displayName: 'Efact API Key',
|
|
42
42
|
name: 'efactApiKey',
|
|
43
43
|
type: 'string',
|
|
44
44
|
typeOptions: { password: true },
|
|
@@ -46,7 +46,7 @@ class SunatPeruApi {
|
|
|
46
46
|
displayOptions: { show: { provider: ['efact'] } },
|
|
47
47
|
},
|
|
48
48
|
{
|
|
49
|
-
displayName: 'RUC
|
|
49
|
+
displayName: 'Issuer RUC',
|
|
50
50
|
name: 'rucEmisor',
|
|
51
51
|
type: 'string',
|
|
52
52
|
default: '',
|
|
@@ -5,15 +5,15 @@ exports.SunatPeru = void 0;
|
|
|
5
5
|
function validarRuc(ruc) {
|
|
6
6
|
const rucLimpio = ruc.replace(/[-\s]/g, '');
|
|
7
7
|
if (!/^\d{11}$/.test(rucLimpio)) {
|
|
8
|
-
return {
|
|
8
|
+
return { valid: false, ruc: rucLimpio, tipo: 'Unknown', message: 'RUC must have 11 digits' };
|
|
9
9
|
}
|
|
10
|
-
//
|
|
10
|
+
// Validate prefix
|
|
11
11
|
const prefijo = rucLimpio.substring(0, 2);
|
|
12
12
|
const prefijosValidos = ['10', '15', '17', '20'];
|
|
13
13
|
if (!prefijosValidos.includes(prefijo)) {
|
|
14
|
-
return {
|
|
14
|
+
return { valid: false, ruc: rucLimpio, tipo: 'Unknown', message: 'Invalid RUC prefix' };
|
|
15
15
|
}
|
|
16
|
-
//
|
|
16
|
+
// Calculate check digit
|
|
17
17
|
const factores = [5, 4, 3, 2, 7, 6, 5, 4, 3, 2];
|
|
18
18
|
let suma = 0;
|
|
19
19
|
for (let i = 0; i < 10; i++) {
|
|
@@ -24,25 +24,25 @@ function validarRuc(ruc) {
|
|
|
24
24
|
const dvFinal = dvCalculado === 10 ? 0 : dvCalculado === 11 ? 1 : dvCalculado;
|
|
25
25
|
const dvIngresado = parseInt(rucLimpio.charAt(10));
|
|
26
26
|
if (dvFinal !== dvIngresado) {
|
|
27
|
-
return {
|
|
27
|
+
return { valid: false, ruc: rucLimpio, tipo: 'Unknown', message: 'Invalid check digit' };
|
|
28
28
|
}
|
|
29
|
-
let tipo = '
|
|
29
|
+
let tipo = 'Unknown';
|
|
30
30
|
if (prefijo === '10')
|
|
31
|
-
tipo = '
|
|
31
|
+
tipo = 'Individual';
|
|
32
32
|
else if (prefijo === '20')
|
|
33
|
-
tipo = '
|
|
33
|
+
tipo = 'Company';
|
|
34
34
|
else if (prefijo === '15')
|
|
35
|
-
tipo = '
|
|
35
|
+
tipo = 'Individual without business';
|
|
36
36
|
else if (prefijo === '17')
|
|
37
|
-
tipo = '
|
|
38
|
-
return {
|
|
37
|
+
tipo = 'Non-domiciled individual';
|
|
38
|
+
return { valid: true, ruc: rucLimpio, tipo, message: 'Valid RUC' };
|
|
39
39
|
}
|
|
40
40
|
function validarDni(dni) {
|
|
41
41
|
const dniLimpio = dni.replace(/[-\s]/g, '');
|
|
42
42
|
if (!/^\d{8}$/.test(dniLimpio)) {
|
|
43
|
-
return {
|
|
43
|
+
return { valid: false, dni: dniLimpio, message: 'DNI must have 8 digits' };
|
|
44
44
|
}
|
|
45
|
-
return {
|
|
45
|
+
return { valid: true, dni: dniLimpio, message: 'Valid DNI' };
|
|
46
46
|
}
|
|
47
47
|
function formatearRuc(ruc) {
|
|
48
48
|
return ruc.replace(/[^0-9]/g, '');
|
|
@@ -61,15 +61,15 @@ async function consultarRuc(that, ruc) {
|
|
|
61
61
|
catch {
|
|
62
62
|
return {
|
|
63
63
|
ruc: rucLimpio,
|
|
64
|
-
|
|
64
|
+
message: 'Could not query RUC. Use API with token for frequent queries.',
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
//
|
|
68
|
+
// Indicator Functions
|
|
69
69
|
async function obtenerTipoCambio(that) {
|
|
70
70
|
var _a;
|
|
71
71
|
try {
|
|
72
|
-
//
|
|
72
|
+
// Peru exchange rate API
|
|
73
73
|
const response = await that.helpers.httpRequest({
|
|
74
74
|
method: 'GET',
|
|
75
75
|
url: 'https://api.apis.net.pe/v1/tipo-cambio-sunat',
|
|
@@ -77,15 +77,15 @@ async function obtenerTipoCambio(that) {
|
|
|
77
77
|
});
|
|
78
78
|
const data = response;
|
|
79
79
|
return {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
indicator: 'Exchange Rate',
|
|
81
|
+
buy: data.compra,
|
|
82
|
+
sell: data.venta,
|
|
83
|
+
date: data.fecha,
|
|
84
|
+
source: 'SUNAT/SBS',
|
|
85
85
|
};
|
|
86
86
|
}
|
|
87
87
|
catch {
|
|
88
|
-
// Fallback
|
|
88
|
+
// Fallback with alternative API
|
|
89
89
|
try {
|
|
90
90
|
const response = await that.helpers.httpRequest({
|
|
91
91
|
method: 'GET',
|
|
@@ -95,33 +95,33 @@ async function obtenerTipoCambio(that) {
|
|
|
95
95
|
const data = response;
|
|
96
96
|
const pen = ((_a = data.rates) === null || _a === void 0 ? void 0 : _a.PEN) || 3.75;
|
|
97
97
|
return {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
98
|
+
indicator: 'Exchange Rate',
|
|
99
|
+
buy: pen - 0.02,
|
|
100
|
+
sell: pen + 0.02,
|
|
101
|
+
date: new Date().toISOString().split('T')[0],
|
|
102
|
+
source: 'Exchange Rate API',
|
|
103
103
|
};
|
|
104
104
|
}
|
|
105
105
|
catch {
|
|
106
106
|
return {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
107
|
+
indicator: 'Exchange Rate',
|
|
108
|
+
buy: 3.73,
|
|
109
|
+
sell: 3.77,
|
|
110
|
+
date: new Date().toISOString().split('T')[0],
|
|
111
|
+
source: 'Estimated',
|
|
112
112
|
};
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
async function obtenerUit(that) {
|
|
117
|
-
// UIT 2025: S/ 5,350 (
|
|
117
|
+
// UIT 2025: S/ 5,350 (fixed annual value)
|
|
118
118
|
const uit2025 = 5350;
|
|
119
119
|
return {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
120
|
+
indicator: 'UIT',
|
|
121
|
+
value: uit2025,
|
|
122
|
+
year: 2025,
|
|
123
|
+
source: 'SUNAT',
|
|
124
|
+
note: 'Current Tax Unit',
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
127
|
function convertirUitSoles(uit, valorUit) {
|
|
@@ -143,7 +143,7 @@ function convertirSolesUit(soles, valorUit) {
|
|
|
143
143
|
// Función para emitir factura
|
|
144
144
|
async function emitirFactura(that, provider, apiKey, tipoComprobante, datos) {
|
|
145
145
|
if (provider === 'none') {
|
|
146
|
-
throw new Error('
|
|
146
|
+
throw new Error('Configure Nubefact or Efact credentials to issue invoices');
|
|
147
147
|
}
|
|
148
148
|
if (provider === 'nubefact') {
|
|
149
149
|
const response = await that.helpers.httpRequest({
|
|
@@ -167,20 +167,20 @@ async function emitirFactura(that, provider, apiKey, tipoComprobante, datos) {
|
|
|
167
167
|
});
|
|
168
168
|
return response;
|
|
169
169
|
}
|
|
170
|
-
throw new Error(`
|
|
170
|
+
throw new Error(`Provider ${provider} not implemented`);
|
|
171
171
|
}
|
|
172
172
|
class SunatPeru {
|
|
173
173
|
constructor() {
|
|
174
174
|
this.description = {
|
|
175
|
-
displayName: 'SUNAT
|
|
175
|
+
displayName: 'SUNAT Peru',
|
|
176
176
|
name: 'sunatPeru',
|
|
177
177
|
icon: 'file:sunat.svg',
|
|
178
178
|
group: ['transform'],
|
|
179
179
|
version: 1,
|
|
180
180
|
subtitle: '={{$parameter["resource"] + ": " + $parameter["operation"]}}',
|
|
181
|
-
description: '
|
|
181
|
+
description: 'Peru Electronic Invoicing - RUC/DNI validation, exchange rate, UIT',
|
|
182
182
|
defaults: {
|
|
183
|
-
name: 'SUNAT
|
|
183
|
+
name: 'SUNAT Peru',
|
|
184
184
|
},
|
|
185
185
|
inputs: ['main'],
|
|
186
186
|
outputs: ['main'],
|
|
@@ -192,29 +192,29 @@ class SunatPeru {
|
|
|
192
192
|
],
|
|
193
193
|
properties: [
|
|
194
194
|
{
|
|
195
|
-
displayName: '
|
|
195
|
+
displayName: 'Resource',
|
|
196
196
|
name: 'resource',
|
|
197
197
|
type: 'options',
|
|
198
198
|
noDataExpression: true,
|
|
199
199
|
options: [
|
|
200
200
|
{ name: 'RUC/DNI', value: 'ruc' },
|
|
201
|
-
{ name: '
|
|
202
|
-
{ name: '
|
|
201
|
+
{ name: 'Indicators', value: 'indicadores' },
|
|
202
|
+
{ name: 'Issue Invoice', value: 'factura' },
|
|
203
203
|
],
|
|
204
204
|
default: 'ruc',
|
|
205
205
|
},
|
|
206
206
|
// Operaciones RUC/DNI
|
|
207
207
|
{
|
|
208
|
-
displayName: '
|
|
208
|
+
displayName: 'Operation',
|
|
209
209
|
name: 'operation',
|
|
210
210
|
type: 'options',
|
|
211
211
|
noDataExpression: true,
|
|
212
212
|
displayOptions: { show: { resource: ['ruc'] } },
|
|
213
213
|
options: [
|
|
214
|
-
{ name: '
|
|
215
|
-
{ name: '
|
|
216
|
-
{ name: '
|
|
217
|
-
{ name: '
|
|
214
|
+
{ name: 'Validate RUC', value: 'validar_ruc', description: 'Validate RUC format', action: 'Validate RUC' },
|
|
215
|
+
{ name: 'Validate DNI', value: 'validar_dni', description: 'Validate DNI format', action: 'Validate DNI' },
|
|
216
|
+
{ name: 'Format RUC', value: 'formatear', description: 'Clean RUC', action: 'Format RUC' },
|
|
217
|
+
{ name: 'Query RUC', value: 'consultar', description: 'Get data from SUNAT', action: 'Query RUC' },
|
|
218
218
|
],
|
|
219
219
|
default: 'validar_ruc',
|
|
220
220
|
},
|
|
@@ -238,28 +238,28 @@ class SunatPeru {
|
|
|
238
238
|
},
|
|
239
239
|
// Operaciones Indicadores
|
|
240
240
|
{
|
|
241
|
-
displayName: '
|
|
241
|
+
displayName: 'Operation',
|
|
242
242
|
name: 'operation',
|
|
243
243
|
type: 'options',
|
|
244
244
|
noDataExpression: true,
|
|
245
245
|
displayOptions: { show: { resource: ['indicadores'] } },
|
|
246
246
|
options: [
|
|
247
|
-
{ name: '
|
|
248
|
-
{ name: '
|
|
249
|
-
{ name: 'UIT
|
|
250
|
-
{ name: 'Soles
|
|
247
|
+
{ name: 'Exchange Rate', value: 'tipo_cambio', description: 'Dollar buy/sell SBS', action: 'Get exchange rate' },
|
|
248
|
+
{ name: 'UIT Value', value: 'uit', description: 'Tax Unit', action: 'Get UIT' },
|
|
249
|
+
{ name: 'UIT to Soles', value: 'uit_soles', description: 'Convert UIT to Soles', action: 'Convert UIT to Soles' },
|
|
250
|
+
{ name: 'Soles to UIT', value: 'soles_uit', description: 'Convert Soles to UIT', action: 'Convert Soles to UIT' },
|
|
251
251
|
],
|
|
252
252
|
default: 'tipo_cambio',
|
|
253
253
|
},
|
|
254
254
|
{
|
|
255
|
-
displayName: '
|
|
255
|
+
displayName: 'UIT Amount',
|
|
256
256
|
name: 'montoUit',
|
|
257
257
|
type: 'number',
|
|
258
258
|
default: 10,
|
|
259
259
|
displayOptions: { show: { resource: ['indicadores'], operation: ['uit_soles'] } },
|
|
260
260
|
},
|
|
261
261
|
{
|
|
262
|
-
displayName: '
|
|
262
|
+
displayName: 'Soles Amount',
|
|
263
263
|
name: 'montoSoles',
|
|
264
264
|
type: 'number',
|
|
265
265
|
default: 50000,
|
|
@@ -267,33 +267,33 @@ class SunatPeru {
|
|
|
267
267
|
},
|
|
268
268
|
// Operaciones Factura
|
|
269
269
|
{
|
|
270
|
-
displayName: '
|
|
270
|
+
displayName: 'Operation',
|
|
271
271
|
name: 'operation',
|
|
272
272
|
type: 'options',
|
|
273
273
|
noDataExpression: true,
|
|
274
274
|
displayOptions: { show: { resource: ['factura'] } },
|
|
275
275
|
options: [
|
|
276
|
-
{ name: '
|
|
277
|
-
{ name: '
|
|
278
|
-
{ name: '
|
|
276
|
+
{ name: 'Invoice', value: 'factura', description: 'Type 01', action: 'Issue Invoice' },
|
|
277
|
+
{ name: 'Sales Receipt', value: 'boleta', description: 'Type 03', action: 'Issue Receipt' },
|
|
278
|
+
{ name: 'Credit Note', value: 'nota_credito', description: 'Type 07', action: 'Issue Credit Note' },
|
|
279
279
|
],
|
|
280
280
|
default: 'factura',
|
|
281
281
|
},
|
|
282
282
|
{
|
|
283
|
-
displayName: '
|
|
283
|
+
displayName: 'Customer Document Type',
|
|
284
284
|
name: 'tipoDocCliente',
|
|
285
285
|
type: 'options',
|
|
286
286
|
options: [
|
|
287
287
|
{ name: 'RUC', value: '6' },
|
|
288
288
|
{ name: 'DNI', value: '1' },
|
|
289
|
-
{ name: '
|
|
290
|
-
{ name: '
|
|
289
|
+
{ name: 'Foreign ID', value: '4' },
|
|
290
|
+
{ name: 'Passport', value: '7' },
|
|
291
291
|
],
|
|
292
292
|
default: '6',
|
|
293
293
|
displayOptions: { show: { resource: ['factura'] } },
|
|
294
294
|
},
|
|
295
295
|
{
|
|
296
|
-
displayName: '
|
|
296
|
+
displayName: 'Document Number',
|
|
297
297
|
name: 'numDocCliente',
|
|
298
298
|
type: 'string',
|
|
299
299
|
default: '',
|
|
@@ -301,7 +301,7 @@ class SunatPeru {
|
|
|
301
301
|
displayOptions: { show: { resource: ['factura'] } },
|
|
302
302
|
},
|
|
303
303
|
{
|
|
304
|
-
displayName: '
|
|
304
|
+
displayName: 'Business Name',
|
|
305
305
|
name: 'razonSocial',
|
|
306
306
|
type: 'string',
|
|
307
307
|
default: '',
|
|
@@ -382,7 +382,7 @@ class SunatPeru {
|
|
|
382
382
|
else if (resource === 'factura') {
|
|
383
383
|
const credentials = await this.getCredentials('sunatPeruApi').catch(() => null);
|
|
384
384
|
if (!credentials || credentials.provider === 'none') {
|
|
385
|
-
throw new Error('
|
|
385
|
+
throw new Error('Configure Nubefact or Efact credentials to issue invoices');
|
|
386
386
|
}
|
|
387
387
|
const tipoComp = operation === 'factura' ? '01' : operation === 'boleta' ? '03' : '07';
|
|
388
388
|
const datos = {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-sunat-peru",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "n8n node for SUNAT Peru integration - Electronic invoicing, RUC/DNI validation, exchange rate, UIT",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"n8n-community-node-package",
|
|
7
7
|
"n8n",
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"peru",
|
|
10
10
|
"ruc",
|
|
11
11
|
"dni",
|
|
12
|
-
"
|
|
13
|
-
"
|
|
12
|
+
"invoicing",
|
|
13
|
+
"tax",
|
|
14
14
|
"uit",
|
|
15
15
|
"latam"
|
|
16
16
|
],
|