Created
February 19, 2020 04:19
-
-
Save espinozaulises/41423847294e4f9de460e5c1b8a867a0 to your computer and use it in GitHub Desktop.
ajustaMontos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ajustaMontos(datos: NcDevolucion, rel: NcRelDevolucion, valor: number) { | |
/* Calculamos el saldo por facturar de el doc relacionado actual */ | |
let id = rel.id; | |
let saldoFactura = rel.montoPorPagar - valor; | |
rel.saldoFactura = saldoFactura; | |
let totalNc = datos.total - valor; | |
var r = datos.relacionados; | |
for (const prop in r) { | |
if(id != datos.relacionados[prop].id) { | |
if(totalNc >= datos.relacionados[prop].montoPorPagar) { | |
datos.relacionados[prop].montoAplicado = datos.relacionados[prop].montoPorPagar; | |
} else if(totalNc > 0 ) { | |
datos.relacionados[prop].montoAplicado = totalNc; | |
} else { | |
datos.relacionados[prop].montoAplicado = 0; | |
} | |
var mpp = datos.relacionados[prop].montoPorPagar; | |
var map = datos.relacionados[prop].montoAplicado; | |
var monto = mpp - map; | |
datos.relacionados[prop].saldoFactura = monto; | |
totalNc = totalNc - monto; | |
console.log(totalNc) | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment