tax-cl 1.0.4 → 1.1.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/lib/config.js +39 -16
- package/lib/index.js +64 -28
- package/package.json +1 -1
package/lib/config.js
CHANGED
|
@@ -4,13 +4,27 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getConfig = getConfig;
|
|
7
|
+
|
|
8
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
9
|
+
|
|
10
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
11
|
+
|
|
12
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
13
|
+
|
|
14
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
15
|
+
|
|
16
|
+
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
17
|
+
|
|
18
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
19
|
+
|
|
7
20
|
// Valor UTA en diciembre en https://www.sii.cl/valores_y_fechas/index_valores_y_fechas.html
|
|
8
21
|
var UTA = {
|
|
9
22
|
2018: 580236,
|
|
10
23
|
2019: 595476,
|
|
11
24
|
2020: 612348,
|
|
12
25
|
2021: 650052,
|
|
13
|
-
2022:
|
|
26
|
+
2022: 733884,
|
|
27
|
+
2023: 741228 // 2023-01
|
|
14
28
|
|
|
15
29
|
}; // Valor UF al 31 de diciembre en https://www.sii.cl/valores_y_fechas/index_valores_y_fechas.html
|
|
16
30
|
|
|
@@ -19,7 +33,8 @@ var UF = {
|
|
|
19
33
|
2019: 28309.94,
|
|
20
34
|
2020: 29070.33,
|
|
21
35
|
2021: 30991.74,
|
|
22
|
-
2022:
|
|
36
|
+
2022: 35110.98,
|
|
37
|
+
2023: 35287.50 // 2023-01-31
|
|
23
38
|
|
|
24
39
|
};
|
|
25
40
|
var RETENCION = {
|
|
@@ -57,37 +72,45 @@ var TOPE_IMPONIBLE_MENSUAL = {
|
|
|
57
72
|
// https://www.spensiones.cl/portal/institucional/594/w3-article-13843.html
|
|
58
73
|
2021: 81.6,
|
|
59
74
|
// https://www.spensiones.cl/portal/institucional/594/w3-article-14366.html
|
|
60
|
-
2022: 81.6
|
|
75
|
+
2022: 81.6,
|
|
76
|
+
// https://www.spensiones.cl/portal/institucional/594/w3-article-15178.html
|
|
77
|
+
2023: 81.6 // https://www.spensiones.cl/portal/institucional/594/w3-article-15486.html
|
|
61
78
|
|
|
62
79
|
};
|
|
63
80
|
|
|
64
81
|
function obtenerTramosImpositivos(uta) {
|
|
65
|
-
var
|
|
82
|
+
var maxValue = Number.MAX_VALUE;
|
|
83
|
+
return [[13.5 * uta, 0, 0], [30 * uta, 0.04, 0.54 * uta], [50 * uta, 0.08, 1.74 * uta], [70 * uta, 0.135, 4.49 * uta], [90 * uta, 0.23, 11.14 * uta], [120 * uta, 0.304, 17.8 * uta], [310 * uta, 0.35, 23.32 * uta], [maxValue, 0.4, 38.82 * uta]].map(function (_ref) {
|
|
84
|
+
var _ref2 = _slicedToArray(_ref, 3),
|
|
85
|
+
montoMaximo = _ref2[0],
|
|
86
|
+
factor = _ref2[1],
|
|
87
|
+
descuento = _ref2[2];
|
|
88
|
+
|
|
66
89
|
return {
|
|
67
90
|
factor: factor,
|
|
68
91
|
montoMaximo: montoMaximo,
|
|
69
92
|
descuento: descuento
|
|
70
93
|
};
|
|
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)];
|
|
94
|
+
});
|
|
74
95
|
}
|
|
75
96
|
|
|
76
97
|
function getConfig(operacionRenta) {
|
|
77
|
-
var
|
|
98
|
+
var commercialYear = operacionRenta - 1;
|
|
78
99
|
|
|
79
|
-
if (!TOPE_IMPONIBLE_MENSUAL[
|
|
80
|
-
var validos = Object.keys(TOPE_IMPONIBLE_MENSUAL).
|
|
100
|
+
if (!TOPE_IMPONIBLE_MENSUAL[commercialYear]) {
|
|
101
|
+
var validos = Object.keys(TOPE_IMPONIBLE_MENSUAL).map(function (year) {
|
|
102
|
+
return parseInt(year) + 1;
|
|
103
|
+
}).join(', ');
|
|
81
104
|
throw new Error("El a\xF1o ingresado es incorrecto. Los valores v\xE1lidos son: ".concat(validos));
|
|
82
105
|
}
|
|
83
106
|
|
|
84
107
|
return {
|
|
85
108
|
OPERACION_RENTA: operacionRenta,
|
|
86
|
-
UTA: UTA[
|
|
87
|
-
UF: UF[
|
|
88
|
-
RETENCION: RETENCION[
|
|
89
|
-
COBERTURA_PARCIAL: COBERTURA_PARCIAL[
|
|
90
|
-
TOPE_IMPONIBLE_MENSUAL: TOPE_IMPONIBLE_MENSUAL[
|
|
91
|
-
TRAMOS_IMPOSITIVOS: obtenerTramosImpositivos(UTA[
|
|
109
|
+
UTA: UTA[commercialYear],
|
|
110
|
+
UF: UF[commercialYear],
|
|
111
|
+
RETENCION: RETENCION[commercialYear] / 100,
|
|
112
|
+
COBERTURA_PARCIAL: COBERTURA_PARCIAL[commercialYear] / 100,
|
|
113
|
+
TOPE_IMPONIBLE_MENSUAL: TOPE_IMPONIBLE_MENSUAL[commercialYear],
|
|
114
|
+
TRAMOS_IMPOSITIVOS: obtenerTramosImpositivos(UTA[commercialYear])
|
|
92
115
|
};
|
|
93
116
|
}
|
package/lib/index.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.configurarDeclaracion = configurarDeclaracion;
|
|
|
7
7
|
exports.obtenerConfiguracion = obtenerConfiguracion;
|
|
8
8
|
exports.calcularGastos = calcularGastos;
|
|
9
9
|
exports.calcularSueldoImponible = calcularSueldoImponible;
|
|
10
|
+
exports.simularCotizaciones = simularCotizaciones;
|
|
10
11
|
exports.calcularCotizacionesObligatorias = calcularCotizacionesObligatorias;
|
|
11
12
|
exports.calcularRetencion = calcularRetencion;
|
|
12
13
|
exports.buscarTramoImpositivo = buscarTramoImpositivo;
|
|
@@ -23,11 +24,11 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
23
24
|
|
|
24
25
|
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
|
|
|
26
|
-
var OPERACION_RENTA_ACTUAL =
|
|
27
|
+
var OPERACION_RENTA_ACTUAL = 2023;
|
|
27
28
|
var config = (0, _config.getConfig)(OPERACION_RENTA_ACTUAL);
|
|
28
29
|
/**
|
|
29
30
|
* Configura el año de la operación renta para los cálculos.
|
|
30
|
-
* @param {Number}
|
|
31
|
+
* @param year {Number}, año de la operación renta
|
|
31
32
|
*/
|
|
32
33
|
|
|
33
34
|
function configurarDeclaracion(year) {
|
|
@@ -45,23 +46,25 @@ function min(a, b) {
|
|
|
45
46
|
return a > b ? b : a;
|
|
46
47
|
}
|
|
47
48
|
|
|
48
|
-
function calcularGastos(
|
|
49
|
-
var gastos =
|
|
49
|
+
function calcularGastos(rentaAnual) {
|
|
50
|
+
var gastos = rentaAnual * 0.3;
|
|
50
51
|
var tope = 15 * config.UTA;
|
|
51
52
|
return min(gastos, tope);
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
var COTIZACIONES_OBLIGATORIAS = [{
|
|
55
|
-
name: "Seguro de invalidez y sobrevivencia",
|
|
56
|
-
percent: 1.
|
|
56
|
+
name: "Seguro de invalidez y sobrevivencia (SIS)",
|
|
57
|
+
percent: 1.54,
|
|
58
|
+
// https://www.spensiones.cl/portal/institucional/594/w3-propertyvalue-9917.html#recuadros_articulo_4130_0
|
|
57
59
|
variable: false
|
|
58
60
|
}, {
|
|
59
|
-
name: "Seguro de la ley de accidentes del trabajo y enfermedades profesionales",
|
|
60
|
-
percent: 0.
|
|
61
|
+
name: "Seguro de la ley de accidentes del trabajo y enfermedades profesionales (ATEP)",
|
|
62
|
+
percent: 0.90,
|
|
61
63
|
variable: false
|
|
62
64
|
}, {
|
|
63
|
-
name: "Seguro de acompañamiento niños y niñas",
|
|
64
|
-
percent: 0.
|
|
65
|
+
name: "Seguro de acompañamiento niños y niñas (Ley SANNA)",
|
|
66
|
+
percent: 0.03,
|
|
67
|
+
// https://www.chileatiende.gob.cl/fichas/53276-seguro-para-el-acompanamiento-de-ninos-y-ninas-afectados-por-una-condicion-grave-de-salud-ley-sanna
|
|
65
68
|
variable: false
|
|
66
69
|
}, {
|
|
67
70
|
name: "Salud",
|
|
@@ -69,12 +72,8 @@ var COTIZACIONES_OBLIGATORIAS = [{
|
|
|
69
72
|
variable: true
|
|
70
73
|
}, {
|
|
71
74
|
name: "AFP",
|
|
72
|
-
percent: 10,
|
|
75
|
+
percent: 10.58,
|
|
73
76
|
variable: true
|
|
74
|
-
}, {
|
|
75
|
-
name: "Comisión AFP",
|
|
76
|
-
percent: 0.77,
|
|
77
|
-
variable: false
|
|
78
77
|
}];
|
|
79
78
|
exports.COTIZACIONES_OBLIGATORIAS = COTIZACIONES_OBLIGATORIAS;
|
|
80
79
|
|
|
@@ -83,19 +82,51 @@ function calcularSueldoImponible(sueldoAnual) {
|
|
|
83
82
|
return min(0.8 * sueldoAnual, topeAnual);
|
|
84
83
|
}
|
|
85
84
|
|
|
86
|
-
function
|
|
85
|
+
function simularCotizaciones(ingresos) {
|
|
87
86
|
var cotizacionParcial = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
88
|
-
var
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
87
|
+
var sueldoImponible = calcularSueldoImponible(ingresos);
|
|
88
|
+
|
|
89
|
+
if (cotizacionParcial) {
|
|
90
|
+
var sueldoImponibleParcial = sueldoImponible * config.COBERTURA_PARCIAL;
|
|
91
|
+
return COTIZACIONES_OBLIGATORIAS.map(function (cotizacion) {
|
|
92
|
+
var monto = (cotizacion.variable ? sueldoImponibleParcial : sueldoImponible) * cotizacion.percent / 100;
|
|
93
|
+
return {
|
|
94
|
+
name: cotizacion.name,
|
|
95
|
+
percent: 100 * monto / sueldoImponible,
|
|
96
|
+
value: monto
|
|
97
|
+
};
|
|
98
|
+
});
|
|
99
|
+
} else {
|
|
100
|
+
var remanente = calcularRetencion(sueldoImponible / 0.8);
|
|
101
|
+
return COTIZACIONES_OBLIGATORIAS.map(function (cotizacion) {
|
|
102
|
+
if (cotizacion.name === 'AFP') {
|
|
103
|
+
var monto = min(remanente, sueldoImponible * cotizacion.percent / 100);
|
|
104
|
+
return {
|
|
105
|
+
name: cotizacion.name,
|
|
106
|
+
percent: 100 * monto / sueldoImponible,
|
|
107
|
+
value: monto
|
|
108
|
+
};
|
|
109
|
+
} else {
|
|
110
|
+
var percent = cotizacion.percent;
|
|
111
|
+
|
|
112
|
+
var _monto = sueldoImponible * cotizacion.percent / 100;
|
|
113
|
+
|
|
114
|
+
remanente -= _monto;
|
|
115
|
+
return {
|
|
116
|
+
name: cotizacion.name,
|
|
117
|
+
percent: percent,
|
|
118
|
+
value: _monto
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
95
124
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
return
|
|
125
|
+
function calcularCotizacionesObligatorias(ingresos) {
|
|
126
|
+
var cotizacionParcial = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
127
|
+
return simularCotizaciones(ingresos, cotizacionParcial).reduce(function (total, cotizacion) {
|
|
128
|
+
return total + cotizacion.value;
|
|
129
|
+
}, 0);
|
|
99
130
|
}
|
|
100
131
|
|
|
101
132
|
function calcularRetencion(sueldoAnual) {
|
|
@@ -126,17 +157,22 @@ function calcular(sueldoMensual) {
|
|
|
126
157
|
var gastos = calcularGastos(sueldoAnual);
|
|
127
158
|
var sueldoTributable = sueldoAnual - gastos;
|
|
128
159
|
var montoCotizacionesObligatorias = calcularCotizacionesObligatorias(sueldoAnual);
|
|
129
|
-
var
|
|
160
|
+
var montoCotizacionParcial = calcularCotizacionesObligatorias(sueldoAnual, true);
|
|
130
161
|
var retencion = calcularRetencion(sueldoAnual);
|
|
131
162
|
var impuestos = calcularImpuestos(sueldoTributable);
|
|
132
163
|
var deuda = calcularDeuda(montoCotizacionesObligatorias, impuestos, retencion);
|
|
133
|
-
var deudaModalidadParcial = calcularDeuda(
|
|
164
|
+
var deudaModalidadParcial = calcularDeuda(montoCotizacionParcial, impuestos, retencion);
|
|
134
165
|
return {
|
|
135
166
|
operacionRenta: config.OPERACION_RENTA,
|
|
136
167
|
sueldoAnual: sueldoAnual,
|
|
137
168
|
gastos: gastos,
|
|
138
169
|
sueldoTributable: sueldoTributable,
|
|
139
170
|
montoCotizacionesObligatorias: montoCotizacionesObligatorias,
|
|
171
|
+
montoCotizacionParcial: montoCotizacionParcial,
|
|
172
|
+
cotizaciones: {
|
|
173
|
+
parcial: simularCotizaciones(sueldoAnual, true),
|
|
174
|
+
total: simularCotizaciones(sueldoAnual)
|
|
175
|
+
},
|
|
140
176
|
retencion: retencion,
|
|
141
177
|
impuestos: impuestos,
|
|
142
178
|
deuda: deuda,
|