tax-cl 1.4.2 → 1.4.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.
@@ -0,0 +1,49 @@
1
+ name: Publish to NPM
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+
7
+ permissions:
8
+ id-token: write
9
+ contents: write
10
+
11
+ jobs:
12
+ publish:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+
17
+ - uses: actions/setup-node@v4
18
+ with:
19
+ node-version: 22
20
+ registry-url: https://registry.npmjs.org
21
+
22
+ - run: npm install -g npm@latest
23
+ - run: npm ci
24
+
25
+ - name: Check if version changed
26
+ id: version
27
+ run: |
28
+ PACKAGE_VERSION=$(node -p "require('./package.json').version")
29
+ NPM_VERSION=$(npm view tax-cl version 2>/dev/null || echo "0.0.0")
30
+ if [ "$PACKAGE_VERSION" = "$NPM_VERSION" ]; then
31
+ echo "changed=false" >> "$GITHUB_OUTPUT"
32
+ else
33
+ echo "changed=true" >> "$GITHUB_OUTPUT"
34
+ echo "version=$PACKAGE_VERSION" >> "$GITHUB_OUTPUT"
35
+ fi
36
+
37
+ - name: Build
38
+ if: steps.version.outputs.changed == 'true'
39
+ run: npx parcel build
40
+
41
+ - name: Publish
42
+ if: steps.version.outputs.changed == 'true'
43
+ run: npm publish
44
+
45
+ - name: Create git tag
46
+ if: steps.version.outputs.changed == 'true'
47
+ run: |
48
+ git tag "v${{ steps.version.outputs.version }}"
49
+ git push origin "v${{ steps.version.outputs.version }}"
package/README.md CHANGED
@@ -85,12 +85,26 @@ Retorna un objeto con las siguientes propiedades:
85
85
  * `deudaModalidadParcial`: *(number)*. Es la deuda final, pero considerando que has optado por pagar las cotizaciones en modalidad parcial.
86
86
  * `operacionRenta`: *(number)*. Es el año de la declaración (**2025** por defecto).
87
87
 
88
- ### `configurarDeclaracion(number: year) : void`
88
+ ### `configurarDeclaracion(number: year, object?: options) : void`
89
89
 
90
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
- Recibe el siguiente argumento:
94
+ Recibe los siguientes argumentos:
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 2026.
97
+ * `options`: *(object, opcional)*, opciones de configuración adicionales:
98
+ * `uf`: *(number, opcional)*, valor UF personalizado. Si no se especifica, se usa el valor por defecto del año.
95
99
 
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.
100
+ #### Example
101
+
102
+ ```javascript
103
+ const { configurarDeclaracion, calcular } = require('tax-cl');
104
+
105
+ // Usar valores por defecto
106
+ configurarDeclaracion(2025);
107
+
108
+ // Usar UF personalizado
109
+ configurarDeclaracion(2025, { uf: 40000 });
110
+ ```
package/lib/index.js CHANGED
@@ -36,7 +36,7 @@ const $100592030dab1e52$var$UF = {
36
36
  2023: 36789.36,
37
37
  2024: 38416.69,
38
38
  2025: 39727.96,
39
- 2026: 39762.52
39
+ 2026: 39706.07
40
40
  };
41
41
  const $100592030dab1e52$var$RETENCION = {
42
42
  2019: 10,
@@ -73,7 +73,7 @@ const $100592030dab1e52$var$TOPE_IMPONIBLE_MENSUAL = {
73
73
  2023: 81.6,
74
74
  2024: 84.3,
75
75
  2025: 87.8,
76
- 2026: 87.8
76
+ 2026: 89.9
77
77
  };
78
78
  /**
79
79
  * Calculates and returns tax brackets based on the provided UTA value.
@@ -137,16 +137,17 @@ const $100592030dab1e52$var$TOPE_IMPONIBLE_MENSUAL = {
137
137
  descuento: descuento
138
138
  }));
139
139
  }
140
- function $100592030dab1e52$export$44487a86467333c3(operacionRenta) {
140
+ function $100592030dab1e52$export$44487a86467333c3(operacionRenta, options = {}) {
141
141
  const commercialYear = operacionRenta - 1;
142
142
  if (!$100592030dab1e52$var$TOPE_IMPONIBLE_MENSUAL[commercialYear]) {
143
143
  const validos = Object.keys($100592030dab1e52$var$TOPE_IMPONIBLE_MENSUAL).map((year)=>parseInt(year) + 1).join(", ");
144
144
  throw new Error(`El a\xf1o ingresado es incorrecto. Los valores v\xe1lidos son: ${validos}`);
145
145
  }
146
+ const ufValue = options.uf !== undefined ? options.uf : $100592030dab1e52$var$UF[commercialYear];
146
147
  return {
147
148
  OPERACION_RENTA: operacionRenta,
148
149
  UTA: $100592030dab1e52$var$UTA[commercialYear],
149
- UF: $100592030dab1e52$var$UF[commercialYear],
150
+ UF: ufValue,
150
151
  RETENCION: $100592030dab1e52$var$RETENCION[commercialYear] / 100,
151
152
  COBERTURA_PARCIAL: $100592030dab1e52$var$COBERTURA_PARCIAL[commercialYear] / 100,
152
153
  TOPE_IMPONIBLE_MENSUAL: $100592030dab1e52$var$TOPE_IMPONIBLE_MENSUAL[commercialYear],
@@ -157,8 +158,8 @@ function $100592030dab1e52$export$44487a86467333c3(operacionRenta) {
157
158
 
158
159
  const $4fa36e821943b400$var$OPERACION_RENTA_ACTUAL = 2025;
159
160
  const $4fa36e821943b400$var$config = (0, $100592030dab1e52$export$44487a86467333c3)($4fa36e821943b400$var$OPERACION_RENTA_ACTUAL);
160
- function $4fa36e821943b400$export$37b8b24baccc291f(year) {
161
- const newConfig = (0, $100592030dab1e52$export$44487a86467333c3)(year);
161
+ function $4fa36e821943b400$export$37b8b24baccc291f(year, options = {}) {
162
+ const newConfig = (0, $100592030dab1e52$export$44487a86467333c3)(year, options);
162
163
  Object.keys(newConfig).forEach((key)=>{
163
164
  $4fa36e821943b400$var$config[key] = newConfig[key];
164
165
  });
@@ -232,10 +233,11 @@ function $4fa36e821943b400$export$d324ef4aacd7699a(ingresos, cotizacionParcial =
232
233
  if (cotizacionParcial) {
233
234
  const sueldoImponibleParcial = sueldoImponible * $4fa36e821943b400$var$config.COBERTURA_PARCIAL;
234
235
  return $4fa36e821943b400$var$COTIZACIONES_OBLIGATORIAS.map((cotizacion)=>{
235
- const monto = (cotizacion.variable ? sueldoImponibleParcial : sueldoImponible) * $4fa36e821943b400$var$getContributionPercentage(cotizacion) / 100;
236
+ const percent = $4fa36e821943b400$var$getContributionPercentage(cotizacion);
237
+ const monto = (cotizacion.variable ? sueldoImponibleParcial : sueldoImponible) * percent / 100;
236
238
  return {
237
239
  name: cotizacion.name,
238
- percent: 100 * monto / sueldoImponible,
240
+ percent: percent,
239
241
  value: monto
240
242
  };
241
243
  });
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;ACAA,4FAA4F;AAC5F,MAAM,4BAAM;IACV,MAAM;IACN,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,MAAM;IACN,MAAM;AACR;AAEA,MAAM,kCAAY;IAChB,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;AACR;AAEA,0FAA0F;AAC1F,MAAM,0CAAoB;IACxB,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;AACR;AAEA,MAAM,+CAAyB;IAC7B,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;AACR;AAEA;;;;;;;;;;;;;CAaC,GACD,SAAS,+CAAyB,GAAG;IACnC,MAAM,WAAW,OAAO,SAAS;IACjC,OAAO;QACL;YAAC,OAAO;YAAS;YAAa;SAAE;QAChC;YAAG,KAAK;YAAM;YAAO,OAAO;SAAI;QAChC;YAAG,KAAK;YAAM;YAAO,OAAO;SAAI;QAChC;YAAG,K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AAO;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 2026: 1.5, // Igual que el 2025, ya que no se ha publicado el valor\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: 834504,\n 2026: 837012, // 2026-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: 39727.96,\n 2026: 39762.52, // 2026-01-09\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 2026: 87.8, // Igual que el 2025, ya que no se ha publicado el valor\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"}
1
+ {"mappings":";;;;;;;;;;;;;;;;ACAA,4FAA4F;AAC5F,MAAM,4BAAM;IACV,MAAM;IACN,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,MAAM;IACN,MAAM;AACR;AAEA,MAAM,kCAAY;IAChB,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;AACR;AAEA,0FAA0F;AAC1F,MAAM,0CAAoB;IACxB,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;AACR;AAEA,MAAM,+CAAyB;IAC7B,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;AACR;AAEA;;;;;;;;;;;;;CAaC,GACD,SAAS,+CAAyB,GAAG;IACnC,MAAM,WAAW,OAAO,SAAS;IACjC,OAAO;QACL;YAAC,OAAO;YAAS;YAAa;SAAE;QAChC;YAAG,KAAK;YAAM;YAAO,OAAO;SAAI;QAChC;YAAG,KAAK;YAAM;YAAO,OAAO;SAAI;QAChC;YAAG,KAAK;YAAK;YAAQ,OAAO;SAAI;QAChC;YAAG,KAAK;YAAM;YAAM,QAAQ;SAAI;QAChC;YAAE,MAAM;YAAK;YAAQ,OAAO;SAAI;QAChC;YAAE,MAAM;YAAM;YAAM,QAAQ;SAAI;QAChC;YAA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ACA;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 {Number} year - Año de la operación renta\n * @param {Object} [options] - Opciones de configuración\n * @param {Number} [options.uf] - Valor UF personalizado (por defecto usa el valor del año)\n */\nexport function configurarDeclaracion(year, options = {}) {\n const newConfig = getConfig(year, options);\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 2026: 1.5, // Igual que el 2025, ya que no se ha publicado el valor\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 percent = getContributionPercentage(cotizacion)\n const monto = (cotizacion.variable ? sueldoImponibleParcial : sueldoImponible) * percent / 100\n return {\n name: cotizacion.name,\n percent,\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: 834504,\n 2026: 837012, // 2026-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: 39727.96,\n 2026: 39706.07, // 2026-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 2026: 89.9, // https://www.spensiones.cl/portal/institucional/594/w3-article-16885.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 * @param {Object} [options] - Optional configuration overrides.\n * @param {Number} [options.uf] - Custom UF value to use instead of the default for the year.\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), or custom value if provided.\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 *\n * @example\n * // With custom UF value\n * const config = getConfig(2025, { uf: 40000 });\n * console.log(config.UF); // 40000\n*/\nexport function getConfig(operacionRenta, options = {}) {\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 const ufValue = options.uf !== undefined ? options.uf : UF[commercialYear];\n\n return {\n OPERACION_RENTA: operacionRenta,\n UTA: UTA[commercialYear],\n UF: ufValue,\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,14 +1,17 @@
1
1
  {
2
2
  "name": "tax-cl",
3
- "version": "1.4.2",
3
+ "version": "1.4.3",
4
4
  "description": "Librería cálculo de impuestos y cotizaciones en Chile 🇨🇱",
5
5
  "source": "src/index.js",
6
6
  "main": "lib/index.js",
7
- "repository": "git@github.com:muZk/tax-cl.git",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+ssh://git@github.com/muZk/tax-cl.git"
10
+ },
8
11
  "author": "Nicolás Gómez <ngomez@hey.com>",
9
12
  "license": "MIT",
10
13
  "scripts": {
11
- "prepublish": "parcel build"
14
+ "prepublishOnly": "parcel build"
12
15
  },
13
16
  "devDependencies": {
14
17
  "@babel/cli": "^7.12.1",