sheetjs run plugin librerias library example javascript excel excel-formula

run - librerias javascript excel



excel CUMIPMT. funciĆ³n en javascript (1)

Esto es un pseudocódigo, deberás ajustarlo:

Object CUMIPMT(double rate, double nper, double pv, double start_period, double end_period, double type) { if (rate <= 0) { return "#NUM!"; } if (nper <= 0) { return "#NUM!"; } nper = (int)nper; if (pv <= 0) { return "#NUM!"; } if (start_period < 1) { return "#NUM!"; } start_period = (int)start_period; if (end_period < 1) { return "#NUM!"; } end_period = (int)end_period; if (start_period > end_period) { return "#NUM!"; } if (!(type == 0 || type == 1)) { return "#NUM!"; } double value = 0; for (int per = (int)start_period; per <= (int)end_period; per++) { value += IPMT(rate, nper, per, pv, 0, type); } return value; } double IPMT(double rate, double nper, double period, double pv, double fv, double type) { if (rate == 0) { return 0; } if (type == 1 && period == 1) { return 0; } double pmt = PMT(rate, nper, pv, fv, 0); if (type == 0) { return (pv * Math.Pow(1.0 + rate, period - 1) + pmt * ((Math.Pow(1 + rate, period - 1) - 1) / rate)) * rate * (-1.0); } else { double pmt2 = PMT(rate, nper, pv, fv, 1); return pmt2 - pmt + (pv * Math.Pow(1.0 + rate, period - 2) + pmt * ((Math.Pow(1 + rate, period - 2) - 1) / rate)) * rate * (-1.0); } } double PMT(double rate, double nper, double pv, double fv, double type) { if (rate == 0) { return (-1.0) * (fv + pv) / nper; } else { return (-1.0) * ((fv + pv * Math.Pow((1 + rate), nper)) * rate / ((1 + rate * type) * (Math.Pow((1 + rate), nper) - 1)) ); } }

¿Alguien sabe cómo implementar la función excel CUMIPMT en javascript? Encontré este código pero parece que faltan algunas funciones.