tax-cl 1.3.1 → 1.4.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
@@ -83,14 +83,14 @@ Retorna un objeto con las siguientes propiedades:
83
83
  * `impuestos`: *(number)*. Es el total de impuestos a pagar según el tramo impositivo.
84
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
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 (**2023** por defecto).
86
+ * `operacionRenta`: *(number)*. Es el año de la declaración (**2025** por defecto).
87
87
 
88
88
  ### `configurarDeclaracion(number: year) : void`
89
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 **2024**.
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 **2025**.
91
91
 
92
92
  #### Arguments
93
93
 
94
94
  Recibe el siguiente argumento:
95
95
 
96
- * `year`: *(number)*, año de la operación renta para la realización de los cálculos. Los valores válidos son desde el 2018 hasta el 2024.
96
+ * `year`: *(number)*, año de la operación renta para la realización de los cálculos. Los valores válidos son desde el 2018 hasta el 2025.
package/lib/index.js CHANGED
@@ -1,197 +1,308 @@
1
- "use strict";
2
1
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.configurarDeclaracion = configurarDeclaracion;
7
- exports.obtenerConfiguracion = obtenerConfiguracion;
8
- exports.calcularGastos = calcularGastos;
9
- exports.calcularSueldoImponible = calcularSueldoImponible;
10
- exports.simularCotizaciones = simularCotizaciones;
11
- exports.calcularCotizacionesObligatorias = calcularCotizacionesObligatorias;
12
- exports.calcularRetencion = calcularRetencion;
13
- exports.buscarTramoImpositivo = buscarTramoImpositivo;
14
- exports.calcularImpuestos = calcularImpuestos;
15
- exports.calcularDeuda = calcularDeuda;
16
- exports.calcular = calcular;
17
-
18
- var _config = require("./config");
19
-
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; }
21
-
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; }
23
-
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; }
2
+ function $parcel$export(e, n, v, s) {
3
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
4
+ }
25
5
 
26
- var OPERACION_RENTA_ACTUAL = 2024;
27
- var config = (0, _config.getConfig)(OPERACION_RENTA_ACTUAL);
6
+ $parcel$export(module.exports, "configurarDeclaracion", () => $4fa36e821943b400$export$37b8b24baccc291f);
7
+ $parcel$export(module.exports, "obtenerConfiguracion", () => $4fa36e821943b400$export$c4d19254e8ccfc93);
8
+ $parcel$export(module.exports, "calcularGastos", () => $4fa36e821943b400$export$f184333c5bef6790);
9
+ $parcel$export(module.exports, "calcularSueldoImponible", () => $4fa36e821943b400$export$bb9b6e0b04e913f8);
10
+ $parcel$export(module.exports, "simularCotizaciones", () => $4fa36e821943b400$export$d324ef4aacd7699a);
11
+ $parcel$export(module.exports, "calcularRetencion", () => $4fa36e821943b400$export$a1907acc7a00487b);
12
+ $parcel$export(module.exports, "calcularCotizacionesObligatorias", () => $4fa36e821943b400$export$b7db102d267c42b8);
13
+ $parcel$export(module.exports, "buscarTramoImpositivo", () => $4fa36e821943b400$export$a839f77c1a88ebba);
14
+ $parcel$export(module.exports, "calcularImpuestos", () => $4fa36e821943b400$export$a42fe1a795d9ef3e);
15
+ $parcel$export(module.exports, "calcularDeuda", () => $4fa36e821943b400$export$60ff41ecf927a3f6);
16
+ $parcel$export(module.exports, "calcular", () => $4fa36e821943b400$export$a7a1c40d1e098fe0);
17
+ // Valor UTA en diciembre en https://www.sii.cl/valores_y_fechas/index_valores_y_fechas.html
18
+ const $100592030dab1e52$var$UTA = {
19
+ 2018: 580236,
20
+ 2019: 595476,
21
+ 2020: 612348,
22
+ 2021: 650052,
23
+ 2022: 733884,
24
+ 2023: 770592,
25
+ 2024: 807528,
26
+ 2025: 807528
27
+ };
28
+ // Valor UF al 31 de diciembre en https://www.sii.cl/valores_y_fechas/index_valores_y_fechas.html
29
+ const $100592030dab1e52$var$UF = {
30
+ 2018: 27565.79,
31
+ 2019: 28309.94,
32
+ 2020: 29070.33,
33
+ 2021: 30991.74,
34
+ 2022: 35110.98,
35
+ 2023: 36789.36,
36
+ 2024: 38416.69,
37
+ 2025: 38384.41
38
+ };
39
+ const $100592030dab1e52$var$RETENCION = {
40
+ 2019: 10,
41
+ 2020: 10.75,
42
+ 2021: 11.5,
43
+ 2022: 12.25,
44
+ 2023: 13,
45
+ 2024: 13.75,
46
+ 2025: 14.5,
47
+ 2026: 15.25,
48
+ 2027: 16,
49
+ 2028: 17
50
+ };
51
+ // Artículo Segundo de la Ley 21.133 (https://www.bcn.cl/leychile/navegar?idNorma=1128420)
52
+ const $100592030dab1e52$var$COBERTURA_PARCIAL = {
53
+ 2018: 5,
54
+ 2019: 17,
55
+ 2020: 27,
56
+ 2021: 37,
57
+ 2022: 47,
58
+ 2023: 57,
59
+ 2024: 70,
60
+ 2025: 80,
61
+ 2026: 90,
62
+ 2027: 100,
63
+ 2028: 100
64
+ };
65
+ const $100592030dab1e52$var$TOPE_IMPONIBLE_MENSUAL = {
66
+ 2018: 78.3,
67
+ 2019: 79.2,
68
+ 2020: 80.2,
69
+ 2021: 81.6,
70
+ 2022: 81.6,
71
+ 2023: 81.6,
72
+ 2024: 84.3,
73
+ 2025: 87.8
74
+ };
28
75
  /**
29
- * Configura el año de la operación renta para los cálculos.
30
- * @param year {Number}, 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
- });
76
+ * Calculates and returns tax brackets based on the provided UTA value.
77
+ *
78
+ * @param {Number} uta - The UTA value for which tax brackets are to be calculated.
79
+ * @returns {Array.<{factor: Number, montoMaximo: Number, descuento: Number}>}
80
+ * An array of objects, each containing:
81
+ * - `factor`: The tax rate for the bracket.
82
+ * - `montoMaximo`: The maximum amount for the bracket.
83
+ * - `descuento`: The discount for the bracket.
84
+ *
85
+ * @example
86
+ * const tramos = obtenerTramosImpositivos(1.5);
87
+ * console.log(tramos); // Output will be an array of tax bracket objects.
88
+ */ function $100592030dab1e52$var$obtenerTramosImpositivos(uta) {
89
+ const maxValue = Number.MAX_VALUE;
90
+ return [
91
+ [
92
+ 13.5 * uta,
93
+ 0,
94
+ 0
95
+ ],
96
+ [
97
+ 30 * uta,
98
+ 0.04,
99
+ 0.54 * uta
100
+ ],
101
+ [
102
+ 50 * uta,
103
+ 0.08,
104
+ 1.74 * uta
105
+ ],
106
+ [
107
+ 70 * uta,
108
+ 0.135,
109
+ 4.49 * uta
110
+ ],
111
+ [
112
+ 90 * uta,
113
+ 0.23,
114
+ 11.14 * uta
115
+ ],
116
+ [
117
+ 120 * uta,
118
+ 0.304,
119
+ 17.8 * uta
120
+ ],
121
+ [
122
+ 310 * uta,
123
+ 0.35,
124
+ 23.32 * uta
125
+ ],
126
+ [
127
+ maxValue,
128
+ 0.4,
129
+ 38.82 * uta
130
+ ]
131
+ ].map(([montoMaximo, factor, descuento])=>({
132
+ factor: factor,
133
+ montoMaximo: montoMaximo,
134
+ descuento: descuento
135
+ }));
38
136
  }
39
-
40
- function obtenerConfiguracion() {
41
- return _objectSpread({}, config);
137
+ function $100592030dab1e52$export$44487a86467333c3(operacionRenta) {
138
+ const commercialYear = operacionRenta - 1;
139
+ if (!$100592030dab1e52$var$TOPE_IMPONIBLE_MENSUAL[commercialYear]) {
140
+ const validos = Object.keys($100592030dab1e52$var$TOPE_IMPONIBLE_MENSUAL).map((year)=>parseInt(year) + 1).join(", ");
141
+ throw new Error(`El a\xf1o ingresado es incorrecto. Los valores v\xe1lidos son: ${validos}`);
142
+ }
143
+ return {
144
+ OPERACION_RENTA: operacionRenta,
145
+ UTA: $100592030dab1e52$var$UTA[commercialYear],
146
+ UF: $100592030dab1e52$var$UF[commercialYear],
147
+ RETENCION: $100592030dab1e52$var$RETENCION[commercialYear] / 100,
148
+ COBERTURA_PARCIAL: $100592030dab1e52$var$COBERTURA_PARCIAL[commercialYear] / 100,
149
+ TOPE_IMPONIBLE_MENSUAL: $100592030dab1e52$var$TOPE_IMPONIBLE_MENSUAL[commercialYear],
150
+ TRAMOS_IMPOSITIVOS: $100592030dab1e52$var$obtenerTramosImpositivos($100592030dab1e52$var$UTA[commercialYear])
151
+ };
42
152
  }
43
153
 
44
- function min(a, b) {
45
- return a > b ? b : a;
46
- }
47
154
 
48
- function calcularGastos(rentaAnual) {
49
- var gastos = rentaAnual * 0.3;
50
- var tope = 15 * config.UTA;
51
- return min(gastos, tope);
155
+ const $4fa36e821943b400$var$OPERACION_RENTA_ACTUAL = 2025;
156
+ const $4fa36e821943b400$var$config = (0, $100592030dab1e52$export$44487a86467333c3)($4fa36e821943b400$var$OPERACION_RENTA_ACTUAL);
157
+ function $4fa36e821943b400$export$37b8b24baccc291f(year) {
158
+ const newConfig = (0, $100592030dab1e52$export$44487a86467333c3)(year);
159
+ Object.keys(newConfig).forEach((key)=>{
160
+ $4fa36e821943b400$var$config[key] = newConfig[key];
161
+ });
52
162
  }
53
-
54
- var COTIZACIONES_OBLIGATORIAS = [{
55
- name: "Seguro de invalidez y sobrevivencia (SIS)",
56
- percent: function percent() {
57
- // Esto cambia por año, no tengo seguridad de los años anteriores al 2022
58
- // Aunque el uso de esta librería es más actual que histórico (importa año comercial presente y anterior)
59
- // No me gusta que esto esté aquí, sin embargo, como hotfix está OK
60
- // https://www.spensiones.cl/portal/institucional/594/w3-propertyvalue-9917.html#recuadros_articulo_4130_0
61
- var SIS = {
62
- 2018: 1.99,
63
- 2019: 1.99,
64
- 2020: 1.99,
65
- 2021: 1.85,
66
- 2022: 1.54,
67
- 2023: 1.47,
68
- 2024: 1.49
163
+ function $4fa36e821943b400$export$c4d19254e8ccfc93() {
164
+ return {
165
+ ...$4fa36e821943b400$var$config
69
166
  };
70
- return SIS[config.OPERACION_RENTA - 1] || SIS[2023];
71
- },
72
- variable: false
73
- }, {
74
- name: "Seguro de la ley de accidentes del trabajo y enfermedades profesionales (ATEP)",
75
- percent: 0.90,
76
- variable: false
77
- }, {
78
- name: "Seguro de acompañamiento niños y niñas (Ley SANNA)",
79
- percent: 0.03,
80
- // https://www.chileatiende.gob.cl/fichas/53276-seguro-para-el-acompanamiento-de-ninos-y-ninas-afectados-por-una-condicion-grave-de-salud-ley-sanna
81
- variable: false
82
- }, {
83
- name: "Salud",
84
- percent: 7,
85
- variable: true
86
- }, {
87
- name: "AFP",
88
- percent: 10.58,
89
- variable: true
90
- }];
91
-
92
- function getContributionPercentage(contribution) {
93
- return typeof contribution.percent === 'function' ? contribution.percent() : contribution.percent;
94
167
  }
95
-
96
- function calcularSueldoImponible(sueldoAnual) {
97
- var topeAnual = config.TOPE_IMPONIBLE_MENSUAL * config.UF * 12;
98
- return min(0.8 * sueldoAnual, topeAnual);
168
+ function $4fa36e821943b400$var$min(a, b) {
169
+ return a > b ? b : a;
99
170
  }
100
-
101
- function simularCotizaciones(ingresos) {
102
- var cotizacionParcial = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
103
- var sueldoImponible = calcularSueldoImponible(ingresos);
104
-
105
- if (cotizacionParcial) {
106
- var sueldoImponibleParcial = sueldoImponible * config.COBERTURA_PARCIAL;
107
- return COTIZACIONES_OBLIGATORIAS.map(function (cotizacion) {
108
- var monto = (cotizacion.variable ? sueldoImponibleParcial : sueldoImponible) * getContributionPercentage(cotizacion) / 100;
109
- return {
110
- name: cotizacion.name,
111
- percent: 100 * monto / sueldoImponible,
112
- value: monto
113
- };
114
- });
115
- } else {
116
- var remanente = calcularRetencion(sueldoImponible / 0.8);
117
- return COTIZACIONES_OBLIGATORIAS.map(function (cotizacion) {
118
- if (cotizacion.name === 'AFP') {
119
- var monto = min(remanente, sueldoImponible * getContributionPercentage(cotizacion) / 100);
120
- return {
121
- name: cotizacion.name,
122
- percent: 100 * monto / sueldoImponible,
123
- value: monto
124
- };
125
- } else {
126
- var percent = getContributionPercentage(cotizacion);
127
-
128
- var _monto = sueldoImponible * percent / 100;
129
-
130
- remanente -= _monto;
131
- return {
132
- name: cotizacion.name,
133
- percent: percent,
134
- value: _monto
135
- };
136
- }
137
- });
138
- }
171
+ function $4fa36e821943b400$export$f184333c5bef6790(rentaAnual) {
172
+ const gastos = rentaAnual * 0.3;
173
+ const tope = 15 * $4fa36e821943b400$var$config.UTA;
174
+ return $4fa36e821943b400$var$min(gastos, tope);
139
175
  }
140
-
141
- function calcularCotizacionesObligatorias(ingresos) {
142
- var cotizacionParcial = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
143
- return simularCotizaciones(ingresos, cotizacionParcial).reduce(function (total, cotizacion) {
144
- return total + cotizacion.value;
145
- }, 0);
176
+ const $4fa36e821943b400$var$COTIZACIONES_OBLIGATORIAS = [
177
+ {
178
+ name: "Seguro de invalidez y sobrevivencia (SIS)",
179
+ percent: ()=>{
180
+ // Esto cambia por año, no tengo seguridad de los años anteriores al 2022
181
+ // Aunque el uso de esta librería es más actual que histórico (importa año comercial presente y anterior)
182
+ // No me gusta que esto esté aquí, sin embargo, como hotfix está OK
183
+ // https://www.spensiones.cl/portal/institucional/594/w3-propertyvalue-9917.html#recuadros_articulo_4130_0
184
+ const SIS = {
185
+ 2018: 1.99,
186
+ 2019: 1.99,
187
+ 2020: 1.99,
188
+ 2021: 1.85,
189
+ 2022: 1.54,
190
+ 2023: 1.47,
191
+ 2024: 1.49,
192
+ 2025: 1.5
193
+ };
194
+ return SIS[$4fa36e821943b400$var$config.OPERACION_RENTA - 1] || SIS[2023];
195
+ },
196
+ variable: false
197
+ },
198
+ {
199
+ name: "Seguro de la ley de accidentes del trabajo y enfermedades profesionales (ATEP)",
200
+ percent: 0.90,
201
+ variable: false
202
+ },
203
+ {
204
+ name: "Seguro de acompa\xf1amiento ni\xf1os y ni\xf1as (Ley SANNA)",
205
+ percent: 0.03,
206
+ variable: false
207
+ },
208
+ {
209
+ name: "Salud",
210
+ percent: 7,
211
+ variable: true
212
+ },
213
+ {
214
+ name: "AFP",
215
+ percent: 10.49,
216
+ variable: true
217
+ }
218
+ ];
219
+ function $4fa36e821943b400$var$getContributionPercentage(contribution) {
220
+ return typeof contribution.percent === "function" ? contribution.percent() : contribution.percent;
146
221
  }
147
-
148
- function calcularRetencion(sueldoAnual) {
149
- return sueldoAnual * config.RETENCION;
222
+ function $4fa36e821943b400$export$bb9b6e0b04e913f8(sueldoAnual) {
223
+ const topeAnual = $4fa36e821943b400$var$config.TOPE_IMPONIBLE_MENSUAL * $4fa36e821943b400$var$config.UF * 12;
224
+ return $4fa36e821943b400$var$min(0.8 * sueldoAnual, topeAnual);
150
225
  }
151
-
152
- function buscarTramoImpositivo(sueldoTributable) {
153
- return config.TRAMOS_IMPOSITIVOS.find(function (_ref) {
154
- var montoMaximo = _ref.montoMaximo;
155
- return sueldoTributable <= montoMaximo;
156
- });
226
+ function $4fa36e821943b400$export$d324ef4aacd7699a(ingresos, cotizacionParcial = false) {
227
+ const sueldoImponible = $4fa36e821943b400$export$bb9b6e0b04e913f8(ingresos);
228
+ if (cotizacionParcial) {
229
+ const sueldoImponibleParcial = sueldoImponible * $4fa36e821943b400$var$config.COBERTURA_PARCIAL;
230
+ return $4fa36e821943b400$var$COTIZACIONES_OBLIGATORIAS.map((cotizacion)=>{
231
+ const monto = (cotizacion.variable ? sueldoImponibleParcial : sueldoImponible) * $4fa36e821943b400$var$getContributionPercentage(cotizacion) / 100;
232
+ return {
233
+ name: cotizacion.name,
234
+ percent: 100 * monto / sueldoImponible,
235
+ value: monto
236
+ };
237
+ });
238
+ } else {
239
+ let remanente = $4fa36e821943b400$export$a1907acc7a00487b(sueldoImponible / 0.8);
240
+ return $4fa36e821943b400$var$COTIZACIONES_OBLIGATORIAS.map((cotizacion)=>{
241
+ if (cotizacion.name === "AFP") {
242
+ const monto = $4fa36e821943b400$var$min(remanente, sueldoImponible * $4fa36e821943b400$var$getContributionPercentage(cotizacion) / 100);
243
+ return {
244
+ name: cotizacion.name,
245
+ percent: 100 * monto / sueldoImponible,
246
+ value: monto
247
+ };
248
+ } else {
249
+ const percent = $4fa36e821943b400$var$getContributionPercentage(cotizacion);
250
+ const monto = sueldoImponible * percent / 100;
251
+ remanente -= monto;
252
+ return {
253
+ name: cotizacion.name,
254
+ percent: percent,
255
+ value: monto
256
+ };
257
+ }
258
+ });
259
+ }
157
260
  }
158
-
159
- function calcularImpuestos(sueldoTributable) {
160
- var _buscarTramoImpositiv = buscarTramoImpositivo(sueldoTributable),
161
- factor = _buscarTramoImpositiv.factor,
162
- descuento = _buscarTramoImpositiv.descuento;
163
-
164
- return factor * sueldoTributable - descuento;
261
+ function $4fa36e821943b400$export$b7db102d267c42b8(ingresos, cotizacionParcial = false) {
262
+ return $4fa36e821943b400$export$d324ef4aacd7699a(ingresos, cotizacionParcial).reduce((total, cotizacion)=>{
263
+ return total + cotizacion.value;
264
+ }, 0);
165
265
  }
166
-
167
- function calcularDeuda(montoCotizacionesObligatorias, impuestos, retencion) {
168
- return impuestos - retencion + montoCotizacionesObligatorias;
266
+ function $4fa36e821943b400$export$a1907acc7a00487b(sueldoAnual) {
267
+ return sueldoAnual * $4fa36e821943b400$var$config.RETENCION;
268
+ }
269
+ function $4fa36e821943b400$export$a839f77c1a88ebba(sueldoTributable) {
270
+ return $4fa36e821943b400$var$config.TRAMOS_IMPOSITIVOS.find(({ montoMaximo: montoMaximo })=>sueldoTributable <= montoMaximo);
271
+ }
272
+ function $4fa36e821943b400$export$a42fe1a795d9ef3e(sueldoTributable) {
273
+ const { factor: factor, descuento: descuento } = $4fa36e821943b400$export$a839f77c1a88ebba(sueldoTributable);
274
+ return factor * sueldoTributable - descuento;
275
+ }
276
+ function $4fa36e821943b400$export$60ff41ecf927a3f6(montoCotizacionesObligatorias, impuestos, retencion) {
277
+ return impuestos - retencion + montoCotizacionesObligatorias;
278
+ }
279
+ function $4fa36e821943b400$export$a7a1c40d1e098fe0(sueldoMensual) {
280
+ const sueldoAnual = 12 * sueldoMensual;
281
+ const gastos = $4fa36e821943b400$export$f184333c5bef6790(sueldoAnual);
282
+ const sueldoTributable = sueldoAnual - gastos;
283
+ const montoCotizacionesObligatorias = $4fa36e821943b400$export$b7db102d267c42b8(sueldoAnual);
284
+ const montoCotizacionParcial = $4fa36e821943b400$export$b7db102d267c42b8(sueldoAnual, true);
285
+ const retencion = $4fa36e821943b400$export$a1907acc7a00487b(sueldoAnual);
286
+ const impuestos = $4fa36e821943b400$export$a42fe1a795d9ef3e(sueldoTributable);
287
+ const deuda = $4fa36e821943b400$export$60ff41ecf927a3f6(montoCotizacionesObligatorias, impuestos, retencion);
288
+ const deudaModalidadParcial = $4fa36e821943b400$export$60ff41ecf927a3f6(montoCotizacionParcial, impuestos, retencion);
289
+ return {
290
+ operacionRenta: $4fa36e821943b400$var$config.OPERACION_RENTA,
291
+ sueldoAnual: sueldoAnual,
292
+ gastos: gastos,
293
+ sueldoTributable: sueldoTributable,
294
+ montoCotizacionesObligatorias: montoCotizacionesObligatorias,
295
+ montoCotizacionParcial: montoCotizacionParcial,
296
+ cotizaciones: {
297
+ parcial: $4fa36e821943b400$export$d324ef4aacd7699a(sueldoAnual, true),
298
+ total: $4fa36e821943b400$export$d324ef4aacd7699a(sueldoAnual)
299
+ },
300
+ retencion: retencion,
301
+ impuestos: impuestos,
302
+ deuda: deuda,
303
+ deudaModalidadParcial: deudaModalidadParcial
304
+ };
169
305
  }
170
306
 
171
- function calcular(sueldoMensual) {
172
- var sueldoAnual = 12 * sueldoMensual;
173
- var gastos = calcularGastos(sueldoAnual);
174
- var sueldoTributable = sueldoAnual - gastos;
175
- var montoCotizacionesObligatorias = calcularCotizacionesObligatorias(sueldoAnual);
176
- var montoCotizacionParcial = calcularCotizacionesObligatorias(sueldoAnual, true);
177
- var retencion = calcularRetencion(sueldoAnual);
178
- var impuestos = calcularImpuestos(sueldoTributable);
179
- var deuda = calcularDeuda(montoCotizacionesObligatorias, impuestos, retencion);
180
- var deudaModalidadParcial = calcularDeuda(montoCotizacionParcial, impuestos, retencion);
181
- return {
182
- operacionRenta: config.OPERACION_RENTA,
183
- sueldoAnual: sueldoAnual,
184
- gastos: gastos,
185
- sueldoTributable: sueldoTributable,
186
- montoCotizacionesObligatorias: montoCotizacionesObligatorias,
187
- montoCotizacionParcial: montoCotizacionParcial,
188
- cotizaciones: {
189
- parcial: simularCotizaciones(sueldoAnual, true),
190
- total: simularCotizaciones(sueldoAnual)
191
- },
192
- retencion: retencion,
193
- impuestos: impuestos,
194
- deuda: deuda,
195
- deudaModalidadParcial: deudaModalidadParcial
196
- };
197
- }
307
+
308
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;;;;;ACAA,4FAA4F;AAC5F,MAAM,4BAAM;IACV,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;AACR;AAEA,iGAAiG;AACjG,MAAM,2BAAK;IACT,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,M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;AAEO,SAAS,0CAAsB,gBAAgB;IACpD,OAAO,6BAAO,kBAAkB,CAAC,IAAI,CAAC,CAAC,eAAE,WAAW,EAAE,GAAK,oBAAoB;AACjF;AAEO,SAAS,0CAAkB,gBAAgB;IAChD,MAAM,UAAE,MAAM,aAAE,SAAS,EAAE,GAAG,0CAAsB;IACpD,OAAO,SAAS,mBAAmB;AACrC;AAEO,SAAS,0CAAc,6BAA6B,EAAE,SAAS,EAAE,SAAS;IAC/E,OAAO,YAAY,YAAY;AACjC;AAEO,SAAS,0CAAS,aAAa;IACpC,MAAM,cAAc,KAAK;IACzB,MAAM,SAAS,0CAAe;IAC9B,MAAM,mBAAmB,cAAc;IACvC,MAAM,gCAAgC,0CAAiC;IACvE,MAAM,yBAAyB,0CAAiC,aAAa;IAC7E,MAAM,YAAY,0CAAkB;IACpC,MAAM,YAAY,0CAAkB;IACpC,MAAM,QAAQ,0CAAc,+BAA+B,WAAW;IACtE,MAAM,wBAAwB,0CAAc,wBAAwB,WAAW;IAC/E,OAAO;QACL,gBAAgB,6BAAO,eAAe;qBACtC;gBACA;0BACA;uCACA;gCACA;QACA,cAAc;YACZ,SAAS,0CAAoB,aAAa;YAC1C,OAAO,0CAAoB;QAC7B;mBACA;mBACA;eACA;+BACA;IACF;AACF","sources":["src/index.js","src/config.js"],"sourcesContent":["import { getConfig } from './config';\n\nconst OPERACION_RENTA_ACTUAL = 2025;\n\nconst config = getConfig(OPERACION_RENTA_ACTUAL);\n\n/**\n * Configura el año de la operación renta para los cálculos.\n * @param year {Number}, año de la operación renta\n */\nexport function configurarDeclaracion(year) {\n const newConfig = getConfig(year);\n Object.keys(newConfig).forEach(key => {\n config[key] = newConfig[key];\n });\n}\n\nexport function obtenerConfiguracion() {\n return { ...config };\n}\n\nfunction min(a, b) {\n return a > b ? b : a;\n}\n\nexport function calcularGastos(rentaAnual) {\n const gastos = rentaAnual * 0.3;\n const tope = 15 * config.UTA;\n return min(gastos, tope);\n}\n\nconst COTIZACIONES_OBLIGATORIAS = [\n {\n name: \"Seguro de invalidez y sobrevivencia (SIS)\",\n percent: () => {\n // Esto cambia por año, no tengo seguridad de los años anteriores al 2022\n // Aunque el uso de esta librería es más actual que histórico (importa año comercial presente y anterior)\n // No me gusta que esto esté aquí, sin embargo, como hotfix está OK\n // https://www.spensiones.cl/portal/institucional/594/w3-propertyvalue-9917.html#recuadros_articulo_4130_0\n const SIS = {\n 2018: 1.99,\n 2019: 1.99,\n 2020: 1.99,\n 2021: 1.85,\n 2022: 1.54,\n 2023: 1.47,\n 2024: 1.49,\n 2025: 1.5,\n };\n return SIS[config.OPERACION_RENTA - 1] || SIS[2023];\n },\n variable: false,\n },\n {\n name:\n \"Seguro de la ley de accidentes del trabajo y enfermedades profesionales (ATEP)\",\n percent: 0.90,\n variable: false,\n },\n {\n name: \"Seguro de acompañamiento niños y niñas (Ley SANNA)\",\n percent: 0.03, // https://www.chileatiende.gob.cl/fichas/53276-seguro-para-el-acompanamiento-de-ninos-y-ninas-afectados-por-una-condicion-grave-de-salud-ley-sanna\n variable: false,\n },\n {\n name: \"Salud\",\n percent: 7,\n variable: true,\n },\n {\n name: \"AFP\",\n percent: 10.49,\n variable: true,\n },\n];\n\nfunction getContributionPercentage(contribution) {\n return typeof contribution.percent === 'function' ? contribution.percent() : contribution.percent\n}\n\nexport function calcularSueldoImponible(sueldoAnual) {\n const topeAnual = config.TOPE_IMPONIBLE_MENSUAL * config.UF * 12;\n return min(0.8 * sueldoAnual, topeAnual);\n}\n\nexport function simularCotizaciones(ingresos, cotizacionParcial = false) {\n const sueldoImponible = calcularSueldoImponible(ingresos)\n\n if (cotizacionParcial) {\n const sueldoImponibleParcial = sueldoImponible * config.COBERTURA_PARCIAL\n\n return COTIZACIONES_OBLIGATORIAS.map(cotizacion => {\n const monto = (cotizacion.variable ? sueldoImponibleParcial : sueldoImponible) * getContributionPercentage(cotizacion) / 100\n return {\n name: cotizacion.name,\n percent: 100 * monto / sueldoImponible,\n value: monto,\n }\n })\n } else {\n let remanente = calcularRetencion(sueldoImponible / 0.8)\n return COTIZACIONES_OBLIGATORIAS.map(cotizacion => {\n if (cotizacion.name === 'AFP') {\n const monto = min(remanente, sueldoImponible * getContributionPercentage(cotizacion) / 100)\n return {\n name: cotizacion.name,\n percent: 100 * monto / sueldoImponible,\n value: monto,\n }\n } else {\n const percent = getContributionPercentage(cotizacion)\n const monto = sueldoImponible * percent / 100\n remanente -= monto\n return {\n name: cotizacion.name,\n percent,\n value: monto,\n }\n }\n })\n }\n}\n\nexport function calcularCotizacionesObligatorias(ingresos, cotizacionParcial = false) {\n return simularCotizaciones(ingresos, cotizacionParcial).reduce((total, cotizacion) => {\n return total + cotizacion.value;\n }, 0)\n}\n\nexport function calcularRetencion(sueldoAnual) {\n return sueldoAnual * config.RETENCION;\n}\n\nexport function buscarTramoImpositivo(sueldoTributable) {\n return config.TRAMOS_IMPOSITIVOS.find(({ montoMaximo }) => sueldoTributable <= montoMaximo);\n}\n\nexport function calcularImpuestos(sueldoTributable) {\n const { factor, descuento } = buscarTramoImpositivo(sueldoTributable);\n return factor * sueldoTributable - descuento;\n}\n\nexport function calcularDeuda(montoCotizacionesObligatorias, impuestos, retencion) {\n return impuestos - retencion + montoCotizacionesObligatorias;\n}\n\nexport function calcular(sueldoMensual) {\n const sueldoAnual = 12 * sueldoMensual;\n const gastos = calcularGastos(sueldoAnual);\n const sueldoTributable = sueldoAnual - gastos;\n const montoCotizacionesObligatorias = calcularCotizacionesObligatorias(sueldoAnual);\n const montoCotizacionParcial = calcularCotizacionesObligatorias(sueldoAnual, true);\n const retencion = calcularRetencion(sueldoAnual);\n const impuestos = calcularImpuestos(sueldoTributable);\n const deuda = calcularDeuda(montoCotizacionesObligatorias, impuestos, retencion);\n const deudaModalidadParcial = calcularDeuda(montoCotizacionParcial, impuestos, retencion);\n return {\n operacionRenta: config.OPERACION_RENTA,\n sueldoAnual,\n gastos,\n sueldoTributable,\n montoCotizacionesObligatorias,\n montoCotizacionParcial,\n cotizaciones: {\n parcial: simularCotizaciones(sueldoAnual, true),\n total: simularCotizaciones(sueldoAnual),\n },\n retencion,\n impuestos,\n deuda,\n deudaModalidadParcial,\n };\n}\n","// Valor UTA en diciembre en https://www.sii.cl/valores_y_fechas/index_valores_y_fechas.html\nconst UTA = {\n 2018: 580236,\n 2019: 595476,\n 2020: 612348,\n 2021: 650052,\n 2022: 733884,\n 2023: 770592,\n 2024: 807528,\n 2025: 807528, // 2025-01\n};\n\n// Valor UF al 31 de diciembre en https://www.sii.cl/valores_y_fechas/index_valores_y_fechas.html\nconst UF = {\n 2018: 27565.79,\n 2019: 28309.94,\n 2020: 29070.33,\n 2021: 30991.74,\n 2022: 35110.98,\n 2023: 36789.36,\n 2024: 38416.69,\n 2025: 38384.41, // 2025-01-31\n};\n\nconst RETENCION = {\n 2019: 10,\n 2020: 10.75,\n 2021: 11.5,\n 2022: 12.25,\n 2023: 13,\n 2024: 13.75,\n 2025: 14.5,\n 2026: 15.25,\n 2027: 16,\n 2028: 17,\n};\n\n// Artículo Segundo de la Ley 21.133 (https://www.bcn.cl/leychile/navegar?idNorma=1128420)\nconst COBERTURA_PARCIAL = {\n 2018: 5,\n 2019: 17,\n 2020: 27,\n 2021: 37,\n 2022: 47,\n 2023: 57,\n 2024: 70,\n 2025: 80,\n 2026: 90,\n 2027: 100,\n 2028: 100,\n};\n\nconst TOPE_IMPONIBLE_MENSUAL = {\n 2018: 78.3, // https://www.spensiones.cl/portal/institucional/594/w3-article-12946.html\n 2019: 79.2, // https://www.spensiones.cl/portal/institucional/594/w3-article-13553.html\n 2020: 80.2, // https://www.spensiones.cl/portal/institucional/594/w3-article-13843.html\n 2021: 81.6, // https://www.spensiones.cl/portal/institucional/594/w3-article-14366.html\n 2022: 81.6, // https://www.spensiones.cl/portal/institucional/594/w3-article-15178.html\n 2023: 81.6, // https://www.spensiones.cl/portal/institucional/594/w3-article-15486.html\n 2024: 84.3, // https://www.spensiones.cl/portal/institucional/594/w3-article-15855.html\n 2025: 87.8, // https://www.spensiones.cl/portal/institucional/594/w3-article-16252.html\n};\n\n/**\n * Calculates and returns tax brackets based on the provided UTA value.\n *\n * @param {Number} uta - The UTA value for which tax brackets are to be calculated.\n * @returns {Array.<{factor: Number, montoMaximo: Number, descuento: Number}>}\n * An array of objects, each containing:\n * - `factor`: The tax rate for the bracket.\n * - `montoMaximo`: The maximum amount for the bracket.\n * - `descuento`: The discount for the bracket.\n * \n * @example\n * const tramos = obtenerTramosImpositivos(1.5);\n * console.log(tramos); // Output will be an array of tax bracket objects.\n */\nfunction obtenerTramosImpositivos(uta) {\n const maxValue = Number.MAX_VALUE;\n return [\n [13.5 * uta, 0, 0],\n [ 30 * uta, 0.04, 0.54 * uta],\n [ 50 * uta, 0.08, 1.74 * uta],\n [ 70 * uta, 0.135, 4.49 * uta],\n [ 90 * uta, 0.23, 11.14 * uta],\n [ 120 * uta, 0.304, 17.8 * uta],\n [ 310 * uta, 0.35, 23.32 * uta],\n [ maxValue, 0.4, 38.82 * uta],\n ].map(([montoMaximo, factor, descuento]) => ({\n factor,\n montoMaximo,\n descuento,\n }));\n}\n\n/**\n * Retrieves the configuration for a given \"operacionRenta\" year.\n *\n * @param {Number} operacionRenta - The year for which the operation configuration is required.\n * @throws {Error} Throws an error if the given year is not available.\n * @returns {{\n * OPERACION_RENTA: Number,\n * UTA: Number,\n * UF: Number,\n * RETENCION: Number,\n * COBERTURA_PARCIAL: Number,\n * TOPE_IMPONIBLE_MENSUAL: Number,\n * TRAMOS_IMPOSITIVOS: Array.<{factor: number, montoMaximo: number, descuento: number}>\n * }}\n * An object containing various configuration values:\n * - `OPERACION_RENTA`: The year for which the configuration is valid.\n * - `UTA`: The UTA value for the given year (December).\n * - `UF`: The UF value for the given year (last day of December).\n * - `RETENCION`: The retention percentage for the given year.\n * - `COBERTURA_PARCIAL`: The partial coverage percentage for the given year.\n * - `TOPE_IMPONIBLE_MENSUAL`: The monthly taxable income cap for the given year.\n * - `TRAMOS_IMPOSITIVOS`: An array of objects, each containing:\n * - `factor`: The tax rate for the bracket.\n * - `montoMaximo`: The maximum amount for the bracket.\n * - `descuento`: The discount for the bracket.\n * \n * @example\n * const config = getConfig(2022);\n * console.log(config.OPERACION_RENTA); // 2022\n*/\nexport function getConfig(operacionRenta) {\n const commercialYear = operacionRenta - 1;\n\n if (!TOPE_IMPONIBLE_MENSUAL[commercialYear]) {\n const validos = Object.keys(TOPE_IMPONIBLE_MENSUAL).map(year => parseInt(year) + 1).join(', ');\n throw new Error(`El año ingresado es incorrecto. Los valores válidos son: ${validos}`);\n }\n\n return {\n OPERACION_RENTA: operacionRenta,\n UTA: UTA[commercialYear],\n UF: UF[commercialYear],\n RETENCION: RETENCION[commercialYear] / 100,\n COBERTURA_PARCIAL: COBERTURA_PARCIAL[commercialYear] / 100,\n TOPE_IMPONIBLE_MENSUAL: TOPE_IMPONIBLE_MENSUAL[commercialYear],\n TRAMOS_IMPOSITIVOS: obtenerTramosImpositivos(UTA[commercialYear]),\n };\n}\n"],"names":[],"version":3,"file":"index.js.map"}
package/package.json CHANGED
@@ -1,20 +1,24 @@
1
1
  {
2
2
  "name": "tax-cl",
3
- "version": "1.3.1",
3
+ "version": "1.4.0",
4
4
  "description": "Librería cálculo de impuestos y cotizaciones en Chile 🇨🇱",
5
+ "source": "src/index.js",
5
6
  "main": "lib/index.js",
6
7
  "repository": "git@github.com:muZk/tax-cl.git",
7
8
  "author": "Nicolás Gómez <ngomez@hey.com>",
8
9
  "license": "MIT",
9
10
  "scripts": {
10
- "prepublish": "babel src -d lib"
11
+ "prepublish": "parcel build"
11
12
  },
12
13
  "devDependencies": {
13
14
  "@babel/cli": "^7.12.1",
14
15
  "@babel/core": "^7.12.3",
15
- "@babel/preset-env": "^7.12.1"
16
+ "@babel/preset-env": "^7.12.1",
17
+ "babel-minify": "^0.5.2",
18
+ "parcel": "^2.12.0"
16
19
  },
17
20
  "babel": {
21
+ "sourceType": "module",
18
22
  "presets": [
19
23
  "@babel/preset-env"
20
24
  ]
package/lib/config.js DELETED
@@ -1,165 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
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
-
20
- // Valor UTA en diciembre en https://www.sii.cl/valores_y_fechas/index_valores_y_fechas.html
21
- var UTA = {
22
- 2018: 580236,
23
- 2019: 595476,
24
- 2020: 612348,
25
- 2021: 650052,
26
- 2022: 733884,
27
- 2023: 770592,
28
- 2024: 772116 // 2024-02
29
-
30
- }; // Valor UF al 31 de diciembre en https://www.sii.cl/valores_y_fechas/index_valores_y_fechas.html
31
-
32
- var UF = {
33
- 2018: 27565.79,
34
- 2019: 28309.94,
35
- 2020: 29070.33,
36
- 2021: 30991.74,
37
- 2022: 35110.98,
38
- 2023: 36789.36,
39
- 2024: 36679.62 // 2024-02-09
40
-
41
- };
42
- var RETENCION = {
43
- 2019: 10,
44
- 2020: 10.75,
45
- 2021: 11.5,
46
- 2022: 12.25,
47
- 2023: 13,
48
- 2024: 13.75,
49
- 2025: 14.5,
50
- 2026: 15.25,
51
- 2027: 16,
52
- 2028: 17
53
- }; // Artículo Segundo de la Ley 21.133 (https://www.bcn.cl/leychile/navegar?idNorma=1128420)
54
-
55
- var COBERTURA_PARCIAL = {
56
- 2018: 5,
57
- 2019: 17,
58
- 2020: 27,
59
- 2021: 37,
60
- 2022: 47,
61
- 2023: 57,
62
- 2024: 70,
63
- 2025: 80,
64
- 2026: 90,
65
- 2027: 100,
66
- 2028: 100
67
- };
68
- var TOPE_IMPONIBLE_MENSUAL = {
69
- 2018: 78.3,
70
- // https://www.spensiones.cl/portal/institucional/594/w3-article-12946.html
71
- 2019: 79.2,
72
- // https://www.spensiones.cl/portal/institucional/594/w3-article-13553.html
73
- 2020: 80.2,
74
- // https://www.spensiones.cl/portal/institucional/594/w3-article-13843.html
75
- 2021: 81.6,
76
- // https://www.spensiones.cl/portal/institucional/594/w3-article-14366.html
77
- 2022: 81.6,
78
- // https://www.spensiones.cl/portal/institucional/594/w3-article-15178.html
79
- 2023: 81.6,
80
- // https://www.spensiones.cl/portal/institucional/594/w3-article-15486.html
81
- 2024: 84.3 // https://www.spensiones.cl/portal/institucional/594/w3-article-15855.html
82
-
83
- };
84
- /**
85
- * Calculates and returns tax brackets based on the provided UTA value.
86
- *
87
- * @param {Number} uta - The UTA value for which tax brackets are to be calculated.
88
- * @returns {Array.<{factor: Number, montoMaximo: Number, descuento: Number}>}
89
- * An array of objects, each containing:
90
- * - `factor`: The tax rate for the bracket.
91
- * - `montoMaximo`: The maximum amount for the bracket.
92
- * - `descuento`: The discount for the bracket.
93
- *
94
- * @example
95
- * const tramos = obtenerTramosImpositivos(1.5);
96
- * console.log(tramos); // Output will be an array of tax bracket objects.
97
- */
98
-
99
- function obtenerTramosImpositivos(uta) {
100
- var maxValue = Number.MAX_VALUE;
101
- 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) {
102
- var _ref2 = _slicedToArray(_ref, 3),
103
- montoMaximo = _ref2[0],
104
- factor = _ref2[1],
105
- descuento = _ref2[2];
106
-
107
- return {
108
- factor: factor,
109
- montoMaximo: montoMaximo,
110
- descuento: descuento
111
- };
112
- });
113
- }
114
- /**
115
- * Retrieves the configuration for a given "operacionRenta" year.
116
- *
117
- * @param {Number} operacionRenta - The year for which the operation configuration is required.
118
- * @throws {Error} Throws an error if the given year is not available.
119
- * @returns {{
120
- * OPERACION_RENTA: Number,
121
- * UTA: Number,
122
- * UF: Number,
123
- * RETENCION: Number,
124
- * COBERTURA_PARCIAL: Number,
125
- * TOPE_IMPONIBLE_MENSUAL: Number,
126
- * TRAMOS_IMPOSITIVOS: Array.<{factor: number, montoMaximo: number, descuento: number}>
127
- * }}
128
- * An object containing various configuration values:
129
- * - `OPERACION_RENTA`: The year for which the configuration is valid.
130
- * - `UTA`: The UTA value for the given year (December).
131
- * - `UF`: The UF value for the given year (last day of December).
132
- * - `RETENCION`: The retention percentage for the given year.
133
- * - `COBERTURA_PARCIAL`: The partial coverage percentage for the given year.
134
- * - `TOPE_IMPONIBLE_MENSUAL`: The monthly taxable income cap for the given year.
135
- * - `TRAMOS_IMPOSITIVOS`: An array of objects, each containing:
136
- * - `factor`: The tax rate for the bracket.
137
- * - `montoMaximo`: The maximum amount for the bracket.
138
- * - `descuento`: The discount for the bracket.
139
- *
140
- * @example
141
- * const config = getConfig(2022);
142
- * console.log(config.OPERACION_RENTA); // 2022
143
- */
144
-
145
-
146
- function getConfig(operacionRenta) {
147
- var commercialYear = operacionRenta - 1;
148
-
149
- if (!TOPE_IMPONIBLE_MENSUAL[commercialYear]) {
150
- var validos = Object.keys(TOPE_IMPONIBLE_MENSUAL).map(function (year) {
151
- return parseInt(year) + 1;
152
- }).join(', ');
153
- throw new Error("El a\xF1o ingresado es incorrecto. Los valores v\xE1lidos son: ".concat(validos));
154
- }
155
-
156
- return {
157
- OPERACION_RENTA: operacionRenta,
158
- UTA: UTA[commercialYear],
159
- UF: UF[commercialYear],
160
- RETENCION: RETENCION[commercialYear] / 100,
161
- COBERTURA_PARCIAL: COBERTURA_PARCIAL[commercialYear] / 100,
162
- TOPE_IMPONIBLE_MENSUAL: TOPE_IMPONIBLE_MENSUAL[commercialYear],
163
- TRAMOS_IMPOSITIVOS: obtenerTramosImpositivos(UTA[commercialYear])
164
- };
165
- }