tax-cl 1.0.5 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/config.js +21 -4
- package/lib/index.js +55 -22
- package/package.json +1 -1
- package/.idea/modules.xml +0 -8
- package/.idea/tax-cl.iml +0 -12
- package/.idea/vcs.xml +0 -6
package/lib/config.js
CHANGED
|
@@ -4,6 +4,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getConfig = getConfig;
|
|
7
|
+
|
|
8
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
9
|
+
|
|
10
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
11
|
+
|
|
12
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
13
|
+
|
|
14
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
15
|
+
|
|
16
|
+
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
17
|
+
|
|
18
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
19
|
+
|
|
7
20
|
// Valor UTA en diciembre en https://www.sii.cl/valores_y_fechas/index_valores_y_fechas.html
|
|
8
21
|
var UTA = {
|
|
9
22
|
2018: 580236,
|
|
@@ -66,15 +79,19 @@ var TOPE_IMPONIBLE_MENSUAL = {
|
|
|
66
79
|
};
|
|
67
80
|
|
|
68
81
|
function obtenerTramosImpositivos(uta) {
|
|
69
|
-
var
|
|
82
|
+
var maxValue = Number.MAX_VALUE;
|
|
83
|
+
return [[13.5 * uta, 0, 0], [30 * uta, 0.04, 0.54 * uta], [50 * uta, 0.08, 1.74 * uta], [70 * uta, 0.135, 4.49 * uta], [90 * uta, 0.23, 11.14 * uta], [120 * uta, 0.304, 17.8 * uta], [310 * uta, 0.35, 23.32 * uta], [maxValue, 0.4, 38.82 * uta]].map(function (_ref) {
|
|
84
|
+
var _ref2 = _slicedToArray(_ref, 3),
|
|
85
|
+
montoMaximo = _ref2[0],
|
|
86
|
+
factor = _ref2[1],
|
|
87
|
+
descuento = _ref2[2];
|
|
88
|
+
|
|
70
89
|
return {
|
|
71
90
|
factor: factor,
|
|
72
91
|
montoMaximo: montoMaximo,
|
|
73
92
|
descuento: descuento
|
|
74
93
|
};
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
return [construirTramoImpositivo(0, 13.5 * uta, 0), construirTramoImpositivo(0.04, 30 * uta, 0.54 * uta), construirTramoImpositivo(0.08, 50 * uta, 1.74 * uta), construirTramoImpositivo(0.135, 70 * uta, 4.49 * uta), construirTramoImpositivo(0.23, 90 * uta, 11.14 * uta), construirTramoImpositivo(0.304, 120 * uta, 17.8 * uta), construirTramoImpositivo(0.35, 150 * uta, 23.92 * uta), construirTramoImpositivo(0.4, Number.MAX_VALUE, 30.67 * uta)];
|
|
94
|
+
});
|
|
78
95
|
}
|
|
79
96
|
|
|
80
97
|
function getConfig(operacionRenta) {
|
package/lib/index.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.configurarDeclaracion = configurarDeclaracion;
|
|
|
7
7
|
exports.obtenerConfiguracion = obtenerConfiguracion;
|
|
8
8
|
exports.calcularGastos = calcularGastos;
|
|
9
9
|
exports.calcularSueldoImponible = calcularSueldoImponible;
|
|
10
|
+
exports.simularCotizaciones = simularCotizaciones;
|
|
10
11
|
exports.calcularCotizacionesObligatorias = calcularCotizacionesObligatorias;
|
|
11
12
|
exports.calcularRetencion = calcularRetencion;
|
|
12
13
|
exports.buscarTramoImpositivo = buscarTramoImpositivo;
|
|
@@ -27,7 +28,7 @@ var OPERACION_RENTA_ACTUAL = 2023;
|
|
|
27
28
|
var config = (0, _config.getConfig)(OPERACION_RENTA_ACTUAL);
|
|
28
29
|
/**
|
|
29
30
|
* Configura el año de la operación renta para los cálculos.
|
|
30
|
-
* @param {Number}
|
|
31
|
+
* @param year {Number}, año de la operación renta
|
|
31
32
|
*/
|
|
32
33
|
|
|
33
34
|
function configurarDeclaracion(year) {
|
|
@@ -45,8 +46,8 @@ function min(a, b) {
|
|
|
45
46
|
return a > b ? b : a;
|
|
46
47
|
}
|
|
47
48
|
|
|
48
|
-
function calcularGastos(
|
|
49
|
-
var gastos =
|
|
49
|
+
function calcularGastos(rentaAnual) {
|
|
50
|
+
var gastos = rentaAnual * 0.3;
|
|
50
51
|
var tope = 15 * config.UTA;
|
|
51
52
|
return min(gastos, tope);
|
|
52
53
|
}
|
|
@@ -71,13 +72,8 @@ var COTIZACIONES_OBLIGATORIAS = [{
|
|
|
71
72
|
variable: true
|
|
72
73
|
}, {
|
|
73
74
|
name: "AFP",
|
|
74
|
-
percent: 10,
|
|
75
|
+
percent: 10.58,
|
|
75
76
|
variable: true
|
|
76
|
-
}, {
|
|
77
|
-
name: "Comisión AFP",
|
|
78
|
-
percent: 0.58,
|
|
79
|
-
// AFP Modelo https://www.spensiones.cl/apps/estcom/estcom.php
|
|
80
|
-
variable: false
|
|
81
77
|
}];
|
|
82
78
|
exports.COTIZACIONES_OBLIGATORIAS = COTIZACIONES_OBLIGATORIAS;
|
|
83
79
|
|
|
@@ -86,19 +82,51 @@ function calcularSueldoImponible(sueldoAnual) {
|
|
|
86
82
|
return min(0.8 * sueldoAnual, topeAnual);
|
|
87
83
|
}
|
|
88
84
|
|
|
89
|
-
function
|
|
85
|
+
function simularCotizaciones(ingresos) {
|
|
90
86
|
var cotizacionParcial = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
91
|
-
var
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
87
|
+
var sueldoImponible = calcularSueldoImponible(ingresos);
|
|
88
|
+
|
|
89
|
+
if (cotizacionParcial) {
|
|
90
|
+
var sueldoImponibleParcial = sueldoImponible * config.COBERTURA_PARCIAL;
|
|
91
|
+
return COTIZACIONES_OBLIGATORIAS.map(function (cotizacion) {
|
|
92
|
+
var monto = (cotizacion.variable ? sueldoImponibleParcial : sueldoImponible) * cotizacion.percent / 100;
|
|
93
|
+
return {
|
|
94
|
+
name: cotizacion.name,
|
|
95
|
+
percent: 100 * monto / sueldoImponible,
|
|
96
|
+
value: monto
|
|
97
|
+
};
|
|
98
|
+
});
|
|
99
|
+
} else {
|
|
100
|
+
var remanente = calcularRetencion(sueldoImponible / 0.8);
|
|
101
|
+
return COTIZACIONES_OBLIGATORIAS.map(function (cotizacion) {
|
|
102
|
+
if (cotizacion.name === 'AFP') {
|
|
103
|
+
var monto = min(remanente, sueldoImponible * cotizacion.percent / 100);
|
|
104
|
+
return {
|
|
105
|
+
name: cotizacion.name,
|
|
106
|
+
percent: 100 * monto / sueldoImponible,
|
|
107
|
+
value: monto
|
|
108
|
+
};
|
|
109
|
+
} else {
|
|
110
|
+
var percent = cotizacion.percent;
|
|
111
|
+
|
|
112
|
+
var _monto = sueldoImponible * cotizacion.percent / 100;
|
|
113
|
+
|
|
114
|
+
remanente -= _monto;
|
|
115
|
+
return {
|
|
116
|
+
name: cotizacion.name,
|
|
117
|
+
percent: percent,
|
|
118
|
+
value: _monto
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
98
124
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
return
|
|
125
|
+
function calcularCotizacionesObligatorias(ingresos) {
|
|
126
|
+
var cotizacionParcial = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
127
|
+
return simularCotizaciones(ingresos, cotizacionParcial).reduce(function (total, cotizacion) {
|
|
128
|
+
return total + cotizacion.value;
|
|
129
|
+
}, 0);
|
|
102
130
|
}
|
|
103
131
|
|
|
104
132
|
function calcularRetencion(sueldoAnual) {
|
|
@@ -129,17 +157,22 @@ function calcular(sueldoMensual) {
|
|
|
129
157
|
var gastos = calcularGastos(sueldoAnual);
|
|
130
158
|
var sueldoTributable = sueldoAnual - gastos;
|
|
131
159
|
var montoCotizacionesObligatorias = calcularCotizacionesObligatorias(sueldoAnual);
|
|
132
|
-
var
|
|
160
|
+
var montoCotizacionParcial = calcularCotizacionesObligatorias(sueldoAnual, true);
|
|
133
161
|
var retencion = calcularRetencion(sueldoAnual);
|
|
134
162
|
var impuestos = calcularImpuestos(sueldoTributable);
|
|
135
163
|
var deuda = calcularDeuda(montoCotizacionesObligatorias, impuestos, retencion);
|
|
136
|
-
var deudaModalidadParcial = calcularDeuda(
|
|
164
|
+
var deudaModalidadParcial = calcularDeuda(montoCotizacionParcial, impuestos, retencion);
|
|
137
165
|
return {
|
|
138
166
|
operacionRenta: config.OPERACION_RENTA,
|
|
139
167
|
sueldoAnual: sueldoAnual,
|
|
140
168
|
gastos: gastos,
|
|
141
169
|
sueldoTributable: sueldoTributable,
|
|
142
170
|
montoCotizacionesObligatorias: montoCotizacionesObligatorias,
|
|
171
|
+
montoCotizacionParcial: montoCotizacionParcial,
|
|
172
|
+
cotizaciones: {
|
|
173
|
+
parcial: simularCotizaciones(sueldoAnual, true),
|
|
174
|
+
total: simularCotizaciones(sueldoAnual)
|
|
175
|
+
},
|
|
143
176
|
retencion: retencion,
|
|
144
177
|
impuestos: impuestos,
|
|
145
178
|
deuda: deuda,
|
package/package.json
CHANGED
package/.idea/modules.xml
DELETED
package/.idea/tax-cl.iml
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<module type="WEB_MODULE" version="4">
|
|
3
|
-
<component name="NewModuleRootManager">
|
|
4
|
-
<content url="file://$MODULE_DIR$">
|
|
5
|
-
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
|
6
|
-
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
|
7
|
-
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
|
8
|
-
</content>
|
|
9
|
-
<orderEntry type="inheritedJdk" />
|
|
10
|
-
<orderEntry type="sourceFolder" forTests="false" />
|
|
11
|
-
</component>
|
|
12
|
-
</module>
|