|  | @@ -5,12 +5,12 @@ function expired_account_counters_now (widget) {
 | 
	
		
			
				|  |  |      var Qweb = openerp.web.qweb;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      widget.ExpiredAccountCountersNowWidget = widget.Base.extend({
 | 
	
		
			
				|  |  | -        template : 'ExpiredAccountCountersNow',
 | 
	
		
			
				|  |  | -        moveLine : [],
 | 
	
		
			
				|  |  | -        resCompany : [],
 | 
	
		
			
				|  |  | -        resCompany : [],
 | 
	
		
			
				|  |  | -        modelId : [],
 | 
	
		
			
				|  |  | -        accountInvoice : [],
 | 
	
		
			
				|  |  | +        template: 'ExpiredAccountCountersNow',
 | 
	
		
			
				|  |  | +        moveLine: [],
 | 
	
		
			
				|  |  | +        resCompany: [],
 | 
	
		
			
				|  |  | +        resCompany: [],
 | 
	
		
			
				|  |  | +        modelId: [],
 | 
	
		
			
				|  |  | +        accountInvoice: [],
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          events: {
 | 
	
		
			
				|  |  |              'click a': 'showCustomers',
 | 
	
	
		
			
				|  | @@ -18,7 +18,7 @@ function expired_account_counters_now (widget) {
 | 
	
		
			
				|  |  |          },
 | 
	
		
			
				|  |  |          init: function (parent) {
 | 
	
		
			
				|  |  |              this._super(parent, {
 | 
	
		
			
				|  |  | -                width : 3,
 | 
	
		
			
				|  |  | +                width: 3,
 | 
	
		
			
				|  |  |                  height: 2
 | 
	
		
			
				|  |  |              });
 | 
	
		
			
				|  |  |          },
 | 
	
	
		
			
				|  | @@ -36,34 +36,35 @@ function expired_account_counters_now (widget) {
 | 
	
		
			
				|  |  |              });
 | 
	
		
			
				|  |  |              self.$el.find('.widget-content.widget-loading').css('display','flex');
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            self.fetchMoveLine().then(function(moveLine){
 | 
	
		
			
				|  |  | +            self.fetchMoveLine().then(function(moveLine) {
 | 
	
		
			
				|  |  |                  return moveLine;
 | 
	
		
			
				|  |  | -            }).then(function(moveLine){
 | 
	
		
			
				|  |  | -                self.moveLine= moveLine;
 | 
	
		
			
				|  |  | -                // console.log(moveLine);
 | 
	
		
			
				|  |  | +            }).then(function(moveLine) {
 | 
	
		
			
				|  |  | +                self.moveLine= _.filter(moveLine, function(item) {
 | 
	
		
			
				|  |  | +                    return item.amount_residual  > 0
 | 
	
		
			
				|  |  | +                });
 | 
	
		
			
				|  |  |                  return self.fetchInvoice(moveLine);
 | 
	
		
			
				|  |  | -            }).then(function(accountInvoice){
 | 
	
		
			
				|  |  | +            }).then(function(accountInvoice) {
 | 
	
		
			
				|  |  |                  self.accountInvoice = accountInvoice
 | 
	
		
			
				|  |  |                  return self.fetchResCompany();
 | 
	
		
			
				|  |  | -            }).then(function(resCompany){
 | 
	
		
			
				|  |  | +            }).then(function(resCompany) {
 | 
	
		
			
				|  |  |                  self.resCompany=resCompany;
 | 
	
		
			
				|  |  |                  return self.fetchResCurrecy();
 | 
	
		
			
				|  |  | -            }).then(function(resCurrecy){
 | 
	
		
			
				|  |  | +            }).then(function(resCurrecy) {
 | 
	
		
			
				|  |  |                  self.resCurrecy= resCurrecy;
 | 
	
		
			
				|  |  |                  return self.fetchGetModelId();
 | 
	
		
			
				|  |  | -            }).then(function(modelId){
 | 
	
		
			
				|  |  | +            }).then(function(modelId) {
 | 
	
		
			
				|  |  |                  self.modelId = modelId;
 | 
	
		
			
				|  |  |                  return self.fetchReduceMoveLine();
 | 
	
		
			
				|  |  |              });
 | 
	
		
			
				|  |  |          },
 | 
	
		
			
				|  |  |          // getModelId
 | 
	
		
			
				|  |  | -        fetchGetModelId: function(){
 | 
	
		
			
				|  |  | +        fetchGetModelId: function() {
 | 
	
		
			
				|  |  |              var self = this;
 | 
	
		
			
				|  |  |              var defer = $.Deferred();
 | 
	
		
			
				|  |  |              var irModelData = new model.web.Model('ir.model.data');
 | 
	
		
			
				|  |  |              var getObtjectReference = irModelData.get_func('get_object_reference');
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            this.alive(getObtjectReference('account', 'invoice_form')).then(function(results){
 | 
	
		
			
				|  |  | +            this.alive(getObtjectReference('account', 'invoice_form')).then(function(results) {
 | 
	
		
			
				|  |  |                  defer.resolve(results);
 | 
	
		
			
				|  |  |              });
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -72,7 +73,7 @@ function expired_account_counters_now (widget) {
 | 
	
		
			
				|  |  |          // Move line
 | 
	
		
			
				|  |  |          fetchMoveLine: function () {
 | 
	
		
			
				|  |  |              var self = this;
 | 
	
		
			
				|  |  | -            var hoy =moment().format('YYYY-MM-DD');
 | 
	
		
			
				|  |  | +            var hoy = moment().format('YYYY-MM-DD');
 | 
	
		
			
				|  |  |              var defer = $.Deferred();
 | 
	
		
			
				|  |  |              var field = ['id', 'partner_id', 'amount_residual', 'credit', 'debit', 'date_maturity', 'invoice','ref', 'invoice', 'amount_residual_currency', 'currency_id'];
 | 
	
		
			
				|  |  |              var domain = [['credit', '<=', 0], ['date_maturity', '=', hoy]];
 | 
	
	
		
			
				|  | @@ -85,7 +86,7 @@ function expired_account_counters_now (widget) {
 | 
	
		
			
				|  |  |              return defer;
 | 
	
		
			
				|  |  |          },
 | 
	
		
			
				|  |  |          // invoice
 | 
	
		
			
				|  |  | -        fetchInvoice: function(moveline){
 | 
	
		
			
				|  |  | +        fetchInvoice: function(moveline) {
 | 
	
		
			
				|  |  |              var self = this ;
 | 
	
		
			
				|  |  |              var defer = $.Deferred()
 | 
	
		
			
				|  |  |              var ref = _.map(moveline, function(map) {
 | 
	
	
		
			
				|  | @@ -104,8 +105,8 @@ function expired_account_counters_now (widget) {
 | 
	
		
			
				|  |  |          fetchResCompany: function () {
 | 
	
		
			
				|  |  |              var self = this;
 | 
	
		
			
				|  |  |              var defer = $.Deferred();
 | 
	
		
			
				|  |  | -            var fields =['id','name', 'currency_id','logo'];
 | 
	
		
			
				|  |  | -            var domain =[['id', '=', 1]];
 | 
	
		
			
				|  |  | +            var fields = ['id','name', 'currency_id','logo'];
 | 
	
		
			
				|  |  | +            var domain = [['id', '=', 1]];
 | 
	
		
			
				|  |  |              var resComapy = new model.web.Model('res.company');
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              resComapy.query(fields).filter(domain).all().then(function (results) {
 | 
	
	
		
			
				|  | @@ -115,14 +116,14 @@ function expired_account_counters_now (widget) {
 | 
	
		
			
				|  |  |              return defer ;
 | 
	
		
			
				|  |  |          } ,
 | 
	
		
			
				|  |  |          // Res currecy
 | 
	
		
			
				|  |  | -        fetchResCurrecy : function(){
 | 
	
		
			
				|  |  | +        fetchResCurrecy : function() {
 | 
	
		
			
				|  |  |              var self = this;
 | 
	
		
			
				|  |  |              var defer = $.Deferred();
 | 
	
		
			
				|  |  | -            var fields =['id','name', 'symbol', 'rate_silent', 'base', 'decimal_separator', 'decimal_places', 'thousands_separator', 'symbol_position'];
 | 
	
		
			
				|  |  | -            var domain =[['active','=', true]];
 | 
	
		
			
				|  |  | +            var fields = ['id','name', 'symbol', 'rate_silent', 'base', 'decimal_separator', 'decimal_places', 'thousands_separator', 'symbol_position'];
 | 
	
		
			
				|  |  | +            var domain = [['active','=', true]];
 | 
	
		
			
				|  |  |              var resCurrecy = new model.web.Model('res.currency');
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            resCurrecy.query(fields).filter(domain).all().then(function(results){
 | 
	
		
			
				|  |  | +            resCurrecy.query(fields).filter(domain).all().then(function(results) {
 | 
	
		
			
				|  |  |                  defer.resolve(results);
 | 
	
		
			
				|  |  |              });
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -133,7 +134,7 @@ function expired_account_counters_now (widget) {
 | 
	
		
			
				|  |  |              var self = this;
 | 
	
		
			
				|  |  |              var newmoveLine = [];
 | 
	
		
			
				|  |  |              var inteMove;
 | 
	
		
			
				|  |  | -            var residual =0;
 | 
	
		
			
				|  |  | +            var residual = 0;
 | 
	
		
			
				|  |  |              var currencyInvoice;
 | 
	
		
			
				|  |  |              var company = self.resCompany.shift();
 | 
	
		
			
				|  |  |              var currencyBase = self.getCurrency(company.currency_id[0]).shift();
 | 
	
	
		
			
				|  | @@ -143,18 +144,18 @@ function expired_account_counters_now (widget) {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  currencyInvoice = self.getInvoiceCurrency(inteMove.invoice[0]).shift();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                if(!currencyInvoice){
 | 
	
		
			
				|  |  | +                if(!currencyInvoice) {
 | 
	
		
			
				|  |  |                      currencyInvoice = {};
 | 
	
		
			
				|  |  |                      currencyInvoice.rate=currencyBase.rate_silent;
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  newmoveLine.push({
 | 
	
		
			
				|  |  | -                    amount_residual : inteMove.amount_residual,
 | 
	
		
			
				|  |  | -                    amount_residual_currency :(inteMove.amount_residual_currency * (currencyBase.rate_silent / currencyInvoice.rate_silent))
 | 
	
		
			
				|  |  | +                    amount_residual: inteMove.amount_residual,
 | 
	
		
			
				|  |  | +                    amount_residual_currency: (inteMove.amount_residual_currency * (currencyBase.rate_silent / currencyInvoice.rate_silent))
 | 
	
		
			
				|  |  |                  });
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            if (newmoveLine.length > 0){
 | 
	
		
			
				|  |  | +            if (newmoveLine.length > 0) {
 | 
	
		
			
				|  |  |                  residual = _.reduce(_.map(newmoveLine, function (map) {
 | 
	
		
			
				|  |  |                      return map.amount_residual_currency;
 | 
	
		
			
				|  |  |                  }), function (memo, num) {
 | 
	
	
		
			
				|  | @@ -189,35 +190,35 @@ function expired_account_counters_now (widget) {
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              var moneda = self.resCurrecy.shift();
 | 
	
		
			
				|  |  | -            var newmoveLine=[];
 | 
	
		
			
				|  |  | +            var newmoveLine = [];
 | 
	
		
			
				|  |  |              newmoveLine = self.moveLine;
 | 
	
		
			
				|  |  | -            var titleData=[
 | 
	
		
			
				|  |  | +            var titleData = [
 | 
	
		
			
				|  |  |                  {
 | 
	
		
			
				|  |  | -                    title:"Deudas con vencimiento en el día de hoy"
 | 
	
		
			
				|  |  | +                    title: "Deudas con vencimiento en el día de hoy"
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              ];
 | 
	
		
			
				|  |  | -            var headerModal=[
 | 
	
		
			
				|  |  | +            var headerModal = [
 | 
	
		
			
				|  |  |                  {
 | 
	
		
			
				|  |  | -                    title:"id"
 | 
	
		
			
				|  |  | +                    title: "id"
 | 
	
		
			
				|  |  |                  },
 | 
	
		
			
				|  |  |                  {
 | 
	
		
			
				|  |  | -                    title:"Cliente"
 | 
	
		
			
				|  |  | +                    title: "Cliente"
 | 
	
		
			
				|  |  |                  },
 | 
	
		
			
				|  |  |                  {
 | 
	
		
			
				|  |  | -                    title:"Numero de Factura"
 | 
	
		
			
				|  |  | +                    title: "Numero de Factura"
 | 
	
		
			
				|  |  |                  },
 | 
	
		
			
				|  |  |                  {
 | 
	
		
			
				|  |  | -                    title:"Vencimiento"
 | 
	
		
			
				|  |  | +                    title: "Vencimiento"
 | 
	
		
			
				|  |  |                  },
 | 
	
		
			
				|  |  |                  {
 | 
	
		
			
				|  |  | -                    title:"Monto "
 | 
	
		
			
				|  |  | +                    title: "Monto "
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              ];
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              var modal = Qweb.render('ExpiredAccountCountersModal', {
 | 
	
		
			
				|  |  | -                data : newmoveLine,
 | 
	
		
			
				|  |  | -                dataThead : headerModal,
 | 
	
		
			
				|  |  | -                modalTitle :titleData
 | 
	
		
			
				|  |  | +                data: newmoveLine,
 | 
	
		
			
				|  |  | +                dataThead: headerModal,
 | 
	
		
			
				|  |  | +                modalTitle: titleData
 | 
	
		
			
				|  |  |              });
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              $('.openerp_webclient_container').after(modal);
 | 
	
	
		
			
				|  | @@ -240,19 +241,19 @@ function expired_account_counters_now (widget) {
 | 
	
		
			
				|  |  |              $('.modal-backdrop').remove();
 | 
	
		
			
				|  |  |          },
 | 
	
		
			
				|  |  |          // Llamar form
 | 
	
		
			
				|  |  | -        renderForm: function(id){
 | 
	
		
			
				|  |  | -            var self= this;
 | 
	
		
			
				|  |  | +        renderForm: function(id) {
 | 
	
		
			
				|  |  | +            var self = this;
 | 
	
		
			
				|  |  |              id = parseInt(id);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              this.do_action({
 | 
	
		
			
				|  |  | -                type : "ir.actions.act_window",
 | 
	
		
			
				|  |  | -                res_model : "account.invoice",
 | 
	
		
			
				|  |  | -                views : [[self.modelId[1], 'form']],
 | 
	
		
			
				|  |  | -                target : 'current',
 | 
	
		
			
				|  |  | -                domain : [['id', '=', id]],
 | 
	
		
			
				|  |  | -                context : {},
 | 
	
		
			
				|  |  | -                res_id : id,
 | 
	
		
			
				|  |  | -            }).then(function(){
 | 
	
		
			
				|  |  | +                type: "ir.actions.act_window",
 | 
	
		
			
				|  |  | +                res_model: "account.invoice",
 | 
	
		
			
				|  |  | +                views: [[self.modelId[1], 'form']],
 | 
	
		
			
				|  |  | +                target: 'current',
 | 
	
		
			
				|  |  | +                domain: [['id', '=', id]],
 | 
	
		
			
				|  |  | +                context: {},
 | 
	
		
			
				|  |  | +                res_id: id,
 | 
	
		
			
				|  |  | +            }).then(function() {
 | 
	
		
			
				|  |  |                  self.removeModal();
 | 
	
		
			
				|  |  |              });
 | 
	
		
			
				|  |  |          }
 |