tax-cl 0.0.1 → 1.0.3
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 +94 -0
- package/lib/config.js +93 -0
- package/lib/index.js +43 -37
- package/lib/tax-brackets.js +21 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,2 +1,96 @@
|
|
|
1
1
|
# tax-cl
|
|
2
|
+
|
|
2
3
|
Librería cálculo de impuestos y cotizaciones en Chile 🇨🇱
|
|
4
|
+
|
|
5
|
+
## Getting Started
|
|
6
|
+
|
|
7
|
+
> Si tienes duda con el cálculo y supuestos, puedes ver el README de https://github.com/muZk/impuestos, donde tiene todo lo necesario para entender bien los cálculos.
|
|
8
|
+
|
|
9
|
+
### Installation
|
|
10
|
+
|
|
11
|
+
```console
|
|
12
|
+
npm install tax-cl --save
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
o
|
|
16
|
+
|
|
17
|
+
```console
|
|
18
|
+
yarn add tax-cl
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
:warning: Debido a que los conceptos de impuestos y contribuciones ya son complicados en español, gran parte del código está en español.
|
|
22
|
+
|
|
23
|
+
### Basic Usage
|
|
24
|
+
|
|
25
|
+
El método que calcula cuánto debes pagar (o cuánto recibirás en la devolución) se llama `calcular`:
|
|
26
|
+
|
|
27
|
+
```javascript
|
|
28
|
+
const { calcular } = require('tax-cl');
|
|
29
|
+
|
|
30
|
+
const resultado = calcular(1400000); // sueldo bruto = 1.400.000 mensual
|
|
31
|
+
|
|
32
|
+
if (resultado.deuda >= 0) {
|
|
33
|
+
console.log(`Tendrás que pagar al SII ${resultado.deuda}`);
|
|
34
|
+
} else {
|
|
35
|
+
console.log(`Recibirás una devolución de ${-resultado.deuda}`);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (resultado.deudaModalidadParcial >= 0) {
|
|
39
|
+
console.log(`En modalidad parcial, tendrás que pagar al SII ${resultado.deudaModalidadParcial}`);
|
|
40
|
+
} else {
|
|
41
|
+
console.log(`En modalidad parcial, recibirás una devolución de ${-resultado.deudaModalidadParcial}`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
`calcular` entrega un objeto que tiene propiedades que indican algunas cosas del cálculo, como por ejemplo el monto a pagar de cotizaciones. La propiedad `deuda` indica cuanto tendrás que pagar en total al SII por cotizaciones e impuestos:
|
|
47
|
+
|
|
48
|
+
- Si `deuda > 0`, le debes dinero al SII.
|
|
49
|
+
- Si `deuda < 0`, el SII te devolverá dinero.
|
|
50
|
+
|
|
51
|
+
A continuación un ejemplo de los otros atributos del resultado:
|
|
52
|
+
|
|
53
|
+
```javascript
|
|
54
|
+
console.log(`Tu sueldo BRUTO anual es ${resultado.sueldoAnual}`);
|
|
55
|
+
console.log(`Tus gastos supuestos son ${resultado.gastos}`);
|
|
56
|
+
console.log(`Tu sueldo tributable es ${resultado.sueldoTributable}`);
|
|
57
|
+
console.log(`Lo que tendrás que pagar por impuestos es ${resultado.impuestos}`);
|
|
58
|
+
console.log(`Lo que tendrás que pagar por cotizaciones es igual a ${resultado.montoCotizacionesObligatorias}`);
|
|
59
|
+
console.log(`La retención de tus boletas anual es ${retencion}`);
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Advanced Usage
|
|
63
|
+
|
|
64
|
+
### `calcular(number: sueldoBrutoMensual)`
|
|
65
|
+
|
|
66
|
+
Retorna un objeto con el detalle de los datos utilizados para realizar el cálculo del pago de impuestos y cotizaciones.
|
|
67
|
+
|
|
68
|
+
#### Arguments
|
|
69
|
+
|
|
70
|
+
Recibe los siguientes argumentos:
|
|
71
|
+
|
|
72
|
+
* `sueldoBrutoMensual`: *(number)*. Es el total de tus ingresos mensuales.
|
|
73
|
+
|
|
74
|
+
#### Returns
|
|
75
|
+
|
|
76
|
+
Retorna un objeto con las siguientes propiedades:
|
|
77
|
+
|
|
78
|
+
* `sueldoAnual`: *(number)*. Es el sueldo bruto recibido en un año.
|
|
79
|
+
* `gastos`: *(number)*. Gastos supuestos, equivalen a un 30% de tu ingreso bruto, hasta un máximo de 15UTA.
|
|
80
|
+
* `sueldoTributable`: *(number)*. Es el monto sobre el cual se calculan los impuestos a pagar. Corresponde al sueldo anual menos los gastos supuestos.
|
|
81
|
+
* `montoCotizacionesObligatorias`: *(number)*. Es el monto total de las cotizaciones obligatorias que debes pagar. Esto incluye el seguro de invalidez y sobrevivencia, el seguro de la ley de accidentes del trabajo y enfermedades profesionales, el seguro de acompañamiento de niños y niñas, la previsión de salud y la AFP.
|
|
82
|
+
* `retencion`: *(number)*. Es el monto total de las retenciones pagadas al Servicio de Impuestos Internos durante un año. Este monto aumenta año a año hasta llegar al 17%.
|
|
83
|
+
* `impuestos`: *(number)*. Es el total de impuestos a pagar según el tramo impositivo.
|
|
84
|
+
* `deuda`: *(number)*. Es la deuda final, si su valor es positivo indica el valor que debes pagar al Servicio de Impuestos Internos, si es negativo es el valor que recibirás como devolución.
|
|
85
|
+
* `deudaModalidadParcial`: *(number)*. Es la deuda final, pero considerando que has optado por pagar las cotizaciones en modalidad parcial.
|
|
86
|
+
* `operacionRenta`: *(number)*. Es el año de la declaración (**2021** por defecto).
|
|
87
|
+
|
|
88
|
+
### `configurarDeclaracion(number: year) : void`
|
|
89
|
+
|
|
90
|
+
Configura el año de la operación renta sobre la cual aplican los cálculos. Por defecto, el año de la declaración es **2021**.
|
|
91
|
+
|
|
92
|
+
#### Arguments
|
|
93
|
+
|
|
94
|
+
Recibe el siguiente argumento:
|
|
95
|
+
|
|
96
|
+
* `year`: *(number)*, año de la operación renta para la realización de los cálculos. Los valores válidos son: `2018`, `2019`, `2020`, `2021` y `2022`.
|
package/lib/config.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getConfig = getConfig;
|
|
7
|
+
// Valor UTA en diciembre en https://www.sii.cl/valores_y_fechas/index_valores_y_fechas.html
|
|
8
|
+
var UTA = {
|
|
9
|
+
2018: 580236,
|
|
10
|
+
2019: 595476,
|
|
11
|
+
2020: 612348,
|
|
12
|
+
2021: 650052,
|
|
13
|
+
2022: 653304 // 2021-01-04
|
|
14
|
+
|
|
15
|
+
}; // Valor UF al 31 de diciembre en https://www.sii.cl/valores_y_fechas/index_valores_y_fechas.html
|
|
16
|
+
|
|
17
|
+
var UF = {
|
|
18
|
+
2018: 27565.79,
|
|
19
|
+
2019: 28309.94,
|
|
20
|
+
2020: 29070.33,
|
|
21
|
+
2021: 30991.74,
|
|
22
|
+
2022: 31036.65 // 2021-01-09
|
|
23
|
+
|
|
24
|
+
};
|
|
25
|
+
var RETENCION = {
|
|
26
|
+
2019: 10,
|
|
27
|
+
2020: 10.75,
|
|
28
|
+
2021: 11.5,
|
|
29
|
+
2022: 12.25,
|
|
30
|
+
2023: 13,
|
|
31
|
+
2024: 13.75,
|
|
32
|
+
2025: 14.5,
|
|
33
|
+
2026: 15.25,
|
|
34
|
+
2027: 16,
|
|
35
|
+
2028: 17
|
|
36
|
+
}; // Artículo Segundo de la Ley 21.133 (https://www.bcn.cl/leychile/navegar?idNorma=1128420)
|
|
37
|
+
|
|
38
|
+
var COBERTURA_PARCIAL = {
|
|
39
|
+
2018: 5,
|
|
40
|
+
2019: 17,
|
|
41
|
+
2020: 27,
|
|
42
|
+
2021: 37,
|
|
43
|
+
2022: 47,
|
|
44
|
+
2023: 57,
|
|
45
|
+
2024: 70,
|
|
46
|
+
2025: 80,
|
|
47
|
+
2026: 90,
|
|
48
|
+
2027: 100,
|
|
49
|
+
2028: 100
|
|
50
|
+
};
|
|
51
|
+
var TOPE_IMPONIBLE_MENSUAL = {
|
|
52
|
+
2018: 78.3,
|
|
53
|
+
// https://www.spensiones.cl/portal/institucional/594/w3-article-12946.html
|
|
54
|
+
2019: 79.2,
|
|
55
|
+
// https://www.spensiones.cl/portal/institucional/594/w3-article-13553.html
|
|
56
|
+
2020: 80.2,
|
|
57
|
+
// https://www.spensiones.cl/portal/institucional/594/w3-article-13843.html
|
|
58
|
+
2021: 81.6,
|
|
59
|
+
// https://www.spensiones.cl/portal/institucional/594/w3-article-14366.html
|
|
60
|
+
2022: 81.6 // Not published yet!
|
|
61
|
+
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
function obtenerTramosImpositivos(uta) {
|
|
65
|
+
var construirTramoImpositivo = function construirTramoImpositivo(factor, montoMaximo, descuento) {
|
|
66
|
+
return {
|
|
67
|
+
factor: factor,
|
|
68
|
+
montoMaximo: montoMaximo,
|
|
69
|
+
descuento: descuento
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
return [construirTramoImpositivo(0, 13.5 * uta, 0), construirTramoImpositivo(0.04, 30 * uta, 0.54 * uta), construirTramoImpositivo(0.08, 50 * uta, 1.74 * uta), construirTramoImpositivo(0.135, 70 * uta, 4.49 * uta), construirTramoImpositivo(0.23, 90 * uta, 11.14 * uta), construirTramoImpositivo(0.304, 120 * uta, 17.8 * uta), construirTramoImpositivo(0.35, 150 * uta, 23.92 * uta), construirTramoImpositivo(0.4, Number.MAX_VALUE, 30.67 * uta)];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function getConfig(operacionRenta) {
|
|
77
|
+
var year = operacionRenta - 1;
|
|
78
|
+
|
|
79
|
+
if (!TOPE_IMPONIBLE_MENSUAL[year]) {
|
|
80
|
+
var validos = Object.keys(TOPE_IMPONIBLE_MENSUAL).join(', ');
|
|
81
|
+
throw new Error("El a\xF1o ingresado es incorrecto. Los valores v\xE1lidos son: ".concat(validos));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
OPERACION_RENTA: operacionRenta,
|
|
86
|
+
UTA: UTA[year],
|
|
87
|
+
UF: UF[year],
|
|
88
|
+
RETENCION: RETENCION[year] / 100,
|
|
89
|
+
COBERTURA_PARCIAL: COBERTURA_PARCIAL[year] / 100,
|
|
90
|
+
TOPE_IMPONIBLE_MENSUAL: TOPE_IMPONIBLE_MENSUAL[year],
|
|
91
|
+
TRAMOS_IMPOSITIVOS: obtenerTramosImpositivos(UTA[year])
|
|
92
|
+
};
|
|
93
|
+
}
|
package/lib/index.js
CHANGED
|
@@ -3,29 +3,43 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.configurarDeclaracion = configurarDeclaracion;
|
|
7
|
+
exports.obtenerConfiguracion = obtenerConfiguracion;
|
|
6
8
|
exports.calcularGastos = calcularGastos;
|
|
7
9
|
exports.calcularSueldoImponible = calcularSueldoImponible;
|
|
8
10
|
exports.calcularCotizacionesObligatorias = calcularCotizacionesObligatorias;
|
|
9
11
|
exports.calcularRetencion = calcularRetencion;
|
|
10
|
-
exports.
|
|
12
|
+
exports.buscarTramoImpositivo = buscarTramoImpositivo;
|
|
11
13
|
exports.calcularImpuestos = calcularImpuestos;
|
|
12
14
|
exports.calcularDeuda = calcularDeuda;
|
|
13
15
|
exports.calcular = calcular;
|
|
14
|
-
exports.
|
|
15
|
-
var UTA = 595476; // UTA december 2019
|
|
16
|
+
exports.COTIZACIONES_OBLIGATORIAS = void 0;
|
|
16
17
|
|
|
17
|
-
var
|
|
18
|
+
var _config = require("./config");
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
var TOPE_DE_GASTOS = 15 * UTA;
|
|
21
|
-
var PORCENTAJE_RETENCION = 10.75;
|
|
22
|
-
var TOPE_IMPONIBLE_UF = 12 * 80.2; // 80.2
|
|
20
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
23
21
|
|
|
24
|
-
|
|
25
|
-
var TOPE_IMPONIBLE = TOPE_IMPONIBLE_UF * UF; // anual
|
|
22
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
26
23
|
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
25
|
+
|
|
26
|
+
var OPERACION_RENTA_ACTUAL = 2021;
|
|
27
|
+
var config = (0, _config.getConfig)(OPERACION_RENTA_ACTUAL);
|
|
28
|
+
/**
|
|
29
|
+
* Configura el año de la operación renta para los cálculos.
|
|
30
|
+
* @param {Number} year, año de la operación renta
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
function configurarDeclaracion(year) {
|
|
34
|
+
var newConfig = (0, _config.getConfig)(year);
|
|
35
|
+
Object.keys(newConfig).forEach(function (key) {
|
|
36
|
+
config[key] = newConfig[key];
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function obtenerConfiguracion() {
|
|
41
|
+
return _objectSpread({}, config);
|
|
42
|
+
}
|
|
29
43
|
|
|
30
44
|
function min(a, b) {
|
|
31
45
|
return a > b ? b : a;
|
|
@@ -33,10 +47,11 @@ function min(a, b) {
|
|
|
33
47
|
|
|
34
48
|
function calcularGastos(sueldoAnual) {
|
|
35
49
|
var gastos = sueldoAnual * 0.3;
|
|
36
|
-
|
|
50
|
+
var tope = 15 * config.UTA;
|
|
51
|
+
return min(gastos, tope);
|
|
37
52
|
}
|
|
38
53
|
|
|
39
|
-
var
|
|
54
|
+
var COTIZACIONES_OBLIGATORIAS = [{
|
|
40
55
|
name: "Seguro de invalidez y sobrevivencia",
|
|
41
56
|
percent: 1.53,
|
|
42
57
|
variable: false
|
|
@@ -61,20 +76,21 @@ var cotizacionesObligatorias = [{
|
|
|
61
76
|
percent: 0.77,
|
|
62
77
|
variable: false
|
|
63
78
|
}];
|
|
64
|
-
exports.
|
|
79
|
+
exports.COTIZACIONES_OBLIGATORIAS = COTIZACIONES_OBLIGATORIAS;
|
|
65
80
|
|
|
66
81
|
function calcularSueldoImponible(sueldoAnual) {
|
|
67
|
-
|
|
82
|
+
var topeAnual = config.TOPE_IMPONIBLE_MENSUAL * config.UF * 12;
|
|
83
|
+
return min(0.8 * sueldoAnual, topeAnual);
|
|
68
84
|
}
|
|
69
85
|
|
|
70
86
|
function calcularCotizacionesObligatorias(ingresos) {
|
|
71
87
|
var cotizacionParcial = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
72
88
|
var totalCotizacionesObligatorias = 0;
|
|
73
|
-
|
|
89
|
+
COTIZACIONES_OBLIGATORIAS.forEach(function (cotizacion) {
|
|
74
90
|
var montoCotizacion = calcularSueldoImponible(ingresos) * cotizacion.percent / 100;
|
|
75
91
|
|
|
76
92
|
if (cotizacion.variable && cotizacionParcial) {
|
|
77
|
-
montoCotizacion = montoCotizacion *
|
|
93
|
+
montoCotizacion = montoCotizacion * config.COBERTURA_PARCIAL;
|
|
78
94
|
}
|
|
79
95
|
|
|
80
96
|
totalCotizacionesObligatorias += montoCotizacion;
|
|
@@ -83,37 +99,26 @@ function calcularCotizacionesObligatorias(ingresos) {
|
|
|
83
99
|
}
|
|
84
100
|
|
|
85
101
|
function calcularRetencion(sueldoAnual) {
|
|
86
|
-
return sueldoAnual *
|
|
102
|
+
return sueldoAnual * config.RETENCION;
|
|
87
103
|
}
|
|
88
104
|
|
|
89
|
-
function
|
|
90
|
-
return {
|
|
91
|
-
factor: factor,
|
|
92
|
-
montoMaximo: montoMaximo,
|
|
93
|
-
descuento: descuento
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
var TRAMOS_IMPOSITIVOS = [construirTramoImpositivo(0, 13.5 * UTA, 0), construirTramoImpositivo(0.04, 30 * UTA, 0.54 * UTA), construirTramoImpositivo(0.08, 50 * UTA, 1.74 * UTA), construirTramoImpositivo(0.135, 70 * UTA, 4.49 * UTA), construirTramoImpositivo(0.23, 90 * UTA, 11.14 * UTA), construirTramoImpositivo(0.304, 120 * UTA, 17.8 * UTA), construirTramoImpositivo(0.35, 150 * UTA, 23.92 * UTA), construirTramoImpositivo(0.4, Number.MAX_VALUE, 30.67 * UTA)];
|
|
98
|
-
exports.TRAMOS_IMPOSITIVOS = TRAMOS_IMPOSITIVOS;
|
|
99
|
-
|
|
100
|
-
function obtenerTramoImpositivo(sueldoTributable) {
|
|
101
|
-
return TRAMOS_IMPOSITIVOS.find(function (_ref) {
|
|
105
|
+
function buscarTramoImpositivo(sueldoTributable) {
|
|
106
|
+
return config.TRAMOS_IMPOSITIVOS.find(function (_ref) {
|
|
102
107
|
var montoMaximo = _ref.montoMaximo;
|
|
103
108
|
return sueldoTributable <= montoMaximo;
|
|
104
109
|
});
|
|
105
110
|
}
|
|
106
111
|
|
|
107
112
|
function calcularImpuestos(sueldoTributable) {
|
|
108
|
-
var
|
|
109
|
-
factor =
|
|
110
|
-
descuento =
|
|
113
|
+
var _buscarTramoImpositiv = buscarTramoImpositivo(sueldoTributable),
|
|
114
|
+
factor = _buscarTramoImpositiv.factor,
|
|
115
|
+
descuento = _buscarTramoImpositiv.descuento;
|
|
111
116
|
|
|
112
117
|
return factor * sueldoTributable - descuento;
|
|
113
118
|
}
|
|
114
119
|
|
|
115
|
-
function calcularDeuda(
|
|
116
|
-
return impuestos - retencion +
|
|
120
|
+
function calcularDeuda(montoCotizacionesObligatorias, impuestos, retencion) {
|
|
121
|
+
return impuestos - retencion + montoCotizacionesObligatorias;
|
|
117
122
|
}
|
|
118
123
|
|
|
119
124
|
function calcular(sueldoMensual) {
|
|
@@ -127,6 +132,7 @@ function calcular(sueldoMensual) {
|
|
|
127
132
|
var deuda = calcularDeuda(montoCotizacionesObligatorias, impuestos, retencion);
|
|
128
133
|
var deudaModalidadParcial = calcularDeuda(cotizacionesParciales, impuestos, retencion);
|
|
129
134
|
return {
|
|
135
|
+
operacionRenta: config.OPERACION_RENTA,
|
|
130
136
|
sueldoAnual: sueldoAnual,
|
|
131
137
|
gastos: gastos,
|
|
132
138
|
sueldoTributable: sueldoTributable,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.obtenerTramos = obtenerTramos;
|
|
7
|
+
|
|
8
|
+
var _config = require("./config");
|
|
9
|
+
|
|
10
|
+
function construirTramoImpositivo(factor, montoMaximo, descuento) {
|
|
11
|
+
return {
|
|
12
|
+
factor: factor,
|
|
13
|
+
montoMaximo: montoMaximo,
|
|
14
|
+
descuento: descuento
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function obtenerTramos(year) {
|
|
19
|
+
var uta = _config.UTA[year - 1];
|
|
20
|
+
return [construirTramoImpositivo(0, 13.5 * uta, 0), construirTramoImpositivo(0.04, 30 * uta, 0.54 * uta), construirTramoImpositivo(0.08, 50 * uta, 1.74 * uta), construirTramoImpositivo(0.135, 70 * uta, 4.49 * uta), construirTramoImpositivo(0.23, 90 * uta, 11.14 * uta), construirTramoImpositivo(0.304, 120 * uta, 17.8 * uta), construirTramoImpositivo(0.35, 150 * uta, 23.92 * uta), construirTramoImpositivo(0.4, Number.MAX_VALUE, 30.67 * uta)];
|
|
21
|
+
}
|