Browse Source

FIX ADD Agregado en report de utilidad cantidad disponible y no disponible

Sebas 6 years ago
parent
commit
2c6e06cd12

+ 5 - 14
static/src/js/configuration_reporting.js

@@ -210,30 +210,21 @@ function configuration_reporting (instance, widget) {
 
         fetchInitial:function() {
             var self = this;
-            self.fetchCurrentUser().then(function (CurrentUser) {
-                return CurrentUser;
-            }).then(function (CurrentUser) {
-                self.CurrentUser = CurrentUser;
-                return self.fetchResUser(CurrentUser);
+            self.fetchResUser().then(function (ResUser) {
+                return ResUser;
             }).then(function (ResUser) {
                 self.ResUser = ResUser;
                 return self.InsertUser();
             });
         },
 
-        fetchCurrentUser: function() {
-            var self = this;
-            var ResUser = new instance.web.Model('res.users');
-            return ResUser.call('get_user', {
-                context: new instance.web.CompoundContext()
-            });
-        },
 
-        fetchResUser: function(id) {
+
+        fetchResUser: function() {
             var self = this;
             var defer = $.Deferred();
             var fields = ['id','name'];
-            var domain = [['id','=',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);

+ 43 - 49
static/src/js/reports/report_invoice_utility.js

@@ -9,6 +9,7 @@ function report_invoice_utility (reporting){
         invoiceLines: [],
         productProduct:[],
         Currency:[],
+        content: [],
         rowsData :[],
         rowOrigin:[],
         accountJournal:[],
@@ -20,7 +21,7 @@ function report_invoice_utility (reporting){
             'change #from' : 'fectSearch',
             'change #to': 'fectSearch',
             'click #volver_btn': 'volver',
-            
+
             // 'click-row.bs.table #table ' : 'ckickAnalysisDetail',
             'click-row.bs.table #table' : 'ckickAnalysisDetail',
         },
@@ -251,6 +252,7 @@ function report_invoice_utility (reporting){
             var data=[];
             var item;
             var invoice;
+
             var producto;
 
             for (var i = 0; i < this.invoiceLines.length; i++) {
@@ -279,33 +281,64 @@ function report_invoice_utility (reporting){
                     });
                 }
           }
-          this.rowsData=data;
-          this.rowOrigin=data;
-          this.loadTable(data)
+          self.content = data;
+          this.loadTable(data);
         },
         // Buscar
         fectSearch: function(){
             var self = this;
+            var today = moment().format('YYYY-MM-DD');
             var desde =this.$el.find('#from').val();
             var hasta =this.$el.find('#to').val();
             var suc =this.$el.find('#current-journal').val();
-            self.rowsData=self.rowOrigin;
+            var content = self.content;
             if (suc != 9999999){
-                self.rowsData=_.filter(self.rowsData, function (inv){ return inv.journal_id == suc});
+                content=_.filter(content, function (inv){ return inv.journal_id == suc});
             }
             if (desde){
                 var date= desde.split('/')
-                self.rowsData=_.filter(self.rowsData, function (inv){
+                content=_.filter(content, function (inv){
                     return inv.date_invoice >= (date[2]+"-"+date[1]+"-"+date[0])
                 });
             }
             if (hasta){
                 var date= hasta.split('/')
-                self.rowsData=_.filter(self.rowsData, function (inv){
+                content=_.filter(content, function (inv){
                     return inv.date_invoice <= (date[2]+"-"+date[1]+"-"+date[0])
                 });
             }
-            self.loadTable(self.rowsData);
+
+            var quantity=_.reduce(_.map(content,function(item){
+                var valor=0;
+                if (item.quantity){valor = parseFloat(((item.quantity.replace(".","")).replace(",",".")))}return valor}), function(memo, num){ return memo + num; },0);
+            var precio_unit=_.reduce(_.map(content,function(item){
+                var valor =0;
+                if (item.price_unity){valor=parseFloat(((item.price_unity.replace(".","")).replace(",",".")))} return valor}), function(memo, num){ return memo + num; },0);
+            var precio_cost=_.reduce(_.map(content,function(item){
+                var valor=0;
+                if(item.standar_price){valor=parseFloat(((item.standar_price.replace(".","")).replace(",",".")))} return valor}), function(memo, num){ return memo + num;},0);
+            var tot_unit=_.reduce(_.map(content,function(item){
+                var valor=0;
+                if (item.price_tot){valor=parseFloat(((item.price_tot.replace(".","")).replace(",",".")))}return valor}), function(memo, num){ return memo + num; },0);
+            var tol_cost=_.reduce(_.map(content,function(item){
+                var valor=0;
+                if (item.standar_tot){valor=parseFloat(((item.standar_tot.replace(".","")).replace(",",".")))} return valor }), function(memo, num){ return memo + num; },0);
+            var utility=_.reduce(_.map(content,function(item){
+                var valor=0;
+                if (item.utility){valor=parseFloat(((item.utility.replace(".","")).replace(",",".")))}return valor }), function(memo, num){ return memo + num; },0);
+
+            rowsPdf.push({
+                            number : "  ",
+                            name : "TOTAL "+company,
+                            quantity: accounting.formatNumber(quantity,0, ".", ","),
+                            price_unity : accounting.formatNumber(precio_unit,2, ".", ","),
+                            standar_price : accounting.formatNumber(precio_cost,2, ".", ","),
+                            price_tot : accounting.formatNumber(tot_unit,2, ".", ","),
+                            standar_tot : accounting.formatNumber(tol_cost,2, ".", ","),
+                            utility : accounting.formatNumber(utility,2, ".", ",")
+                        });
+
+            self.loadTable(content);
         },
         // cargara la tabla
         loadTable:function(rowsTable){
@@ -377,51 +410,12 @@ function report_invoice_utility (reporting){
             var pdfDoc = new jsPDF();
 
             // rows=this.rowsData;
-            var quantity=_.reduce(_.map(rows,function(item){
-                var valor=0;
-                if (item.quantity){valor = parseFloat(((item.quantity.replace(".","")).replace(",",".")))}return valor}), function(memo, num){ return memo + num; },0);
-            var precio_unit=_.reduce(_.map(rows,function(item){
-                var valor =0;
-                if (item.price_unity){valor=parseFloat(((item.price_unity.replace(".","")).replace(",",".")))} return valor}), function(memo, num){ return memo + num; },0);
-            var precio_cost=_.reduce(_.map(rows,function(item){
-                var valor=0;
-                if(item.standar_price){valor=parseFloat(((item.standar_price.replace(".","")).replace(",",".")))} return valor}), function(memo, num){ return memo + num;},0);
-            var tot_unit=_.reduce(_.map(rows,function(item){
-                var valor=0;
-                if (item.price_tot){valor=parseFloat(((item.price_tot.replace(".","")).replace(",",".")))}return valor}), function(memo, num){ return memo + num; },0);
-            var tol_cost=_.reduce(_.map(rows,function(item){
-                var valor=0;
-                if (item.standar_tot){valor=parseFloat(((item.standar_tot.replace(".","")).replace(",",".")))} return valor }), function(memo, num){ return memo + num; },0);
-            var utility=_.reduce(_.map(rows,function(item){
-                var valor=0;
-                if (item.utility){valor=parseFloat(((item.utility.replace(".","")).replace(",",".")))}return valor }), function(memo, num){ return memo + num; },0);
 
             rowsPdf=rows;
 
             var company = _.map(self.resCompany, function (map) {
                 return map.currency_id[1];
             });
-            rowsPdf.push({
-                        number : "  ",
-                        name : "TOTAL "+company,
-                        quantity: accounting.formatNumber(quantity,0, ".", ","),
-                        price_unity : accounting.formatNumber(precio_unit,2, ".", ","),
-                        standar_price : accounting.formatNumber(precio_cost,2, ".", ","),
-                        price_tot : accounting.formatNumber(tot_unit,2, ".", ","),
-                        standar_tot : accounting.formatNumber(tol_cost,2, ".", ","),
-                        utility : accounting.formatNumber(utility,2, ".", ",")
-                    });
-
-            rowsPdf.unshift({
-                        number : "  ",
-                        name : "TOTAL "+company,
-                        quantity: accounting.formatNumber(quantity,0, ".", ","),
-                        price_unity : accounting.formatNumber(precio_unit,2, ".", ","),
-                        standar_price : accounting.formatNumber(precio_cost,2, ".", ","),
-                        price_tot : accounting.formatNumber(tot_unit,2, ".", ","),
-                        standar_tot : accounting.formatNumber(tol_cost,2, ".", ","),
-                        utility : accounting.formatNumber(utility,2, ".", ",")
-                    });
 
             pdfDoc.autoTable(getColumns, rowsPdf, {
                 styles: { overflow: 'linebreak', fontSize: 8, columnWidth: 'wrap'},
@@ -440,7 +434,7 @@ function report_invoice_utility (reporting){
                     pdfDoc.setFontSize(12);
                     pdfDoc.setFontStyle('bold');
                     pdfDoc.setTextColor(40);
-                    pdfDoc.text('Utilidad de facturas detalladas por '+ sucusal, data.settings.margin.left, 10);
+                    pdfDoc.text('Utilidad de facturas detalladas', data.settings.margin.left, 10);
 
                     if(desde.length > 0 || hasta.length > 0){
                       var fecha='';

+ 1 - 2
static/src/js/reports/report_pos.js

@@ -306,9 +306,8 @@ function report_pos(reporting){
                 order = self.getStatementLine(item.id);
                 store = self.getAccountJournal(item.sale_journal[0]);
                 if(order.length > 0 & store.length > 0){
-                    var tz = moment.tz.guess();
                     var utc = moment.utc(item.create_date,'YYYY-MM-DD h:mm:ss A');
-                    var date = utc.clone().tz(tz).format("DD/MM/YYYY hh:mm A");
+                    var date = moment(utc._d).format('DD/MM/YYYY hh:mm A');
                     data.push({
                         id : item.id,
                         number: item.name,

+ 4 - 4
static/src/js/reports/report_pos_orders.js

@@ -326,7 +326,6 @@ function report_pos_orders(reporting){
             });
         },
 
-
         // Productos
         fetchProductProduct: function(){
             var self = this;
@@ -453,9 +452,10 @@ function report_pos_orders(reporting){
 
 
                 if(store.length > 0 && producto.length > 0){
-                    var tz = moment.tz.guess();
-                    var utc = moment.utc(item.create_date,'YYYY-MM-DD h:mm:ss A');
-                    var date = utc.clone().tz(tz).format("DD/MM/YYYY hh:mm A");
+
+                    var utc = moment.utc(order.date_order,'YYYY-MM-DD h:mm:ss A');
+                    var date = moment(utc._d).format('DD/MM/YYYY h:mm A');
+
                     data.push({
                         id : item.id,
                         order_id : item.order_id[0],

+ 37 - 36
static/src/js/reports/report_resumen_egresos.js

@@ -9,7 +9,7 @@ function report_resumen_egresos (reporting){
         accountJournal:[],
         dataVoucher:[],
         currencyRate:[],
-        companyCurrency:[],
+        resCompany:[],
         modules:[],
 
         events:{
@@ -84,6 +84,41 @@ function report_resumen_egresos (reporting){
             });
             return
         },
+
+        //  Metodo inicial
+        fecthInitial: 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.$el.find('#current-journal').append('<option value="' + item.id + '">' + item.name + '</option>');
+                });
+                return self.fecthCurrency();
+            }).then(function(resCurrency){
+                self.$el.find('#current-currency').append('<option value="999">Todas las Monedas</option>');
+                _.each(resCurrency,function(item){
+                    self.$el.find('#current-currency').append('<option value="'+item.id+'">'+item.name +' '+item.symbol+'</option>');
+                });
+                self.resCurrency =resCurrency;
+                return self.fecthCurrencyRate();
+            }).then(function(currencyRate){
+                self.currencyRate =currencyRate;
+                return self.fecthVoucher();
+            }).then(function(accountVoucher){
+                self.accountVoucher=accountVoucher;
+                return self.fecthComanyCurrency();
+            }).then(function(resCompany){
+                self.resCompany = resCompany;
+                return self.fecthDataVoucher(self.accountVoucher,self.accountJournal);
+            });
+        },
+
         // Fecha
         fecthFecha: function() {
             var to;
@@ -118,41 +153,7 @@ function report_resumen_egresos (reporting){
                 return date;
             }
         },
-        //  Metodo inicial
-        fecthInitial: 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.$el.find('#current-journal').append('<option value="' + item.id + '">' + item.name + '</option>');
-                });
-                return self.fecthCurrency();
-            }).then(function(resCurrency){
-                self.$el.find('#current-currency').append('<option value="999">Todas las Monedas</option>');
-                _.each(resCurrency,function(item){
-                    self.$el.find('#current-currency').append('<option value="'+item.id+'">'+item.name +' '+item.symbol+'</option>');
-                });
-                self.resCurrency =resCurrency;
-                return self.fecthCurrencyRate();
-            }).then(function(currencyRate){
-                self.currencyRate =currencyRate;
-                return self.fecthVoucher();
-            }).then(function(accountVoucher){
-                self.accountVoucher =accountVoucher;
-                return self.fecthComanyCurrency();
-            }).then(function(companyCurrency){
-                self.companyCurrency = companyCurrency;
-                return self.fecthDataVoucher(self.accountVoucher,self.accountJournal);
-            });
-            // return self.renderReport()
-        },
         // Modelos instalados
         fecthIrModuleModule: function(){
             var self = this;
@@ -280,7 +281,7 @@ function report_resumen_egresos (reporting){
                                                 journal_id: journal.id,
                                                 journal_name: journal.name,
                                                 graficar: false
-                                        })
+                        })
                     }
                 }
                 if (voucherObjectItem.length > 0){

+ 20 - 19
static/src/js/reports/report_resumen_ingresos.js

@@ -89,7 +89,6 @@ function report_resumen_ingresos (reporting){
         //  Metodo inicial
         fecthInitial: function(){
             var self = this;
-
             self.fecthIrModuleModule().then(function(modules){
                 self.modules = modules;
                 return modules;
@@ -119,7 +118,7 @@ function report_resumen_ingresos (reporting){
                 self.resCompany = resCompany;
                 return self.fecthDataVoucher(self.accountVoucher,self.accountJournal);
             });
-    
+
         },
         // Modelos instalados
         fecthIrModuleModule: function(){
@@ -168,18 +167,7 @@ function report_resumen_ingresos (reporting){
                 return date;
             }
         },
-        // company_curency
-        fecthComanyCurrency: function(){
-            var self = this;
-            var defer = $.Deferred();
-            var currency = new instance.web.Model('res.company');
-            var field=['id', 'currency_id'];
-            var domain=[['id','=',1]];
-            currency.query(field).filter(domain).all().then(function(results){
-                defer.resolve(results);
-            });
-            return defer;
-        },
+
         // Journal
         fecthJournalStore: function(){
             var self = this;
@@ -199,6 +187,18 @@ function report_resumen_ingresos (reporting){
             });
             return defer;
         },
+        // company_curency
+        fecthComanyCurrency: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var currency = new instance.web.Model('res.company');
+            var field=['id', 'currency_id'];
+            var domain=[['id','=',1]];
+            currency.query(field).filter(domain).all().then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
         // Moneda
         fecthCurrency:function(){
             var self = this;
@@ -245,6 +245,7 @@ function report_resumen_ingresos (reporting){
         // Join object
         fecthDataVoucher:function(objVoucher,objJournal){
             var self=this;
+            console.log(self);
             var item;
             var journal;
             var voucherLine;
@@ -282,13 +283,14 @@ function report_resumen_ingresos (reporting){
                                                 journal_id: journal.id,
                                                 journal_name: journal.name,
                                                 graficar: false
-                                        })
+                        })
                     }
                 }
-                var company = _.map(self.resCompany, function (map) {
-                    return map.currency_id[1];
-                });
                 if (voucherObjectItem.length > 0){
+                    var company = _.map(self.companyCurrency, 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 : " ",
@@ -321,7 +323,6 @@ function report_resumen_ingresos (reporting){
                                         graficar: false
                                 });
             }
-            // self.content = voucherObject;
             self.loadTable(voucherObject);
         },
         // Obtener Voucher

+ 2 - 2
static/src/js/reports/report_sale_pos_cab.js

@@ -453,9 +453,9 @@ function report_sale_pos_cab(reporting){
                 order = self.getStatementLine(item.id);
                 store = self.getAccountJournalPos(item.sale_journal[0]);
                 if(order.length > 0 & store.length > 0){
-                    var tz = moment.tz.guess();
                     var utc = moment.utc(item.create_date,'YYYY-MM-DD h:mm:ss A');
-                    var date = utc.clone().tz(tz).format("DD/MM/YYYY hh:mm A");
+                    var date = moment(utc._d).format('DD/MM/YYYY h:mm A');
+
                     data.push({
                         id : item.id,
                         number: "",

+ 4 - 19
static/src/js/reports/report_sales.js

@@ -166,7 +166,10 @@ function report_sales(reporting){
         },
         factSearch: function(){
             var self = this;
-            var hoy = moment().format('YYYY-MM-DD');
+            var today = moment().format('YYYY-MM-DD');
+            var yesterday = moment().add(-1, 'days').format('YYYY-MM-DD');
+            var month = moment().format('YYYY-MM');
+            var last_month = moment().add(-1, 'months').format('YYYY-MM');
             var desde =this.$el.find('#from').val();
             var hasta =this.$el.find('#to').val();
             var partner= this.$el.find('#partner').val().split('-');
@@ -266,24 +269,6 @@ function report_sales(reporting){
         getObjetPdf: function(rowsTable){
             var self = this;
             var rows=self.rowsData;
-            var amount = _.reduce(_.map(rows,function(map){
-                return(map.amount);
-            }),function(memo, num){
-                return memo + num;
-            },0);
-            var total_residual = _.reduce(_.map(rows,function(map){
-                return(map.total_residual);
-            }),function(memo, num){
-                return memo + num;
-            },0);
-            if (rows.length > 0){
-                rows.push({
-                    number: "Total",
-                    amount_total: accounting.formatNumber((amount),2,".",","),
-                    residual: accounting.formatNumber((total_residual),2,".",","),
-
-                });
-            }
 
             return rows;
         },

+ 95 - 128
static/src/js/reports/report_sales_invoice_analysis.js

@@ -10,6 +10,7 @@ function report_sales_invoice_analysis (reporting){
         productProduct:[],
         Currency:[],
         rowsData :[],
+        content :[],
         rowOrigin:[],
         accountJournal:[],
         resCompany:[],
@@ -31,9 +32,9 @@ function report_sales_invoice_analysis (reporting){
           this._super(parent);
         },
         start: function () {
-
+            var self = this;
             var table = this.$el.find('#table');
-            table.bootstrapTable({data : self.rowOrigin});
+            table.bootstrapTable({data : self.rowsData});
             this.fecthFecha();
             this.submitForm();
         },
@@ -159,6 +160,66 @@ function report_sales_invoice_analysis (reporting){
             return defer;
         },
 
+        valorNull:function(dato){
+            var valor ="";
+            if (dato){
+                valor=dato;
+            }
+            return valor;
+        },
+
+        search: function () {
+            var self = this;
+            var results = self.ResPartner;
+            results = _.map(results, function (item) {
+                return {
+                        label: item.id + '-'+ item.name + ' ' + self.valorNull(item.ruc),
+                        value: item.id + '-'+ item.name + ' ' + self.valorNull(item.ruc)
+                }
+            });
+            self.$('#partner').autocomplete({
+                source: results,
+                minLength:0,
+                search: function(event, ui) {
+                    if (!(self.$('#partner').val())){
+                        self.fectSearch();
+                    }
+                },
+                close: function( event, ui ) {
+                        self.fectSearch();
+                },
+                select: function(event, ui) {
+                    self.fectSearch();
+                }
+            });
+        },
+
+        searchProduct: function () {
+            var self = this;
+            var results = self.productProduct;
+            results = _.map(results, function (item) {
+                return {
+                    label: item.id + '- '+ ' [ ' + self.valorNull(item.default_code) + ' - ' + self.valorNull(item.ean13) + ' ] ' + item.name + ' ( ' +  self.valorNull(item.attribute_str) + ' ) ' ,
+                    value: item.id + '- '+ ' [ ' + self.valorNull(item.default_code) + ' - ' + self.valorNull(item.ean13) + ' ] ' + item.name + ' ( ' +  self.valorNull(item.attribute_str) + ' ) '
+                }
+            });
+            self.$('#product').autocomplete({
+                source: results,
+                minLength:0,
+                search: function(event, ui) {
+                    if (!(self.$('#product').val())){
+                        self.fectSearch();
+                    }
+                },
+                close: function( event, ui ) {
+                        self.fectSearch();
+                },
+                select: function(event, ui) {
+                    self.fectSearch();
+                }
+            });
+        },
+
         fecthAccountJournal: function(){
             var self = this;
             var defer = $.Deferred();
@@ -333,7 +394,7 @@ function report_sales_invoice_analysis (reporting){
                         price_tot_tot : ((item.quantity * (item.price_unit / invoice.rate))),
                         standar_tot_tot : ((item.quantity * producto.standard_price)),
                         utility_tot : (((item.quantity * (item.price_unit / invoice.rate)) - (item.quantity * producto.standard_price))),
-                        date_create :moment(invoice.date_invoice).format("DD/MM/YYYY HH:mm"),
+                        date_create :moment(invoice.date_invoice).format("DD/MM/YYYY"),
                         date_invoice : (invoice.date_invoice),
                         partner_id : invoice.partner_id[0],
                         partner_name : invoice.partner_id[1],
@@ -342,9 +403,8 @@ function report_sales_invoice_analysis (reporting){
                 }
 
           }
-          this.rowsData=data;
-          this.rowOrigin=data;
-          this.loadTable(data)
+          self.content = data;
+          this.loadTable(data);
         },
 
         fectSearch: function(){
@@ -358,25 +418,25 @@ function report_sales_invoice_analysis (reporting){
             var desde =this.$el.find('#from').val();
             var hasta =this.$el.find('#to').val();
             var store = this.$el.find('#current-store').val();
-            self.rowsData=self.rowOrigin;
+            var content = self.content;
 
             if ($('#A').is(":checked")){
-                self.rowsData = _.filter(self.rowsData, function (inv){
+                content = _.filter(content, function (inv){
                     return moment(inv.date_invoice).format('YYYY-MM-DD') == today;
                 });
             }
             if ($('#B').is(":checked")){
-                self.rowsData = _.filter(self.rowsData, function (inv){
+                content = _.filter(content, function (inv){
                     return moment(inv.date_invoice).format('YYYY-MM-DD') == yesterday;
                 });
             }
             if ($('#C').is(":checked")){
-                self.rowsData = _.filter(self.rowsData, function (inv){
+                content = _.filter(content, function (inv){
                     return moment(inv.date_invoice).format('YYYY-MM') == month;
                 });
             }
             if ($('#D').is(":checked")){
-                self.rowsData = _.filter(self.rowsData, function (inv){
+                content = _.filter(content, function (inv){
                     return moment(inv.date_invoice).format('YYYY-MM') == last_month;
                 });
             }
@@ -385,13 +445,13 @@ function report_sales_invoice_analysis (reporting){
                 $('#datepicker').css('display','block');
                 if (desde.length > 0){
                     var date= desde.split('/');
-                    self.rowsData = _.filter(self.rowsData, function (inv){
+                    content = _.filter(content, function (inv){
                         return inv.date_invoice >= (date[2]+"-"+date[1]+"-"+date[0]);
                     });
                 }
                 if (hasta.length > 0){
                     var date= hasta.split('/');
-                    self.rowsData = _.filter(self.rowsData, function (inv){
+                    content = _.filter(content, function (inv){
                         return inv.date_invoice <= (date[2]+"-"+date[1]+"-"+date[0]);
                     });
                 }
@@ -399,47 +459,47 @@ function report_sales_invoice_analysis (reporting){
                 $('#datepicker').css('display','none');
             }
             if (partner != ""){
-                self.rowsData = _.filter(self.rowsData, function(inv){
+                content = _.filter(content, function(inv){
                     return inv.partner_id == partner[0];
                 });
             }
             if (product != ""){
-                self.rowsData = _.filter(self.rowsData, function(inv){
+                content = _.filter(content, function(inv){
                     return inv.id_product == product[0];
                 });
             }
 
             if(store != 9999999){
-                self.rowsData =_.filter(self.rowsData, function (inv){
+                content =_.filter(content, function (inv){
                     return inv.store_id == store;
                 });
             }
 
-            var quantity_tot_total = _.reduce(_.map(self.rowsData,function(map){
+            var quantity_tot_total = _.reduce(_.map(content,function(map){
                 return(map.quantity_tot);
             }),function(memo, num){
                 return memo + num;
             },0);
 
-            var price_total_total = _.reduce(_.map(self.rowsData,function(map){
+            var price_total_total = _.reduce(_.map(content,function(map){
                 return(map.price_tot_tot);
             }),function(memo, num){
                 return memo + num;
             },0);
 
-            var standar_total_total = _.reduce(_.map(self.rowsData,function(map){
+            var standar_total_total = _.reduce(_.map(content,function(map){
                 return(map.standar_tot_tot);
             }),function(memo, num){
                 return memo + num;
             },0);
 
-            var amount_total_total = _.reduce(_.map(self.rowsData,function(map){
+            var amount_total_total = _.reduce(_.map(content,function(map){
                 return(map.utility);
             }),function(memo, num){
                 return memo + num;
             },0);
 
-            self.rowsData.push({
+            content.push({
                 number: "Totales:",
                 quantity: accounting.formatNumber((quantity_tot_total),0,".",","),
                 price_tot: accounting.formatNumber((price_total_total),0,".",","),
@@ -447,84 +507,35 @@ function report_sales_invoice_analysis (reporting){
                 utility: accounting.formatNumber((amount_total_total),0,".",","),
             });
 
-            self.loadTable(self.rowsData);
-        },
-
-        valorNull:function(dato){
-            var valor ="";
-            if (dato){
-                valor=dato;
-            }
-            return valor;
+            self.loadTable(content)
         },
 
-        search: function () {
+        loadTable:function(rowsTable){
             var self = this;
-            var results = self.ResPartner;
-            results = _.map(results, function (item) {
-                return {
-                        label: item.id + '-'+ item.name + ' ' + self.valorNull(item.ruc),
-                        value: item.id + '-'+ item.name + ' ' + self.valorNull(item.ruc)
-                }
-            });
-            self.$('#partner').autocomplete({
-                source: results,
-                minLength:0,
-                search: function(event, ui) {
-                    if (!(self.$('#partner').val())){
-                        self.fectSearch();
-                    }
-                },
-                close: function( event, ui ) {
-                        self.fectSearch();
-                },
-                select: function(event, ui) {
-                    self.fectSearch();
-                }
-            });
+            self.rowsData = rowsTable;
+            var table = this.$el.find('#table');
+            table.bootstrapTable('load', rowsTable);
         },
 
-        searchProduct: function () {
+        getObjetPdf: function(rowsTable){
             var self = this;
-            var results = self.productProduct;
-            results = _.map(results, function (item) {
-                return {
-                    label: item.id + '- '+ ' [ ' + self.valorNull(item.default_code) + ' - ' + self.valorNull(item.ean13) + ' ] ' + item.name + ' ( ' +  self.valorNull(item.attribute_str) + ' ) ' ,
-                    value: item.id + '- '+ ' [ ' + self.valorNull(item.default_code) + ' - ' + self.valorNull(item.ean13) + ' ] ' + item.name + ' ( ' +  self.valorNull(item.attribute_str) + ' ) '
-                }
-            });
-            self.$('#product').autocomplete({
-                source: results,
-                minLength:0,
-                search: function(event, ui) {
-                    if (!(self.$('#product').val())){
-                        self.fectSearch();
-                    }
-                },
-                close: function( event, ui ) {
-                        self.fectSearch();
-                },
-                select: function(event, ui) {
-                    self.fectSearch();
-                }
-            });
-        },
+            var rows=self.rowsData;
 
-        loadTable:function(rowsTable){
-            var table = this.$el.find('#table');
-            table.bootstrapTable('load', rowsTable);
+            return rows;
         },
 
         clickOnAction: function (e) {
-            var action = this.$el.find(e.target).val();
             var self = this;
+            var rowsNew;
+            var action = this.$el.find(e.target).val();
             var getColumns=[];
             var rows=[];
+            rowsNew = self.getObjetPdf();
             var table = this.$el.find("#table");
             var data2 = table.bootstrapTable('getVisibleColumns');
             if (action === 'pdf') {
                 var dataNEW = _.map(data2, function (val){ return val.field});
-                _.each(this.rowsData,function (item){
+                _.each(rowsNew,function (item){
                     rows.push(_.pick(item, dataNEW));
                 });
                 // Obtener los nombre de la Cabezera
@@ -578,59 +589,15 @@ function report_sales_invoice_analysis (reporting){
             var totalPagesExp = "{total_pages_count_string}";
             var pdfDoc = new jsPDF('l');
 
-            // rows=this.rowsData;
-            var quantity=_.reduce(_.map(rows,function(item){
-                var valor=0;
-                if (item.quantity){valor = parseFloat(((item.quantity.replace(".","")).replace(",",".")))}return valor}), function(memo, num){ return memo + num; },0);
-            var precio_unit=_.reduce(_.map(rows,function(item){
-                var valor =0;
-                if (item.price_unity){valor=parseFloat(((item.price_unity.replace(".","")).replace(",",".")))} return valor}), function(memo, num){ return memo + num; },0);
-            var precio_cost=_.reduce(_.map(rows,function(item){
-                var valor=0;
-                if(item.standar_price){valor=parseFloat(((item.standar_price.replace(".","")).replace(",",".")))} return valor}), function(memo, num){ return memo + num;},0);
-            var tot_unit=_.reduce(_.map(rows,function(item){
-                var valor=0;
-                if (item.price_tot){valor=parseFloat(((item.price_tot.replace(".","")).replace(",",".")))}return valor}), function(memo, num){ return memo + num; },0);
-            var tol_cost=_.reduce(_.map(rows,function(item){
-                var valor=0;
-                if (item.standar_tot){valor=parseFloat(((item.standar_tot.replace(".","")).replace(",",".")))} return valor }), function(memo, num){ return memo + num; },0);
-            var utility=_.reduce(_.map(rows,function(item){
-                var valor=0;
-                if (item.utility){valor=parseFloat(((item.utility.replace(".","")).replace(",",".")))}return valor }), function(memo, num){ return memo + num; },0);
-
-            rowsPdf=rows;
-
             var company = _.map(self.resCompany, function (map) {
                 return map.currency_id[1];
             });
-            rowsPdf.push({
-                        number : "TOTAL "+company,
-                        date_create : " ",
-                        name : " ",
-                        quantity: accounting.formatNumber(quantity,0, ".", ","),
-                        price_unity : accounting.formatNumber(precio_unit,2, ".", ","),
-                        standar_price : accounting.formatNumber(precio_cost,2, ".", ","),
-                        price_tot : accounting.formatNumber(tot_unit,2, ".", ","),
-                        standar_tot : accounting.formatNumber(tol_cost,2, ".", ","),
-                        utility : accounting.formatNumber(utility,2, ".", ",")
-                    });
 
-            rowsPdf.unshift({
-                        number : "TOTAL "+company,
-                        date_create : " ",
-                        name : " ",
-                        quantity: accounting.formatNumber(quantity,0, ".", ","),
-                        price_unity : accounting.formatNumber(precio_unit,2, ".", ","),
-                        standar_price : accounting.formatNumber(precio_cost,2, ".", ","),
-                        price_tot : accounting.formatNumber(tot_unit,2, ".", ","),
-                        standar_tot : accounting.formatNumber(tol_cost,2, ".", ","),
-                        utility : accounting.formatNumber(utility,2, ".", ",")
-                    });
 
-            pdfDoc.autoTable(getColumns, rowsPdf, {
+            pdfDoc.autoTable(getColumns, rows, {
                 styles: { overflow: 'linebreak', fontSize: 8, columnWidth: 'wrap'},
                 columnStyles: {
-                              number: {fontStyle: 'bold',columnWidth: '8px'},
+                              number: {fontStyle: 'bold',columnWidth: '9px'},
                               date_create :{columnWidth: '14px'},
                               name :{columnWidth: '12px'},
                               quantity :{halign:'right',columnWidth: '8px'},

+ 20 - 15
static/src/js/reports/report_stock_original.js

@@ -15,6 +15,9 @@ function report_stock_original (reporting){
         events : {
             'change #current-location' : 'factSearch',
             'change #current-category' : 'factSearch',
+            'click #Y' : 'factSearch',
+            'click #disponible' : 'factSearch',
+            'click #nodisponible' : 'factSearch',
             'click #toolbar > button' : 'clickOnAction',
             'click-row.bs.table #table ' : 'clickAnalysisDetail',
         },
@@ -214,7 +217,7 @@ function report_stock_original (reporting){
                         return mamo + num;
                     },0);
                 }
-                inv.qty = accounting.formatNumber(quantity,2, ".", ",");     
+                inv.qty = accounting.formatNumber(quantity,2, ".", ",");
             });
             return content;
         },
@@ -224,7 +227,7 @@ function report_stock_original (reporting){
             var category = this.$el.find('#current-category').val();
             var location =this.$el.find('#current-location').val();
             var content = self.content;
-            
+
             if (location != 9999999){
                 content = self.getQuantProduct(content,location);
             }
@@ -232,12 +235,24 @@ function report_stock_original (reporting){
             if (location = 9999999){
                 self.BuildTable();
             }
-            
+
             if(category != 9999999){
                 content = _.filter(content,function(inv){
-                    return inv.category_id == category;
+                    return inv.category_id === category[0];
+                });
+            }
+
+            if ($('#disponible').is(":checked")){
+                content = _.filter(content, function(inv){
+                    return parseFloat(inv.qty) > 0;
                 });
             }
+            if ($('#nodisponible').is(":checked")){
+                content = _.filter(content, function(inv){
+                    return parseFloat(inv.qty) <= 0;
+                });
+            }
+
             self.loadTable(content)
         },
 
@@ -252,17 +267,7 @@ function report_stock_original (reporting){
             var self = this;
             var rows=[];
             var rows = self.rowsData;
-            // var total = _.reduce(_.map(rows,function(map){
-            //     return(map.total);
-            // }),function(memo, num){
-            //     return memo + num;
-            // },0);
-            // if (rows.length > 0){
-            //     rows.push({
-            //         product: "Totales ",
-            //         valuation: accounting.formatNumber(total,0,".",","),
-            //     });
-            // }
+
             return rows;
         },
         clickOnAction: function (e) {

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

@@ -454,12 +454,13 @@ function report_ventas_pos_orders(reporting){
             var item;
 
             for (var i = 0; i < this.PosOrderLine.length; i++) {
-                var tz = moment.tz.guess();
-                var utc = moment.utc(item.create_date,'YYYY-MM-DD h:mm:ss A');
-                var date = utc.clone().tz(tz).format("DD/MM/YYYY hh:mm A");
+
+
                 item = this.PosOrderLine[i];
                 producto = self.getProductProduct(item.product_id[0]);
                 order = self.getPosOrder(item.order_id[0]).shift();
+                var utc = moment.utc(item.create_date,'YYYY-MM-DD h:mm:ss A');
+                var date = moment(utc._d).format('DD/MM/YYYY h:mm A');
 
                var store = self.getAccountJournal(order.sale_journal[0]);
 

+ 32 - 11
static/src/reports/report_stock_original.xml

@@ -15,18 +15,39 @@
                                 <div class="panel-heading">Características</div>
                                 <div class="panel-body">
                                     <div class="col-xs-6">
-                                        <div class="form-group">
-                                            <label for="current-location">Todas las Ubicaciones: </label>
-                                            <select id="current-location" class="form-control ui-autocomplete-input"  name="current-location"></select>
+
+                                            <div class="panel panel-default">
+                                                <div class="panel-heading">Características</div>
+                                                <div class="panel-body">
+                                                    <h3>Stock</h3>
+                                                    <ul class="list-unstyled">
+                                                        <li>
+                                                            <input type="radio" name="tipo" id="Y" value="Y" checked="checked"/>
+                                                            <label for="Y">Sin Filtro</label>
+                                                            <li>
+                                                                <input type="radio" name="tipo" id="disponible" value="disponible"/>
+                                                                <label for="disponible">Disponible</label>
+                                                            </li>
+                                                            <li>
+                                                                <input type="radio" name="tipo" id="nodisponible" value="nodisponible"/>
+                                                                <label for="nodisponible">No Disponible</label>
+                                                            </li>
+                                                        </li>
+
+                                                    </ul>
+
+                                                    <div class="form-group">
+                                                        <label for="current-location">Todas las Ubicaciones: </label>
+                                                        <select id="current-location" class="form-control ui-autocomplete-input"  name="current-location"></select>
+                                                    </div>
+                                                    <div class="form-group">
+                                                        <label for="current-category">Todas la categorias: </label>
+                                                        <select id="current-category" class="form-control ui-autocomplete-input"  name="current-category"></select>
+                                                    </div>
+
+                                            </div>
                                         </div>
-                                        <div class="form-group">
-                                            <label for="current-category">Todas la categorias: </label>
-                                            <select id="current-category" class="form-control ui-autocomplete-input"  name="current-category"></select>
-                                        </div>
-                                        <!-- <div class="form-group">
-                                            <label for="product">Buscar Producto:</label>
-                                            <input id="product" type="text" class="form-control ui-autocomplete-input" autocomplete="off" placeholder="Nombre/ Referencia/ Codigo de barras"/>
-                                        </div> -->
+
                                     </div>
                                 </div>
                             </div>

+ 3 - 3
static/src/xml/eiru_reporting_welcome.xml

@@ -3,12 +3,12 @@
 <template xml:space="preserve">
     <t t-name="EiruReportingWelcome">
         <div class="container" style="background:#6cbaf1;color:#fff;height:100%;width:100%;padding-bottom:12%;">
-            <!-- #6cbaf1 -->
-            <!-- #0288d1 -->
             <div class="row">
                 <div class="col-md-6">
                     <div class="page-header">
-                      <h1>Bienvenido al Area de Reportes</h1>
+                        <div align="center">
+                            <h1>Bienvenido al Area de Reportes</h1>
+                        </div>
                     </div>
                     <p style="font-size:20px">
                         <!-- Este sistema te ofrece una funcionalidad muy necesaria para realizar el análisis de la información, denominada “reportes”, que tiene como objetivo principal mostrar la situación actual de la empresa de forma detallada. Consecuentemente, estos reportes revelan la situación de las operaciones regulares dentro de su organización para poder controlar y dirigir de forma ágil. -->