tax-cl 1.3.0 → 1.3.1
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 -5
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -89,6 +89,10 @@ var COTIZACIONES_OBLIGATORIAS = [{
|
|
|
89
89
|
variable: true
|
|
90
90
|
}];
|
|
91
91
|
|
|
92
|
+
function getContributionPercentage(contribution) {
|
|
93
|
+
return typeof contribution.percent === 'function' ? contribution.percent() : contribution.percent;
|
|
94
|
+
}
|
|
95
|
+
|
|
92
96
|
function calcularSueldoImponible(sueldoAnual) {
|
|
93
97
|
var topeAnual = config.TOPE_IMPONIBLE_MENSUAL * config.UF * 12;
|
|
94
98
|
return min(0.8 * sueldoAnual, topeAnual);
|
|
@@ -101,8 +105,7 @@ function simularCotizaciones(ingresos) {
|
|
|
101
105
|
if (cotizacionParcial) {
|
|
102
106
|
var sueldoImponibleParcial = sueldoImponible * config.COBERTURA_PARCIAL;
|
|
103
107
|
return COTIZACIONES_OBLIGATORIAS.map(function (cotizacion) {
|
|
104
|
-
var
|
|
105
|
-
var monto = (cotizacion.variable ? sueldoImponibleParcial : sueldoImponible) * percentage / 100;
|
|
108
|
+
var monto = (cotizacion.variable ? sueldoImponibleParcial : sueldoImponible) * getContributionPercentage(cotizacion) / 100;
|
|
106
109
|
return {
|
|
107
110
|
name: cotizacion.name,
|
|
108
111
|
percent: 100 * monto / sueldoImponible,
|
|
@@ -113,16 +116,16 @@ function simularCotizaciones(ingresos) {
|
|
|
113
116
|
var remanente = calcularRetencion(sueldoImponible / 0.8);
|
|
114
117
|
return COTIZACIONES_OBLIGATORIAS.map(function (cotizacion) {
|
|
115
118
|
if (cotizacion.name === 'AFP') {
|
|
116
|
-
var monto = min(remanente, sueldoImponible * cotizacion
|
|
119
|
+
var monto = min(remanente, sueldoImponible * getContributionPercentage(cotizacion) / 100);
|
|
117
120
|
return {
|
|
118
121
|
name: cotizacion.name,
|
|
119
122
|
percent: 100 * monto / sueldoImponible,
|
|
120
123
|
value: monto
|
|
121
124
|
};
|
|
122
125
|
} else {
|
|
123
|
-
var percent = cotizacion
|
|
126
|
+
var percent = getContributionPercentage(cotizacion);
|
|
124
127
|
|
|
125
|
-
var _monto = sueldoImponible *
|
|
128
|
+
var _monto = sueldoImponible * percent / 100;
|
|
126
129
|
|
|
127
130
|
remanente -= _monto;
|
|
128
131
|
return {
|