Przeglądaj źródła

FIX ADD Informes positiva

Sebas 6 lat temu
rodzic
commit
209328064c

+ 11 - 0
static/src/js/reports/report_sale_cab.js

@@ -456,6 +456,17 @@ function report_sale_cab(reporting){
                     });
                 }
             });
+
+            data.sort(function (a, b) {
+                 if (a.date > b.date) {
+                     return -1;
+                 }
+                 if (a.date < b.date) {
+                     return 1;
+                 }
+                 return 0;
+             });
+
             self.content = data;
             this.loadTable(data);
         },

+ 267 - 304
static/src/js/reports/report_sale_vendor (copia).js

@@ -6,9 +6,11 @@ function report_sale_vendor (reporting){
         template :'ReportSaleVendor',
         accountVoucher:[],
         resCurrency:[],
-        accountJournal:[],
+        invoices:[],
+        Journal:[],
         dataVoucher:[],
-        currencyRate:[],
+        rowsData :[],
+        content :[],
         resCompany:[],
         modules:[],
 
@@ -27,19 +29,28 @@ function report_sale_vendor (reporting){
             'change #current-currency': 'fectSearch',
             'change #from' : 'fectSearch',
             'change #to': 'fectSearch',
-            'click #volver_btn': 'volver',
         },
 
-        init:function(parent){
+        init : function(parent){
             this._super(parent);
         },
-        start: function(){
+
+        start: function () {
             var self = this;
             var table = this.$el.find('#table');
             table.bootstrapTable({data : self.dataVoucher});
-            self.fecthFecha();
-            self.fecthInitial();
+            this.fecthFecha();
+            this.fetchInitial();
         },
+
+        valorNull:function(dato){
+            var valor = "";
+            if (dato){
+                valor = dato;
+            }
+            return valor;
+        },
+
         // Redirecionar
         renderReport: function () {
             var self = this;
@@ -51,78 +62,59 @@ function report_sale_vendor (reporting){
                 duration: 200,
             });
         },
-        // Verificar el modelo
+
         checkModel : function(model){
             var self = this;
-            return _.filter(self.modules,function(item){return item.name === model});
-        },
-        // Lanzar el mensaje
-        showMensaje : function(modelos){
-            var self = this;
-            $("#dialog" ).dialog({
-                autoOpen: true,
-                resizable: false,
-                modal: true,
-                title: 'Atención',
-                width: 500,
-                open: function() {
-                    $(this).html('Reporte in-disponible, contacte con el administrador del sistema ref : '+modelos);
-                },
-                show: {
-                    effect: "fade",
-                    duration: 200
-                },
-                hide: {
-                    effect: "fade",
-                    duration: 200
-                },
-                buttons: {
-                    Aceptar: function() {
-                        $(this).dialog('close');
-                        self.renderReport()
-                    }
-                }
+            return _.filter(self.IrModuleModule,function(item){
+                return item.name === model
             });
-            return
         },
 
-        //  Metodo inicial
-        fecthInitial: function(){
+        fetchInitial: function () {
             var self = this;
-            self.fecthIrModuleModule().then(function(modules){
-                self.modules = modules;
-                return modules;
-            }).then(function(modules){
-                return self.fecthJournalStore();
-            }).then(function(accountJournal){
-                self.accountJournal=accountJournal;
-                self.$el.find('#current-journal').append('<option value="9999999">Todas las SUC.</option>');
-                _.each(accountJournal,function(item){
+            self.fecthIrModuleModule().then(function (IrModuleModule) {
+                return IrModuleModule;
+            }).then(function(IrModuleModule) {
+                self.IrModuleModule = IrModuleModule;
+                return self.fetchResUser();
+            }).then(function (ResUser) {
+                self.ResUser = ResUser;
+                return self.fetchResCompany();
+            }).then(function(ResCompany){
+                self.ResCompany = ResCompany;
+                if(ResCompany.length > 1){
+                    self.$el.find('#current-company').append('<option value="9999999">Todas las empresas</option>');
+                    _.each(ResCompany,function(item){
+                        self.$el.find('#current-company').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    });
+                }else{
+                    self.$el.find('.company').css('display','none');
+                }
+                return self.fetchResStore();
+            }).then(function(ResStore){
+                self.ResStore = ResStore;
+                if(ResStore.length > 1){
+                    self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</option>');
+                    _.each(ResStore,function(item){
+                        self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    });
+                }else{
+                    self.$el.find('.store').css('display','none');
+                }
+                return self.fetchAccountJournal();
+            }).then(function(AccountJournal){
+                self.AccountJournal = AccountJournal;
+                self.$el.find('#current-journal').append('<option value="9999999">Todas las facturas</option>');
+                _.each(AccountJournal,function(item){
                     self.$el.find('#current-journal').append('<option value="' + item.id + '">' + item.name + '</option>');
                 });
                 return self.fetchResCurrency();
-             }).then(function(ResCurrency){
+            }).then(function(ResCurrency){
                 self.ResCurrency = ResCurrency;
-                return self.fecthCompanyCurrency();
-            }).then(function(ResCompany){
-                self.ResCompany = ResCompany;
-                return self.fecthCurrencyRate();
-            }).then(function(currencyRate){
-                self.currencyRate =currencyRate;
-                return self.fecthVoucher();
-            }).then(function(accountVoucher){
-                self.accountVoucher=accountVoucher;
-                return self.fetchInvoiceV2();
-            }).then(function (invoices){
-               self.invoices = invoices;
-                return self.fetchWarehouse();
-            }).then(function(WareHouse){
-                self.WareHouse=WareHouse;
-                self.$el.find('#current-warehouse').append('<option value="9999999">Todos los vendedores</option>');
-                _.each(WareHouse,function(item){
-                    self.$el.find('#current-warehouse').append('<option value="' + item.id + '">' + item.name + '</option>');
-                });
-                return self.fecthDataVoucher(self.accountVoucher,self.accountJournal);
+                return self.fetchAccountInvoice();
+            }).then(function (AccountInvoice) {
+                self.AccountInvoice = AccountInvoice;
+                return self.BuildTable(self.AccountInvoice,self.ResStore);
             });
         },
 
@@ -167,34 +159,51 @@ function report_sale_vendor (reporting){
             var defer = $.Deferred();
             var fields = ['name','id'];
             var domain=[['state','=','installed']];
-            var irModule = new instance.web.Model('ir.module.module');
+            var IrModuleModule = new instance.web.Model('ir.module.module');
 
-            irModule.query(fields).filter(domain).all().then(function(results){
+            IrModuleModule.query(fields).filter(domain).all().then(function(results){
                 defer.resolve(results);
             });
             return defer;
         },
-        // Journal
-        fecthJournalStore: function(){
+
+        fetchResUser: function() {
             var self = this;
             var defer = $.Deferred();
-            var modules = _.flatten(self.checkModel('multi_store'));
-
-            if (modules.length <= 0){
-                self.showMensaje('multi_store');
-                return defer;
-            }
+            var fields = ['id','name','store_id'];
+            var domain = [['id','=',self.session.uid]];
+            var ResUser = new instance.web.Model('res.users');
+            ResUser.query(fields).filter(domain).all().then(function (results) {
+                defer.resolve(results);
+            });
+            return defer;
+        },
 
-            var journal = new instance.web.Model('res.store');
+        fetchResStore: function(){
+            var self = this;
+            var defer = $.Deferred();
             var field=['id', 'name','journal_ids'];
+            var ResStore = new instance.web.Model('res.store');
+            ResStore.query(field).all().then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
 
-            journal.query(field).order_by('id').all().then(function(results){
+        fetchAccountJournal: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var field = ['id', 'name','store_ids','type'];
+            var domain = [['active','=',true],['type', '=', 'sale']];
+            var AccountJournal = new instance.web.Model('account.journal');
+            AccountJournal.query(field).filter(domain).all().then(function(results){
                 defer.resolve(results);
             });
             return defer;
         },
+
         // company_curency
-        fecthCompanyCurrency: function(){
+        fetchResCompany: function(){
             var self = this;
             var defer = $.Deferred();
             var field=['id','name', 'currency_id', 'vat'];
@@ -205,7 +214,6 @@ function report_sale_vendor (reporting){
             });
             return defer;
         },
-        // Moneda
         fetchResCurrency:function(){
             var self = this;
             var defer = $.Deferred();
@@ -217,82 +225,20 @@ function report_sale_vendor (reporting){
             });
             return defer;
         },
-        // Cambio de la moneda
-        fecthCurrencyRate:function(){
-            var defer = $.Deferred();
-            var currency_Rate = new instance.web.Model('res.currency.rate');
-            var fields = ['id', 'name', 'currency_id', 'rate', 'create_date'];
-            var domain = [['currency_id', 'in', [166 , 20, 7, 3]]];
-            currency_Rate.query(fields).filter(domain).all().then(function (results) {
-              defer.resolve(results);
-            });
-            return defer;
-        },
-        // Invoice (FACTURAS)
-        fetchInvoiceV2: function () {
-            var self = this;
-            var filter ="[['state', 'in',['open','paid']],['type', '=', 'out_invoice']";
-            var journal_ids = _.flatten(_.map(self.AccountJournal, function (item) {
-                return item.id;
-            }));
-            if (journal_ids){
-                filter=filter.concat(",['journal_id', 'in',["+journal_ids+"]]");
-            }
-            filter=filter.concat("]");
-            var field =['id', 'type', 'number', 'origin', 'reference', 'state', 'journal_id', 'currency_id', 'user_id','date_invoice','amount_total','amount_tax','amount_untaxed','partner_id'];
-            var defer = $.Deferred();
-            var invoices = new instance.web.Model('account.invoice');
-            invoices.query(field).filter(filter).all().then(function (results) {
-                defer.resolve(results);
-            });
-            return defer;
-        },
 
-        // Voucher -
-        fecthVoucher: function () {
-             var self = this;
-             var defer = $.Deferred();
-             var voucher = new instance.web.Model('sale.order');
-             var filter = [['state', 'in', ['progress','done']],['shipped', '=', true]];
-             // var warehouse_ids = _.flatten(_.map(self.WareHouse, function (item) {
-             //     return item.id;
-             // }));
-             // if (warehouse_ids){
-             //     filter=filter.concat(",['warehouse_id', 'in',["+ warehouse_ids+"]]");
-             // }
-             // filter=filter.concat("]");
-             var field =['id', 'number', 'name','origin', 'state', 'type_id', 'warehouse_id', 'currency_id', 'amount_total', 'date_order', 'shipped'];
-             voucher.query(field).filter(filter).all().then(function (results) {
-                 defer.resolve(results);
-             });
-             return defer;
-         },
-
-        fetchWarehouse: function(){
+        fetchAccountInvoice: function () {
             var self = this;
             var defer = $.Deferred();
-            var field=['id', 'name'];
-            var WareHouse = new instance.web.Model('stock.warehouse');
-            WareHouse.query(field).all().then(function(results){
+            var AccountInvoice = new instance.web.Model('account.invoice');
+            var filter =[['state', 'in',['open','paid']],['type', '=', 'out_invoice']];
+
+            var fields =['id', 'type', 'number', 'origin', 'reference', 'state', 'journal_id', 'currency_id', 'user_id','date_invoice','amount_total','amount_tax','amount_untaxed','partner_id'];
+
+            AccountInvoice.query(fields).filter(filter).all().then(function (results) {
                 defer.resolve(results);
             });
             return defer;
-         },
-
-         getResCurrency: function (id) {
-             var self = this;
-             return _.filter(self.ResCurrency,function (item) {
-                 return item.id === id;
-             })
-         },
-
-         getSaleOrder: function (id) {
-             var self = this;
-             return _.filter(self.accountVoucher,function (item) {
-                 return item.number === id;
-             });
-         },
-
+        },
         // Verificar Valor null
         valorNull:function(dato){
             var valor ="";
@@ -302,110 +248,135 @@ function report_sale_vendor (reporting){
             return valor;
         },
 
+        getAccountInvoice: function (id) {
+            var self = this;
+            return _.filter(self.AccountInvoice,function (item) {
+                return item.journal_id[0] === id;
+            });
+        },
+
+        getStore: function (id) {
+            var self = this;
+            return _.filter(self.ResStore,function (item) {
+                return item.id === id;
+            });
+        },
+
+        getResCurrency: function (id) {
+            var self = this;
+            return _.filter(self.ResCurrency,function (item) {
+                return item.id === id;
+            })
+        },
+
         // Join object
-        fecthDataVoucher:function(objVoucher,objJournal){
+        BuildTable:function(objVoucher,objJournal){
             var self=this;
             var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
             var item;
-            var journal;
+            //var journal=self.AccountJournal;
+
+            var company = $('#current-company').val();
+            if(company && company != 9999999){
+                var ResCompany = self.getResCompany(company).shift();
+                var CurrencyBase = self.getResCurrency(ResCompany.currency_id[0]).shift();
+            }else{
+                var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
+            };
             var voucherLine;
             var voucherItem;//Contenido del voucher
             var sumaAmount; //Guardar la suma de los pagos
             var voucherObject=[];
+            var invoice=[];
+            var cabjournal;
             var voucherObjectItem=[];
-            var sale = [];
-            var cutrrencyRate; //Valor del cambio
+            var currency;
+            var store;
+            var store_id="";
+            var store_name="";
             var total=0;
             var sumaAmountTot=0;
             var  itemVoucher;
+            var  itemjournal;
 
             for (var i = 0; i < objJournal.length; i++) {
+
                 voucherObjectItem=[];
-                journal=objJournal[i];
+                cabjournal=objJournal[i];
+
+                for (var f = 0; f < cabjournal.journal_ids.length; f++) { //este
+                    voucherLine = cabjournal.journal_ids[f];
 
-                for (var f = 0; f < journal.journal_ids.length; f++) {
-                    voucherLine = journal.journal_ids[f];
                     voucherItem = self.getVoucherjournal(objVoucher,voucherLine)
 
-                    // sale = self.getSaleOrder(voucherItem.name);
-                    // console.log(sale);
+                    // invoice = self.getAccountInvoice(cabjournal.id);
 
                     if (voucherItem.length > 0){
-                         sumaAmount=_.reduce(_.map(voucherItem,function(item){return item.amount_total}), function(memo, num){ return memo + num; },0);
-                         itemVoucher = voucherItem.shift();
-                         var currency = self.getResCurrency(itemVoucher.currency_id[0]).shift();
-
-                         // Guardar item
-                         voucherObjectItem.push({journal : " ",
-                                 method  :self.valorNull(itemVoucher.warehouse_id[1]),
-                                 amount  : accounting.formatNumber(self.valorNull(sumaAmount * (CurrencyBase.rate_silent/currency.rate_silent)),0, ".", ","),
-                                 currency_name : self.valorNull(itemVoucher.currency_id[0]),
-                                 currency_id : self.valorNull(itemVoucher.currency_id[1]),
-                                 amountBase : self.valorNull(sumaAmount * (CurrencyBase.rate_silent/currency.rate_silent)),
-                                 journal_id: journal.id,
-                                 journal_name: journal.name,
-                                 warehouse_id: itemVoucher.warehouse_id[0],
-                                 graficar: false
-                         })
-                     }
-                 }
-                 if (voucherObjectItem.length > 0){
-                     var company = _.map(self.ResCompany, function (map) {
-                         return map.currency_id[1];
-                     });
-
-                     sumaAmountTot=_.reduce(_.map(voucherObjectItem,function(item){return (item.amountBase)}), function(memo, num){ return memo + num; },0);
-                     total=total+sumaAmountTot;
-                     voucherObjectItem.push({journal : " ",
-                         method  :"Total " + company,
-                         amount  : accounting.formatNumber(self.valorNull(sumaAmountTot),0, ".", ","),
-                         currency_name : "",
-                         currency_id : "",
-                         rate : "cutrrencyRate.rate",
-                         amountBase:"",
-                         journal_id: journal.id,
-                         journal_name: journal.name,
-                         graficar: true
-                     });
-
-                    // General la Cabezera
-                    voucherObjectItem.unshift({ journal : journal.name, method  :"", amount  :"", voucherLine_name :"", voucherLine_id :"",rate :"",amountBase :"", warehouse_id:"",journal_id:journal.id, journal_name:journal.name, graficar:false});
+                        sumaAmount=_.reduce(_.map(voucherItem,function(item){return item.amount_total}), function(memo, num){ return memo + num; },0);
+
+                        itemVoucher = voucherItem.shift();
+                        var currency = self.getResCurrency(itemVoucher.currency_id[0]).shift();
+
+                        // Guardar item
+                        voucherObjectItem.push({    journal : " ",
+                                                method  :self.valorNull(itemVoucher.journal_id[1]),
+                                                amount  : accounting.formatNumber(self.valorNull(sumaAmount* (CurrencyBase.rate_silent/currency.rate_silent)),0, ".", ","),
+                                                amountBase : self.valorNull(sumaAmount* (CurrencyBase.rate_silent/currency.rate_silent)),
+                                                journal_id: cabjournal.id,
+                                                journal_name: cabjournal.name,
+                                                graficar: false
+                        })
+                    }
+                }
+                if (voucherObjectItem.length > 0){
+                    var company = _.map(self.ResCompany, function (map) {
+                        return map.currency_id[1];
+                    });
+
+                    sumaAmountTot=_.reduce(_.map(voucherObjectItem,function(item){return (item.amountBase)}), function(memo, num){ return memo + num; },0);
+                    total=total+sumaAmountTot;
+                    voucherObjectItem.push({journal : " ",
+                                            method  :"Total "+ company,
+                                            amount  : accounting.formatNumber(self.valorNull(sumaAmountTot),0, ".", ","),
+                                            amountBase:"",
+                                            journal_id: cabjournal.id,
+                                            journal_name: cabjournal.name,
+                                            graficar: true
+                                    });
+                    // Generar la Cabecera
+                    voucherObjectItem.unshift({ journal : cabjournal.name, method  :"", amount  :"", voucherLine_name :"", voucherLine_id :"",rate :"",amountBase :"",journal_id:cabjournal.id, journal_name:cabjournal.name, graficar:false});
                     // Generar Objeto Principal
                     voucherObject=voucherObject.concat(voucherObjectItem);
                 }
             }
-            if (voucherObject.length >0){
-                voucherObject.push({journal : " Total de Egreso",
-                    method  :"",
-                    amount  : accounting.formatNumber(self.valorNull(total),0, ".", ","),
-                    currency_name : "",
-                    currency_id : "",
-                    rate : "",
-                    amountBase:"",
-                    journal_id: journal.id,
-                    journal_name: journal.name,
-                    warehouse_id:"",
-                    graficar: false
-                });
+            if (voucherObject.length > 0){
+                voucherObject.push({journal : " Total de Ingreso",
+                                        method  :"",
+                                        amount  : accounting.formatNumber(self.valorNull(total),0, ".", ","),
+                                        amountBase:"",
+                                        journal_id: cabjournal.id,
+                                        journal_name: cabjournal.name,
+                                        graficar: false
+                                });
             }
+            // voucherObjectItem.sort(function (a, b) {
+            //     return b.amountBase - a.amountBase
+            // });
             self.loadTable(voucherObject);
-            self.content = voucherObject;
         },
+
         // Obtener Voucher
         getVoucherjournal:function(objVoucher,journal_id){
-            return _.map(_.filter(objVoucher, function (inv){return inv.warehouse_id[0] === journal_id}),function(item){return item});
+            return _.map(_.filter(objVoucher, function (inv){return inv.journal_id[0] === journal_id}),function(item){return item});
         },
-        // Obtener Cambio
-        // getCutrrencyRate: function(currency_id){
-        //     return _.filter(this.currencyRate, function(rate){return rate.currency_id[0] === currency_id}).shift();
-        // },
-        // Generar la tabla
+
         loadTable:function(rowsTable){
-            this.dataVoucher=rowsTable;
+            var self = this;
+            self.dataVoucher = rowsTable;
             var table = this.$el.find('#table');
-            table.bootstrapTable('load' ,rowsTable);
+            table.bootstrapTable('load',rowsTable);
         },
-        // Buscar
+
         fectSearch: function(){
             var self = this;
             var today = moment().format('YYYY-MM-DD');
@@ -415,28 +386,27 @@ function report_sale_vendor (reporting){
             var desde =this.$el.find('#from').val();
             var hasta =this.$el.find('#to').val();
             var journal =this.$el.find('#current-journal').val();
-            var currency =this.$el.find('#current-currency').val();
-            var newJournal= self.accountJournal; //copia del Diario
-            var newVoucher= self.accountVoucher; //copia del Vouacher
+            var newJournal= self.ResStore; //copia del Diario
+            var newVoucher= self.AccountInvoice; //copia del Vouacher
 
             if ($('#A').is(":checked")){
                 newVoucher = _.filter(newVoucher, function (inv){
-                    return inv.date_order == today;
+                    return inv.date_invoice == today;
                 });
             }
             if ($('#B').is(":checked")){
                 newVoucher = _.filter(newVoucher, function (inv){
-                    return moment(inv.date_order).format('YYYY-MM-DD') == yesterday;
+                    return moment(inv.date_invoice).format('YYYY-MM-DD') == yesterday;
                 });
             }
             if ($('#C').is(":checked")){
                 newVoucher = _.filter(newVoucher, function (inv){
-                    return moment(inv.date_order).format('YYYY-MM') == month;
+                    return moment(inv.date_invoice).format('YYYY-MM') == month;
                 });
             }
             if ($('#D').is(":checked")){
                 newVoucher = _.filter(newVoucher, function (inv){
-                    return moment(inv.date_order).format('YYYY-MM') == last_month;
+                    return moment(inv.date_invoice).format('YYYY-MM') == last_month;
                 });
             }
 
@@ -445,13 +415,13 @@ function report_sale_vendor (reporting){
                 if (desde.length > 0){
                     var date= desde.split('/');
                     newVoucher = _.filter(newVoucher, function (inv){
-                        return inv.date_order >= (date[2]+"-"+date[1]+"-"+date[0]);
+                        return inv.date_invoice >= (date[2]+"-"+date[1]+"-"+date[0]);
                     });
                 }
                 if (hasta.length > 0){
                     var date= hasta.split('/');
-                    newVoucher = _.filter(newVoucher, function (inv){
-                        return inv.date_order <= (date[2]+"-"+date[1]+"-"+date[0]);
+                    newVoucher= _.filter(newVoucher, function (inv){
+                        return inv.date_invoice <= (date[2]+"-"+date[1]+"-"+date[0]);
                     });
                 }
             }else{
@@ -464,7 +434,8 @@ function report_sale_vendor (reporting){
             }else {
                 var botonChart =this.$el.find('#chart').attr("disabled", false);
             }
-            self.fecthDataVoucher(newVoucher,newJournal);
+            self.BuildTable(newVoucher,newJournal);
+            // self.loadTable(content)
         },
         // volver
         volver: function(){
@@ -529,7 +500,7 @@ function report_sale_vendor (reporting){
                         pdfDoc.setFontSize(12);
                         pdfDoc.setFontStyle('bold');
                         pdfDoc.setTextColor(40);
-                        pdfDoc.text('Resumen de Egreso de '+ sucusal, data.settings.margin.left, 10);
+                        pdfDoc.text('Resumen de Ventas por Vendedores '+ sucusal, data.settings.margin.left, 10);
                         if(desde.length > 0 || hasta.length > 0){
                             var fecha='';
                             if(desde){
@@ -558,74 +529,66 @@ function report_sale_vendor (reporting){
                 if (typeof pdfDoc.putTotalPages === 'function') {
                     pdfDoc.putTotalPages(totalPagesExp);
                 }
-                pdfDoc.save('Resumen de Egreso.pdf');
+                pdfDoc.save('Resumen de Ventas por Vendedores.pdf');
             },
-        // // Char filter
-        // fectCharFilter: function(objetChar){
-        //     var self = this;
-        //     var dataBody=[];
-        //     var dataHeader=[];
-        //     // objetChar
-        //     var canvas="<canvas id='graf_resume'></canvas>";
-        //       this.$el.find('#grafico').append(canvas);
-        //     _.each(objetChar,function(voucher){
-        //         dataHeader.push(voucher.journal_name);
-        //         dataBody.push(parseFloat(((voucher.amount.replace(".","")).replace(",","."))));
-        //     });
-        //   var selector ="<button type='button' class='oe_button oe_form_button oe_highlight' id='volver_btn' name='volver_btn'><span>Atras</span></button>";
-        //   this.$el.find('#volver').append(selector);
-        //   this.$el.find('.bootstrap-table').hide({
-        //       effect: 'drop',
-        //       direction: 'up',
-        //       duration: 200,
-        //       complete: function () {
-        //         self.drawChart(dataHeader,dataBody);
-        //       }
-        //   });
-        //   this.$el.find('#toolbar').hide({
-        //       effect: 'drop',
-        //       direction: 'up',
-        //       duration: 200,
-        //       complete: function () {
-        //         self.drawChart(dataHeader,dataBody);
-        //       }
-        //   });
-        // },
-        // //Chart
-        // drawChart: function (dataHeader,dataBody) {
-        //     var barChart = new Chart(this.$el.find('#graf_resume'), {
-        //         type: 'doughnut',//bar, doughnut
-        //         data: {
-        //             labels: dataHeader,
-        //             datasets: [
-        //                 {
-        //                     labels: dataHeader,
-        //                     backgroundColor: [
-        //                         'rgba(255, 99, 132, 0.2)',
-        //                         'rgba(54, 162, 235, 0.2)',
-        //                         'rgba(255, 206, 86, 0.2)',
-        //                         'rgba(75, 192, 192, 0.2)',
-        //                         'rgba(153, 102, 255, 0.2)',
-        //                     ],
-        //                     borderColor: [
-        //                         'rgba(255,99,132,1)',
-        //                         'rgba(54, 162, 235, 1)',
-        //                         'rgba(255, 206, 86, 1)',
-        //                         'rgba(75, 192, 192, 1)',
-        //                         'rgba(153, 102, 255, 1)',
-        //                     ],
-        //                     borderWidth: 1,
-        //                     data: dataBody,
-        //                 }
-        //             ]
-        //         },
-        //         options: {
-        //             maintainAspectRatio: false,
-        //             layout: {
-        //                 padding: 30
-        //             }
-        //         },
-        //     });
-        // },
+            // Char filter
+            // fectCharFilter: function(objetChar){
+            //     var self = this;
+            //     var dataBody=[];
+            //     var dataHeader=[];
+            //     // objetChar
+            //     var canvas="<canvas id='graf_resume'></canvas>";
+            //     this.$el.find('#grafico').append(canvas);
+            //     _.each(objetChar,function(voucher){
+            //         dataHeader.push(voucher.journal_name);
+            //         dataBody.push(parseFloat(((voucher.amount.replace(".","")).replace(",","."))));
+            //     });
+            //     var selector ="<button type='button' class='oe_button oe_form_button oe_highlight' id='volver_btn' name='volver_btn'><span>Atras</span></button>";
+            //     this.$el.find('#volver').append(selector);
+            //     this.$el.find('.bootstrap-table').hide({
+            //             effect: 'drop',
+            //             direction: 'up',
+            //             duration: 200,
+            //             complete: function () {
+            //                 self.drawChart(dataHeader,dataBody);
+            //             }
+            //         });
+            // },
+            // //Chart
+            // drawChart: function (dataHeader,dataBody) {
+            //     var barChart = new Chart(this.$el.find('#graf_resume'), {
+            //         type: 'doughnut',//bar, doughnut
+            //         data: {
+            //             labels: dataHeader,
+            //             datasets: [
+            //                 {
+            //                     labels: dataHeader,
+            //                     backgroundColor: [
+            //                         'rgba(255, 99, 132, 0.2)',
+            //                         'rgba(54, 162, 235, 0.2)',
+            //                         'rgba(255, 206, 86, 0.2)',
+            //                         'rgba(75, 192, 192, 0.2)',
+            //                         'rgba(153, 102, 255, 0.2)',
+            //                     ],
+            //                     borderColor: [
+            //                         'rgba(255,99,132,1)',
+            //                         'rgba(54, 162, 235, 1)',
+            //                         'rgba(255, 206, 86, 1)',
+            //                         'rgba(75, 192, 192, 1)',
+            //                         'rgba(153, 102, 255, 1)',
+            //                     ],
+            //                     borderWidth: 1,
+            //                     data: dataBody,
+            //                 }
+            //             ]
+            //         },
+            //         options: {
+            //             maintainAspectRatio: false,
+            //             layout: {
+            //                 padding: 30
+            //             }
+            //         },
+            //     });
+            // },
     });
 }

+ 3 - 4
static/src/js/reports/report_sale_vendor.js

@@ -308,7 +308,7 @@ function report_sale_vendor (reporting){
                     voucherLine = cabjournal.journal_ids[f];
 
                     voucherItem = self.getVoucherjournal(objVoucher,voucherLine)
-
+                    console.log(voucherItem);
                     // invoice = self.getAccountInvoice(cabjournal.id);
 
                     if (voucherItem.length > 0){
@@ -359,9 +359,7 @@ function report_sale_vendor (reporting){
                                         graficar: false
                                 });
             }
-            // voucherObjectItem.sort(function (a, b) {
-            //     return b.amountBase - a.amountBase
-            // });
+
             self.loadTable(voucherObject);
         },
 
@@ -387,6 +385,7 @@ function report_sale_vendor (reporting){
             var hasta =this.$el.find('#to').val();
             var journal =this.$el.find('#current-journal').val();
             var newJournal= self.ResStore; //copia del Diario
+            
             var newVoucher= self.AccountInvoice; //copia del Vouacher
 
             if ($('#A').is(":checked")){

+ 9 - 0
static/src/js/reports/report_sales_invoice_analysis.js

@@ -547,6 +547,15 @@ function report_sales_invoice_analysis (reporting){
                 }
 
           }
+          data.sort(function (a, b) {
+               if (a.date_invoice > b.date_invoice) {
+                   return -1;
+               }
+               if (a.date_invoice < b.date_invoice) {
+                   return 1;
+               }
+               return 0;
+           });
           this.rowsData=data;
           self.content = data;
           this.loadTable(data)

+ 1 - 1
static/src/js/reports/report_vouchers.js

@@ -240,7 +240,7 @@ function report_vouchers (reporting){
                      return 1;
                  }
                  return 0;
-             });
+            });
             self.content = data;
             this.loadTable(data);
         },

+ 9 - 0
static/src/js/reports/reporting_accountpending.js

@@ -278,6 +278,15 @@ function reporting_accountpending (reporting){
                     invoice_id: item.invoice[0]
                 });
             });
+            data.sort(function (a, b) {
+                 if (a.date > b.date) {
+                     return -1;
+                 }
+                 if (a.date < b.date) {
+                     return 1;
+                 }
+                 return 0;
+             });
             self.content = data;
             this.loadTable(data);
         },

+ 1 - 1
static/src/reports/report_invoice_balance.xml

@@ -128,7 +128,7 @@
                     <tr>
                         <th data-field="number" data-sortable="true">Factura</th>
                         <th data-field="partner" data-sortable="true">Cliente / Proveedor</th>
-                        <th data-field="date_invoice" data-sortable="true">Fecha</th>
+                        <th data-field="date_invoice" >Fecha</th>
                         <th data-field="user" data-sortable="true">Responsable</th>
                         <th data-field="amount_total" data-sortable="true" data-align="right">Valor</th>
                         <th data-field="entry" data-sortable="true" data-align="right">Ingreso</th>

+ 1 - 1
static/src/reports/report_sale_cab.xml

@@ -91,7 +91,7 @@
                 <thead>
                     <tr>
                         <th data-field="number" data-sortable="true">N°Factura</th>
-                        <th data-field="date_invoice" data-sortable="true">Fecha</th>
+                        <th data-field="date_invoice">Fecha</th>
                         <th data-field="ruc" data-sortable="true">CIN/RUC</th>
                         <th data-field="partner" data-sortable="true">Cliente</th>
                         <th data-field="journal_name">Forma Pago</th>

+ 1 - 1
static/src/reports/report_sales_invoice_analysis.xml

@@ -112,7 +112,7 @@
             <thead>
               <tr>
                 <th data-field="number" data-sortable="true">Factura</th>
-                <th data-field="date_create" data-sortable="true">Fecha</th>
+                <th data-field="date_create">Fecha</th>
                 <th data-field="journal_name" data-sortable="true">Formas Pago</th>
                 <th data-field="partner_name" data-sortable="true">Cliente</th>
                 <th data-field="ean13" data-sortable="true">Cod. Barra</th>

+ 1 - 1
static/src/reports/report_vouchers.xml

@@ -102,7 +102,7 @@
                         <th data-field="reference" data-sortable="true">Factura</th>
                         <th data-field="number" data-sortable="true">Nro. de pago</th>
                         <th data-field="journal" data-sortable="true">Metodo de pago</th>
-                        <th data-field="date_voucher" data-sortable="true">Fecha</th>
+                        <th data-field="date_voucher">Fecha</th>
                         <th data-field="partner" data-sortable="true">Cliente/Proveedor</th>
                         <th data-field="amount_in" data-sortable="true" data-align="right">Pagos de clientes</th>
                         <th data-field="amount_out" data-sortable="true" data-align="right">Pagos a proveedores</th>

+ 1 - 1
static/src/reports/reporting_accountpending.xml

@@ -101,7 +101,7 @@
                     <tr>
                         <th data-field="reference" data-sortable="true">Nro Factura</th>
                         <th data-field="partner" data-sortable="true">Cliente</th>
-                        <th data-field="date_maturity" data-sortable="true">Vence</th>
+                        <th data-field="date_maturity">Vence</th>
                         <th data-field="amount_residual" data-sortable="true" data-align="right">Monto</th>
                     </tr>
                 </thead>