tax-cl 1.4.1 → 1.4.2
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/index.js +8 -4
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -23,7 +23,8 @@ const $100592030dab1e52$var$UTA = {
|
|
|
23
23
|
2022: 733884,
|
|
24
24
|
2023: 770592,
|
|
25
25
|
2024: 807528,
|
|
26
|
-
2025:
|
|
26
|
+
2025: 834504,
|
|
27
|
+
2026: 837012
|
|
27
28
|
};
|
|
28
29
|
// Valor UF al 31 de diciembre en https://www.sii.cl/valores_y_fechas/index_valores_y_fechas.html
|
|
29
30
|
const $100592030dab1e52$var$UF = {
|
|
@@ -34,7 +35,8 @@ const $100592030dab1e52$var$UF = {
|
|
|
34
35
|
2022: 35110.98,
|
|
35
36
|
2023: 36789.36,
|
|
36
37
|
2024: 38416.69,
|
|
37
|
-
2025:
|
|
38
|
+
2025: 39727.96,
|
|
39
|
+
2026: 39762.52
|
|
38
40
|
};
|
|
39
41
|
const $100592030dab1e52$var$RETENCION = {
|
|
40
42
|
2019: 10,
|
|
@@ -70,7 +72,8 @@ const $100592030dab1e52$var$TOPE_IMPONIBLE_MENSUAL = {
|
|
|
70
72
|
2022: 81.6,
|
|
71
73
|
2023: 81.6,
|
|
72
74
|
2024: 84.3,
|
|
73
|
-
2025: 87.8
|
|
75
|
+
2025: 87.8,
|
|
76
|
+
2026: 87.8
|
|
74
77
|
};
|
|
75
78
|
/**
|
|
76
79
|
* Calculates and returns tax brackets based on the provided UTA value.
|
|
@@ -189,7 +192,8 @@ const $4fa36e821943b400$var$COTIZACIONES_OBLIGATORIAS = [
|
|
|
189
192
|
2022: 1.54,
|
|
190
193
|
2023: 1.47,
|
|
191
194
|
2024: 1.49,
|
|
192
|
-
2025: 1.5
|
|
195
|
+
2025: 1.5,
|
|
196
|
+
2026: 1.5
|
|
193
197
|
};
|
|
194
198
|
return SIS[$4fa36e821943b400$var$config.OPERACION_RENTA - 1] || SIS[2023];
|
|
195
199
|
},
|
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;AACR;AAEA,iGAAiG;AACjG,MAAM,2BAAK;IACT,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;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;YAAG;YAAY;YAAK,QAAQ;SAAI;KACj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ACF,OAAO;gBACL,MAAM,UAAU,gDAA0B;gBAC1C,MAAM,QAAQ,kBAAkB,UAAU;gBAC1C,aAAa;gBACb,OAAO;oBACL,MAAM,WAAW,IAAI;6BACrB;oBACA,OAAO;gBACT;YACF;QACF;IACF;AACF;AAEO,SAAS,0CAAiC,QAAQ,EAAE,oBAAoB,KAAK;IAClF,OAAO,0CAAoB,UAAU,mBAAmB,MAAM,CAAC,CAAC,OAAO;QACrE,OAAO,QAAQ,WAAW,KAAK;IACjC,GAAG;AACL;AAEO,SAAS,0CAAkB,WAAW;IAC3C,OAAO,cAAc,6BAAO,SAAS;AACvC;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"}
|
|
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;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AO;QACrE,OAAO,QAAQ,WAAW,KAAK;IACjC,GAAG;AACL;AAEO,SAAS,0CAAkB,WAAW;IAC3C,OAAO,cAAc,6BAAO,SAAS;AACvC;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 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"}
|