Browse Source

ADD-FIX añadir nuevo pantalla de inicio y agregado concepto de multisucursal

Sebas 7 years ago
parent
commit
746d913937
30 changed files with 3072 additions and 294 deletions
  1. BIN
      static/src/img/powtoon.mp4
  2. 43 0
      static/src/js/configuration_reporting.js
  3. 1 1
      static/src/js/main.js
  4. 7 7
      static/src/js/reports/ranking_pos_orders_product_cy.js
  5. 92 28
      static/src/js/reports/report_invoice_balance.js
  6. 52 30
      static/src/js/reports/report_pos.js
  7. 129 32
      static/src/js/reports/report_pos_orders.js
  8. 336 0
      static/src/js/reports/report_product_pack.js
  9. 548 0
      static/src/js/reports/report_product_pack_utilidad.js
  10. 70 40
      static/src/js/reports/report_purchases_invoice_analysis.js
  11. 1 1
      static/src/js/reports/report_ranking_purchases_orders_supplier.js
  12. 622 0
      static/src/js/reports/report_refund_invoice_customer.js
  13. 601 0
      static/src/js/reports/report_refund_invoice_supplier.js
  14. 160 132
      static/src/js/reports/report_sales_invoice_analysis.js
  15. 7 6
      static/src/reports/ranking_mrp_orders_product_cy.xml
  16. 9 8
      static/src/reports/ranking_pos_orders_product_cy.xml
  17. 6 0
      static/src/reports/report_invoice_balance.xml
  18. 4 0
      static/src/reports/report_pos.xml
  19. 7 0
      static/src/reports/report_pos_orders.xml
  20. 51 0
      static/src/reports/report_product_pack.xml
  21. 55 0
      static/src/reports/report_product_pack_utilidad.xml
  22. 4 0
      static/src/reports/report_purchases_invoice_analysis.xml
  23. 103 0
      static/src/reports/report_refund_invoice_customer.xml
  24. 112 0
      static/src/reports/report_refund_invoice_supplier.xml
  25. 4 0
      static/src/reports/report_sales_invoice_analysis.xml
  26. 2 2
      static/src/reports/report_stock.xml
  27. 6 4
      static/src/xml/eiru_reporting.xml
  28. 28 0
      static/src/xml/eiru_reporting_welcome.xml
  29. 8 1
      templates.xml
  30. 4 2
      views/menus.xml

BIN
static/src/img/powtoon.mp4


+ 43 - 0
static/src/js/configuration_reporting.js

@@ -146,6 +146,8 @@ function configuration_reporting (instance, widget) {
 
         ],
         start: function () {
+            var self = this;
+            self.fetchInitial();
         },
 
         clickOnReport: function (e) {
@@ -170,5 +172,46 @@ function configuration_reporting (instance, widget) {
             var widgetName = `${templateName}Widget`;
             return _.pick(widget, widgetName)[widgetName];
         },
+
+        fetchInitial:function() {
+            var self = this;
+            self.fetchCurrentUser().then(function (CurrentUser) {
+                return CurrentUser;
+            }).then(function (CurrentUser) {
+                self.CurrentUser = CurrentUser;
+                return self.fetchResUser(CurrentUser);
+            }).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) {
+            var self = this;
+            var defer = $.Deferred();
+            var fields = ['id','name'];
+            var domain = [['id','=',id]];
+            var ResUser = new instance.web.Model('res.users');
+            ResUser.query(fields).filter(domain).all().then(function (results) {
+                defer.resolve(results);
+            });
+
+            return defer;
+        },
+
+        InsertUser: function(id) {
+            var self = this;
+            var user = self.ResUser[0].name;
+            self.$el.find('.user-content').find('p').text("Hola " + user + " ...!");
+        },
+
     });
 }

+ 1 - 1
static/src/js/main.js

@@ -46,7 +46,7 @@ openerp.eiru_reporting = function (instance) {
 
     }
 
-    // Todos los informes
+    // Todos los informes 
     instance.web.client_actions.add('eiru_reporting.action_report', 'instance.eiru_reporting.ReportingWidget');
 
     // ******************************************* Finanzas **********************************************************************

+ 7 - 7
static/src/js/reports/ranking_pos_orders_product_cy.js

@@ -541,13 +541,13 @@ function ranking_pos_orders_product_cy (reporting) {
                 return map.id;
             })
             this.do_action({
-                // name: "Listado de productos más comprados",
-                // type: 'ir.actions.act_window',
-                // res_model: "product.product",
-                // views: [[false,'list'],[self.modelId[1],'form']],
-                // target: 'current',
-                // domain: [['id', 'in', product_id]],
-                // context: {},
+                name: "Listado de productos más comprados",
+                type: 'ir.actions.act_window',
+                res_model: "product.product",
+                views: [[false,'list'],[self.modelId[1],'form']],
+                target: 'current',
+                domain: [['id', 'in', product_id]],
+                context: {},
             });
         }
     });

+ 92 - 28
static/src/js/reports/report_invoice_balance.js

@@ -26,8 +26,8 @@ function report_invoice_balance (reporting){
             'click #open' : 'factSearch',
             'click #paid' : 'factSearch',
 
-            'change #current-journal' : 'factSearch',
-            'change #current-currency' : 'factSearch',
+            'change #current-store' : 'factSearch',
+            // 'change #current-currency' : 'factSearch',
 
             'change #from' : 'factSearch',
             'change #to' : 'factSearch',
@@ -79,6 +79,16 @@ function report_invoice_balance (reporting){
                 return AccountInvoice;
             }).then(function (AccountInvoice) {
                 self.AccountInvoice = AccountInvoice;
+                return self.fecthResStore();
+            }).then(function(ResStore){
+                self.ResStore = ResStore;
+                self.$el.find('#current-store').append('<option value="9999999">Todas las SUC.</option>');
+                _.each(ResStore,function(item){
+                    self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+                });
+                 return self.fecthAccountJournal();
+            }).then(function(AccountJournal){
+                self.AccountJournal = AccountJournal;
                 return self.fetchResPartner();
             }).then(function(ResPartner){
                 self.ResPartner = ResPartner;
@@ -86,6 +96,7 @@ function report_invoice_balance (reporting){
                 return self.BuildTable();
             });
         },
+
         fecthFecha: function() {
             var to;
             var dateFormat1 = "mm/dd/yy",
@@ -119,7 +130,32 @@ function report_invoice_balance (reporting){
                 return date;
             }
         },
+
+        fecthResStore: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var field=['id', 'name'];
+            var ResStore = new instance.web.Model('res.store');
+            ResStore.query(field).all().then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
+        fecthAccountJournal: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var field = ['id', 'name','store_ids'];
+            var domain = [['active','=',true],['type','in',['sale','purchase']]];
+            var AccountJournal = new instance.web.Model('account.journal');
+            AccountJournal.query(field).filter(domain).all().then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
         fetchAccountInvoice: function () {
+            var self = this;
             var filter = [['type','not in',['in_refund','out_refund']],['state','in',['open','paid']]];
             var field = ['id', 'type', 'number', 'origin', 'state', 'journal_id', 'currency_id', 'supplier_invoice_number','date_invoice','partner_id','amount_total','user_id','type','residual'];
             var defer = $.Deferred();
@@ -129,6 +165,7 @@ function report_invoice_balance (reporting){
             });
             return defer;
         },
+
         fetchResPartner: function() {
             var self = this;
             var defer = $.Deferred();
@@ -138,6 +175,7 @@ function report_invoice_balance (reporting){
             });
             return defer;
         },
+
         valorNull:function(dato){
             var valor ="";
             if (dato){
@@ -145,6 +183,7 @@ function report_invoice_balance (reporting){
             }
             return valor;
         },
+
         search: function () {
             var self = this;
             var results = self.ResPartner;
@@ -170,9 +209,18 @@ function report_invoice_balance (reporting){
                 }
             });
         },
+
+        getAccountJournal: function (id) {
+            var self = this;
+            return _.filter(self.AccountJournal,function (item) {
+                return item.id === id;
+            });
+        },
+
         BuildTable: function(){
             var self = this;
             var data = [];
+            console.log(self);
             var AccountInvoice = self.AccountInvoice;
             var amount_total_num;
             var entry;
@@ -202,40 +250,47 @@ function report_invoice_balance (reporting){
                         invoice_type = 'purchase';
                     }
                 }
-                data.push({
-                    id : item.id,
-                    number: item.number,
-                    partner: item.partner_id[1],
-                    date_invoice: moment(item.date_invoice).format("DD/MM/YYYY"),
-                    user: item.user_id[1],
-                    amount_total: accounting.formatNumber(item.amount_total,0,".",","),
-                    entry: accounting.formatNumber(entry,0,".",","),
-                    egress: accounting.formatNumber(egress,0,".",","),
-                    to_receive: accounting.formatNumber(to_receive,0,".",","),
-                    to_pay: accounting.formatNumber(to_pay,0,".",","),
-                    state: item.state,
-                    invoice_type: invoice_type,
-                    date: item.date_invoice,
-                    journal_id : item.journal_id[0],
-                    currency_id : item.currency_id[0],
-                    partner_id : item.partner_id[0],
-                    amount_total_num: item.amount_total,
-                    entry_num: entry,
-                    egress_num: egress,
-                    to_receive_num: to_receive,
-                    to_pay_num: to_pay,
-                });
+                var store_id = self.getAccountJournal(item.journal_id[0]);
+                if(store_id.length > 0){
+                    data.push({
+                        id : item.id,
+                        number: item.number,
+                        partner: item.partner_id[1],
+                        date_invoice: moment(item.date_invoice).format("DD/MM/YYYY"),
+                        user: item.user_id[1],
+                        amount_total: accounting.formatNumber(item.amount_total,0,".",","),
+                        entry: accounting.formatNumber(entry,0,".",","),
+                        egress: accounting.formatNumber(egress,0,".",","),
+                        to_receive: accounting.formatNumber(to_receive,0,".",","),
+                        to_pay: accounting.formatNumber(to_pay,0,".",","),
+                        state: item.state,
+                        invoice_type: invoice_type,
+                        date: item.date_invoice,
+                        journal_id : item.journal_id[0],
+                        currency_id : item.currency_id[0],
+                        partner_id : item.partner_id[0],
+                        amount_total_num: item.amount_total,
+                        entry_num: entry,
+                        egress_num: egress,
+                        to_receive_num: to_receive,
+                        to_pay_num: to_pay,
+                        store_id: store_id[0].store_ids[0],
+                    });
+                }
             });
             self.content = data;
             this.loadTable(data);
         },
+
         factSearch: function(){
             var self = this;
             var hoy = moment().format('YYYY-MM-DD');
-            var desde =this.$el.find('#from').val();
-            var hasta =this.$el.find('#to').val();
-            var partner= this.$el.find('#partner').val().split('-');
+            var desde = this.$el.find('#from').val();
+            var hasta = this.$el.find('#to').val();
+            var partner = this.$el.find('#partner').val().split('-');
+            var store = this.$el.find('#current-store').val();
             var content = self.content;
+
             if ($('#A').is(":checked")){
                 content = _.filter(content, function (inv){
                     return inv.date == hoy;
@@ -331,6 +386,11 @@ function report_invoice_balance (reporting){
                     return inv.partner_id == partner[0];
                 });
             }
+            if(store != 9999999){
+                content=_.filter(content, function (inv){ 
+                    return inv.store_id == store
+                });
+            }
 
             var amount_entry_num = _.reduce(_.map(content,function(map){
                 return(map.entry_num);
@@ -367,12 +427,14 @@ function report_invoice_balance (reporting){
 
             self.loadTable(content)
         },
+
         loadTable:function(rowsTable){
             var self = this;
             self.rowsData = rowsTable;
             var table = this.$el.find('#table');
             table.bootstrapTable('load',rowsTable);
         },
+
         getObjectPdf: function(rowsTable){
             var self = this;
             var rowsPdf=[];
@@ -423,6 +485,7 @@ function report_invoice_balance (reporting){
 
             return rows;
         },
+
         clickOnAction: function (e) {
             var self = this;
             var rowsNew;
@@ -450,6 +513,7 @@ function report_invoice_balance (reporting){
                 this.drawPDF(_.flatten(getColumns),rows);
             }
         },
+
         drawPDF: function (getColumns,rows) {
             var self = this;
             var hoy = moment().format('DD/MM/YYYY');

+ 52 - 30
static/src/js/reports/report_pos.js

@@ -19,7 +19,7 @@ function report_pos(reporting){
             'click #D' : 'factSearch',
             'click #Z' : 'factSearch',
             'change #from' : 'factSearch',
-            'change #current-journal' : 'factSearch',
+            'change #current-store' : 'factSearch',
             'change #to' : 'factSearch',
             'click-row.bs.table #table ' : 'ckickAnalysisDetail',
         },
@@ -108,16 +108,19 @@ function report_pos(reporting){
                 return self.fetchStatementLine(PosOrder);
             }).then(function(StatementLine){
                 self.StatementLine=StatementLine;
-                return self.fetchAccountJournal();
-            }).then(function (AccountJournal) {
-                self.AccountJournal =AccountJournal;
-                self.$el.find('#current-journal').append('<option value="9999999">Todos los pagos</option>');
-                _.each(AccountJournal, function (item) {
-                    self.$el.find('#current-journal').append('<option value="' + item.id + '">' + item.name + '</option>');
+                return self.fecthResStore();
+            }).then(function(ResStore){
+                self.ResStore = ResStore;
+                self.$el.find('#current-store').append('<option value="9999999">Todas las SUC.</option>');
+                _.each(ResStore,function(item){
+                    self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
                 });
+                 return self.fecthAccountJournal();
+            }).then(function(AccountJournal){
+                self.AccountJournal = AccountJournal;
                 return self.fetchResPartner();
             }).then(function(ResPartner){
-                self.ResPartner=ResPartner;
+                self.ResPartner = ResPartner;
                 self.search();
                 return self.BuildTable();
             });
@@ -171,10 +174,33 @@ function report_pos(reporting){
             }
         },
 
+        fecthResStore: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var field=['id', 'name'];
+            var ResStore = new instance.web.Model('res.store');
+            ResStore.query(field).all().then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
+        fecthAccountJournal: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var field = ['id', 'name','store_ids'];
+            var domain = [['active','=',true],['type','in',['sale','purchase']]];
+            var AccountJournal = new instance.web.Model('account.journal');
+            AccountJournal.query(field).filter(domain).all().then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
         fetchPosOrder: function () {
             var self = this;
             var filter =[['state', 'in',['done','paid','invoiced']]];
-            var field =['id', 'name', 'session_id', 'state', 'table_id', 'statement_ids','date_order','partner_id','amount_total','user_id','amount_tax'];
+            var field =['id', 'name', 'session_id', 'state', 'table_id', 'statement_ids','date_order','partner_id','amount_total','user_id','amount_tax','sale_journal'];
             var defer = $.Deferred();
             var modules = self.checkModel('point_of_sale');
 
@@ -203,20 +229,6 @@ function report_pos(reporting){
             return defer;
         },
 
-        fetchAccountJournal: function () {
-            var self = this;
-            var defer = $.Deferred();
-            var journal_id = _.flatten(_.map(self.StatementLine, function (item) {
-                return item.journal_id;
-            }));
-            var AccountJournal = new instance.web.Model('account.journal');
-            var domain = [['id','in', journal_id]];
-            AccountJournal.query(['id','name']).filter([['active','=',true],['type', 'in', ['bank','cash']]]).all().then(function(results){
-                defer.resolve(results);
-            });
-            return defer;
-        },
-
         fetchResPartner: function() {
             var self = this;
             var defer = $.Deferred();
@@ -268,15 +280,25 @@ function report_pos(reporting){
             });
         },
 
+        getAccountJournal: function (id) {
+            var self = this;
+            return _.filter(self.AccountJournal,function (item) {
+                return item.id === id;
+            });
+        },
+
         BuildTable: function(){
             var self = this;
             var PosOrder = self.PosOrder;
             var data = [];
             var order = [];
-            var amount_total_total=0;
+            var store = [];
+            var amount_total_total = 0;
+            console.log(self);
             _.each(PosOrder, function(item){
                 order = self.getStatementLine(item.id);
-                if(order.length > 0){
+                store = self.getAccountJournal(item.sale_journal[0]);
+                if(order.length > 0 & store.length > 0){
                     data.push({
                         id : item.id,
                         number: item.name,
@@ -289,11 +311,11 @@ function report_pos(reporting){
                         amount : item.amount_total,
                         journal_id: order[0].journal_id[0],
                         journal_name: order[0].journal_id[1],
-                        user: item.user_id[1]
+                        user: item.user_id[1],
+                        store_id : store[0].store_ids[0]
                     });
                 }
             });
-
             self.content = data;
             this.loadTable(data);
         },
@@ -301,7 +323,7 @@ function report_pos(reporting){
         factSearch: function(){
             var self = this;
             var hoy = moment().format('YYYY-MM-DD');
-            var journal = this.$el.find('#current-journal').val();
+            var store = this.$el.find('#current-store').val();
             var desde =this.$el.find('#from').val();
             var hasta =this.$el.find('#to').val();
             var partner= this.$el.find('#partner').val().split('-');
@@ -367,9 +389,9 @@ function report_pos(reporting){
             }else{
                 $('#datepicker').css('display','none');
             }
-            if (journal != 9999999){
+            if (store != 9999999){
                 content = _.filter(content,function(inv){
-                    return inv.journal_id == journal[0];
+                    return inv.store_id == store;
                 });
             }
             if (partner != ""){

+ 129 - 32
static/src/js/reports/report_pos_orders.js

@@ -18,8 +18,10 @@ function report_pos_orders(reporting){
             'click #Z' : 'fectSearch',
             'change #from' : 'fectSearch',
             'change #to': 'fectSearch',
+            'change #current-category' : 'fectSearch',
             'change #current-floor': 'fectSearch',
             'change #current-table': 'fectSearch',
+            'change #current-store': 'fectSearch',
             'click-row.bs.table #table' : 'clickAnalysisDetail',
         },
 
@@ -105,7 +107,7 @@ function report_pos_orders(reporting){
             return valor;
         },
 
-        // Cansultar
+        // Consultar
         submitForm: function () {
             var self = this;
             this.fetchPosOrder().then(function(PosOrder) {
@@ -121,6 +123,13 @@ function report_pos_orders(reporting){
                 return self.fetchProductProduct();
             }).then(function (ProductProduct) {
                 self.ProductProduct = ProductProduct;
+                return self.fecthPosCategory();
+            }).then(function(PosCategory){
+                self.PosCategory = PosCategory;
+                self.$el.find('#current-category').append('<option value="9999999">Todos las categorias</option>');
+                _.each(PosCategory, function (item) {
+                    self.$el.find('#current-category').append('<option value="' + item.id + '">' + item.name + '</option>');
+                });
                 return self.fetchPosFloor();
             }).then(function(PosFloor){
                 self.PosFloor = PosFloor;
@@ -135,16 +144,49 @@ function report_pos_orders(reporting){
                 _.each(PosTable,function(item){
                      self.$el.find('#current-table').append('<option value="' + item.id + '">' + item.name + '</option>');
                 });
+                return self.fecthResStore();
+            }).then(function(ResStore){
+                self.ResStore = ResStore;
+                self.$el.find('#current-store').append('<option value="9999999">Todas las SUC.</option>');
+                _.each(ResStore,function(item){
+                    self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+                });
+                 return self.fecthAccountJournal();
+            }).then(function(AccountJournal){
+                self.AccountJournal = AccountJournal;
                 self.searchProduct();
                 return self.BuildTable();
             });
         },
 
+        fecthResStore: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var field=['id', 'name'];
+            var ResStore = new model.web.Model('res.store');
+            ResStore.query(field).all().then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
+        fecthAccountJournal: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var field = ['id', 'name','store_ids'];
+            var domain = [['active','=',true],['type','in',['sale','purchase']]];
+            var AccountJournal = new model.web.Model('account.journal');
+            AccountJournal.query(field).filter(domain).all().then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
         // Ventas (Point Of Sale)
         fetchPosOrder: function () {
             var self = this;
             var defer = $.Deferred();
-            var fields = ['id','name','date_order','lines','table_id'];
+            var fields = ['id','name','date_order','lines','table_id','sale_journal'];
             var domain = [['state', 'not in', ['draft','cancel']]];
             var PosOrder = new model.web.Model('pos.order');
             PosOrder.query(fields).filter(domain).all().then(function(results){
@@ -189,7 +231,7 @@ function report_pos_orders(reporting){
             var porduct_ids = _.flatten(_.map(self.PosOrderLine, function (item) {
                 return item.product_id[0];
             }));
-            var fields = ['id','name', 'default_code', 'name_template','ean13', 'standard_price','type','attribute_str'];
+            var fields = ['id','name', 'default_code', 'name_template','pos_categ_id', 'ean13', 'standard_price','type','attribute_str'];
             var domain = [['id', 'in', porduct_ids]];
             var ProductProduct =  new model.web.Model('product.product');
             ProductProduct.query(fields).filter(domain).all().then(function (results) {
@@ -198,6 +240,17 @@ function report_pos_orders(reporting){
             return defer;
         },
 
+        fecthPosCategory: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var fields = ['id','name'];
+            var PosCategory =  new model.web.Model('pos.category');
+            PosCategory.query(fields).filter().all().then(function (results) {
+                defer.resolve(results)
+            });
+            return defer;
+        },
+
         // Mesa o delivery
         fetchPosTable: function(){
             var self = this;
@@ -243,15 +296,43 @@ function report_pos_orders(reporting){
             });
         },
 
+        getPosCategory: function(id){
+            var self = this;
+            return _.filter(self.PosCategory, function(item){
+                return item.id == id;
+            });
+        },
+
+        getAccountJournal: function (id) {
+            var self = this;
+            return _.filter(self.AccountJournal,function (item) {
+                return item.id === id;
+            });
+        },
+
         BuildTable: function(){
             var self = this;
             var PosOrderLine = self.PosOrderLine;
             var data = [];
             var order;
             var product;
+            var category;
+            var category_name;
+            var category_id;
+            var store;
+
             _.each(PosOrderLine, function(item){
                 product = self.getProductProduct(item.product_id[0]);
                 order = self.getPosOrder(item.order_id[0]).shift();
+                store = self.getAccountJournal(order.sale_journal[0]);
+                category = self.getPosCategory(item.product_id[0]);
+                if(category.length > 0){
+                    category_name = category[0].name;
+                    category_id = category[0].id;
+                }else {
+                    category_name = '';
+                    category_id = '';
+                }
                 var place_id;
                 var place_name;
                 var floor;
@@ -261,35 +342,29 @@ function report_pos_orders(reporting){
                     place_id = order.table_id[0];
                     place_name = order.table_id[1];
                 }
-                data.push({
-                    id : item.id,
-                    order_id : item.order_id[0],
-                    order_name : item.order_id[1],
-                    date : order.date_order,
-                    date_order : moment(order.date_order).format("DD/MM/YYYY"),
-                    table_id : self.valorNull(place_id),
-                    table_name : self.valorNull(place_name),
-                    floor_id : floor,
-                    product_id : item.product_id[0],
-                    product_name : item.product_id[1],
-                    price_unit : accounting.formatNumber(item.price_unit,0,".",","),
-                    qty : accounting.formatNumber(item.qty,0,".",","),
-                    price_subtotal_incl : accounting.formatNumber(item.price_subtotal_incl,0,".",","),
-                    price_subtotal_total : item.price_subtotal_incl,
-                });
+                if(store.length > 0){
+                    data.push({
+                        id : item.id,
+                        order_id : item.order_id[0],
+                        order_name : item.order_id[1],
+                        date : order.date_order,
+                        date_order : moment(order.date_order).format("DD/MM/YYYY"),
+                        table_id : self.valorNull(place_id),
+                        table_name : self.valorNull(place_name),
+                        floor_id : floor,
+                        product_id : item.product_id[0],
+                        product_name : item.product_id[1],
+                        price_unit : accounting.formatNumber(item.price_unit,0,".",","),
+                        qty : accounting.formatNumber(item.qty,0,".",","),
+                        price_subtotal_incl : accounting.formatNumber(item.price_subtotal_incl,0,".",","),
+                        price_subtotal_total : item.price_subtotal_incl,
+                        store_id : store[0].store_ids[0],
+                        qty_total : item.qty,
+                        category_name : category_name,
+                        category_id : category_id,
+                    });
+                }
             });
-
-            // var amount_total_total = _.reduce(_.map(data,function(map){
-            //     return(map.price_subtotal_total);
-            // }),function(memo, num){
-            //     return memo + num;
-            // },0);
-            //
-            // data.push({
-            //     order_name: "Total",
-            //     price_subtotal_incl: accounting.formatNumber((amount_total_total),0,".",","),
-            // });
-
             self.content = data;
             self.loadTable(data)
         },
@@ -298,6 +373,8 @@ function report_pos_orders(reporting){
             var self = this;
             var floor =this.$el.find('#current-floor').val();
             var table =this.$el.find('#current-table').val();
+            var category = this.$el.find('#current-category').val();
+            var store =this.$el.find('#current-store').val();
             var desde =this.$el.find('#from').val();
             var hasta =this.$el.find('#to').val();
             var product = this.$el.find('#product').val().split('-');
@@ -369,6 +446,24 @@ function report_pos_orders(reporting){
                 });
             }
 
+            if(category != 9999999){
+                content = _.filter(content,function(inv){
+                    return inv.category_id == category;
+                });
+            }
+
+            if (store != 9999999){
+                content=_.filter(content, function (inv){
+                    return inv.store_id == store;
+                });
+            }
+
+            var qty_total_total = _.reduce(_.map(content,function(map){
+                return(map.qty_total);
+            }),function(memo, num){
+                return memo + num;
+            },0);
+
             var amount_total_total = _.reduce(_.map(content,function(map){
                 return(map.price_subtotal_total);
             }),function(memo, num){
@@ -377,6 +472,7 @@ function report_pos_orders(reporting){
 
             content.push({
                 order_name: "Total",
+                qty: accounting.formatNumber((qty_total_total),0,".",","),
                 price_subtotal_incl: accounting.formatNumber((amount_total_total),0,".",","),
             });
 
@@ -470,6 +566,7 @@ function report_pos_orders(reporting){
                 columnStyles: {
                     order_name: {halign:'left', fontStyle: 'bold'},
                     date_order :{halign:'left'},
+                    category_name :{halign:'left', columnWidth: '8px'},
                     table_id :{halign:'left'},
                     product_name :{halign:'left' },
                     price_unit : {halign:'right' },
@@ -481,7 +578,7 @@ function report_pos_orders(reporting){
                     pdfDoc.setFontSize(12);
                     pdfDoc.setFontStyle('bold');
                     pdfDoc.setTextColor(40);
-                    pdfDoc.text('Análisis de pedidos (Point Of Sale)', data.settings.margin.left, 10);
+                    pdfDoc.text('Análisis de Ventas (Punto de Ventas)', data.settings.margin.left, 10);
 
                     if(desde.length > 0 || hasta.length > 0){
                       var fecha='';

+ 336 - 0
static/src/js/reports/report_product_pack.js

@@ -0,0 +1,336 @@
+function report_product_pack (reporting) {
+    "use strict";
+
+    var instance = openerp;
+
+    reporting.ReportProductPackWidget = reporting.Base.extend({
+        template: 'ReportProductPack',
+        data: [],
+        PosOrderLine: [],
+        PosOrder: [],
+        invoiceLine: [],
+        productProduct: [],
+        productPack: [],
+        productAtributo: [],
+        ranking: [],
+        content: [],
+        modelId: [],
+
+        events:{
+            'click #toolbar > button' : 'clickOnAction',
+            'click #X' : 'factSearch',
+            'click #A' : 'factSearch',
+            'click #B' : 'factSearch',
+            'click #C' : 'factSearch',
+            'click #D' : 'factSearch',
+            'click #Z' : 'factSearch',
+
+            'click #Y' : 'factSearch',
+            'click-row.bs.table #table ' : 'clickAnalysisDetail',
+        },
+
+        init : function(parent){
+            this._super(parent);
+        },
+
+        start: function () {
+            var self = this;
+            var table = this.$el.find('#table');
+            table.bootstrapTable({data : self.rowsData});
+            this.submitForm();
+        },
+
+        // Redirecionar
+        renderReport: function () {
+            var self = this;
+
+            var container = this.$el.closest('.oe_form_sheet.oe_form_sheet_width');
+            this.$el.closest('.report_view').remove();
+            container.find('.report_view').show({
+                effect: 'fade',
+                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
+        },
+
+        submitForm: function () {
+            var self = this;
+            self.fecthIrModuleModule().then(function(modules){
+                self.modules = modules;
+                return modules;
+            }).then(function(modules){
+                return self.fecthProductProduct();
+            }).then(function(productProduct){
+                self.productProduct = productProduct;
+                return self.fetchProductPack();
+            }).then(function(productPack){
+                self.productPack = productPack;
+                self.search();
+                return self.BuildTable();
+            });
+        },
+
+        // Modelos instalados
+        fecthIrModuleModule: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var fields = ['name','id'];
+            var domain=[['state','=','installed']];
+            var irModule = new instance.web.Model('ir.module.module');
+            irModule.query(fields).filter(domain).all().then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
+        // Obtener Productos
+        fecthProductProduct: function() {
+            var self = this;
+            var defer = $.Deferred();
+            var modules = self.checkModel('product_pack');
+
+            if (modules.length <= 0){
+                self.showMensaje('product_pack');
+                return defer;
+            }
+
+            var fields = ['id', 'name','name_template', 'pack_line_ids','type', 'ean13','attribute_str'];
+            var domain = [['active', '=', true],['pack', '=', true]];
+            var ProductProduct = new instance.web.Model('product.product');
+            ProductProduct.query(fields).filter(domain).all().then(function (results) {
+                defer.resolve(results);
+            });
+
+            return defer;
+        },
+
+        valorNull:function(dato){
+            var valor ="";
+            if (dato){
+                valor=dato;
+            }
+            return valor;
+        },
+
+        // Product Pack
+        fetchProductPack: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var ids = _.flatten(_.map(self.productProduct,function (item) {
+                return item.id;
+            }));
+            var fields = ['id','product_id', 'price','parent_product_id', 'quantity', 'subtotal'];
+            var domain = [['parent_product_id', 'in', ids]];
+            var ProductPack =  new instance.web.Model('product.pack.line');
+            ProductPack.query(fields).filter(domain).all().then(function (results) {
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
+        getProductPack: function(id){
+            var self = this;
+            return _.filter(self.productPack,function (item) {
+                return item.parent_product_id[0] == id;
+            });
+        },
+
+        search: function () {
+            var self = this;
+            var results = self.productProduct;
+            results = _.map(results, function (item) {
+                return {
+                        label: item.id + '- '+ ' [ ' + self.valorNull(item.ean13) + ' ] ' + item.name + ' ( ' +  self.valorNull(item.attribute_str) + ' ) ' ,
+                        value: item.id + '- '+ ' [ ' + 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.factSearch();
+                    }
+                },
+                close: function( event, ui ) {
+                        self.factSearch();
+                },
+                select: function(event, ui) {
+                    self.factSearch();
+                }
+            });
+        },
+
+        // Generar el ranking
+        BuildTable: function() {
+            var self = this;
+            var ProductProduct = self.productProduct;
+            var itemProduct;
+            var itemLine;
+            var itemProductPack;
+            var itemPack;
+            var qty = 0;
+            var rankingItem = [];
+            var rankingCab = [];
+            var cat = 0;
+            var countPack = 0;
+
+            _.each(ProductProduct, function(item){
+                itemProductPack = self.getProductPack(item.id);
+                for (var i = 0; i < itemProductPack.length; i++) {
+                    if (itemProductPack.length > 0){
+                        rankingItem.push({
+                            product_main: "",
+                            product: itemProductPack[i].product_id[1],
+                            qty: accounting.formatNumber(itemProductPack[i].quantity,3,".",","),
+                            //id: itemProductPack.parent_product_id[0],
+                            countPack: itemProductPack[i].quantity,
+                            product_main_id: itemProductPack[i].parent_product_id[0],
+                        })
+                    }
+                }
+                rankingItem.unshift({
+                    product_main: item.name_template,
+                    product: "",
+                    qty: "",
+                    countPack: ""
+                });
+                // Generar Objeto Principal
+                rankingItem=rankingItem.concat(rankingCab);
+
+            });
+
+            self.content = rankingItem;
+            self.loadTable(rankingItem);
+
+        },
+
+        factSearch: function(){
+            var self = this;
+            var product = this.$el.find('#product').val().split('-');
+            var content = self.content;
+
+            if (product != ""){
+                content = _.filter(content, function(inv){
+                    return inv.parent_product_id[0] == product[0];
+                });
+            }
+
+            self.loadTable(content)
+        },
+
+        loadTable:function(rowsTable){
+            var self = this;
+            self.rowsData = rowsTable;
+            var table = this.$el.find('#table');
+            table.bootstrapTable('load',rowsTable);
+        },
+
+        getObjetPdf: function(rowsTable){
+            var self = this;
+            var rows=self.rowsData;
+
+            return rows;
+        },
+
+        clickOnAction: function (e) {
+            var self = this;
+            var rowsNew;
+            var action = self.$el.find(e.target).val();
+            var table = self.$el.find("#table");
+            var data2 = table.bootstrapTable('getVisibleColumns');
+            var getColumns=[];
+            var rows=[];
+            rowsNew = self.getObjetPdf();
+            if (action === 'pdf') {
+                var dataNEW = _.map(data2, function (val){
+                    return val.field;
+                });
+                _.each(rowsNew,function (item){
+                    rows.push(_.pick(item, dataNEW));
+                });
+                // Obtener los nombre de la Cabezera
+                _.each(_.map(data2,function(val){
+                        return val;
+                    }), function(item){
+                            getColumns.push([{
+                                        title: item.title,
+                                        dataKey: item.field
+                                    }]);
+                });
+                this.drawPDF(_.flatten(getColumns),rows);
+            }
+        },
+        drawPDF: function (getColumns,rows) {
+            var self = this;
+            var fechaActu= new Date();
+            var totalPagesExp = "{total_pages_count_string}";
+            var pdfDoc = new window.jsPDF();
+
+            pdfDoc.autoTable(getColumns, rows, {
+                styles: { overflow: 'linebreak', fontSize: 8, columnWidth: 'wrap'},
+                columnStyles: {
+                    product_main : {columnWidth: '6px'},
+                    product : {columnWidth: '8px'},
+                    qty : {halign:'right',columnWidth: '6px'},
+                },
+                margin: { top: 16, horizontal: 7},
+                addPageContent: function (data) {
+                    pdfDoc.setFontSize(12);
+                    pdfDoc.setFontStyle('bold');
+                    pdfDoc.setTextColor(40);
+                    pdfDoc.text('Listado Receta de Producto ', data.settings.margin.left, 10);
+                    // FOOTER
+                    var str = "Pagina  " + data.pageCount;
+                    // Total page number plugin only available in jspdf v1.0+
+                    if (typeof pdfDoc.putTotalPages === 'function') {
+                        str = str + " de " + totalPagesExp;
+                    }
+                    pdfDoc.setFontSize(9);
+                    pdfDoc.setFontStyle('bold');
+                    pdfDoc.setTextColor(40);
+                    pdfDoc.text(str, data.settings.margin.left, pdfDoc.internal.pageSize.height - 5);
+                    }
+            });
+
+            if (typeof pdfDoc.putTotalPages === 'function') {
+                pdfDoc.putTotalPages(totalPagesExp);
+            }
+            pdfDoc.save('Listado Receta de Producto.pdf')
+        },
+    });
+}

+ 548 - 0
static/src/js/reports/report_product_pack_utilidad.js

@@ -0,0 +1,548 @@
+function report_product_pack_utilidad (reporting) {
+    "use strict";
+
+    var instance = openerp;
+
+    reporting.ReportProductPackUtilidadWidget = reporting.Base.extend({
+        template: 'ReportProductPackUtilidad',
+        data: [],
+        PosOrderLine: [],
+        PosOrder: [],
+        invoiceLine: [],
+        productProduct: [],
+        productPack: [],
+        productAtributo: [],
+        ranking: [],
+        content: [],
+        modelId: [],
+
+        events:{
+            'click #toolbar > button' : 'clickOnAction',
+            'click #X' : 'factSearch',
+            'click #A' : 'factSearch',
+            'click #B' : 'factSearch',
+            'click #C' : 'factSearch',
+            'click #D' : 'factSearch',
+            'click #Z' : 'factSearch',
+            'change #from' : 'factSearch',
+            'change #to': 'factSearch',
+
+            'click #Y' : 'factSearch',
+            'click-row.bs.table #table ' : 'clickAnalysisDetail',
+        },
+
+        init : function(parent){
+            this._super(parent);
+        },
+
+        start: function () {
+            var self = this;
+            var table = this.$el.find('#table');
+            table.bootstrapTable({data : self.rowsData});
+            this.fecthFecha();
+            this.submitForm();
+        },
+
+        // Redirecionar
+        renderReport: function () {
+            var self = this;
+
+            var container = this.$el.closest('.oe_form_sheet.oe_form_sheet_width');
+            this.$el.closest('.report_view').remove();
+            container.find('.report_view').show({
+                effect: 'fade',
+                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
+        },
+
+        fecthFecha: function() {
+            var to;
+            var dateFormat1 = "mm/dd/yy",
+                from = $( "#from" )
+                .datepicker({
+                  dateFormat: "dd/mm/yy",
+                  changeMonth: true,
+                  numberOfMonths: 1,
+                })
+                .on( "change", function() {
+                  to.datepicker( "option", "minDate", getDate(this), "dd/mm/yyyy");
+                });
+                to = $( "#to" ).datepicker({
+                dateFormat: "dd/mm/yy",
+                defaultDate: "+7d",
+                changeMonth: true,
+                numberOfMonths: 1,
+                })
+                .on( "change", function() {
+                    from.datepicker( "option", "maxDate", getDate(this));
+                });
+            function getDate( element ) {
+                var fechaSel =element.value.split('/');
+                var date;
+                try {
+                    date = $.datepicker.parseDate( dateFormat1, (fechaSel[1]+"/"+fechaSel[0]+"/"+fechaSel[2]));
+                } catch( error ) {
+                    date = null;
+                }
+                return date;
+            }
+        },
+
+        submitForm: function () {
+            var self = this;
+            self.fecthIrModuleModule().then(function(modules){
+                self.modules = modules;
+                return modules;
+            }).then(function(modules){
+                return self.fecthPosOrder();
+            }).then(function (PosOrder) {
+                self.PosOrder = PosOrder;
+                return self.fecthPosOrderLine(PosOrder);
+            }).then(function (PosOrderLine) {
+                self.PosOrderLine = PosOrderLine;
+                return self.fetchProductProduct();
+            }).then(function (ProductProduct) {
+                self.ProductProduct = ProductProduct;
+                return self.fetchProductPack();
+            }).then(function(productPack){
+                self.productPack = productPack;
+                self.search();
+                return self.BuildTable();
+            });
+        },
+
+        fecthFecha: function() {
+            var to;
+            var dateFormat1 = "mm/dd/yy",
+                from = $( "#from" )
+                .datepicker({
+                  dateFormat: "dd/mm/yy",
+                  changeMonth: true,
+                  numberOfMonths: 1,
+                })
+                .on( "change", function() {
+                  to.datepicker( "option", "minDate", getDate(this), "dd/mm/yyyy");
+                });
+                to = $( "#to" ).datepicker({
+                dateFormat: "dd/mm/yy",
+                defaultDate: "+7d",
+                changeMonth: true,
+                numberOfMonths: 1,
+                })
+                .on( "change", function() {
+                    from.datepicker( "option", "maxDate", getDate(this));
+                });
+            function getDate( element ) {
+                var fechaSel =element.value.split('/');
+                var date;
+                try {
+                    date = $.datepicker.parseDate( dateFormat1, (fechaSel[1]+"/"+fechaSel[0]+"/"+fechaSel[2]));
+                } catch( error ) {
+                    date = null;
+                }
+                return date;
+            }
+        },
+        // Modelos instalados
+        fecthIrModuleModule: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var fields = ['name','id'];
+            var domain=[['state','=','installed']];
+            var irModule = new instance.web.Model('ir.module.module');
+            irModule.query(fields).filter(domain).all().then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
+        // Obtener Pedido
+        fecthPosOrder: function() {
+            var self = this;
+            var defer = $.Deferred();
+            var modules = self.checkModel('point_of_sale');
+
+            if (modules.length <= 0){
+                self.showMensaje('point_of_sale');
+                return defer;
+            }
+
+            var fields = ['id', 'lines', 'date_order'];
+        //    var domain = [['date_order', '>=', desde], ['date_order', '<', hasta], ['state', 'in', ['paid','done','invoiced']]];
+            var domain = [ ['state', 'in', ['paid','done','invoiced']]];
+            var PosOrder = new instance.web.Model('pos.order');
+            PosOrder.query(fields).filter(domain).all().then(function (results) {
+                defer.resolve(results);
+            });
+
+            return defer;
+        },
+        // Obtener linea de la factura
+        fecthPosOrderLine: function(PosOrder) {
+            var self = this;
+            var defer = $.Deferred();
+            var lines = _.flatten(_.map(PosOrder, function (item) {
+                return item.lines;
+            }));
+            var fields = ['id', 'product_id', 'create_date', 'qty'];
+            var domain = [['id','in', lines]];
+            var PosOrderLine = new instance.web.Model('pos.order.line');
+            PosOrderLine.query(fields).filter(domain).all().then(function (results) {
+                defer.resolve(results);
+            });
+
+            return defer;
+        },
+        // Obtener Productos ['id', 'in', product_id],
+        fetchProductProduct: function (PosOrderLine) {
+            var self = this;
+
+            var defer = $.Deferred();
+            var modules = self.checkModel('product_pack');
+
+            if (modules.length <= 0){
+                self.showMensaje('product_pack');
+                return defer;
+            }
+            var product_id = _.flatten(_.map(PosOrderLine,function (item) {
+                return item.product_id[0];
+            }));
+            var fields = ['id', 'name','name_template', 'pack_line_ids','type', 'ean13','attribute_str', 'standard_price'];
+            var domain = [['active', '=', true],['pack', '=', true]];
+            var ProductProduct = new instance.web.Model('product.product');
+            ProductProduct.query(fields).filter(domain).all().then(function (results) {
+                defer.resolve(results);
+            });
+
+            return defer;
+        },
+
+        valorNull:function(dato){
+            var valor ="";
+            if (dato){
+                valor=dato;
+            }
+            return valor;
+        },
+
+        // Product Pack
+        fetchProductPack: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var ids = _.flatten(_.map(self.ProductProduct,function (item) {
+                return item.id;
+            }));
+            var fields = ['id','product_id', 'price','parent_product_id', 'quantity', 'subtotal'];
+            var domain = [['parent_product_id', 'in', ids]];
+            var ProductPack =  new instance.web.Model('product.pack.line');
+            ProductPack.query(fields).filter(domain).all().then(function (results) {
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
+        getProductPack: function(id){
+            var self = this;
+            return _.filter(self.productPack,function (item) {
+                return item.parent_product_id[0] == id;
+            });
+        },
+
+        getPosOrder: function(id){
+            var self = this;
+            return _.filter(self.PosOrder,function (item) {
+                return item.id == id;
+            });
+        },
+
+        getProductProduct: function(id){
+            var self = this;
+            return _.filter(self.ProductProduct,function (item) {
+                return item.id == id;
+            });
+        },
+
+        search: function () {
+            var self = this;
+            var results = self.ProductProduct;
+            results = _.map(results, function (item) {
+                return {
+                        label: item.id + '- '+ ' [ ' + self.valorNull(item.ean13) + ' ] ' + item.name + ' ( ' +  self.valorNull(item.attribute_str) + ' ) ' ,
+                        value: item.id + '- '+ ' [ ' + 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.factSearch();
+                    }
+                },
+                close: function( event, ui ) {
+                        self.factSearch();
+                },
+                select: function(event, ui) {
+                    self.factSearch();
+                }
+            });
+        },
+
+        // Obtener facturas por cada clientes
+        getPosOrderLiners:function(product_id) {
+            var self = this;
+            var desde = self.$el.find('#from').val();
+            var hasta = self.$el.find('#to').val();
+            var PosOrderLine = self.PosOrderLine;
+            // Hoy
+            if ($('#A').is(":checked")){
+                PosOrderLine = _.filter(PosOrderLine, function (inv){
+                    return moment(inv.create_date).format('YYYY-MM-DD') == moment().format('YYYY-MM-DD');
+                });
+            }
+            // Ayer
+            if ($('#B').is(":checked")){
+                PosOrderLine = _.filter(PosOrderLine, function (inv){
+                    return moment(inv.create_date).format('YYYY-MM-DD') == moment().add(-1,'days').format('YYYY-MM-DD');
+                });
+            }
+            // Mes Actual
+            if ($('#C').is(":checked")){
+                PosOrderLine = _.filter(PosOrderLine, function (inv){
+                    return moment(inv.create_date).format('MM') == moment().format('MM');
+                });
+            }
+            // Mes Pasado
+            if ($('#D').is(":checked")){
+                PosOrderLine = _.filter(PosOrderLine, function (inv){
+                    return moment(inv.create_date).format('MM') == moment().add(-1,'months').format('MM');
+                });
+            }
+            // Rango de fechas
+            if ($('#Z').is(":checked")){
+                $('#datepicker').css('display','block');
+                if (desde.length > 0){
+                    var date = desde.split('/');
+                    PosOrderLine = _.filter(PosOrderLine, function (inv){
+                        return moment(inv.create_date).format('YYYY-MM-DD') >= (date[2]+"-"+date[1]+"-"+date[0]);
+                    });
+                }
+                if (hasta.length > 0){
+                    var date= hasta.split('/');
+                    PosOrderLine = _.filter(PosOrderLine, function (inv){
+                        return moment(inv.create_date).format('YYYY-MM-DD') <= (date[2]+"-"+date[1]+"-"+date[0]);
+                    });
+                }
+            }else{
+                $('#datepicker').css('display','none');
+            }
+
+            return _.flatten(_.filter(PosOrderLine,function (inv) {
+                return inv.product_id[0] === product_id;
+            }));
+        },
+
+
+        // Generar el ranking
+        BuildTable: function() {
+            var self = this;
+            var itemProduct;
+            var itemLine;
+            var qty = 0;
+            var rankingCab = [];
+            var rankingItem = [];
+            var cat = 0;
+            var itemProductPack;
+            var countSalesOrder = 0;
+            var attribute;
+            var lineUnik;
+
+            for (var i = 0; i < self.ProductProduct.length; i++) {
+                itemProduct = self.ProductProduct[i];
+                itemLine = self.getPosOrderLiners(itemProduct.id);
+                if (itemLine.length > 0) {
+                    cat = _.reduce(_.map(itemLine, function (map) {
+                        return map.qty
+                    }), function (meno,num) {
+                        return meno + num
+                    }, 0);
+
+                    lineUnik = itemLine.shift();
+
+                    if(itemProduct.attribute_str){
+                        attribute = '*' + itemProduct.attribute_str;
+                    }else{
+                        attribute = ' ';
+                    }
+                }
+
+                itemProductPack = self.getProductPack(itemProduct.id);
+                for (var i = 0; i < itemProductPack.length; i++) {
+                    if (itemProductPack.length > 0){
+                        rankingItem.push({
+                            product_main: "",
+                            price_costo: "",
+                            product: itemProductPack[i].product_id[1],
+                            price_insumo: accounting.formatNumber(itemProductPack[i].price,2,".",","),
+                            qty_pos: cat,
+                            qty: accounting.formatNumber(itemProductPack[i].quantity,3,".",","),
+                            subtotal_total: (itemProductPack[i].price*itemProductPack[i].quantity*cat),
+                            subtotal: accounting.formatNumber(itemProductPack[i].subtotal,2,".",","),
+                            countPack: itemProductPack[i].quantity,
+                            product_main_id: itemProductPack[i].parent_product_id[0],
+                        })
+                    }
+                }
+                rankingItem.unshift({
+                    product_main: itemProduct.name_template,
+                    price_costo: itemProduct.standard_price,
+                    product: "",
+                    price_insumo: "",
+                    qty_pos: cat,
+                    qty: "",
+                    subtotal_total: (itemProduct.standard_price*cat),
+                    countPack: ""
+                });
+                    // Generar Objeto Principal
+                    rankingItem=rankingItem.concat(rankingCab);
+
+            }
+
+            self.content = rankingItem;
+            self.loadTable(rankingItem);
+
+        },
+
+        factSearch: function(){
+            var self = this;
+            var product = this.$el.find('#product').val().split('-');
+            var content = self.content;
+
+            if (product != ""){
+                content = _.filter(content, function(inv){
+                    return inv.parent_product_id[0] == product[0];
+                });
+            }
+
+            self.loadTable(content)
+        },
+
+        loadTable:function(rowsTable){
+            var self = this;
+            self.rowsData = rowsTable;
+            var table = this.$el.find('#table');
+            table.bootstrapTable('load',rowsTable);
+        },
+
+        getObjetPdf: function(rowsTable){
+            var self = this;
+            var rows=self.rowsData;
+
+            return rows;
+        },
+
+        clickOnAction: function (e) {
+            var self = this;
+            var rowsNew;
+            var action = self.$el.find(e.target).val();
+            var table = self.$el.find("#table");
+            var data2 = table.bootstrapTable('getVisibleColumns');
+            var getColumns=[];
+            var rows=[];
+            rowsNew = self.getObjetPdf();
+            if (action === 'pdf') {
+                var dataNEW = _.map(data2, function (val){
+                    return val.field;
+                });
+                _.each(rowsNew,function (item){
+                    rows.push(_.pick(item, dataNEW));
+                });
+                // Obtener los nombre de la Cabezera
+                _.each(_.map(data2,function(val){
+                        return val;
+                    }), function(item){
+                            getColumns.push([{
+                                        title: item.title,
+                                        dataKey: item.field
+                                    }]);
+                });
+                this.drawPDF(_.flatten(getColumns),rows);
+            }
+        },
+        drawPDF: function (getColumns,rows) {
+            var self = this;
+            var fechaActu= new Date();
+            var totalPagesExp = "{total_pages_count_string}";
+            var pdfDoc = new window.jsPDF();
+
+            pdfDoc.autoTable(getColumns, rows, {
+                styles: { overflow: 'linebreak', fontSize: 8, columnWidth: 'wrap'},
+                columnStyles: {
+                    product_main : {columnWidth: '6px'},
+                    product : {columnWidth: '8px'},
+                    price : {halign:'right',columnWidth: '6px'},
+                    qty_pos : {halign:'right',columnWidth: '5px'},
+                    qty : {halign:'right',columnWidth: '5px'},
+                    subtotal_total : {halign:'right',columnWidth: '6px'},
+                },
+                margin: { top: 16, horizontal: 7},
+                addPageContent: function (data) {
+                    pdfDoc.setFontSize(12);
+                    pdfDoc.setFontStyle('bold');
+                    pdfDoc.setTextColor(40);
+                    pdfDoc.text('Análisis de Utilidad de Pack de Producto ', data.settings.margin.left, 10);
+                    // FOOTER
+                    var str = "Pagina  " + data.pageCount;
+                    // Total page number plugin only available in jspdf v1.0+
+                    if (typeof pdfDoc.putTotalPages === 'function') {
+                        str = str + " de " + totalPagesExp;
+                    }
+                    pdfDoc.setFontSize(9);
+                    pdfDoc.setFontStyle('bold');
+                    pdfDoc.setTextColor(40);
+                    pdfDoc.text(str, data.settings.margin.left, pdfDoc.internal.pageSize.height - 5);
+                    }
+            });
+
+            if (typeof pdfDoc.putTotalPages === 'function') {
+                pdfDoc.putTotalPages(totalPagesExp);
+            }
+            pdfDoc.save('Análisis de Utilidad de Pack de Producto.pdf')
+        },
+    });
+}

+ 70 - 40
static/src/js/reports/report_purchases_invoice_analysis.js

@@ -21,16 +21,12 @@ function report_purchases_invoice_analysis (reporting){
             'click #C' : 'factSearch',
             'click #D' : 'factSearch',
             'click #Z' : 'factSearch',
-
             'click #Y' : 'factSearch',
             'click #purchase' : 'factSearch',
             'click #expense' : 'factSearch',
-
-            'change #current-journal': 'factSearch',
-
+            'change #current-store': 'factSearch',
             'change #from' : 'factSearch',
             'change #to': 'factSearch',
-            // 'click #volver_btn': 'volver',
             'click-row.bs.table #table' : 'ckickAnalysisDetail',
         },
         init : function(parent){
@@ -81,7 +77,7 @@ function report_purchases_invoice_analysis (reporting){
               }
               return date;
             }
-          },
+        },
         ckickAnalysisDetail: function(e, row, $element, field){
             if (field == 'name'){
                 this.do_action({
@@ -117,13 +113,16 @@ function report_purchases_invoice_analysis (reporting){
                 self.ResCurrencyRate = ResCurrencyRate;
                 return ResCurrencyRate;
             }).then(function (ResCurrencyRate) {
-                return self.fetchAccountJournal();
-            }).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.fecthResStore();
+            }).then(function(ResStore){
+                self.ResStore = ResStore;
+                self.$el.find('#current-store').append('<option value="9999999">Todas las SUC.</option>');
+                _.each(ResStore,function(item){
+                    self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
                 });
+                 return self.fecthAccountJournal();
+            }).then(function(AccountJournal){
+                self.AccountJournal = AccountJournal;
                 return self.fetchAccountInvoice();
             }).then(function (AccountInvoice){
                 self.AccountInvoice = AccountInvoice;
@@ -144,25 +143,37 @@ function report_purchases_invoice_analysis (reporting){
                 return self.getInvoiceCurrency();
             });
         },
-        fetchResCurrencyRate: function () {
+        fecthResStore: function(){
+            var self = this;
             var defer = $.Deferred();
-            var fields = ['id', 'name', 'currency_id', 'rate', 'create_date'];
-
-            var domain = [['currency_id', 'in', [166 , 20, 7, 3]]];
-            var ResCurrencyRate = new model.web.Model('res.currency.rate');
-            ResCurrencyRate.query(fields).filter(domain).all().then(function (results) {
+            var field=['id', 'name'];
+            var ResStore = new model.web.Model('res.store');
+            ResStore.query(field).all().then(function(results){
                 defer.resolve(results);
             });
             return defer;
         },
-        fetchAccountJournal: function () {
+        fecthAccountJournal: function(){
             var self = this;
             var defer = $.Deferred();
+            var field = ['id', 'name','store_ids'];
+            var domain = [['active','=',true],['type','in',['sale','purchase']]];
             var AccountJournal = new model.web.Model('account.journal');
-            AccountJournal.query(['id', 'name']).filter([['type', '=', 'purchase'], ['active', '=', true]]).all().then(function (results) {
+            AccountJournal.query(field).filter(domain).all().then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
+        fetchResCurrencyRate: function () {
+            var defer = $.Deferred();
+            var fields = ['id', 'name', 'currency_id', 'rate', 'create_date'];
+
+            var domain = [['currency_id', 'in', [166 , 20, 7, 3]]];
+            var ResCurrencyRate = new model.web.Model('res.currency.rate');
+            ResCurrencyRate.query(fields).filter(domain).all().then(function (results) {
                 defer.resolve(results);
             });
-              return defer;
+            return defer;
         },
         fetchAccountInvoice: function () {
             var filter = [['state', 'in',['open','paid']],['type', '=', 'in_invoice']];
@@ -255,15 +266,23 @@ function report_purchases_invoice_analysis (reporting){
             }
             return this.BuildTable();
         },
+        getAccountJournal: function (id) {
+            var self = this;
+            return _.filter(self.AccountJournal,function (item) {
+                return item.id === id;
+            });
+        },
         BuildTable: function(){
             var self = this;
             var data=[];
             var AccountInvoiceLine = self.AccountInvoiceLine
             var invoice;
+            var store;
             var producto;
             var invoice_type;
             _.each(AccountInvoiceLine, function(item){
                 invoice = self.getAccountInvoice(item.id);
+                store = self.getAccountJournal(invoice.journal_id[0]);
                 producto =self.getProductProduct(item.product_id);
                 if (!producto){
                     producto={};
@@ -274,23 +293,26 @@ function report_purchases_invoice_analysis (reporting){
                 }else{
                     invoice_type = 'purchase'
                 }
-                data.push({
-                    id : invoice.id,
-                    number : (invoice.number),
-                    id_product : producto.id,
-                    name : (item.name),
-                    quantity : accounting.formatNumber((item.quantity),0, ".", ","),
-                    price_unity : accounting.formatNumber((item.price_unit / invoice.rate),2, ".", ","),
-                    standar_tot : accounting.formatNumber((item.quantity * item.price_unit),2, ".", ","),
-                    journal_id :(invoice.journal_id[0]),
-                    journal_name :(invoice.journal_id[1]),
-                    date_invoice : (invoice.date_invoice),
-                    partner_id : invoice.partner_id[0],
-                    date_create :moment(invoice.date_invoice).format("DD/MM/YYYY"),
-                    amount : (item.quantity * item.price_unit),
-                    partner_name : invoice.partner_id[1],
-                    invoice_type : invoice_type
-                });
+                if(store.length > 0){
+                    data.push({
+                        id : invoice.id,
+                        number : (invoice.number),
+                        id_product : producto.id,
+                        name : (item.name),
+                        quantity : accounting.formatNumber((item.quantity),0, ".", ","),
+                        price_unity : accounting.formatNumber((item.price_unit / invoice.rate),2, ".", ","),
+                        standar_tot : accounting.formatNumber((item.quantity * item.price_unit),2, ".", ","),
+                        journal_id :(invoice.journal_id[0]),
+                        journal_name :(invoice.journal_id[1]),
+                        date_invoice : (invoice.date_invoice),
+                        partner_id : invoice.partner_id[0],
+                        date_create :moment(invoice.date_invoice).format("DD/MM/YYYY"),
+                        amount : (item.quantity * item.price_unit),
+                        partner_name : invoice.partner_id[1],
+                        invoice_type : invoice_type,
+                        store_id : store[0].store_ids[0]
+                    });
+                }
             });
 
             self.rowsData=data;
@@ -302,6 +324,7 @@ function report_purchases_invoice_analysis (reporting){
             var hoy = moment().format('YYYY-MM-DD');
             var partner = this.$el.find('#partner').val().split('-');
             var product = this.$el.find('#product').val().split('-');
+            var store =this.$el.find('#current-store').val();
             var desde =this.$el.find('#from').val();
             var hasta =this.$el.find('#to').val();
             self.rowsData=self.rowOrigin;
@@ -345,7 +368,7 @@ function report_purchases_invoice_analysis (reporting){
                     }
                 }
                 self.rowsData = _.filter(self.rowsData, function (inv){
-                    var mes = inv.date.split('-');
+                    var mes = inv.date_invoice.split('-');
                     return mes[0]+'-'+mes[1] == date[0]+'-'+date[1];
                 });
             }
@@ -383,6 +406,7 @@ function report_purchases_invoice_analysis (reporting){
                     return inv.partner_id == partner[0];
                 });
             }
+
             if (product != ""){
                 self.rowsData = _.filter(self.rowsData, function(inv){
 
@@ -390,6 +414,12 @@ function report_purchases_invoice_analysis (reporting){
                 });
             }
 
+            if (store != 9999999){
+                self.rowsData =_.filter(self.rowsData, function (inv){
+                    return inv.store_id == store;
+                });
+            }
+
             var amount_total_total = _.reduce(_.map(self.rowsData,function(map){
                 return(map.amount);
             }),function(memo, num){
@@ -397,7 +427,7 @@ function report_purchases_invoice_analysis (reporting){
             },0);
 
             self.rowsData.push({
-                number: "Total",
+                number: "Totales:",
                 standar_tot: accounting.formatNumber((amount_total_total),2,".",","),
             });
 

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

@@ -531,7 +531,7 @@ function report_ranking_purchases_orders_supplier (reporting) {
                 return map.id;
             })
             this.do_action({
-                name: "Listado de proveedores a quien mas compras",
+                name: "Listado de proveedores a quien más compras",
                 type: 'ir.actions.act_window',
                 res_model: "res.partner",
                 views: [[false,'list'],[self.modelId[1],'form']],

+ 622 - 0
static/src/js/reports/report_refund_invoice_customer.js

@@ -0,0 +1,622 @@
+function report_refund_invoice_customer (reporting){
+    "use strict";
+
+    var model = openerp;
+
+    reporting.ReportRefundInvoiceCustomerWidget = reporting.Base.extend({
+        template: 'ReportRefundInvoiceCustomer',
+        invoices: [],
+        invoiceLines: [],
+        productProduct:[],
+        Currency:[],
+        rowsData :[],
+        rowOrigin:[],
+        accountJournal:[],
+        resCompany:[],
+        events:{
+            'click #toolbar > button' : 'clickOnAction',
+            'click #X' : 'fectSearch',
+            'click #A' : 'fectSearch',
+            'click #B' : 'fectSearch',
+            'click #C' : 'fectSearch',
+            'click #D' : 'fectSearch',
+            'click #Z' : 'fectSearch',
+            'change #current-journal': 'fectSearch',
+            'change #from' : 'fectSearch',
+            'change #to': 'fectSearch',
+            'click #volver_btn': 'volver',
+            'click-row.bs.table #table' : 'ckickAnalysisDetail',
+        },
+        init : function(parent){
+          this._super(parent);
+        },
+        start: function () {
+            var table = this.$el.find('#table');
+            table.bootstrapTable({data : self.rowOrigin});
+            this.fecthFecha();
+            this.submitForm();
+        },
+        ckickAnalysisDetail: function(e, row, $element, field){
+            if (field == 'name'){
+                this.do_action({
+                    name : "Variantes de Producto",
+                    type : 'ir.actions.act_window',
+                    res_model : "product.product",
+                    views : [[false,'form']],
+                    target : 'new',
+                    domain : [['id','=', row.id_product]],
+                    context : {},
+                    flags : {'form': {'action_buttons': false, 'options': {'mode': 'view'}}},
+                    res_id : row.id_product,
+                });
+            }
+            if (field == 'number'){
+                this.do_action({
+                    name : "Factura de Cliente",
+                    type : 'ir.actions.act_window',
+                    res_model : "account.invoice",
+                    views : [[false,'form']],
+                    target : 'new',
+                    domain : [['type', '=', 'out_refund'],['id','=', row.id]],
+                    context : {},
+                    flags : {'form': {'action_buttons': false, 'options': {'mode': 'view'}}},
+                    res_id : row.id,
+                });
+            }
+            // if (field == 'reference'){
+            //     this.do_action({
+            //         name : "Factura Rectificada",
+            //         type : 'ir.actions.act_window',
+            //         res_model : "account.invoice",
+            //         views : [[false,'form']],
+            //         target : 'new',
+            //         domain : [['id','=', row.reference]],
+            //         context : {},
+            //         flags : {'form': {'action_buttons': false, 'options': {'mode': 'view'}}},
+            //         res_id : row.reference,
+            //     });
+            // }
+            e.stopImmediatePropagation();
+        },
+        volver: function(){
+            this.$el.find('#volver').empty();
+            this.$el.find('#grafico').empty();
+            this.$el.find('.bootstrap-table').show({
+                effect: 'drop',
+                direction: 'down',
+                duration: 200,
+            });
+        },
+        // Cansultar
+        submitForm: function () {
+            var self = this;
+            this.fetchCurency().then(function(Currency) {
+                self.Currency = Currency;
+                return Currency;
+            }).then(function (Currency) {
+                return self.fetchJournal();
+            }).then(function (journal) {
+                self.accountJournal =journal;
+                self.$el.find('#current-journal').append('<option value="9999999">TODAS LAS SUC.</option>');
+                _.each(journal, function (item) {
+                  self.$el.find('#current-journal').append('<option value="' + item.id + '">' + item.name + '</option>');
+                });
+                return self.fetchInvoiceV2();
+            }).then(function (invoices){
+                self.invoices = invoices;
+                return self.fetchInvoiceLine(invoices);
+            }).then(function (invoiceLines) {
+                self.invoiceLines = invoiceLines;
+                return self.fecthProduct(invoiceLines);
+            }).then(function(productProduct){
+                self.productProduct = productProduct;
+                return self.fecthComanyCurrency();
+            }).then(function(resCompany){
+                self.resCompany = resCompany;
+            return self.fetchResPartner();
+            }).then(function(ResPartner){
+                self.ResPartner = ResPartner;
+                self.search();
+                self.searchProduct();
+                return self.invoice_Currency();
+            });
+        },
+        // company_curency
+        fecthComanyCurrency: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var currency = new model.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;
+        },
+        // Fecha
+        fecthFecha: function() {
+            var to;
+            var dateFormat1 = "mm/dd/yy",
+              from = $( "#from" )
+                .datepicker({
+                  dateFormat: "dd/mm/yy",
+                  changeMonth: true,
+                  numberOfMonths: 1,
+                })
+                .on( "change", function() {
+                  to.datepicker( "option", "minDate", getDate(this), "dd/mm/yyyy");
+                });
+              to = $( "#to" ).datepicker({
+                dateFormat: "dd/mm/yy",
+                defaultDate: "+7d",
+                changeMonth: true,
+                numberOfMonths: 1,
+              })
+              .on( "change", function() {
+                from.datepicker( "option", "maxDate", getDate(this));
+              });
+
+            function getDate( element ) {
+              var fechaSel =element.value.split('/');
+              var date;
+              try {
+                date = $.datepicker.parseDate( dateFormat1, (fechaSel[1]+"/"+fechaSel[0]+"/"+fechaSel[2]));
+              } catch( error ) {
+               date = null;
+              }
+              return date;
+            }
+          },
+        // Buscar Diario
+        fetchJournal: function () {
+            var self = this;
+            var defer = $.Deferred();
+            var Journal = new model.web.Model('account.journal');
+            Journal.query(['id', 'name']).filter([['type', '=', 'sale'], ['active', '=', true]]).all().then(function (results) {
+                defer.resolve(results);
+            });
+              return defer;
+        },
+        // Buscar Cambio de Monedas USD,PYG,ARG,BRL
+        fetchCurency: function () {
+            var defer = $.Deferred();
+            var currency_Rate = new model.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 filter ="[['state', 'in',['open','paid']],['type', '=', 'out_refund']]";
+            var journal_ids = _.flatten(_.map(this.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', 'invoice_line','date_invoice','partner_id'];
+            var defer = $.Deferred();
+            var Invoice = new model.web.Model('account.invoice');
+
+            Invoice.query(field).filter(filter).all().then(function (results) {
+                defer.resolve(results);
+            });
+
+            return defer;
+        },
+        // Invoice line (Linea de Factura)
+        fetchInvoiceLine: function (invoices) {
+            var defer = $.Deferred();
+            var linesIds = _.flatten(_.map(invoices, function (item) {
+                return item.invoice_line;
+            }));
+            var InvoiceLine = new model.web.Model('account.invoice.line');
+            InvoiceLine.query(['id', 'quantity', 'price_unit', 'discount', 'name', 'product_id', 'origin','invoice_id']).filter([['id', 'in', linesIds]]).all().then(function (results) {
+                defer.resolve(results)
+            });
+            return defer;
+        },
+        fetchResPartner: function () {
+            var self = this;
+            var defer = $.Deferred();
+            var ResPartner = new model.web.Model('res.partner');
+            ResPartner.query(['id','name','ruc']).filter([['active', '=', true],['customer', '=', true]]).all().then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
+        // Product Product
+        fecthProduct: function(invoiceLines){
+            var defer = $.Deferred();
+            var porductIDS = _.flatten(_.map(invoiceLines, function (item) {
+                return item.product_id[0];
+            }));
+            var ProductProdcut =  new model.web.Model('product.product');
+            var fields = ['id','name', 'default_code', 'name_template','ean13', 'standard_price','type','attribute_str'];
+            ProductProdcut.query(fields).filter([['id', 'in', porductIDS]]).all().then(function (results) {
+                defer.resolve(results)
+            });
+            return defer;
+        },
+        // Obtener Monedas de la Factura
+        getCutrrency: function (id){
+            return _.find(this.Currency,function (curr) {
+                return _.contains(curr.currency_id,id);
+            });
+        },
+        // Actualizar cambio de las moneda de Factura
+        invoice_Currency: function(){
+            for (var i = 0; i < this.invoices.length; i++) {
+                var currency_new;
+                var item = this.invoices[i];
+                var id = item.currency_id[0];
+                currency_new = this.getCutrrency(id);
+                if (!currency_new){
+                    currency_new={};
+                    currency_new.rate=1;
+                }
+                this.invoices[i].rate=(currency_new.rate);
+            }
+            return this.fectUtility();
+        },
+        // Obtener la Detalles de la Factura
+        getInvoice: function (id_line){
+            return _.find(this.invoices, function (inv) {
+                return _.contains(inv.invoice_line, id_line);
+            });
+          },
+        // Obtener las lineas de las Facturas
+        getProduct: function(pro_id){
+            return _.find(this.productProduct, function(prod){
+                return _.contains(pro_id, prod.id);
+            });
+        },
+
+        fectUtility: function(){
+            var data=[];
+            var item;
+            var invoice;
+            var producto;
+
+            for (var i = 0; i < this.invoiceLines.length; i++) {
+                item = this.invoiceLines[i];
+                invoice = this.getInvoice(item.id);
+                producto =this.getProduct(item.product_id);
+                if (!producto){
+                    producto={};
+                    producto.standard_price=0;
+                }
+                data.push({
+                        id : invoice.id,
+                        number : (invoice.number),
+                        reference : (invoice.reference),
+                        id_product : producto.id,
+                        name : (item.name),
+                        quantity : accounting.formatNumber((item.quantity),0, ".", ","),
+                        price_unity : accounting.formatNumber((item.price_unit),2, ".", ","),
+                        price_tot : accounting.formatNumber((item.quantity * item.price_unit),2, ".", ","),
+                        journal_id :(invoice.journal_id[0]),
+                        journal_name :(invoice.journal_id[1]),
+                        date_create :moment(invoice.date_invoice).format("DD/MM/YYYY"),
+                        date_invoice : (invoice.date_invoice),
+                        price_tot_tot : (item.quantity * item.price_unit),
+                        partner_id : invoice.partner_id[0],
+                        partner_name : invoice.partner_id[1]
+                });
+          }
+          this.rowsData=data;
+          this.rowOrigin=data;
+          this.loadTable(data)
+        },
+
+
+        fectSearch: function(){
+            var self = this;
+            var hoy = moment().format('YYYY-MM-DD');
+            var partner = this.$el.find('#partner').val().split('-');
+            var product = this.$el.find('#product').val().split('-');
+            var desde =this.$el.find('#from').val();
+            var hasta =this.$el.find('#to').val();
+            self.rowsData=self.rowOrigin;
+
+            if ($('#A').is(":checked")){
+                self.rowsData = _.filter(self.rowsData, function (inv){
+                    return inv.date_invoice == hoy;
+                });
+            }
+            if ($('#B').is(":checked")){
+                var date = hoy.split('-');
+                var ayer = date[2] - 1;
+                date.splice(2,0);
+                date[2] = '0'+ayer;
+                self.rowsData = _.filter(self.rowsData, function (inv){
+                    return inv.date_invoice == date[0]+'-'+date[1]+'-'+date[2];
+                });
+            }
+            if ($('#C').is(":checked")){
+                var date = hoy.split('-');
+                self.rowsData = _.filter(self.rowsData, function (inv){
+                    var mes = inv.date_invoice.split('-');
+                    return mes[0]+'-'+mes[1] == date[0]+'-'+date[1];
+                });
+            }
+            if ($('#D').is(":checked")){
+                var date = hoy.split('-');
+                var mes = date[1] - 1;
+                var year;
+                date.splice(1,0);
+                if(date[1] == 1){
+                    date[1] = '12';
+                    year = date[0] - 1;
+                    date[0] = year;
+                }else{
+
+                    if(date[1] < 10){
+                        date[1] = '0'+mes;
+                    }else{
+                        date[1] = mes;
+                    }
+                }
+                self.rowsData = _.filter(content, function (inv){
+                    var mes = inv.date.split('-');
+                    return mes[0]+'-'+mes[1] == date[0]+'-'+date[1];
+                });
+            }
+            if ($('#Z').is(":checked")){
+                $('#datepicker').css('display','block');
+                if (desde.length > 0){
+                    var date= desde.split('/');
+                    self.rowsData = _.filter(self.rowsData, 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){
+                        return inv.date_invoice <= (date[2]+"-"+date[1]+"-"+date[0]);
+                    });
+                }
+            }else{
+                $('#datepicker').css('display','none');
+            }
+            if (partner != ""){
+                self.rowsData = _.filter(self.rowsData, function(inv){
+                    return inv.partner_id == partner[0];
+                });
+            }
+            if (product != ""){
+                self.rowsData = _.filter(self.rowsData, function(inv){
+                    return inv.id_product == product[0];
+                });
+            }
+
+            var amount_total_total = _.reduce(_.map(self.rowsData,function(map){
+                return(map.price_tot_tot);
+            }),function(memo, num){
+                return memo + num;
+            },0);
+
+            self.rowsData.push({
+                number: "Total",
+                price_tot: accounting.formatNumber((amount_total_total),0,".",","),
+            });
+
+            self.loadTable(self.rowsData);
+        },
+        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();
+                }
+            });
+        },
+        loadTable:function(rowsTable){
+            var table = this.$el.find('#table');
+            table.bootstrapTable('load', rowsTable);
+        },
+        clickOnAction: function (e) {
+            var action = this.$el.find(e.target).val();
+            var self = this;
+            var getColumns=[];
+            var rows=[];
+            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){
+                    rows.push(_.pick(item, dataNEW));
+                });
+                // Obtener los nombre de la Cabezera
+                _.each(_.map(data2,function(val){
+                    return val}), function(item){
+                    getColumns.push([{
+                                    title: item.title,
+                                    dataKey: item.field
+                                }]);
+                });
+                // Llamar al pdf
+                this.drawPDF(_.flatten(getColumns),rows)
+            }
+            if (action === 'chart'){
+                var suc =this.$el.find('#current-journal').val();
+                if (suc == 9999999){
+                    self.fectCharFilter();
+                }else{
+                    $("#dialog" ).dialog({
+                        autoOpen: true,
+                        resizable: false,
+                        modal: true,
+                        title: 'Atención',
+                        open: function() {
+                            $(this).html('Para Generar el Gráfico debes Seleccionar todas las Sucursales');
+                        },
+                        show: {
+                            effect: "shake",
+                            duration: 300
+                        },
+                        hide: {
+                            effect: "fade",
+                            duration: 300
+                        },
+                        buttons: {
+                            Aceptar: function() {
+                                $(this).dialog('close');
+                            }
+                        }
+                    });
+                }
+            }
+        },
+        drawPDF: function (getColumns,rows) {
+            var self = this;
+            var rowsPdf=[];
+            var sucusal = this.sucDescrip = this.$el.find('#current-journal option:selected').text();
+            var desde =(this.$el.find('#from').val());
+            var hasta =(this.$el.find('#to').val());
+            var totalPagesExp = "{total_pages_count_string}";
+            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 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);
+
+            rowsPdf=rows;
+
+            var company = _.map(self.resCompany, function (map) {
+                return map.currency_id[1];
+            });
+            rowsPdf.push({
+                        number : "TOTAL "+company,
+                        date_create : " ",
+                        reference: " ",
+                        name : " ",
+                        quantity: accounting.formatNumber(quantity,0, ".", ","),
+                        price_unity : accounting.formatNumber(precio_unit,2, ".", ","),
+                        price_tot : accounting.formatNumber(tot_unit,2, ".", ",")
+                    });
+
+            // rowsPdf.unshift({
+            //             number : "TOTAL "+company,
+            //             date_create : " ",
+            //             name : " ",
+            //             quantity: accounting.formatNumber(quantity,0, ".", ","),
+            //             price_unity : accounting.formatNumber(precio_unit,2, ".", ","),
+            //             price_tot : accounting.formatNumber(tot_unit,2, ".", ",")
+            //         });
+
+            pdfDoc.autoTable(getColumns, rowsPdf, {
+                styles: { overflow: 'linebreak', fontSize: 8, columnWidth: 'wrap'},
+                columnStyles: {
+                              number: {fontStyle: 'bold'},
+                              date_create :{columnWidth: '12px'},
+                              reference :{columnWidth: '8px'},
+                              name :{columnWidth: '10px'},
+                              quantity :{halign:'right' },
+                              price_unity : {halign:'right' },
+                              price_tot : {halign:'right' },
+                          },
+                margin: { top: 16, horizontal: 7},
+                addPageContent: function (data) {
+                    pdfDoc.setFontSize(12);
+                    pdfDoc.setFontStyle('bold');
+                    pdfDoc.setTextColor(40);
+                    pdfDoc.text('Análisis de facturas rectificativas de ventas ', data.settings.margin.left, 10);
+
+                    if(desde.length > 0 || hasta.length > 0){
+                      var fecha='';
+                      if(desde){
+                        fecha=fecha.concat(' Desde '+desde);
+                      }
+                      if (hasta){
+                        fecha=fecha.concat(' Hasta '+hasta);
+                      }
+                        pdfDoc.setFontSize(10);
+                        pdfDoc.setFontStyle('bold');
+                        pdfDoc.setTextColor(40)
+                        pdfDoc.text(fecha, data.settings.margin.left,14);
+                    }
+                    // FOOTER
+                    var str = "Pagina  " + data.pageCount;
+                    // Total page number plugin only available in jspdf v1.0+
+                    if (typeof pdfDoc.putTotalPages === 'function') {
+                        str = str + " de " + totalPagesExp;
+                    }
+                    pdfDoc.setFontSize(9);
+                    pdfDoc.setFontStyle('bold');
+                    pdfDoc.setTextColor(40);
+                    pdfDoc.text(str, data.settings.margin.left, pdfDoc.internal.pageSize.height - 5);
+                }
+            });
+
+            if (typeof pdfDoc.putTotalPages === 'function') {
+                pdfDoc.putTotalPages(totalPagesExp);
+            }
+            pdfDoc.save('Análisis de facturas rectificativas de ventas.pdf')
+        },
+
+
+    });
+}

+ 601 - 0
static/src/js/reports/report_refund_invoice_supplier.js

@@ -0,0 +1,601 @@
+function report_refund_invoice_supplier (reporting){
+    "use strict";
+
+    var model = openerp;
+
+    reporting.ReportRefundInvoiceSupplierWidget = reporting.Base.extend({
+        template: 'ReportRefundInvoiceSupplier',
+        invoices: [],
+        invoiceLines: [],
+        productProduct:[],
+        Currency:[],
+        rowsData :[],
+        rowOrigin:[],
+        accountJournal:[],
+        resCompany:[],
+        events:{
+            'click #toolbar > button' : 'clickOnAction',
+            'click #X' : 'factSearch',
+            'click #A' : 'factSearch',
+            'click #B' : 'factSearch',
+            'click #C' : 'factSearch',
+            'click #D' : 'factSearch',
+            'click #Z' : 'factSearch',
+
+            'click #Y' : 'factSearch',
+            'click #purchase' : 'factSearch',
+            'click #expense' : 'factSearch',
+
+            'change #current-journal': 'factSearch',
+
+            'change #from' : 'factSearch',
+            'change #to': 'factSearch',
+            // 'click #volver_btn': 'volver',
+            'click-row.bs.table #table' : 'ckickAnalysisDetail',
+        },
+        init : function(parent){
+          this._super(parent);
+        },
+        start: function () {
+            var table = this.$el.find('#table');
+            table.bootstrapTable({data : self.rowOrigin});
+            this.fecthFecha();
+            this.submitForm();
+        },
+        valorNull:function(dato){
+            var valor ="";
+            if (dato){
+                valor=dato;
+            }
+            return valor;
+        },
+        fecthFecha: function() {
+            var to;
+            var dateFormat1 = "mm/dd/yy",
+              from = $( "#from" )
+                .datepicker({
+                  dateFormat: "dd/mm/yy",
+                  changeMonth: true,
+                  numberOfMonths: 1,
+                })
+                .on( "change", function() {
+                  to.datepicker( "option", "minDate", getDate(this), "dd/mm/yyyy");
+                });
+              to = $( "#to" ).datepicker({
+                dateFormat: "dd/mm/yy",
+                defaultDate: "+7d",
+                changeMonth: true,
+                numberOfMonths: 1,
+              })
+              .on( "change", function() {
+                from.datepicker( "option", "maxDate", getDate(this));
+              });
+
+            function getDate( element ) {
+              var fechaSel =element.value.split('/');
+              var date;
+              try {
+                date = $.datepicker.parseDate( dateFormat1, (fechaSel[1]+"/"+fechaSel[0]+"/"+fechaSel[2]));
+              } catch( error ) {
+               date = null;
+              }
+              return date;
+            }
+          },
+        ckickAnalysisDetail: function(e, row, $element, field){
+            if (field == 'name'){
+                this.do_action({
+                    name : "Variantes de Producto",
+                    type : 'ir.actions.act_window',
+                    res_model : "product.product",
+                    views : [[false,'form']],
+                    target : 'new',
+                    domain : [['id','=', row.id_product]],
+                    context : {},
+                    flags : {'form': {'action_buttons': false, 'options': {'mode': 'view'}}},
+                    res_id : row.id_product,
+                });
+            }
+            if (field == 'number'){
+                this.do_action({
+                    name : "Factura de Proveedor",
+                    type : 'ir.actions.act_window',
+                    res_model : "account.invoice",
+                    views : [[false,'form']],
+                    target : 'new',
+                    domain : [['type', '=', 'in_refund'],['id','=', row.id]],
+                    context : {},
+                    flags : {'form': {'action_buttons': false, 'options': {'mode': 'view'}}},
+                    res_id : row.id,
+                });
+            }
+            e.stopImmediatePropagation();
+        },
+        submitForm: function () {
+            var self = this;
+            this.fetchResCurrencyRate().then(function(ResCurrencyRate) {
+                self.ResCurrencyRate = ResCurrencyRate;
+                return ResCurrencyRate;
+            }).then(function (ResCurrencyRate) {
+                return self.fetchAccountJournal();
+            }).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.fetchAccountInvoice();
+            }).then(function (AccountInvoice){
+                self.AccountInvoice = AccountInvoice;
+                return self.fetchAccountInvoiceLine();
+            }).then(function (AccountInvoiceLine) {
+                self.AccountInvoiceLine = AccountInvoiceLine;
+                return self.fecthProductProduct();
+            }).then(function(ProductProduct){
+                self.ProductProduct = ProductProduct;
+                return self.fecthResCompany();
+            }).then(function(ResCompany){
+                self.ResCompany = ResCompany;
+            return self.fetchResPartner();
+            }).then(function(ResPartner){
+                self.ResPartner = ResPartner;
+                self.search();
+                self.searchProduct();
+                return self.getInvoiceCurrency();
+            });
+        },
+        fetchResCurrencyRate: function () {
+            var defer = $.Deferred();
+            var fields = ['id', 'name', 'currency_id', 'rate', 'create_date'];
+
+            var domain = [['currency_id', 'in', [166 , 20, 7, 3]]];
+            var ResCurrencyRate = new model.web.Model('res.currency.rate');
+            ResCurrencyRate.query(fields).filter(domain).all().then(function (results) {
+                defer.resolve(results);
+            });
+            return defer;
+        },
+        fetchAccountJournal: function () {
+            var self = this;
+            var defer = $.Deferred();
+            var AccountJournal = new model.web.Model('account.journal');
+            AccountJournal.query(['id', 'name']).filter([['type', '=', 'purchase'], ['active', '=', true]]).all().then(function (results) {
+                defer.resolve(results);
+            });
+              return defer;
+        },
+        fetchAccountInvoice: function () {
+            var filter = [['state', 'in',['open','paid']],['type', '=', 'in_refund']];
+            var journal_ids = _.flatten(_.map(this.AccountJournal, function (item) {
+                return item.id;
+            }));
+            var field =['id', 'type', 'number', 'origin', 'state', 'journal_id', 'currency_id', 'invoice_line','date_invoice','partner_id'];
+            var defer = $.Deferred();
+            var AccountInvoice = new model.web.Model('account.invoice');
+            AccountInvoice.query(field).filter(filter).all().then(function (results) {
+                defer.resolve(results);
+            });
+            return defer;
+        },
+        fetchAccountInvoiceLine: function () {
+            var self = this;
+            var defer = $.Deferred();
+            var linesIds = _.flatten(_.map(self.AccountInvoice, function (item) {
+                return item.invoice_line;
+            }));
+            var InvoiceLine = new model.web.Model('account.invoice.line');
+            InvoiceLine.query(['id', 'quantity', 'price_unit', 'discount', 'name', 'product_id', 'origin','invoice_id']).filter([['id', 'in', linesIds]]).all().then(function (results) {
+                defer.resolve(results)
+            });
+            return defer;
+        },
+        fecthProductProduct: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var porductIDS = _.flatten(_.map(self.AccountInvoiceLine, function (item) {
+                return item.product_id[0];
+            }));
+            var ProductProduct =  new model.web.Model('product.product');
+            var fields = ['id','name', 'default_code', 'name_template','ean13', 'standard_price','type','attribute_str'];
+            ProductProduct.query(fields).filter([['id', 'in', porductIDS]]).all().then(function (results) {
+                defer.resolve(results)
+            });
+            return defer;
+        },
+        fecthResCompany: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var currency = new model.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;
+        },
+        fetchResPartner: function () {
+            var self = this;
+            var defer = $.Deferred();
+            var ResPartner = new model.web.Model('res.partner');
+            ResPartner.query(['id','name','ruc']).filter([['active', '=', true],['supplier', '=', true]]).all().then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
+        getAccountInvoice: function (id){
+            var self = this;
+            return _.find(self.AccountInvoice, function (inv) {
+                return _.contains(inv.invoice_line, id);
+            });
+        },
+        getProductProduct: function(id){
+            var self = this;
+            return _.find(self.ProductProduct, function(item){
+                return _.contains(id, item.id);
+            });
+        },
+        getResCurrencyRate: function (id){
+            var self = this;
+            return _.find(self.ResCurrencyRate,function (item) {
+                return _.contains(item.currency_id,id);
+            });
+        },
+        getInvoiceCurrency: function(){
+            var self = this;
+            for (var i = 0; i < self.AccountInvoice.length; i++) {
+                var currency_new;
+                var item = self.AccountInvoice[i];
+                var id = item.currency_id[0];
+                currency_new = self.getResCurrencyRate(id);
+                if (!currency_new){
+                    currency_new={};
+                    currency_new.rate=1;
+                }
+                self.AccountInvoice[i].rate=(currency_new.rate);
+            }
+            return this.BuildTable();
+        },
+        BuildTable: function(){
+            var self = this;
+            var data=[];
+            var AccountInvoiceLine = self.AccountInvoiceLine
+            var invoice;
+            var producto;
+            var invoice_type;
+            _.each(AccountInvoiceLine, function(item){
+                invoice = self.getAccountInvoice(item.id);
+                producto =self.getProductProduct(item.product_id);
+                if (!producto){
+                    producto={};
+                    producto.standard_price=0;
+                }
+                if(invoice.origin == false){
+                    invoice_type = 'expense'
+                }else{
+                    invoice_type = 'purchase'
+                }
+                data.push({
+                    id : invoice.id,
+                    number : (invoice.number),
+                    id_product : producto.id,
+                    name : (item.name),
+                    quantity : accounting.formatNumber((item.quantity),0, ".", ","),
+                    price_unity : accounting.formatNumber((item.price_unit / invoice.rate),2, ".", ","),
+                    standar_tot : accounting.formatNumber((item.quantity * item.price_unit),2, ".", ","),
+                    journal_id :(invoice.journal_id[0]),
+                    journal_name :(invoice.journal_id[1]),
+                    date_invoice : (invoice.date_invoice),
+                    partner_id : invoice.partner_id[0],
+                    date_create :moment(invoice.date_invoice).format("DD/MM/YYYY"),
+                    amount : (item.quantity * item.price_unit),
+                    partner_name : invoice.partner_id[1],
+                    invoice_type : invoice_type
+                });
+            });
+
+            self.rowsData=data;
+            self.rowOrigin=data;
+            self.loadTable(data)
+        },
+        factSearch: function(){
+            var self = this;
+            var hoy = moment().format('YYYY-MM-DD');
+            var partner = this.$el.find('#partner').val().split('-');
+            var product = this.$el.find('#product').val().split('-');
+            var desde =this.$el.find('#from').val();
+            var hasta =this.$el.find('#to').val();
+            self.rowsData=self.rowOrigin;
+
+            if ($('#A').is(":checked")){
+                self.rowsData = _.filter(self.rowsData, function (inv){
+                    return inv.date_invoice == hoy;
+                });
+            }
+            if ($('#B').is(":checked")){
+                var date = hoy.split('-');
+                var ayer = date[2] - 1;
+                date.splice(2,0);
+                date[2] = '0'+ayer;
+                self.rowsData = _.filter(self.rowsData, function (inv){
+                    return inv.date_invoice == date[0]+'-'+date[1]+'-'+date[2];
+                });
+            }
+            if ($('#C').is(":checked")){
+                var date = hoy.split('-');
+                self.rowsData = _.filter(self.rowsData, function (inv){
+                    var mes = inv.date_invoice.split('-');
+                    return mes[0]+'-'+mes[1] == date[0]+'-'+date[1];
+                });
+            }
+            if ($('#D').is(":checked")){
+                var date = hoy.split('-');
+                var mes = date[1] - 1;
+                var year;
+                date.splice(1,0);
+                if(date[1] == 1){
+                    date[1] = '12';
+                    year = date[0] - 1;
+                    date[0] = year;
+                }else{
+
+                    if(date[1] < 10){
+                        date[1] = '0'+mes;
+                    }else{
+                        date[1] = mes;
+                    }
+                }
+                self.rowsData = _.filter(self.rowsData, function (inv){
+                    var mes = inv.date.split('-');
+                    return mes[0]+'-'+mes[1] == date[0]+'-'+date[1];
+                });
+            }
+            if ($('#Z').is(":checked")){
+                $('#datepicker').css('display','block');
+                if (desde.length > 0){
+                    var date= desde.split('/');
+                    self.rowsData = _.filter(self.rowsData, 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){
+                        return inv.date_invoice <= (date[2]+"-"+date[1]+"-"+date[0]);
+                    });
+                }
+            }else{
+                $('#datepicker').css('display','none');
+            }
+
+            if ($('#purchase').is(":checked")){
+                self.rowsData = _.filter(self.rowsData, function (inv){
+                    return inv.invoice_type == 'purchase';
+                });
+            }
+            if ($('#expense').is(":checked")){
+                self.rowsData = _.filter(self.rowsData, function (inv){
+                    return inv.invoice_type == 'expense';
+                });
+            }
+
+            if (partner != ""){
+                self.rowsData = _.filter(self.rowsData, function(inv){
+                    return inv.partner_id == partner[0];
+                });
+            }
+            if (product != ""){
+                self.rowsData = _.filter(self.rowsData, function(inv){
+
+                    return inv.id_product == product[0];
+                });
+            }
+
+            var amount_total_total = _.reduce(_.map(self.rowsData,function(map){
+                return(map.amount);
+            }),function(memo, num){
+                return memo + num;
+            },0);
+
+            self.rowsData.push({
+                number: "Total",
+                standar_tot: accounting.formatNumber((amount_total_total),2,".",","),
+            });
+
+            self.loadTable(self.rowsData);
+        },
+        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.factSearch();
+                    }
+                },
+                close: function( event, ui ) {
+                        self.factSearch();
+                },
+                select: function(event, ui) {
+                    self.factSearch();
+                }
+            });
+        },
+        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.factSearch();
+                    }
+                },
+                close: function( event, ui ) {
+                        self.factSearch();
+                },
+                select: function(event, ui) {
+                    self.factSearch();
+                }
+            });
+        },
+        loadTable:function(rowsTable){
+            var table = this.$el.find('#table');
+            table.bootstrapTable('load', rowsTable);
+        },
+        clickOnAction: function (e) {
+            var action = this.$el.find(e.target).val();
+            var self = this;
+            var getColumns=[];
+            var rows=[];
+            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){
+                    rows.push(_.pick(item, dataNEW));
+                });
+                _.each(_.map(data2,function(val){
+                    return val}), function(item){
+                    getColumns.push([{
+                                    title: item.title,
+                                    dataKey: item.field
+                                }]);
+                });
+                this.drawPDF(_.flatten(getColumns),rows)
+            }
+        },
+        drawPDF: function (getColumns,rows) {
+            var self = this;
+            var rowsPdf=[];
+            var hoy = moment().format('DD/MM/YYYY');
+            var desde =(this.$el.find('#from').val());
+            var hasta =(this.$el.find('#to').val());
+            var totalPagesExp = "{total_pages_count_string}";
+            var company = _.map(self.ResCompany, function (map) {
+                return map.currency_id[1];
+            });
+
+            var pdfDoc = new jsPDF();
+
+            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 price_unity=_.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 standar_tot=_.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);
+
+            rowsPdf=rows;
+
+            rowsPdf.push({
+                number : "TOTAL "+ company,
+                quantity: accounting.formatNumber(quantity,0, ".", ","),
+                standar_tot : accounting.formatNumber(standar_tot,2, ".", ","),
+            });
+
+            pdfDoc.autoTable(getColumns, rowsPdf, {
+                styles: { overflow: 'linebreak', fontSize: 8, columnWidth: 'wrap'},
+                columnStyles: {
+                    number: {fontStyle: 'bold'},
+                    date_create :{columnWidth: '12px'},
+                    partner_name :{columnWidth: '10px'},
+                    name :{columnWidth: '10px'},
+                    quantity :{halign:'right' },
+                    price_unity : {halign:'right' },
+                    standar_tot : {halign:'right' },
+                },
+                margin: { top: 20, horizontal: 7},
+                addPageContent: function (data) {
+                    pdfDoc.setFontSize(12);
+                    pdfDoc.setFontStyle('bold');
+                    pdfDoc.setTextColor(40);
+                    pdfDoc.text('Análisis de facturas rectificativas de compras ',80,10);
+
+                    var tipo = '';
+                    if ($('#Y').is(":checked")){
+                        tipo = tipo.concat(' Tipo de factura : Todas las facturas' );
+                    }
+                    if ($('#purchase').is(":checked")){
+                        tipo = tipo.concat(' Tipo de factura : Compras' );
+                    }
+                    if ($('#expense').is(":checked")){
+                        tipo = tipo.concat(' Tipo de factura : Gastos' );
+                    }
+                    pdfDoc.setFontSize(9);
+                    pdfDoc.setFontStyle('normal');
+                    pdfDoc.setTextColor(40)
+                    pdfDoc.text(6,14,tipo);
+
+                    var fecha = '';
+                    if ($('#X').is(":checked")){
+                        fecha = fecha.concat(' Filtro de fecha : Sin Filtros' );
+                    }
+                    if ($('#A').is(":checked")){
+                        fecha = fecha.concat(' Filtro de fecha : Hoy' );
+                    }
+                    if ($('#B').is(":checked")){
+                        fecha = fecha.concat(' Filtro de fecha : Ayer' );
+                    }
+                    if ($('#C').is(":checked")){
+                        fecha = fecha.concat(' Filtro de fecha : Mes Actual' );
+                    }
+                    if ($('#D').is(":checked")){
+                        fecha = fecha.concat(' Filtro de fecha : Mes Pasado' );
+                    }
+                    if ($('#Z').is(":checked")){
+                        if(desde.length > 0 || hasta.length > 0){
+                            if(desde){
+                                fecha=fecha.concat(' Desde: '+ desde);
+                            }
+                            if (hasta){
+                                fecha=fecha.concat(' Hasta: '+ hasta);
+                            }
+                        }
+                    }
+                    pdfDoc.setFontSize(9);
+                    pdfDoc.setFontStyle('normal');
+                    pdfDoc.setTextColor(40)
+                    pdfDoc.text(6,18,fecha);
+
+                    pdfDoc.setFontSize(9);
+                    pdfDoc.setFontStyle('normal');
+                    pdfDoc.setTextColor(40)
+                    pdfDoc.text(150,14," Fecha de Expedición: " + hoy);
+
+
+
+                    var str = "Pagina  " + data.pageCount;
+                    if (typeof pdfDoc.putTotalPages === 'function') {
+                        str = str + " de " + totalPagesExp;
+                    }
+                    pdfDoc.setFontSize(9);
+                    pdfDoc.setFontStyle('bold');
+                    pdfDoc.setTextColor(40);
+                    pdfDoc.text(175,pdfDoc.internal.pageSize.height - 5,str);
+                }
+            });
+
+            if (typeof pdfDoc.putTotalPages === 'function') {
+                pdfDoc.putTotalPages(totalPagesExp);
+            }
+            pdfDoc.save('Análisis de facturas rectificativas de compras.pdf')
+        },
+    });
+}

+ 160 - 132
static/src/js/reports/report_sales_invoice_analysis.js

@@ -21,7 +21,7 @@ function report_sales_invoice_analysis (reporting){
             'click #C' : 'fectSearch',
             'click #D' : 'fectSearch',
             'click #Z' : 'fectSearch',
-            'change #current-journal': 'fectSearch',
+            'change #current-store': 'fectSearch',
             'change #from' : 'fectSearch',
             'change #to': 'fectSearch',
             'click #volver_btn': 'volver',
@@ -74,53 +74,7 @@ function report_sales_invoice_analysis (reporting){
                 duration: 200,
             });
         },
-        // Cansultar
-        submitForm: function () {
-            var self = this;
-            this.fetchCurency().then(function(Currency) {
-                self.Currency = Currency;
-                return Currency;
-            }).then(function (Currency) {
-                return self.fetchJournal();
-            }).then(function (journal) {
-                self.accountJournal =journal;
-                self.$el.find('#current-journal').append('<option value="9999999">TODAS LAS SUC.</option>');
-                _.each(journal, function (item) {
-                  self.$el.find('#current-journal').append('<option value="' + item.id + '">' + item.name + '</option>');
-                });
-                return self.fetchInvoiceV2();
-            }).then(function (invoices){
-                self.invoices = invoices;
-                return self.fetchInvoiceLine(invoices);
-            }).then(function (invoiceLines) {
-                self.invoiceLines = invoiceLines;
-                return self.fecthProduct(invoiceLines);
-            }).then(function(productProduct){
-                self.productProduct = productProduct;
-                return self.fecthComanyCurrency();
-            }).then(function(resCompany){
-                self.resCompany = resCompany;
-            return self.fetchResPartner();
-            }).then(function(ResPartner){
-                self.ResPartner = ResPartner;
-                self.search();
-                self.searchProduct();
-                return self.invoice_Currency();
-            });
-        },
-        // company_curency
-        fecthComanyCurrency: function(){
-            var self = this;
-            var defer = $.Deferred();
-            var currency = new model.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;
-        },
-        // Fecha
+         // Fecha
         fecthFecha: function() {
             var to;
             var dateFormat1 = "mm/dd/yy",
@@ -153,17 +107,81 @@ function report_sales_invoice_analysis (reporting){
               }
               return date;
             }
-          },
-        // Buscar Diario
-        fetchJournal: function () {
+        },
+
+        // Cansultar
+        submitForm: function () {
+            var self = this;
+            this.fetchCurency().then(function(Currency) {
+                self.Currency = Currency;
+                return Currency;
+            }).then(function (Currency) {
+               return self.fecthResStore();
+            }).then(function(ResStore){
+                self.ResStore = ResStore;
+                self.$el.find('#current-store').append('<option value="9999999">Todas las SUC.</option>');
+                _.each(ResStore,function(item){
+                    self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+                });
+                 return self.fecthAccountJournal();
+            }).then(function(AccountJournal){
+                self.AccountJournal = AccountJournal;
+                return self.fetchInvoiceV2();
+            }).then(function (invoices){
+                self.invoices = invoices;
+                return self.fetchInvoiceLine(invoices);
+            }).then(function (invoiceLines) {
+                self.invoiceLines = invoiceLines;
+                return self.fecthProduct(invoiceLines);
+            }).then(function(ProductProduct){
+                self.ProductProduct = ProductProduct;
+                return self.fecthCompanyCurrency();
+            }).then(function(resCompany){
+                self.resCompany = resCompany;
+            return self.fetchResPartner();
+            }).then(function(ResPartner){
+                self.ResPartner = ResPartner;
+                self.search();
+                self.searchProduct();
+                return self.invoice_Currency();
+            });
+        },
+
+        fecthResStore: function(){
             var self = this;
             var defer = $.Deferred();
-            var Journal = new model.web.Model('account.journal');
-            Journal.query(['id', 'name']).filter([['type', '=', 'sale'], ['active', '=', true]]).all().then(function (results) {
+            var field=['id', 'name'];
+            var ResStore = new model.web.Model('res.store');
+            ResStore.query(field).all().then(function(results){
                 defer.resolve(results);
             });
-              return defer;
+            return defer;
+        },
+
+        fecthAccountJournal: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var field = ['id', 'name','store_ids'];
+            var domain = [['active','=',true],['type','in',['sale','purchase']]];
+            var AccountJournal = new model.web.Model('account.journal');
+            AccountJournal.query(field).filter(domain).all().then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
         },
+
+        fecthCompanyCurrency: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var currency = new model.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;
+        },
+
         // Buscar Cambio de Monedas USD,PYG,ARG,BRL
         fetchCurency: function () {
             var defer = $.Deferred();
@@ -174,11 +192,13 @@ function report_sales_invoice_analysis (reporting){
                 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(this.accountJournal, function (item) {
+            var journal_ids = _.flatten(_.map(self.AccountJournal, function (item) {
                 return item.id;
             }));
             if (journal_ids){
@@ -193,6 +213,7 @@ function report_sales_invoice_analysis (reporting){
             });
             return defer;
         },
+
         // Invoice line (Linea de Factura)
         fetchInvoiceLine: function (invoices) {
             var defer = $.Deferred();
@@ -205,6 +226,7 @@ function report_sales_invoice_analysis (reporting){
             });
             return defer;
         },
+
         fetchResPartner: function () {
             var self = this;
             var defer = $.Deferred();
@@ -214,32 +236,35 @@ function report_sales_invoice_analysis (reporting){
             });
             return defer;
         },
+
         // Product Product
         fecthProduct: function(invoiceLines){
             var defer = $.Deferred();
             var porductIDS = _.flatten(_.map(invoiceLines, function (item) {
                 return item.product_id[0];
             }));
-            var ProductProdcut =  new model.web.Model('product.product');
+            var ProductProduct =  new model.web.Model('product.product');
             var fields = ['id','name', 'default_code', 'name_template','ean13', 'standard_price','type','attribute_str'];
-            ProductProdcut.query(fields).filter([['id', 'in', porductIDS]]).all().then(function (results) {
+            ProductProduct.query(fields).filter([['id', 'in', porductIDS]]).all().then(function (results) {
                 defer.resolve(results)
             });
             return defer;
         },
+
         // Obtener Monedas de la Factura
-        getCutrrency: function (id){
+        getCurrency: function (id){
             return _.find(this.Currency,function (curr) {
                 return _.contains(curr.currency_id,id);
             });
         },
+
         // Actualizar cambio de las moneda de Factura
         invoice_Currency: function(){
             for (var i = 0; i < this.invoices.length; i++) {
                 var currency_new;
                 var item = this.invoices[i];
                 var id = item.currency_id[0];
-                currency_new = this.getCutrrency(id);
+                currency_new = this.getCurrency(id);
                 if (!currency_new){
                     currency_new={};
                     currency_new.rate=1;
@@ -248,20 +273,32 @@ function report_sales_invoice_analysis (reporting){
             }
             return this.fectUtility();
         },
+
         // Obtener la Detalles de la Factura
         getInvoice: function (id_line){
             return _.find(this.invoices, function (inv) {
                 return _.contains(inv.invoice_line, id_line);
             });
-          },
+        },
+
         // Obtener las lineas de las Facturas
         getProduct: function(pro_id){
-            return _.find(this.productProduct, function(prod){
+            var self = this;
+            return _.find(self.ProductProduct, function(prod){
                 return _.contains(pro_id, prod.id);
             });
         },
 
+        getAccountJournal: function (id) {
+            var self = this;
+            // console.log(id);
+            return _.filter(self.AccountJournal,function (item) {
+                return item.id === id;
+            });
+        },
+
         fectUtility: function(){
+            var self = this;
             var data=[];
             var item;
             var invoice;
@@ -271,11 +308,14 @@ function report_sales_invoice_analysis (reporting){
                 item = this.invoiceLines[i];
                 invoice = this.getInvoice(item.id);
                 producto =this.getProduct(item.product_id);
+
                 if (!producto){
                     producto={};
                     producto.standard_price=0;
                 }
-                data.push({
+                var store_id = self.getAccountJournal(invoice.journal_id[0]);
+                if(store_id.length > 0){
+                    data.push({
                         id : invoice.id,
                         number : (invoice.number),
                         id_product : producto.id,
@@ -288,19 +328,24 @@ function report_sales_invoice_analysis (reporting){
                         utility : accounting.formatNumber(((item.quantity * (item.price_unit / invoice.rate)) - (item.quantity * producto.standard_price)),2, ".", ","),
                         journal_id :(invoice.journal_id[0]),
                         journal_name :(invoice.journal_id[1]),
+                        quantity_tot : (item.quantity),
+                        price_tot_tot : ((item.quantity * (item.price_unit / invoice.rate))),
+                        standar_tot_tot : ((item.quantity * producto.standard_price)),
+                        utility : (((item.quantity * (item.price_unit / invoice.rate)) - (item.quantity * producto.standard_price))),
                         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]
-                });
-                // }
+                        partner_name : invoice.partner_id[1],
+                        store_id : store_id[0].store_ids[0],
+                    });
+                }
+
           }
           this.rowsData=data;
           this.rowOrigin=data;
           this.loadTable(data)
         },
 
-
         fectSearch: function(){
             var self = this;
             var hoy = moment().format('YYYY-MM-DD');
@@ -308,6 +353,7 @@ function report_sales_invoice_analysis (reporting){
             var product = this.$el.find('#product').val().split('-');
             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;
 
             if ($('#A').is(":checked")){
@@ -348,8 +394,8 @@ function report_sales_invoice_analysis (reporting){
                         date[1] = mes;
                     }
                 }
-                self.rowsData = _.filter(content, function (inv){
-                    var mes = inv.date.split('-');
+                self.rowsData = _.filter(self.rowsData, function (inv){
+                    var mes = inv.date_invoice.split('-');
                     return mes[0]+'-'+mes[1] == date[0]+'-'+date[1];
                 });
             }
@@ -380,8 +426,48 @@ function report_sales_invoice_analysis (reporting){
                     return inv.id_product == product[0];
                 });
             }
+
+            if(store != 9999999){
+                self.rowsData =_.filter(self.rowsData, function (inv){
+                    return inv.store_id == store
+                });
+            }
+
+            var quantity_tot_total = _.reduce(_.map(self.rowsData,function(map){
+                return(map.quantity_tot);
+            }),function(memo, num){
+                return memo + num;
+            },0);
+
+            var price_total_total = _.reduce(_.map(self.rowsData,function(map){
+                return(map.price_tot_tot);
+            }),function(memo, num){
+                return memo + num;
+            },0);
+
+            var standar_total_total = _.reduce(_.map(self.rowsData,function(map){
+                return(map.standar_tot_tot);
+            }),function(memo, num){
+                return memo + num;
+            },0);
+
+            var amount_total_total = _.reduce(_.map(self.rowsData,function(map){
+                return(map.utility);
+            }),function(memo, num){
+                return memo + num;
+            },0);
+
+            self.rowsData.push({
+                number: "Totales:",
+                quantity: accounting.formatNumber((quantity_tot_total),0,".",","),
+                price_tot: accounting.formatNumber((price_total_total),0,".",","),
+                standar_tot: accounting.formatNumber((standar_total_total),0,".",","),
+                utility: accounting.formatNumber((amount_total_total),0,".",","),
+            });
+
             self.loadTable(self.rowsData);
         },
+
         valorNull:function(dato){
             var valor ="";
             if (dato){
@@ -389,6 +475,7 @@ function report_sales_invoice_analysis (reporting){
             }
             return valor;
         },
+
         search: function () {
             var self = this;
             var results = self.ResPartner;
@@ -414,6 +501,7 @@ function report_sales_invoice_analysis (reporting){
                 }
             });
         },
+
         searchProduct: function () {
             var self = this;
             var results = self.productProduct;
@@ -439,10 +527,12 @@ function report_sales_invoice_analysis (reporting){
                 }
             });
         },
+
         loadTable:function(rowsTable){
             var table = this.$el.find('#table');
             table.bootstrapTable('load', rowsTable);
         },
+
         clickOnAction: function (e) {
             var action = this.$el.find(e.target).val();
             var self = this;
@@ -496,6 +586,7 @@ function report_sales_invoice_analysis (reporting){
                 }
             }
         },
+
         drawPDF: function (getColumns,rows) {
             var self = this;
             var rowsPdf=[];
@@ -605,68 +696,5 @@ function report_sales_invoice_analysis (reporting){
             }
             pdfDoc.save('Análisis de facturas de venta.pdf')
         },
-
-        // fectCharFilter: function(){
-        //   var self = this;
-        //   var dataBody=[];
-        //   var dataHeader=[];
-
-        //   var canvas="<canvas id='graf_resume'></canvas>";
-        //   this.$el.find('#grafico').append(canvas);
-
-        //   _.each(self.accountJournal, function(journal){
-        //     dataHeader.push(journal.name);
-        //     var utility=_.reduce(_.map(_.filter(self.rowsData, function (inv){ return inv.journal_id == journal.id}),function(item){
-        //       return parseFloat(((item.utility.replace(".","")).replace(",",".")))}), function(memo, num){ return memo + num; },0);
-        //     dataBody.push(accounting.toFixed((utility),2));
-        //   });
-        //   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);
-        //       }
-        //   });
-        // },
-        // drawChart: function (dataHeader,dataBody) {
-        //     var barChart = new Chart(this.$el.find('#graf_resume'), {
-        //         type: '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
-        //             }
-        //         },
-        //     });
-        // },
     });
 }

+ 7 - 6
static/src/reports/ranking_mrp_orders_product_cy.xml

@@ -5,6 +5,11 @@
             <div class="reporting_page_header">
                 <h1>Ranking Producto más fabricados</h1>
                 <div id="volver"></div>
+                <div id="toolbar">
+                    <button type="button" class="oe_button oe_form_button oe_highlight" aria-label="Left Align" data-toggle="collapse" href="#collapseExample" aria-expanded="false" aria-controls="collapseExample">FILTRAR</button>
+                    <button class="oe_button oe_form_button oe_highlight" value="pdf">PDF</button>
+                    <button class="oe_button oe_form_button oe_highlight" value="chart" id="chart">Graficar</button>
+                </div>
             </div>
             <div class="collapse" id="collapseExample">
                 <div class="card card-body">
@@ -62,11 +67,7 @@
                     </div>
                 </div>
             </div>
-            <div id="toolbar">
-                <button type="button" class="oe_button oe_form_button oe_highlight btn-block" aria-label="Left Align" data-toggle="collapse" href="#collapseExample" aria-expanded="false" aria-controls="collapseExample">FILTRAR</button>
-                <button class="oe_button oe_form_button oe_highlight btn-block" value="pdf">PDF</button>
-                <button class="oe_button oe_form_button oe_highlight btn-block" value="chart" id="chart">Graficar</button>
-            </div>
+
             <table id="table" class="table_paint_first_row"
                 data-pagination="true"
                 data-toggle="table"
@@ -85,7 +86,7 @@
                     </tr>
                 </thead>
             </table>
-            <canvas></canvas>
+            <!-- <canvas></canvas> -->
             <div class="widget-content" id="grafico"></div>
             <div id="dialog"></div>
         </div>

+ 9 - 8
static/src/reports/ranking_pos_orders_product_cy.xml

@@ -10,6 +10,11 @@
                 <div class="card card-body">
                     <br/>
                     <div class="row">
+                        <div id="toolbar">
+                            <button type="button" class="oe_button oe_form_button oe_highlight" aria-label="Left Align" data-toggle="collapse" href="#collapseExample" aria-expanded="false" aria-controls="collapseExample">FILTRAR</button>
+                            <button class="oe_button oe_form_button oe_highlight" value="pdf">PDF</button>
+                            <button class="oe_button oe_form_button oe_highlight" value="chart" id="chart">Graficar</button>
+                        </div>
                         <div class="col-xs-6">
                             <div class="panel panel-default">
                                 <div class="panel-heading">Fechas</div>
@@ -62,16 +67,12 @@
                     </div>
                 </div>
             </div>
-            <div id="toolbar">
-                <button type="button" class="oe_button oe_form_button oe_highlight btn-block" aria-label="Left Align" data-toggle="collapse" href="#collapseExample" aria-expanded="false" aria-controls="collapseExample">FILTRAR</button>
-                <button class="oe_button oe_form_button oe_highlight btn-block" value="pdf">PDF</button>
-                <button class="oe_button oe_form_button oe_highlight btn-block" value="chart" id="chart">Graficar</button>
-            </div>
+
             <table id="table" class="table_paint_first_row"
                 data-pagination="true"
+                data-toolbar="#toolbar"
                 data-toggle="table"
                 data-reorderable-columns="true"
-                data-toolbar="#toolbar"
                 data-show-columns="true"
                 data-buttons-class="oe_button oe_form_button oe_highlight"
                 data-height="auto"
@@ -86,8 +87,8 @@
                     </tr>
                 </thead>
             </table>
-            <canvas></canvas>
-            <div class="widget-content" id="grafico"></div>
+            <!-- <canvas></canvas> -->
+            <div class="widget-content" id="grafico" width="800" height="450"></div>
             <div id="dialog"></div>
         </div>
     </t>

+ 6 - 0
static/src/reports/report_invoice_balance.xml

@@ -99,6 +99,12 @@
                                         <input id="partner" type="text" class="form-control ui-autocomplete-input" autocomplete="off" placeholder="Nombre/ CI/ Ruc"/>
                                     </div>
                                 </div>
+                                <div class="col-xs-12">
+                                    <div class="form-group">
+                                         <label for="current-store">Sucursal: </label>
+                                        <select id="current-store" class="form-control ui-autocomplete-input" name="store"></select>
+                                    </div>
+                                </div>
                             </div>
                         </div>
                     </div>

+ 4 - 0
static/src/reports/report_pos.xml

@@ -63,6 +63,10 @@
                                         <label for="partner">Buscar Cliente:</label>
                                         <input id="partner" type="text" class="form-control ui-autocomplete-input" autocomplete="off" placeholder="Nombre/ CI/ Ruc"/>
                                     </div>
+                                    <div class="form-group">
+                                        <label for="current-store">Sucursal: </label>
+                                        <select id="current-store" class="form-control ui-autocomplete-input" name="store"></select>
+                                    </div>
                                 </div>
                             </div>
                         </div>

+ 7 - 0
static/src/reports/report_pos_orders.xml

@@ -56,6 +56,8 @@
                             <div class="panel-heading">Características</div>
                             <div class="panel-body">
                                 <div class="form-group">
+                                    <label for="current-category">Todas las categorias: </label>
+                                    <select id="current-category" class="form-control ui-autocomplete-input"  name="current-category"></select>
                                     <label for="current-floor">Ubicacion: </label>
                                     <select id="current-floor" class="form-control ui-autocomplete-input"  name="floor"></select>
                                     <label for="current-table">Lugar: </label>
@@ -63,6 +65,10 @@
                                     <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 class="form-group">
+                                    <label for="current-store">Sucursal: </label>
+                                    <select id="current-store" class="form-control ui-autocomplete-input" name="store"></select>
+                                </div>
                             </div>
                         </div>
                     </div>
@@ -86,6 +92,7 @@
               <tr>
                 <th data-field="order_name" data-sortable="true">Pedido</th>
                 <th data-field="date_order" data-sortable="true">Fecha</th>
+                <th data-field="category_name" data-sortable="true" >Categoria</th>
                 <th data-field="table_name">Lugar</th>
                 <th data-field="product_name" data-sortable="true">Productos</th>
                 <th data-field="price_unit" data-align="right">Precio Unitario</th>

+ 51 - 0
static/src/reports/report_product_pack.xml

@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<template xml:space="preserve">
+    <t t-name="ReportProductPack">
+        <div class="report_view">
+            <div class="reporting_page_header">
+                <h1>Analisis de Receta de Producto</h1>
+                <div id="volver"></div>
+            </div>
+            <div class="collapse" id="collapseExample">
+                <div class="card card-body">
+                    <br/>
+                    <div class="row">
+                        <div class="col-xs-6">
+                            <div class="panel panel-default">
+                                <div class="panel-heading">Características</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>
+                </div>
+            </div>
+            <div id="toolbar">
+                <button type="button" class="oe_button oe_form_button oe_highlight btn-block" aria-label="Left Align" data-toggle="collapse" href="#collapseExample" aria-expanded="false" aria-controls="collapseExample">FILTRAR</button>
+                <button class="oe_button oe_form_button oe_highlight btn-block" value="pdf">PDF</button>
+            </div>
+            <table id="table" class="table_paint_first_row"
+                data-pagination="true"
+                data-toggle="table"
+                data-reorderable-columns="true"
+                data-toolbar="#toolbar"
+                data-show-columns="true"
+                data-buttons-class="oe_button oe_form_button oe_highlight"
+                data-height="auto"
+                data-classes="table table-hover table-condensed"
+                data-row-style="rowStyle"
+                data-search="true">
+                <thead>
+                    <tr>
+                        <th data-field="product_main">Producto</th>
+                        <th data-field="product">Insumo</th>
+                        <th data-field="qty" data-sortable="true" data-align="right">Cantidad</th>
+                    </tr>
+                </thead>
+            </table>
+            <canvas></canvas>
+        </div>
+    </t>
+</template>

+ 55 - 0
static/src/reports/report_product_pack_utilidad.xml

@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<template xml:space="preserve">
+    <t t-name="ReportProductPackUtilidad">
+        <div class="report_view">
+            <div class="reporting_page_header">
+                <h1>Análisis de Utilidad de Pack de Producto</h1>
+                <div id="volver"></div>
+            </div>
+            <div class="collapse" id="collapseExample">
+                <div class="card card-body">
+                    <br/>
+                    <div class="row">
+                        <div class="col-xs-6">
+                            <div class="panel panel-default">
+                                <div class="panel-heading">Características</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>
+                </div>
+            </div>
+            <div id="toolbar">
+                <button type="button" class="oe_button oe_form_button oe_highlight btn-block" aria-label="Left Align" data-toggle="collapse" href="#collapseExample" aria-expanded="false" aria-controls="collapseExample">FILTRAR</button>
+                <button class="oe_button oe_form_button oe_highlight btn-block" value="pdf">PDF</button>
+            </div>
+            <table id="table" class="table_paint_first_row"
+                data-pagination="true"
+                data-toggle="table"
+                data-reorderable-columns="true"
+                data-toolbar="#toolbar"
+                data-show-columns="true"
+                data-buttons-class="oe_button oe_form_button oe_highlight"
+                data-height="auto"
+                data-classes="table table-hover table-condensed"
+                data-row-style="rowStyle"
+                data-search="true">
+                <thead>
+                    <tr>
+                        <th data-field="product_main">Producto</th>
+                        <th data-field="product">Insumo</th>
+                        <th data-field="price_costo" data-align="right">P.Costo</th>
+                        <th data-field="price_insumo" data-align="right">P.C.Insumo</th>
+                        <th data-field="qty_pos" data-sortable="true" data-align="right">Cant. Venta</th>
+                        <th data-field="qty" data-sortable="true" data-align="right">Cantidad</th>
+                        <th data-field="subtotal_total" data-align="right">Subtotal</th>
+                    </tr>
+                </thead>
+            </table>
+            <canvas></canvas>
+        </div>
+    </t>
+</template>

+ 4 - 0
static/src/reports/report_purchases_invoice_analysis.xml

@@ -76,6 +76,10 @@
                                     <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 class="form-group">
+                                    <label for="current-store">Sucursal: </label>
+                                    <select id="current-store" class="form-control ui-autocomplete-input" name="store"></select>
+                                </div>
                             </div>
                         </div>
                     </div>

+ 103 - 0
static/src/reports/report_refund_invoice_customer.xml

@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="UTF-8"?>
+  <template xml:space="preserve">
+      <t t-name="ReportRefundInvoiceCustomer">
+        <div class="report_view">
+          <div class="reporting_page_header">
+            <h1>Análisis de facturas de rectificativas de ventas</h1>
+            <div id="volver"></div>
+          </div>
+          <button type="button" class="oe_button oe_form_button oe_highlight" aria-label="Left Align" data-toggle="collapse" href="#collapseExample" aria-expanded="false" aria-controls="collapseExample">FILTRAR
+            </button>
+            <div class="collapse" id="collapseExample">
+                <br/>
+                <div class="row">
+                    <div class="col-xs-6">
+                        <div class="panel panel-default">
+                            <div class="panel-heading">Fechas</div>
+                            <div class="panel-body">
+                                <ul class="list-unstyled">
+                                    <li>
+                                        <input type="radio" name="valores" id="X" value="X" checked="checked"/>
+                                        <label for="X">Sin Filtro</label>
+                                    </li>
+                                    <li>
+                                        <input type="radio" name="valores" id="A" value="A"/>
+                                        <label for="A">Hoy</label>
+                                    </li>
+                                    <li>
+                                        <input type="radio" name="valores" id="B" value="B"/>
+                                        <label for="B">Ayer</label>
+                                    </li>
+                                    <li>
+                                        <input type="radio" name="valores" id="C" value="C"/>
+                                        <label for="C">Mes Actual</label>
+                                    </li>
+                                    <li>
+                                        <input type="radio" name="valores" id="D" value="D"/>
+                                        <label for="D">Mes Pasado</label>
+                                    </li>
+                                    <li>
+                                        <input type="radio" name="valores" id="Z" value="Z"/>
+                                        <label for="Z">Busqueda Avanzada</label>
+                                    </li>
+                                </ul>
+                                <div id="datepicker" style="display:none;" class="container">
+                                    <label for="from">Desde: </label>
+                                    <input type="text"  id="from" name="from"/>
+                                    <label for="to" >Hasta: </label>
+                                    <input type="text"  id="to" name="to" />
+                                </div>
+
+                            </div>
+                        </div>
+                    </div>
+                    <div class="col-xs-6">
+                        <div class="panel panel-default">
+                            <div class="panel-heading">Características</div>
+                            <div class="panel-body">
+                                <div class="form-group">
+                                    <label for="partner">Buscar Cliente</label>
+                                    <input id="partner" type="text" class="form-control ui-autocomplete-input" autocomplete="off"/>
+                                </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>
+                </div>
+            </div>
+          <div id="toolbar">
+            <button class="oe_button oe_form_button oe_highlight" value="pdf">PDF</button>
+        </div>
+        <table id="table" class="table_paint_first_row"
+            data-pagination="true"
+            data-toggle="table"
+            data-reorderable-columns="true"
+            data-toolbar="#toolbar"
+            data-show-columns="true"
+            data-buttons-class="oe_button oe_form_button oe_highlight"
+            data-height="auto"
+            data-classes="table table-hover table-condensed"
+            data-row-style="rowStyle"
+            data-search="true">
+            <thead>
+              <tr>
+                <th data-field="number" data-sortable="true">Factura</th>
+                <th data-field="date_create" data-sortable="true">Fecha</th>
+                <th data-field="reference" data-sortable="true">Referencia</th>
+                <th data-field="partner_name" >Cliente</th>
+                <th data-field="name" >Producto</th>
+                <th data-field="quantity" data-sortable="true" data-align="right">Cantidad</th>
+                <th data-field="price_unity" data-sortable="true" data-align="right">Precio de Venta</th>
+                <th data-field="price_tot" data-sortable="true" data-align="right">Total Venta</th>
+              </tr>
+            </thead>
+        </table>
+        <!-- <canvas></canvas> -->
+        <div class="widget-content" id="grafico"></div>
+        <div id="dialog"></div>
+      </div>
+      </t>
+  </template>

+ 112 - 0
static/src/reports/report_refund_invoice_supplier.xml

@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="UTF-8"?>
+    <template xml:space="preserve">
+        <t t-name="ReportRefundInvoiceSupplier">
+            <div class="report_view">
+              <div class="reporting_page_header">
+                <h1>Análisis de facturas rectificativas de compras</h1>
+            </div>
+            <button type="button" class="oe_button oe_form_button oe_highlight" aria-label="Left Align" data-toggle="collapse" href="#collapseExample" aria-expanded="false" aria-controls="collapseExample">FILTRAR
+            </button>
+            <div class="collapse" id="collapseExample">
+                <br/>
+                <div class="row">
+                    <div class="col-xs-6">
+                        <div class="panel panel-default">
+                            <div class="panel-heading">Fechas</div>
+                            <div class="panel-body">
+                                <ul class="list-unstyled">
+                                    <li>
+                                        <input type="radio" name="valores" id="X" value="X" checked="checked"/>
+                                        <label for="X">Sin Filtro</label>
+                                    </li>
+                                    <li>
+                                        <input type="radio" name="valores" id="A" value="A"/>
+                                        <label for="A">Hoy</label>
+                                    </li>
+                                    <li>
+                                        <input type="radio" name="valores" id="B" value="B"/>
+                                        <label for="B">Ayer</label>
+                                    </li>
+                                    <li>
+                                        <input type="radio" name="valores" id="C" value="C"/>
+                                        <label for="C">Mes Actual</label>
+                                    </li>
+                                    <li>
+                                        <input type="radio" name="valores" id="D" value="D"/>
+                                        <label for="D">Mes Pasado</label>
+                                    </li>
+                                    <li>
+                                        <input type="radio" name="valores" id="Z" value="Z"/>
+                                        <label for="Z">Busqueda Avanzada</label>
+                                    </li>
+                                </ul>
+                                <div id="datepicker" style="display:none;" class="container">
+                                    <label for="from">Desde: </label>
+                                    <input type="text"  id="from" name="from"/>
+                                    <label for="to" >Hasta: </label>
+                                    <input type="text"  id="to" name="to" />
+                                </div>
+
+                            </div>
+                        </div>
+                    </div>
+                    <div class="col-xs-6">
+                        <div class="panel panel-default">
+                            <div class="panel-heading">Características</div>
+                            <div class="panel-body">
+                                <ul class="list-unstyled">
+                                    <li>
+                                        <input type="radio" name="tipo" id="Y" value="Y" checked="checked"/>
+                                        <label for="Y">Sin Filtro</label>
+                                    </li>
+                                    <li>
+                                        <input type="radio" name="tipo" id="purchase" value="purchase"/>
+                                        <label for="purchase">Facturas de compra</label>
+                                    </li>
+                                    <li>
+                                        <input type="radio" name="tipo" id="expense" value="expense"/>
+                                        <label for="expense">Facturas de gasto</label>
+                                    </li>
+                                </ul>
+                                <div class="form-group">
+                                    <label for="partner">Buscar Proveedor</label>
+                                    <input id="partner" type="text" class="form-control ui-autocomplete-input" autocomplete="off"/>
+                                </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>
+                </div>
+            </div>
+            <div id="toolbar">
+                <button class="oe_button oe_form_button oe_highlight" value="pdf">PDF</button>
+            </div>
+            <table id="table" class="table_paint_first_row"
+                data-pagination="true"
+                data-toggle="table"
+                data-reorderable-columns="true"
+                data-toolbar="#toolbar"
+                data-show-columns="true"
+                data-buttons-class="oe_button oe_form_button oe_highlight"
+                data-height="auto"
+                data-classes="table table-hover table-condensed"
+                data-row-style="rowStyle"
+                data-search="true">
+                <thead>
+                    <tr>
+                        <th data-field="number" data-sortable="true">Factura</th>
+                        <th data-field="date_create" data-sortable="true">Fecha</th>
+                        <th data-field="partner_name" >Proveedor</th>
+                        <th data-field="name" >Producto</th>
+                        <th data-field="quantity" data-sortable="true" data-align="right">Cantidad</th>
+                        <th data-field="price_unity" data-sortable="true" data-align="right">Precio Unitario</th>
+                        <th data-field="standar_tot" data-sortable="true" data-align="right">Total Costo</th>
+                    </tr>
+                </thead>
+            </table>
+        </div>
+    </t>
+</template>

+ 4 - 0
static/src/reports/report_sales_invoice_analysis.xml

@@ -63,6 +63,10 @@
                                     <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 class="form-group">
+                                    <label for="current-store">Sucursal: </label>
+                                    <select id="current-store" class="form-control ui-autocomplete-input" name="store"></select>
+                                </div>
                             </div>
                         </div>
                     </div>

+ 2 - 2
static/src/reports/report_stock.xml

@@ -49,8 +49,8 @@
                             <th data-field="ean13" data-sortable="true" >Codigo de barras</th>
                             <th data-field="category_name" data-sortable="true" >Categoria</th>
                             <th data-field="qty" data-sortable="true" data-align="center">Cantidad</th>
-                            <th data-field="standard_price" data-sortable="true" data-align="right">Precio</th>
-                            <th data-field="valuation" data-sortable="true" data-align="right">Valoración</th>
+                            <!-- <th data-field="standard_price" data-sortable="true" data-align="right">Precio</th>
+                            <th data-field="valuation" data-sortable="true" data-align="right">Valoración</th> -->
                         </tr>
                     </thead>
                 </table>

+ 6 - 4
static/src/xml/eiru_reporting.xml

@@ -3,12 +3,14 @@
 <template xml:space="preserve">
     <t t-name="EiruReporting">
         <t t-call="EiruReportingBase">
-            <!-- <header class="reporting_view_header">
-                <h2>Reportes</h2>
-            </header> -->
             <div class="oe_form_sheetbg">
-                <t t-call="EiruReportingCards" />
+                <!-- Llamar lista de reportes -->
+                <!-- <t t-call="EiruReportingCards" /> -->
+                
+                <!-- LLamar pantalla de bienvenida -->
+                <t t-call="EiruReportingWelcome"/>
             </div>
+
         </t>
     </t>
 </template>

+ 28 - 0
static/src/xml/eiru_reporting_welcome.xml

@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<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>
+                    <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.
+                    </p>
+                </div>
+                <div class="col-md-6">
+                    <h3 class="text-center user-content"><p></p></h3>
+                    <div align="center" class="embed-responsive embed-responsive-4by3">
+                        <video autoplay="autoplay" loop="loop" class="embed-responsive-item">
+                            <source src="/eiru_reporting/static/src/img/powtoon.mp4" type="video/mp4"/>
+                        </video>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </t>
+</template>

+ 8 - 1
templates.xml

@@ -19,18 +19,25 @@
                 <!-- Historico de pagos -->
                 <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_vouchers.js" />
                 <!-- Historico de facturas -->
-                <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_invoice_balance.js" /> -->
+                <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_invoice_balance.js" />
                 <!-- Historico de punto de ventas -->
                 <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_pos.js"/>
 
+                <!-- Análisis de pack de productos -->
+                <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_product_pack.js"/>
+                <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_product_pack_utilidad.js"/>
+
                 <!-- Analisis de ventas -->
                 <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_sales_invoice_analysis.js" />
                 <!-- Ranking ventas -->
                 <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/ranking_sales_orders_product_cy.js"/>
+                <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_refund_invoice_customer.js"/>
+
                 <!-- Analisis de compras -->
                 <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_purchases_invoice_analysis.js" />
                 <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_stock.js" />
                 <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_stock_move.js" />
+                <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_refund_invoice_supplier.js" />
                 <!-- account -->
                 <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/reporting_account_apagar.js"/>
                 <!-- accountpending -->

+ 4 - 2
views/menus.xml

@@ -5,10 +5,12 @@
         <menuitem id="eiru_report_main_menu" name="Informes" sequence="175"/>
         <!-- Primer Submenu -->
         <!-- <menuitem id="all_report_parent_menu" name="Todos los informes" parent="eiru_report_main_menu" sequence="1"/> -->
-         <menuitem id="report_dashboard_parent_menu" name="Panel de control" parent="eiru_report_main_menu" sequence="1"/>
+        <menuitem id="report_dashboard_parent_menu" name="Inicio" parent="eiru_report_main_menu" sequence="1"/>
 
 	        <!-- Todos los informes -->
-	        <menuitem id="report_dashboard_menu_submenu" parent="report_dashboard_parent_menu" name="Dashboard" action="eiru_reporting_dashboard_action" />
+	        <!-- <menuitem id="report_dashboard_menu_submenu" parent="report_dashboard_parent_menu" name="Dashboard" action="eiru_reporting_dashboard_action" /> -->
+
+	        <menuitem id="report_menu_submenu" parent="report_dashboard_parent_menu" name="Bienvenido" action="all_report_action" />
 
 	    <!-- Segundo Submenu -->
         <menuitem id="account_report_parent_menu" name="Finanzas" parent="eiru_report_main_menu" sequence="2"/>