|
@@ -91,6 +91,7 @@ function report_amortization_and_interest(reporting){
|
|
|
self.AccountInvoiceLine = DataSQL.invoice_lines;
|
|
|
self.AccountMoveLine = DataSQL.move_lines;
|
|
|
self.AccountVoucher = DataSQL.vouchers;
|
|
|
+ self.AccountMoveLinePartialReconcile = DataSQL.reconcile_partials;
|
|
|
});
|
|
|
self.$el.find('#generate').css('display','inline');
|
|
|
return;
|
|
@@ -135,6 +136,13 @@ function report_amortization_and_interest(reporting){
|
|
|
return content;
|
|
|
},
|
|
|
|
|
|
+ getAccountMoveLinePartialReconcile: function (id) {
|
|
|
+ var self = this;
|
|
|
+ return _.filter(self.AccountMoveLinePartialReconcile,function (item) {
|
|
|
+ return item.reconcile_partial_id == id;
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
getAccountVoucher: function (number) {
|
|
|
var self = this;
|
|
|
var valor = _.reduce(_.map(self.AccountVoucher, function (map) {
|
|
@@ -240,7 +248,6 @@ function report_amortization_and_interest(reporting){
|
|
|
|
|
|
BuildTable: function(){
|
|
|
var self = this;
|
|
|
- console.log(self);
|
|
|
var columns = [];
|
|
|
var data = [];
|
|
|
var AccountInvoice = self.getContent();
|
|
@@ -300,6 +307,7 @@ function report_amortization_and_interest(reporting){
|
|
|
amount_value:item.amount,
|
|
|
residual_value:item.amount - pagado,
|
|
|
});
|
|
|
+ item.residual = item.amount - pagado;
|
|
|
}
|
|
|
});
|
|
|
data.sort(function (a, b) {
|
|
@@ -330,20 +338,22 @@ function report_amortization_and_interest(reporting){
|
|
|
|
|
|
columns.push({
|
|
|
field:'description',
|
|
|
- title:'Descripcion',
|
|
|
+ title:'Descripción',
|
|
|
align:'center',
|
|
|
+ with:'8%',
|
|
|
footerFormatter:'Totales'
|
|
|
});
|
|
|
|
|
|
columns.push({
|
|
|
field:'date_maturity',
|
|
|
title:'Vencimiento',
|
|
|
+ with:'8%',
|
|
|
align:'center',
|
|
|
});
|
|
|
|
|
|
columns.push({
|
|
|
field:'capital_residual',
|
|
|
- title:'Saldo del Prestamo',
|
|
|
+ title:'Amortización',
|
|
|
align:'right',
|
|
|
with:'12%',
|
|
|
footerFormatter:'0'
|
|
@@ -359,7 +369,7 @@ function report_amortization_and_interest(reporting){
|
|
|
|
|
|
columns.push({
|
|
|
field:'capital_amount',
|
|
|
- title:'Amortizacion',
|
|
|
+ title:'Capital',
|
|
|
align:'right',
|
|
|
with:'12%',
|
|
|
footerFormatter:'CapitalAmountFormatter'
|
|
@@ -391,7 +401,7 @@ function report_amortization_and_interest(reporting){
|
|
|
|
|
|
columns.push({
|
|
|
field:'capital_receive',
|
|
|
- title:'Capital Recuperado',
|
|
|
+ title:'Capital Cobrado',
|
|
|
align:'right',
|
|
|
with:'12%',
|
|
|
footerFormatter:'CapitalReceiveFormatter'
|
|
@@ -424,42 +434,36 @@ function report_amortization_and_interest(reporting){
|
|
|
}), function (memo, num) {
|
|
|
return memo + num;
|
|
|
});
|
|
|
-
|
|
|
- var interest_amount = interes / cant_cuota;
|
|
|
- var capital_amount = amortizacion / cant_cuota;
|
|
|
+ var interest_amount = 0;
|
|
|
+ var capital_amount = 0;
|
|
|
var capital_receive = 0;
|
|
|
var interest_receive = 0;
|
|
|
var razon_capital = (capital - interes) / capital;
|
|
|
var razon_interes = interes / capital;
|
|
|
+ var band = true;
|
|
|
+ var residual = 0;
|
|
|
_.each(AccountMoveLine,function(item) {
|
|
|
if(item.number == number){
|
|
|
capital_receive = 0;
|
|
|
interest_receive = 0;
|
|
|
if(item.debit > 0 && item.date_maturity != false){
|
|
|
if(item.reconcile_partial_id == null){
|
|
|
- var residual = item.debit;
|
|
|
+ residual = item.debit;
|
|
|
}else{
|
|
|
- var pagado = self.getAccountVoucher(item.number);
|
|
|
- var x = 0;
|
|
|
- var band = true;
|
|
|
- _.each(AccountMoveLine,function(i) {
|
|
|
- x += i.debit;
|
|
|
- var saldo = Math.abs(pagado - x);
|
|
|
- if(AccountMoveLine.length == 1){
|
|
|
- residual = saldo;
|
|
|
- band = false;
|
|
|
- }
|
|
|
- if(saldo < i.debit && band == true){
|
|
|
- residual = i.debit - saldo;
|
|
|
- if((razon_interes * item.debit) >= saldo){
|
|
|
- interest_receive = saldo;
|
|
|
- }else{
|
|
|
- interest_receive = razon_interes * item.debit;
|
|
|
- capital_receive = saldo - (razon_interes * item.debit);
|
|
|
- }
|
|
|
- band = false;
|
|
|
- }
|
|
|
+ var reconcile = self.getAccountMoveLinePartialReconcile(item.reconcile_partial_id);
|
|
|
+ reconcile = _.reduce(_.map(reconcile, function (map) {
|
|
|
+ return map.amount;
|
|
|
+ }), function (memo, num) {
|
|
|
+ return memo + num;
|
|
|
});
|
|
|
+
|
|
|
+ residual = item.debit - reconcile;
|
|
|
+ if((razon_interes * item.debit) >= reconcile){
|
|
|
+ interest_receive = reconcile;
|
|
|
+ }else{
|
|
|
+ interest_receive = razon_interes * item.debit;
|
|
|
+ capital_receive = reconcile - (razon_interes * item.debit);
|
|
|
+ }
|
|
|
}
|
|
|
if(item.reconcile_id != null){
|
|
|
residual = 0;
|
|
@@ -655,12 +659,5 @@ function report_amortization_and_interest(reporting){
|
|
|
}
|
|
|
return filter;
|
|
|
},
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
});
|
|
|
}
|