tax-cl 1.1.0 → 1.2.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
@@ -93,4 +93,4 @@ Configura el año de la operación renta sobre la cual aplican los cálculos. Po
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: `2018`, `2019`, `2020`, `2021`, `2022` y `2023`.
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.
package/lib/config.js CHANGED
@@ -24,7 +24,8 @@ var UTA = {
24
24
  2020: 612348,
25
25
  2021: 650052,
26
26
  2022: 733884,
27
- 2023: 741228 // 2023-01
27
+ 2023: 770592,
28
+ 2024: 772116 // 2024-02
28
29
 
29
30
  }; // Valor UF al 31 de diciembre en https://www.sii.cl/valores_y_fechas/index_valores_y_fechas.html
30
31
 
@@ -34,7 +35,8 @@ var UF = {
34
35
  2020: 29070.33,
35
36
  2021: 30991.74,
36
37
  2022: 35110.98,
37
- 2023: 35287.50 // 2023-01-31
38
+ 2023: 36789.36,
39
+ 2024: 36679.62 // 2024-02-09
38
40
 
39
41
  };
40
42
  var RETENCION = {
@@ -74,9 +76,25 @@ var TOPE_IMPONIBLE_MENSUAL = {
74
76
  // https://www.spensiones.cl/portal/institucional/594/w3-article-14366.html
75
77
  2022: 81.6,
76
78
  // 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
79
+ 2023: 81.6,
80
+ // https://www.spensiones.cl/portal/institucional/594/w3-article-15486.html
81
+ 2024: 81.6 // Not yet available
78
82
 
79
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
+ */
80
98
 
81
99
  function obtenerTramosImpositivos(uta) {
82
100
  var maxValue = Number.MAX_VALUE;
@@ -93,6 +111,37 @@ function obtenerTramosImpositivos(uta) {
93
111
  };
94
112
  });
95
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
+
96
145
 
97
146
  function getConfig(operacionRenta) {
98
147
  var commercialYear = operacionRenta - 1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tax-cl",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Librería cálculo de impuestos y cotizaciones en Chile 🇨🇱",
5
5
  "main": "lib/index.js",
6
6
  "repository": "git@github.com:muZk/tax-cl.git",