Skip to content

Instantly share code, notes, and snippets.

@Falciighol
Last active August 4, 2022 07:14
Show Gist options
  • Save Falciighol/e5974142f953f1056036c9271494347b to your computer and use it in GitHub Desktop.
Save Falciighol/e5974142f953f1056036c9271494347b to your computer and use it in GitHub Desktop.
[Excel PAGO Func] Función PAGO de Excel en Javascript #js #bp
// Basado en la formula de matemática financiera:
// https://luismasanchezmaestre.files.wordpress.com/2014/08/calculo-anualidad.jpg
var a = 0;
// Monto
var co = 5700;
// Años
var n = 13;
// Pagos Anuales
var m = 12;
// Tasa Interes
var ti = 7.5;
// Tipo de interés fraccionado (del periodo)
var im = ti / m / 100;
var im2 = Math.pow((1 + im), -(m * n));
// Cuota Cap. + Int.
a = (co * im) / (1 - im2);
console.log("Cuota Cap + Int: " + a.toFixed(2));
@gabrielrincon
Copy link

export class FinancialClass{

private value: number;
private periods: number;
private rate: number;
private payment: number

constructor(value: number, periods: number, rate: number) {
    this.value = value;
    this.periods = periods;
    this.rate = rate;
    this.payment = ((rate * Math.pow(1 + rate, periods)) * value)/(Math.pow(1 + rate, periods) - 1);
}

getPayment() {
    return this.payment;
}

getInterest() {
    return this.value * this.rate;
}

getCapital() {
    var interest = this.value * this.rate;
    return this.payment - interest;
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment