Parcourir la source

[ADD] nuevos reportes y filtros

Rodney Enciso Arias il y a 7 ans
Parent
commit
f06c4e92f7

+ 46 - 19
static/src/js/configuration_reporting.js

@@ -26,35 +26,62 @@ function configuration_reporting (instance, widget) {
                 action: 'ReportVoucher'
             },
             {
-                title: 'Histórico de Ventas',
-                description: 'Permite visualizar las facturas de ventas',
-                action: 'ReportSale'
-            },
-            {
-                title: 'Histórico de Compras',
-                description: 'Permite visualizar un histórico de compras realizado por la empresa.',
-                action: 'AllPurchases'
-            },
-            {
-                title: 'Histórico de Gastos',
-                description: 'Permite visualizar un histórico de gastos realizado por la empresa.',
-                action: 'ReposrtExpenses'
+                title: 'Histórico de Facturas',
+                description: 'Permite visualizar las facturas',
+                action: 'ReportInvoiceBalance'
             },
+            // {
+            //     title: 'Histórico de Ventas',
+            //     description: 'Permite visualizar las facturas de ventas',
+            //     action: 'ReportSale'
+            // },
+            // {
+            //     title: 'Histórico de Compras',
+            //     description: 'Permite visualizar un histórico de compras realizado por la empresa.',
+            //     action: 'AllPurchases'
+            // },
+            // {
+            //     title: 'Histórico de Gastos',
+            //     description: 'Permite visualizar un histórico de gastos realizado por la empresa.',
+            //     action: 'ReposrtExpenses'
+            // },
             {
                 title: 'Análisis de Ventas',
                 description: 'Permite realizar un analisis de las facturas de venta.',
                 action: 'ReportSaleInvoiceAnalysis'
             },
             {
-                title: 'Utilidad de facturas detalladas',
-                description: 'Permite visualizar la ganancia de cada ítem de las facturas detalladamente.',
-                action: 'ReportInvoiceUtility'
+                title: 'Análisis de Compras y Gastos',
+                description: 'Permite realizar un analisis de las facturas de compra y de gastos',
+                action: 'ReportPurchaseInvoiceAnalysis'
             },
+            
+            // {
+            //     title: 'Análisis de Gastos',
+            //     description: 'Permite realizar un analisis de las facturas de gastos.',
+            //     action: 'ReportExpenseInvoiceAnalysis'
+            // },
+            // {
+            //     title: 'Utilidad de facturas detalladas',
+            //     description: 'Permite visualizar la ganancia de cada ítem de las facturas detalladamente.',
+            //     action: 'ReportInvoiceUtility'
+            // },
             {
-                title: 'Listado de productos',
-                description: 'Permite visualizar un listado de productos activos.',
-                action: 'ReportStockProduct'
+                title: 'Análisis de stock',
+                description: 'Permite realizar un analisis de los productos disponibles en el stock.',
+                action: 'ReportStock'
+            },
+            {
+                title: 'Análisis de Movimientos de Stock',
+                description: 'Permite realizar un analisis de los productos disponibles en el stock.',
+                action: 'ReportStockMove'
             }
+            // {
+            //     title: 'Listado de productos',
+            //     description: 'Permite visualizar un listado de productos activos.',
+            //     action: 'ReportStockProduct'
+            // }
+
         ],
         start: function () {
         },

+ 11 - 9
static/src/js/main.js

@@ -11,15 +11,17 @@ openerp.eiru_reporting = function (instance) {
     report_resumen_ingresos(reporting);
     report_resumen_engreso(reporting);
     report_vouchers(reporting);
-    report_sales(reporting);
-    report_puchases(reporting);
-    report_expenses(reporting);
-    report_sale_invoice_analysis(reporting)
-    report_invoice_utility(reporting);
-    report_stock_product(reporting);
+    report_invoice_balance(reporting);
+    // report_sales(reporting);
+    // report_puchases(reporting);
+    // report_expenses(reporting);
+    report_sale_invoice_analysis(reporting);
+    report_purchases_invoice_analysis(reporting);
+    report_stock(reporting);
+    report_stock_move(reporting);
+    // report_expenses_invoice_analysis(reporting);
+    // report_invoice_utility(reporting);
+    // report_stock_product(reporting);
     // report_stock_location(reporting);
-    
-
-
     instance.web.client_actions.add('eiru_reporting.action_report', 'instance.eiru_reporting.ReportingWidget');
 }

+ 656 - 0
static/src/js/reports/report_expenses_invoice _analysis.js

@@ -0,0 +1,656 @@
+function report_expenses_invoice_analysis (reporting){
+    "use strict";
+
+    var model = openerp;
+
+    reporting.ReportExpenseInvoiceAnalysisWidget = reporting.Base.extend({
+        template: 'ReportExpenseInvoiceAnalysis',
+        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_invoice'],['id','=', row.id]],
+                    context : {},
+                    flags : {'form': {'action_buttons': false, 'options': {'mode': 'view'}}},
+                    res_id : row.id,
+                });
+            }
+            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', '=', 'purchase'], ['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', '=', 'in_invoice'],['origin','=',false]];
+            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 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],['supplier', '=', 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'];
+            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);
+            });
+        },
+        // unir los objetos
+        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),
+                    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],
+                    partner_name : invoice.partner_id[1]
+                });
+          }
+          this.rowsData=data;
+          this.rowOrigin=data;
+          this.loadTable(data)
+        },
+        // Buscar
+        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;
+                date.splice(1,0);
+                if(date[1] < 10){
+                    date[1] = '0'+mes;
+                }else{
+                    date[1] = mes;
+                }
+                self.rowsData = _.filter(self.rowsData, function (inv){
+                    var mes = inv.date_invoice.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){
+                    // console.log(inv.partner_id + " --- " + partner[0]);
+                    return inv.id_product == product[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 + '-'+ item.name,
+                        value: item.id + '-'+ item.name
+                }
+            });
+            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();
+                }
+            });
+        },
+        // cargara la tabla
+        loadTable:function(rowsTable){
+            var table = this.$el.find('#table');
+            table.bootstrapTable('load', rowsTable);
+        },
+        // imprimir PDF
+        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');
+                            }
+                        }
+                    });
+                }
+            }
+        },
+        // Generar pdfDoc
+        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 precio_cost=_.reduce(_.map(rows,function(item){
+                var valor=0;
+                if(item.standar_price){valor=parseFloat(((item.standar_price.replace(".","")).replace(",",".")))} return valor}), function(memo, num){ return memo + num;},0);
+            var tot_unit=_.reduce(_.map(rows,function(item){
+                var valor=0;
+                if (item.price_tot){valor=parseFloat(((item.price_tot.replace(".","")).replace(",",".")))}return valor}), function(memo, num){ return memo + num; },0);
+            var tol_cost=_.reduce(_.map(rows,function(item){
+                var valor=0;
+                if (item.standar_tot){valor=parseFloat(((item.standar_tot.replace(".","")).replace(",",".")))} return valor }), function(memo, num){ return memo + num; },0);
+            var utility=_.reduce(_.map(rows,function(item){
+                var valor=0;
+                if (item.utility){valor=parseFloat(((item.utility.replace(".","")).replace(",",".")))}return valor }), function(memo, num){ return memo + num; },0);
+
+            rowsPdf=rows;
+
+            var company = _.map(self.resCompany, function (map) {
+                return map.currency_id[1];
+            });
+            rowsPdf.push({
+                        number : "TOTAL "+company,
+                        name : " ", 
+                        quantity: accounting.formatNumber(quantity,0, ".", ","),
+                        price_unity : accounting.formatNumber(precio_unit,2, ".", ","),
+                        standar_price : accounting.formatNumber(precio_cost,2, ".", ","),
+                        price_tot : accounting.formatNumber(tot_unit,2, ".", ","),
+                        standar_tot : accounting.formatNumber(tol_cost,2, ".", ","),
+                        utility : accounting.formatNumber(utility,2, ".", ",")
+                    });
+
+            rowsPdf.unshift({
+                        number : "TOTAL "+company,
+                        name : " ",
+                        quantity: accounting.formatNumber(quantity,0, ".", ","),
+                        price_unity : accounting.formatNumber(precio_unit,2, ".", ","),
+                        standar_price : accounting.formatNumber(precio_cost,2, ".", ","),
+                        price_tot : accounting.formatNumber(tot_unit,2, ".", ","),
+                        standar_tot : accounting.formatNumber(tol_cost,2, ".", ","),
+                        utility : accounting.formatNumber(utility,2, ".", ",")
+                    });
+
+            pdfDoc.autoTable(getColumns, rowsPdf, {
+                styles: { overflow: 'linebreak', fontSize: 8, columnWidth: 'wrap'},
+                columnStyles: {
+                              number: {fontStyle: 'bold'},
+                              name :{columnWidth: '10px'},
+                              quantity :{halign:'right' },
+                              price_unity : {halign:'right' },
+                              standar_price : {halign:'right' },
+                              price_tot : {halign:'right' },
+                              standar_tot : {halign:'right' },
+                              utility : {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 de compra ', 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 de compra.pdf')
+        },
+        // Chart Filter
+        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);
+              }
+          });
+        },
+        // Chart
+        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
+                    }
+                },
+            });
+        },
+    });
+}

+ 504 - 0
static/src/js/reports/report_invoice_balance.js

@@ -0,0 +1,504 @@
+function report_invoice_balance (reporting){
+    "use strict";
+
+    var instance = openerp;
+
+    reporting.ReportInvoiceBalanceWidget = reporting.Base.extend({
+        template: 'ReportInvoiceBalance',
+        content:[],
+        rowsData :[],
+        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 #sale' : 'factSearch',
+            'click #purchase' : 'factSearch',
+            'click #expense' : 'factSearch',
+
+            'click #W' : 'factSearch',
+            'click #open' : 'factSearch',
+            'click #paid' : 'factSearch',
+            
+            'change #current-journal' : 'factSearch',
+            'change #current-currency' : 'factSearch',
+            
+            'change #from' : 'factSearch',
+            'change #to' : '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();
+        },
+        clickAnalysisDetail: function(e, row, $element, field){
+            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_invoice'],['id','=', row.id]],
+                    context: {},
+                    flags: {'form': {'action_buttons': false, 'options': {'mode': 'view'}}},
+                    res_id: row.id,
+                });
+            }
+            if (field == 'partner'){
+                this.do_action({
+                    name:"Registro",
+                    type: 'ir.actions.act_window',
+                    res_model: "res.partner",
+                    views: [[false,'form']],
+                    target: 'new',
+                    domain: [['id','=', row.partner_id]],
+                    context: {},
+                    flags: {'form': {'action_buttons': false, 'options': {'mode': 'view'}}},
+                    res_id: row.partner_id,
+                });
+            }
+            e.stopImmediatePropagation();
+        },
+        submitForm: function () {
+            var self = this;
+            self.fetchAccountInvoice().then(function(AccountInvoice) {
+                return AccountInvoice;
+            }).then(function (AccountInvoice) {
+                self.AccountInvoice = AccountInvoice;
+                return self.fetchResPartner();
+            }).then(function(ResPartner){
+                self.ResPartner = ResPartner;
+                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;
+            }
+        },
+        fetchAccountInvoice: function () {
+            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();
+            var AccountInvoice = new instance.web.Model('account.invoice');
+            AccountInvoice.query(field).filter(filter).all().then(function (results) {
+                defer.resolve(results);
+            });
+            return defer;
+        },
+        fetchResPartner: function() {
+            var self = this;
+            var defer = $.Deferred();
+            var ResPartner = new instance.web.Model('res.partner');
+            ResPartner.query(['id', 'name', 'ruc', 'active']).filter([['active', '=', true]]).all().then(function (results) {
+                defer.resolve(results);
+            });
+            return defer;
+        },
+        valorNull:function(dato){
+            var valor ="";
+            if (dato){
+                valor=dato;
+            }
+            return valor;
+        },
+        search: function () {
+            var self = this;
+            var results = self.ResPartner;
+            results = _.map(results, function (item) {
+                return {
+                        label: item.id + '-'+ item.name + ' ' + self.valorNull(item.ruc),
+                        value: item.id + '-'+ item.name + ' ' + self.valorNull(item.ruc)
+                }
+            });
+            self.$('#partner').autocomplete({
+                source: results,
+                minLength:0,
+                search: function(event, ui) {
+                    if (!(self.$('#partner').val())){
+                        self.factSearch();
+                    }
+                },
+                close: function( event, ui ) {
+                        self.factSearch();
+                },
+                select: function(event, ui) {
+                    self.factSearch();
+                }
+            });
+        },
+        BuildTable: function(){
+            var self = this;
+            var data = [];
+            var AccountInvoice = self.AccountInvoice;
+            var entry;
+            var egress;
+            var to_receive;
+            var to_pay;
+            var invoice_type;
+            _.each(AccountInvoice, function(item){
+                if (item.type == 'out_invoice') {
+                    entry = item.amount_total - item.residual;
+                    egress = 0;
+                    to_receive = item.residual;
+                    to_pay = 0;
+                    invoice_type = 'sale';
+                } else {
+                    entry = 0;
+                    egress = item.amount_total - item.residual;
+                    to_receive = 0;
+                    to_pay = item.residual;
+                    if (item.origin == false) {
+                        invoice_type = 'expense';
+                    } else {
+                        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],
+                });
+            });
+            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 content = self.content;  
+            if ($('#A').is(":checked")){
+                content = _.filter(content, function (inv){
+                    return inv.date == hoy;
+                });
+            }
+            if ($('#B').is(":checked")){
+                var date = hoy.split('-');
+                var ayer = date[2] - 1;
+                date.splice(2,0);
+                if(date[2] < 10){
+                    date[2] = '0'+ayer;
+                }else{
+                    date[2] = ayer;
+                }
+                content = _.filter(content, function (inv){
+                    return inv.date == date[0]+'-'+date[1]+'-'+date[2];
+                });
+            }
+            if ($('#C').is(":checked")){
+                var date = hoy.split('-');
+                content = _.filter(content, function (inv){
+                    var mes = inv.date.split('-');
+                    return mes[0]+'-'+mes[1] == date[0]+'-'+date[1];
+                });
+            }
+            if ($('#D').is(":checked")){
+                var date = hoy.split('-');
+                var mes = date[1] - 1;
+                date.splice(1,0);
+                if(date[1] < 10){
+                    date[1] = '0'+mes;
+                }else{
+                    date[1] = mes;
+                }
+                content = _.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('/');
+                    content = _.filter(content, function (inv){
+                        return inv.date >= (date[2]+"-"+date[1]+"-"+date[0]);
+                    });
+                }
+                if (hasta.length > 0){
+                    var date= hasta.split('/');
+                    content = _.filter(content, function (inv){
+                        return inv.date <= (date[2]+"-"+date[1]+"-"+date[0]);
+                    });
+                }
+            }else{
+                $('#datepicker').css('display','none');
+            }
+            
+            if ($('#sale').is(":checked")){
+                content = _.filter(content, function (inv){
+                    return inv.invoice_type == 'sale';
+                });
+            }
+            if ($('#purchase').is(":checked")){
+                content = _.filter(content, function (inv){
+                    return inv.invoice_type == 'purchase';
+                });
+            }
+            if ($('#expense').is(":checked")){
+                content = _.filter(content, function (inv){
+                    return inv.invoice_type == 'expense';
+                });
+            }
+            if ($('#open').is(":checked")){
+                content = _.filter(content, function (inv){
+                    return inv.state == 'open';
+                });
+            }
+            if ($('#paid').is(":checked")){
+                content = _.filter(content, function (inv){
+                    return inv.state == 'paid';
+                });
+            }
+            if (partner != ""){
+                content = _.filter(content, function(inv){
+                    return inv.partner_id == partner[0];
+                });
+            }
+            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=[];
+            var rows = self.rowsData;
+            var amount_total =_.reduce(_.map(rows,function(item){
+                var valor = 0;
+                if (item.amount_total){
+                    valor = parseFloat(((item.amount_total.replace(".","")).replace(",",".")))
+                }return valor
+            }), function(memo, num){ 
+                return memo + num; 
+            },0);
+            var entry =_.reduce(_.map(rows,function(item){
+                var valor = 0;
+                if (item.entry){
+                    valor = parseFloat(((item.entry.replace(".","")).replace(",",".")))
+                }return valor
+            }), function(memo, num){ 
+                return memo + num; 
+            },0);
+            var egress =_.reduce(_.map(rows,function(item){
+                var valor = 0;
+                if (item.egress){
+                    valor = parseFloat(((item.egress.replace(".","")).replace(",",".")))
+                }return valor
+            }), function(memo, num){ 
+                return memo + num; 
+            },0);
+            var to_receive =_.reduce(_.map(rows,function(item){
+                var valor = 0;
+                if (item.to_receive){
+                    valor = parseFloat(((item.to_receive.replace(".","")).replace(",",".")))
+                }return valor
+            }), function(memo, num){ 
+                return memo + num; 
+            },0);
+            var to_pay =_.reduce(_.map(rows,function(item){
+                var valor = 0;
+                if (item.to_pay){
+                    valor = parseFloat(((item.to_pay.replace(".","")).replace(",",".")))
+                }return valor
+            }), function(memo, num){ 
+                return memo + num; 
+            },0);
+            if (rows.length > 0){
+                rows.push({
+                    number: "Totales ",
+                    amount_total: accounting.formatNumber(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,".",","),        
+                });
+            } 
+            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.getObjectPdf();
+            if (action === 'pdf') {
+                var dataNEW = _.map(data2, function (val){
+                    return val.field;
+                });
+                _.each(rowsNew,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 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 pdfDoc = new jsPDF();
+
+            pdfDoc.autoTable(getColumns, rows, {
+                styles: { overflow: 'linebreak', fontSize: 8, columnWidth: 'wrap'},
+                columnStyles: {
+                    number : {columnWidth: '8px'},
+                    supplier_invoice_number : {columnWidth: '8px'},
+                    partner : {columnWidth: '8px'},
+                    date : {columnWidth: '8px'},
+                    user : {columnWidth: '8px'},
+                    currency : {columnWidth: '8px'},
+                    amount_total: {halign:'right',columnWidth: '8px'},
+                },
+                margin: { top: 20, horizontal: 7},
+
+                addPageContent: function (data) {
+                    pdfDoc.setFontSize(12);
+                    pdfDoc.setFontStyle('bold');
+                    pdfDoc.setTextColor(40);
+                    pdfDoc.text('Histórico de Facturas', 80, 10);
+
+                    var tipo = '';
+                    if ($('#Y').is(":checked")){
+                        tipo = tipo.concat(' Tipo de factura : Todas las facturas' );
+                    }
+                    if ($('#sale').is(":checked")){
+                        tipo = tipo.concat(' Tipo de factura : Ventas' );
+                    }
+                    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('normal');
+                    pdfDoc.setTextColor(40);
+                    pdfDoc.text(175,pdfDoc.internal.pageSize.height - 5,str);                       
+                    }
+            });
+            if (typeof pdfDoc.putTotalPages === 'function') {
+                pdfDoc.putTotalPages(totalPagesExp);
+            }
+            pdfDoc.save('Histórico de Facturas.pdf')
+        },
+    });
+}

+ 606 - 0
static/src/js/reports/report_purchases_invoice _analysis.js

@@ -0,0 +1,606 @@
+function report_purchases_invoice_analysis (reporting){
+    "use strict";
+
+    var model = openerp;
+
+    reporting.ReportPurchaseInvoiceAnalysisWidget = reporting.Base.extend({
+        template: 'ReportPurchaseInvoiceAnalysis',
+        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 Cliente",
+                    type : 'ir.actions.act_window',
+                    res_model : "account.invoice",
+                    views : [[false,'form']],
+                    target : 'new',
+                    domain : [['type', '=', 'out_invoice'],['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_invoice']];
+            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 ProductProdcut =  new model.web.Model('product.product');
+            var fields = ['id','name', 'default_code', 'name_template','ean13', 'standard_price','type'];
+            ProductProdcut.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],
+                    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;
+                date.splice(1,0);
+                if(date[1] < 10){
+                    date[1] = '0'+mes;
+                }else{
+                    date[1] = mes;
+                }
+                self.rowsData = _.filter(self.rowsData, function (inv){
+                    var mes = inv.date_invoice.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){
+                    // console.log(inv.partner_id + " --- " + partner[0]);
+                    return inv.id_product == product[0];
+                });
+            }
+            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.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 + '-'+ item.name,
+                        value: item.id + '-'+ item.name
+                }
+            });
+            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));
+                });
+                _.each(_.map(data2,function(val){
+                    return val}), function(item){
+                    getColumns.push([{
+                                    title: item.title,
+                                    dataKey: item.field
+                                }]);
+                });
+                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 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'},
+                    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 de compra ',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 de compra.pdf')
+        },
+    });
+}

+ 62 - 67
static/src/js/reports/report_sales_invoice _analysis.js

@@ -260,7 +260,7 @@ function report_sale_invoice_analysis (reporting){
                 return _.contains(pro_id, prod.id);
             });
         },
-        // unir los objetos
+
         fectUtility: function(){
             var data=[];
             var item;
@@ -275,7 +275,6 @@ function report_sale_invoice_analysis (reporting){
                     producto={};
                     producto.standard_price=0;
                 }
-                // if (producto.type =="product"){
                 data.push({
                         id : invoice.id,
                         number : (invoice.number),
@@ -299,7 +298,8 @@ function report_sale_invoice_analysis (reporting){
           this.rowOrigin=data;
           this.loadTable(data)
         },
-        // Buscar
+        
+
         fectSearch: function(){
             var self = this;
             var hoy = moment().format('YYYY-MM-DD');
@@ -368,7 +368,6 @@ function report_sale_invoice_analysis (reporting){
             }
             if (product != ""){
                 self.rowsData = _.filter(self.rowsData, function(inv){
-                    // console.log(inv.partner_id + " --- " + partner[0]);
                     return inv.id_product == product[0];
                 });
             }
@@ -431,12 +430,10 @@ function report_sale_invoice_analysis (reporting){
                 }
             });
         },
-        // cargara la tabla
         loadTable:function(rowsTable){
             var table = this.$el.find('#table');
             table.bootstrapTable('load', rowsTable);
         },
-        // imprimir PDF
         clickOnAction: function (e) {
             var action = this.$el.find(e.target).val();
             var self = this;
@@ -490,7 +487,6 @@ function report_sale_invoice_analysis (reporting){
                 }
             }
         },
-        // Generar pdfDoc
         drawPDF: function (getColumns,rows) {
             var self = this;
             var rowsPdf=[];
@@ -597,69 +593,68 @@ function report_sale_invoice_analysis (reporting){
             }
             pdfDoc.save('Análisis de facturas de venta.pdf')
         },
-        // Chart Filter
-        fectCharFilter: function(){
-          var self = this;
-          var dataBody=[];
-          var dataHeader=[];
 
-          var canvas="<canvas id='graf_resume'></canvas>";
-          this.$el.find('#grafico').append(canvas);
+        // fectCharFilter: function(){
+        //   var self = this;
+        //   var dataBody=[];
+        //   var dataHeader=[];
 
-          _.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>";
+        //   var canvas="<canvas id='graf_resume'></canvas>";
+        //   this.$el.find('#grafico').append(canvas);
 
-          this.$el.find('#volver').append(selector);
+        //   _.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('.bootstrap-table').hide({
-              effect: 'drop',
-              direction: 'up',
-              duration: 200,
-              complete: function () {
-                self.drawChart(dataHeader,dataBody);
-              }
-          });
-        },
-        // Chart
-        drawChart: function (dataHeader,dataBody) {
-            var barChart = new Chart(this.$el.find('#graf_resume'), {
-                type: 'doughnut',
-                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
-                    }
-                },
-            });
-        },
+        //   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
+        //             }
+        //         },
+        //     });
+        // },
     });
 }

+ 326 - 0
static/src/js/reports/report_stock.js

@@ -0,0 +1,326 @@
+function report_stock (reporting){
+    "use strict";
+
+    var instance = openerp;
+
+    reporting.ReportStockWidget = reporting.Base.extend({
+        template: 'ReportStock',
+        stockLocation: [],
+        stockQuant: [],
+        productProduct : [],
+        rowsData: [],
+        content: [],
+        newStock: [],
+
+        events : {
+            'change #current-location' : 'factSearch',
+            'change #current-category' : 'factSearch',
+            'click #toolbar > button' : 'clickOnAction',
+            'click-row.bs.table #table ' : 'clickAnalysisDetail',
+        },
+        init : function(parent){
+            this._super(parent);
+        },
+        start : function(){
+            var self = this;
+            var dato=[];
+            var table = this.$el.find('#table');
+            table.bootstrapTable({data : self.rowsData});
+            self.submitForm();
+        },
+        valorNull:function(dato){
+            var valor ="";
+            if (dato){
+                valor=dato;
+            }
+            return valor;
+        },
+        clickAnalysisDetail: function(e, row, $element,field){
+            if (field == 'product'){
+                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 ]],
+                    context: {},
+                    flags: {'form': {'action_buttons': false, 'options': {'mode': 'view'}}},
+                    res_id: row.id,
+                });
+            }
+            e.stopImmediatePropagation();
+        },
+        submitForm: function(){
+            var self = this;
+            self.fecthStockLocation().then(function(StockLocation){
+                self.StockLocation=StockLocation;
+                return StockLocation;
+            }).then(function(StockLocation){
+                return self.fecthStockQuant();
+            }).then(function(StockQuant){
+                self.StockQuant = StockQuant;
+                return self.fecthProductProduct();
+            }).then(function(ProductProduct){
+                self.ProductProduct = ProductProduct;
+                return self.fecthProductCategory();
+            }).then(function(ProductCategory){
+                self.ProductCategory = ProductCategory;
+                self.$el.find('#current-category').append('<option value="9999999">Todos las categorias</option>');
+                _.each(ProductCategory, function (item) {
+                    self.$el.find('#current-category').append('<option value="' + item.id + '">' + item.name + '</option>');
+                });
+                self.search();
+                return self.BuildTable(self.stockQuant, self.stockLocation);
+            });
+        },
+        fecthStockLocation : function(){
+            var self = this;
+            var defer = $.Deferred();
+            var location = new instance.web.Model('stock.location');
+            var fields = ['id', 'name', 'company_id', 'location_id'];
+            var domain =[['active', '=', true],['usage', '=', 'internal']];
+            location.query(fields).filter(domain).order_by('id').all().then(function(results){
+                defer.resolve(results);
+            })
+            return defer;
+        },
+        fecthStockQuant : function(){
+            var self = this;
+            var defer = $.Deferred();
+            var location = _.flatten(_.map(self.StockLocation,function(item){
+                return item.id;
+            }));
+            var company_id =(_.map(self.StockLocation, function(item){
+                return item.company_id[0];
+            })).shift();
+            var quant = new instance.web.Model('stock.quant');
+            var fields = ['id', 'product_id', 'qty', 'cost','location_id'];
+            var domain =[['company_id', '=', company_id],['location_id', 'in',location]];
+            quant.query(fields).filter(domain).all().then(function(results){
+                defer.resolve(results);
+            })
+            return defer;
+        },
+        fecthProductProduct: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var ids = _.flatten(_.map(self.StockQuant, function (item) {
+                return item.product_id[0];
+            }));
+            var fields = ['id','name','name_template', 'standard_price','type','attribute_value_ids', 'lst_price','ean13','categ_id'];
+            var ProductProduct =  new instance.web.Model('product.product');
+            ProductProduct.query(fields).filter([['id', 'in', ids]]).all().then(function (results) {
+              defer.resolve(results)
+            });
+            return defer;
+        },
+        fecthProductCategory: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var fields = ['id','name'];
+            var ProductCategory =  new instance.web.Model('product.category');
+            ProductCategory.query(fields).filter([['type', '=', 'normal']]).all().then(function (results) {
+              defer.resolve(results)
+            });
+            return defer;
+        },
+        getProductProduct: function(ProductProduct, StockQuant){
+            var self = this;
+            var product_ids= _.flatten(_.map(StockQuant,function(map){
+                return map.product_id[0];
+            }));
+
+            return _.filter(ProductProduct,function(prod){return _.contains(product_ids, prod.id)});
+        },
+        getStockQuant: function(product_id, quantObjs){
+            var self = this;
+            var quantProduct = quantObjs;
+            if (product_id){
+                quantProduct = _.filter(quantProduct, function(item){
+                    return item.product_id[0] == product_id;
+                });
+            }
+            return quantProduct;
+        },
+        BuildTable : function(stockQuant,stockLocation){
+            var self = this;
+            var data=[];
+            var itemLocation;
+            var itemProduct;
+            var itemQuant;
+            var ProductProduct;
+            var product;
+            var quantity = 0;
+            var total=0;
+            ProductProduct = self.getProductProduct(self.ProductProduct, self.StockQuant);
+            _.each(ProductProduct, function(item){    
+                itemProduct = item;
+                itemQuant = self.getStockQuant( itemProduct.id, self.StockQuant);
+                if (itemQuant.length > 0){
+                    quantity = _.reduce(_.map(itemQuant,function(item){
+                        return item.qty;
+                    }),function(mamo, num){
+                        return mamo + num;
+                    },0);
+                    product = itemQuant.shift();
+                    total = parseInt(quantity * itemProduct.standard_price);
+                    data.push({ 
+                        id : product.product_id[0],
+                        product : product.product_id[1],
+                        ean13 : self.valorNull(itemProduct.ean13),
+                        category_name : itemProduct.categ_id[1],
+                        qty : quantity,
+                        standard_price : accounting.formatNumber(itemProduct.standard_price,0, ".", ","),
+                        lst_price : accounting.formatNumber(itemProduct.lst_price,0, ".", ","),
+                        valuation: accounting.formatNumber(total,0,".",","),
+                        category_id : itemProduct.categ_id[0],
+                        location_id : product.location_id[0]
+                    });
+                }
+            })
+            self.content = data;
+            self.loadTable(data);
+        },
+        search: function () {
+            var self = this;
+            var results = self.ProductProduct;
+            results = _.map(results, function (item) {
+                return {
+                        label: item.id + '-'+ item.name,
+                        value: item.id + '-'+ item.name
+                }
+            });
+            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();
+                }
+            });
+        },
+        factSearch: function(){
+            var self = this;
+            var category = this.$el.find('#current-category').val();
+            var product= this.$el.find('#product').val().split('-');
+            var content = self.content;
+            if(category != 9999999){
+                content = _.filter(content,function(inv){
+                    return inv.category_id == category;
+                });
+            }
+            if (product != ""){
+                content = _.filter(content, function(inv){
+                    return inv.id == product[0];
+                });
+            }
+            self.loadTable(content)
+        },
+        loadTable:function(rowsTable){
+            var self = this;
+            self.rowsData = rowsTable;
+            var table = self.$el.find('#table');
+            table.bootstrapTable('load' ,rowsTable);
+        },
+        getObjectPdf: function(){
+            var self = this;
+            var rows=[];
+            var newStock = self.newStock;
+            var amount_total = 0;
+            var qty = 0;
+            for (var i = 0; i < newStock.length; i++) {
+                rows.push({
+                    product : newStock[i].product,
+                    qty : newStock[i].qty,
+                    standard_price : newStock[i].standard_price,
+                    lst_price : newStock[i].lst_price,
+                    total: newStock[i].total
+                });
+                qty+=parseInt(newStock[i].qty);
+                amount_total+=parseInt(newStock[i].total.replace(".",""));
+            }
+            rows.push({
+                product : 'Totales',
+                qty : accounting.formatNumber(qty,0,".",","),
+                standard_price : '',
+                lst_price : '',
+                total: accounting.formatNumber(amount_total,0,".",","),
+            });
+            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.getObjectPdf();
+            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 location = this.sucDescrip = this.$el.find('#current-location option:selected').text();
+            var totalPagesExp = "{total_pages_count_string}";
+            var pdfDoc = new jsPDF();
+            pdfDoc.autoTable(getColumns, rows, {
+                    styles: { overflow: 'linebreak', fontSize:8 , columnWidth: 'wrap'},
+                    columnStyles:{
+                                    product :{columnWidth: '8px'},
+                                    qty : {halign:'center'},
+                                    standard_price : {halign:'right'},
+                                    lst_price : {halign:'right'},
+                                    total : {halign:'right'},
+                                },
+                    margin: { top: 16, horizontal: 7},
+                addPageContent: function (data) {
+                    pdfDoc.setFontSize(12);
+                    pdfDoc.setFontStyle('bold');
+                    pdfDoc.setTextColor(40);
+                    pdfDoc.text('Listado de productos', data.settings.margin.left, 10);
+                    // FOOTER
+                    var str = "Pagina  " + data.pageCount;
+                    if (typeof pdfDoc.putTotalPages === 'function') {
+                        str = str + " de " + totalPagesExp;
+                        // +"\n  Día de Expedición  "+fechaActu.getDate()+"/"+fechaActu.getMonth()+"/"+fechaActu.getFullYear();
+                    }
+                    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 de productos.pdf');
+        }
+    });
+}

+ 442 - 0
static/src/js/reports/report_stock_move.js

@@ -0,0 +1,442 @@
+function report_stock_move(reporting){
+    "use strict";
+
+    var instance = openerp;
+
+    reporting.ReportStockMoveWidget = reporting.Base.extend({
+        template: 'ReportStockMove',
+        content: [],
+        rowsData :[],
+        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',
+            'change #current-location-origin' : 'factSearch',
+            'change #current-location-destiny' : '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();
+        },
+        valorNull:function(dato){
+            var valor ="";
+            if (dato){
+                valor=dato;
+            }
+            return valor;
+        },
+        clickAnalysisDetail: function(e, row, $element, field){
+            if (field == 'picking_name'){
+                if(row.picking_id != undefined){
+                    this.do_action({
+                    name:"Transferencia",
+                    type: 'ir.actions.act_window',
+                    res_model: "stock.picking",
+                    views: [[false,'form']],
+                    target: 'new',
+                    domain: [['id','=', row.picking_id]],
+                    context: {},
+                    flags: {'form': {'action_buttons': false, 'options': {'mode': 'view'}}},
+                    res_id: row.picking_id,
+                    });
+                }
+                
+            }
+            if (field == 'product_name'){   
+                this.do_action({
+                name:"Producto",
+                type: 'ir.actions.act_window',
+                res_model: "product.product",
+                views: [[false,'form']],
+                target: 'new',
+                domain: [['id','=', row.product_id]],
+                context: {},
+                flags: {'form': {'action_buttons': false, 'options': {'mode': 'view'}}},
+                res_id: row.product_id,
+                });
+            }
+            if (field == 'partner_name'){
+                if(row.partner_id != undefined){
+                    this.do_action({
+                    name:"Registro",
+                    type: 'ir.actions.act_window',
+                    res_model: "res.partner",
+                    views: [[false,'form']],
+                    target: 'new',
+                    domain: [['id','=', row.partner_id]],
+                    context: {},
+                    flags: {'form': {'action_buttons': false, 'options': {'mode': 'view'}}},
+                    res_id: row.partner_id,
+                    });
+                }
+                
+            }
+            e.stopImmediatePropagation();
+        },
+        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.fetchStockMove().then(function(StockMove) {
+                return StockMove;
+            }).then(function (StockMove){
+                self.StockMove = StockMove;
+                return self.fetchResPartner();
+            }).then(function(ResPartner){
+                self.ResPartner=ResPartner;
+                return self.fetchStockLocation();
+            }).then(function(StockLocation){
+                self.StockLocation=StockLocation;
+                self.$el.find('#current-location-origin').append('<option value="9999999">Todas las ubicaciones</option>');
+                _.each(StockLocation, function (item) {
+                    self.$el.find('#current-location-origin').append('<option value="' + item.id + '">'+ item.location_id[1] + " / " + item.name + '</option>');
+                });
+                self.$el.find('#current-location-destiny').append('<option value="9999999">Todas las ubicaciones</option>');
+                _.each(StockLocation, function (item) {
+                    self.$el.find('#current-location-destiny').append('<option value="' + item.id + '">'+ item.location_id[1] + " / " + item.name + '</option>');
+                }); 
+                self.search();
+                return self.BuildTable();
+            });
+        },
+        fetchStockMove: function () {
+            var self = this;
+            var defer = $.Deferred();
+            var filter =[['state', '=', 'done']];
+            var field =['id', 'name', 'product_id', 'product_uom_qty', 'location_id', 'location_dest_id', 'date', 'picking_id','origin','partner_id'];
+            var StockMove = new instance.web.Model('stock.move');
+            StockMove.query(field).filter(filter).all().then(function (results) {
+                defer.resolve(results);
+            });
+            return defer;
+        },
+        fetchResPartner: function() {
+            var self = this;
+            var defer = $.Deferred();
+            var ResPartner = new instance.web.Model('res.partner');
+            ResPartner.query(['id', 'name', 'ruc']).filter([['active', '=', true], ['customer', '=', true]]).all().then(function (results) {
+                defer.resolve(results);
+            });
+            return defer;
+        },
+        fetchStockLocation : function(){
+            var self = this;
+            var defer = $.Deferred();
+            var fields = ['id', 'name', 'location_id'];
+            var domain =[['usage', 'not in', ['view','transit','production','procurement']],['scrap_location','=',false],['active','!=',false]];
+            var StockLocation = new instance.web.Model('stock.location');
+            StockLocation.query(fields).filter(domain).order_by('id').all().then(function(results){
+                defer.resolve(results);
+            })
+            return defer;
+        },
+        
+        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();
+                }
+            });
+        },
+        BuildTable: function(){
+            var self = this;
+            var StockMove = self.StockMove;
+            var data = [];
+            var origin;
+            _.each(StockMove, function(item){  
+                data.push({
+                    id : item.id,
+                    name : item.name,
+                    picking_name : self.valorNull(item.picking_id[1]),
+                    origin_name : self.valorNull(item.origin),
+                    product_name : item.product_id[1],
+                    product_uom_qty : item.product_uom_qty,
+                    date_move : moment(item.date).format("DD/MM/YYYY"),
+                    partner_name : self.valorNull(item.partner_id[1]),
+                    location : item.location_id[1],
+                    location_dest : item.location_dest_id[1],
+                    picking_id : item.picking_id[0],
+                    product_id : item.product_id[0],
+                    partner_id : item.partner_id[0],
+                    date : moment(item.date).format("YYYY-MM-DD"),
+                    location_id : item.location_id[0],
+                    location_dest_id : item.location_dest_id[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 location_id = this.$el.find('#current-location-origin').val();
+            var location_dest_id = this.$el.find('#current-location-destiny').val();
+            var partner= this.$el.find('#partner').val().split('-');
+            var content = self.content;
+            if ($('#A').is(":checked")){
+                content = _.filter(content, function (inv){
+                    return inv.date == hoy;
+                });
+            }
+            if ($('#B').is(":checked")){
+                var date = hoy.split('-');
+                var ayer = date[2] - 1;
+                date.splice(2,0);
+                if(date[2] < 10){
+                    date[2] = '0'+ayer;
+                }else{
+                    date[2] = ayer;
+                }
+                content = _.filter(content, function (inv){
+                    return inv.date == date[0]+'-'+date[1]+'-'+date[2];
+                });
+            }
+            if ($('#C').is(":checked")){
+                var date = hoy.split('-');
+                content = _.filter(content, function (inv){
+                    var mes = inv.date.split('-');
+                    return mes[0]+'-'+mes[1] == date[0]+'-'+date[1];
+                });
+            }
+            if ($('#D').is(":checked")){
+                var date = hoy.split('-');
+                var mes = date[1] - 1;
+                date.splice(1,0);
+                if(date[1] < 10){
+                    date[1] = '0'+mes;
+                }else{
+                    date[1] = mes;
+                }
+                content = _.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('/');
+                    content = _.filter(content, function (inv){
+                        return inv.date >= (date[2]+"-"+date[1]+"-"+date[0]);
+                    });
+                }
+                if (hasta.length > 0){
+                    var date= hasta.split('/');
+                    content = _.filter(content, function (inv){
+                        return inv.date <= (date[2]+"-"+date[1]+"-"+date[0]);
+                    });
+                }
+            }else{
+                $('#datepicker').css('display','none');
+            }
+            if (partner != ''){
+                content = _.filter(content, function(inv){
+                    return inv.partner_id == partner[0];
+                });
+            }
+            if (location_id != 9999999){
+                content = _.filter(content, function(inv){
+                    return inv.location_id == location_id;
+                });
+            }
+            if (location_dest_id != 9999999){
+                content = _.filter(content, function(inv){
+                    return inv.location_dest_id == location_dest_id;
+                });
+            }
+            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 rows=self.rowsData;
+            var product_uom_qty = _.reduce(_.map(rows,function(map){
+                return(map.product_uom_qty);
+            }),function(memo, num){
+                return memo + num;
+            },0);
+            if (rows.length > 0){
+                rows.push({
+                    product_uom_qty: accounting.formatNumber((product_uom_qty),0,".",","),
+                });
+            }
+            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.getObjectPdf();
+            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 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 pdfDoc = new jsPDF('l');
+
+            pdfDoc.autoTable(getColumns, rows, {
+                styles: { overflow: 'linebreak', fontSize: 8, columnWidth: 'wrap'},
+                columnStyles: {
+                    picking_name : {columnWidth: '8px'},
+                    origin_name : {columnWidth: '8px'},
+                    product_name : {columnWidth: '8px'},
+                    partner_name : {columnWidth: '8px'},
+                    product_uom_qty : {halign:'center',columnWidth: '8px'},
+                    date_move : {columnWidth: '8px'},
+                    location : {columnWidth: '8px'},
+                    location_dest : {columnWidth: '8px'},
+                },
+                margin: { top: 20, horizontal: 7},
+                addPageContent: function (data) {
+                    pdfDoc.setFontSize(12);
+                    pdfDoc.setFontStyle('bold');
+                    pdfDoc.setTextColor(40);
+                    pdfDoc.text('Análisis de Movimientos de Stock', 115, 10);
+
+                    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(240,18," Fecha de Expedición: " + hoy);
+
+                    var str = " Pagina  " + data.pageCount;
+                    if (typeof pdfDoc.putTotalPages === 'function') {
+                        str = str + " de " + totalPagesExp
+                    }
+                    pdfDoc.setFontSize(9);
+                    pdfDoc.setFontStyle('normal');
+                    pdfDoc.setTextColor(40);
+                    pdfDoc.text(260,pdfDoc.internal.pageSize.height - 5,str);                       
+                    }
+            });
+
+            if (typeof pdfDoc.putTotalPages === 'function') {
+                pdfDoc.putTotalPages(totalPagesExp);
+            }
+            pdfDoc.save('Análisis de Movimientos de Stock.pdf')
+        },
+    });
+}

+ 35 - 13
static/src/js/reports/report_vouchers.js

@@ -10,17 +10,23 @@ function report_vouchers (reporting){
         rowsData :[],
         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 #customer' : 'factSearch',
+            'click #supplier' : 'factSearch',
+
             'change #current-journal' : 'factSearch',
-            'change #current-currency' : 'factSearch',
+
             'change #from' : 'factSearch',
             'change #to' : 'factSearch',
-            'click-row.bs.table #table ' : 'ckickAnalysisDetail',
+            'click-row.bs.table #table ' : 'clickAnalysisDetail',
         },
         init : function(parent){
             this._super(parent);
@@ -32,7 +38,14 @@ function report_vouchers (reporting){
             this.fecthFecha();
             this.submitForm();
         },
-        ckickAnalysisDetail: function(e, row, $element, field){
+        valorNull:function(dato){
+            var valor ="";
+            if (dato){
+                valor=dato;
+            }
+            return valor;
+        },
+        clickAnalysisDetail: function(e, row, $element, field){
             if (field == 'reference'){
                 this.do_action({
                     name:"Factura",
@@ -139,7 +152,7 @@ function report_vouchers (reporting){
             var self = this;
             var defer = $.Deferred();
             var AccountInvoice = new instance.web.Model('account.invoice');
-            AccountInvoice.query(['id','number']).filter([['state', '=', ['open','paid']]]).all().then(function(results){
+            AccountInvoice.query(['id','number']).filter([['state', 'in', ['open','paid']]]).all().then(function(results){
                 defer.resolve(results);
             });
             return defer;
@@ -148,18 +161,12 @@ function report_vouchers (reporting){
             var self = this;
             var defer = $.Deferred();
             var AccountJournal = new instance.web.Model('account.journal');
-            AccountJournal.query(['id','name']).filter([['active','=',true],['type', '=', ['bank','cash']]]).all().then(function(results){
+            AccountJournal.query(['id','name']).filter([['active','=',true],['type', 'in', ['bank','cash']]]).all().then(function(results){
                 defer.resolve(results);
             });
             return defer;
         },
-        valorNull:function(dato){
-            var valor ="";
-            if (dato){
-                valor=dato;
-            }
-            return valor;
-        },
+        
         getAccountInvoice: function (number) {
             var self = this;
             return _.filter(self.AccountInvoice,function (item) {
@@ -216,6 +223,7 @@ function report_vouchers (reporting){
                     partner: item.partner_id[1],
                     amount_in: accounting.formatNumber(amount_in,2,".",","),
                     amount_out: accounting.formatNumber(amount_out,2,".",","),
+                    type: item.type,
                     date: item.date,
                     journal_id: item.journal_id[0],
                     partner_id: item.partner_id[0],
@@ -244,7 +252,11 @@ function report_vouchers (reporting){
                 var date = hoy.split('-');
                 var ayer = date[2] - 1;
                 date.splice(2,0);
-                date[2] = '0'+ayer;
+                if(date[2] < 10){
+                    date[2] = '0'+ayer;
+                }else{
+                    date[2] = ayer;
+                }
                 content = _.filter(content, function (inv){
                     return inv.date == date[0]+'-'+date[1]+'-'+date[2];
                 });
@@ -287,6 +299,16 @@ function report_vouchers (reporting){
             }else{
                 $('#datepicker').css('display','none');
             }
+            if ($('#customer').is(":checked")){
+                content = _.filter(content, function (inv){
+                    return inv.type == 'receipt';
+                });
+            }
+            if ($('#supplier').is(":checked")){
+                content = _.filter(content, function (inv){
+                    return inv.type == 'payment';
+                });
+            }
             if(journal != 9999999){
                 content = _.filter(content,function(inv){
                     return inv.journal_id == journal;

+ 104 - 0
static/src/reports/report_expenses_invoice_analysis.xml

@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+  <template xml:space="preserve">
+      <t t-name="ReportExpenseInvoiceAnalysis">
+        <div class="report_view">
+          <div class="reporting_page_header">
+            <h1>Análisis de facturas de gasto</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">
+                <div class="card card-body">
+                    <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 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"/> 
+                                    </div>    
+                                </div>
+                            </div> 
+                        </div>
+                    </div>
+                </div>
+            </div>
+          <div id="toolbar">
+            <button class="oe_button oe_form_button oe_highlight" value="pdf">PDF</button>
+            <!-- <button class="oe_button oe_form_button oe_highlight" value="chart">Graficar</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="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>
+        <!-- <canvas></canvas> -->
+        <div class="widget-content" id="grafico"></div>
+        <div id="dialog"></div>
+      </div>
+      </t>
+  </template>

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

@@ -0,0 +1,141 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<template xml:space="preserve">
+    <t t-name="ReportInvoiceBalance">
+        <div class="report_view">
+            <div class="reporting_page_header">
+                <h1>Histórico de Facturas</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">
+                <div class="card card-body">
+                    <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="col-xs-6">
+                                        <h3>Tipo</h3>
+                                        <ul class="list-unstyled">
+                                            <li>
+                                                <input type="radio" name="cateritica" id="Y" value="Y" checked="checked"/> 
+                                                <label for="Y">Sin Filtro</label>  
+                                            </li>
+                                            <li>
+                                                <input type="radio" name="cateritica" id="sale" value="sale"/> 
+                                                <label for="sale">Factura de venta</label>  
+                                            </li>
+                                            <li>
+                                                <input type="radio" name="cateritica" id="purchase" value="purchase"/>
+                                                <label for="purchase">Factura de compra</label>
+                                            </li>
+                                            <li>
+                                                <input type="radio" name="cateritica" id="expense" value="expense"/>
+                                                <label for="expense">Factura de gasto</label>
+                                            </li>
+                                        </ul>
+                                    </div>
+                                    <div class="col-xs-6">
+                                        <h3>Estado</h3>
+                                        <ul class="list-unstyled">
+                                            <li>
+                                                <input type="radio" name="estado" id="W" value="W" checked="checked"/> 
+                                                <label for="W">Sin Filtro</label>  
+                                            </li>
+                                            <li>
+                                                <input type="radio" name="estado" id="open" value="open"/> 
+                                                <label for="open">Abierto</label>  
+                                            </li>
+                                            <li>
+                                                <input type="radio" name="estado" id="paid" value="paid"/>
+                                                <label for="paid">Pagado</label>
+                                            </li>
+                                        </ul>
+                                    </div>
+                                    <div class="col-xs-12"> 
+                                        <div class="form-group">
+                                            <label for="partner">Buscar Cliente / Proveedor:</label>
+                                            <input id="partner" type="text" class="form-control ui-autocomplete-input" autocomplete="off" placeholder="Nombre/ CI/ Ruc"/>
+                                        </div>
+                                    </div>
+                                </div>
+                            </div> 
+                        </div>
+                    </div>
+                </div>
+            </div>
+            <div id="toolbar">
+                <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="number" data-sortable="true">Factura</th>
+                        <th data-field="partner">Cliente / Proveedor</th>
+                        <th data-field="date_invoice">Fecha</th>
+                        <th data-field="user">Responsable</th>
+                        <th data-field="amount_total" data-sortable="true" data-align="right">Valor</th>
+                        <th data-field="entry" data-sortable="true" data-align="right">Ingreso</th>
+                        <th data-field="egress" data-sortable="true" data-align="right">Egreso</th>
+                        <th data-field="to_receive" data-sortable="true" data-align="right">A Cobrar</th>
+                        <th data-field="to_pay" data-sortable="true" data-align="right">Por Pagar</th>
+                    </tr>
+                </thead>
+            </table>
+            <canvas></canvas>
+            <div id="dialog"></div>
+        </div>
+    </t>
+</template>

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

@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="UTF-8"?>
+    <template xml:space="preserve">
+        <t t-name="ReportPurchaseInvoiceAnalysis">
+            <div class="report_view">
+              <div class="reporting_page_header">
+                <h1>Análisis de facturas de Compras y Gastos</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">
+                <div class="card card-body">
+                    <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"/>
+                                    </div>  
+
+                                </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="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>

+ 7 - 5
static/src/reports/report_sales_invoice_analysis.xml

@@ -3,7 +3,7 @@
       <t t-name="ReportSaleInvoiceAnalysis">
         <div class="report_view">
           <div class="reporting_page_header">
-            <h1>Análisis de facturas de venta</h1>
+            <h1>Análisis de facturas 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
@@ -16,7 +16,7 @@
                             <div class="panel panel-default">
                                 <div class="panel-heading">Fechas</div>
                                 <div class="panel-body">
-                                    <ul>
+                                    <ul class="list-unstyled">
                                         <li>
                                             <input type="radio" name="valores" id="X" value="X" checked="checked"/> 
                                             <label for="X">Sin Filtro</label>  
@@ -56,12 +56,14 @@
                             <div class="panel panel-default">
                                 <div class="panel-heading">Características</div>
                                 <div class="panel-body">
-                                       <!--  <label for="current-journal">Metodo de pago: </label>
-                                        <select id="current-journal" class="form-control ui-autocomplete-input"  name="current-journal"></select>  -->   
+                                    <div class="form-group">
                                         <label for="partner">Buscar Cliente</label>
-                                        <input id="partner" type="text" class="form-control ui-autocomplete-input" autocomplete="off"/>
+                                        <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"/>
+                                    </div>     
                                 </div>
                             </div> 
                         </div>

+ 61 - 0
static/src/reports/report_stock.xml

@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+    <template xml:space="preserve">
+        <t t-name="ReportStock">
+            <div class="report_view">
+                <div class="reporting_page_header">
+                    <h1>Análisis de Stock</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">
+                    <div class="card card-body">
+                        <br/>
+                        <div class="row">
+                            <div class="col-xs-12">
+                                <div class="panel panel-default">
+                                    <div class="panel-heading">Características</div>
+                                    <div class="panel-body">
+                                        <div class="col-xs-6">
+                                            <div class="form-group">
+                                                <label for="current-category">Todas la categorias: </label>
+                                                <select id="current-category" class="form-control ui-autocomplete-input"  name="current-category"></select>    
+                                            </div>
+                                            <div class="form-group">
+                                                <label for="product">Buscar Producto:</label>
+                                                <input id="product" type="text" class="form-control ui-autocomplete-input" autocomplete="off" placeholder="Nombre/ Referencia/ Codigo de barras"/>    
+                                            </div>   
+                                        </div>
+                                    </div>
+                                </div> 
+                            </div>
+                        </div>
+                    </div>
+                </div>
+                <div id="toolbar">
+                    <button class="oe_button oe_form_button oe_highlight" value="pdf" id="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 class="table_header">
+                        <tr>
+                            <th data-field="product" data-sortable="true" >Producto</th>
+                            <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>
+                        </tr>
+                    </thead>
+                </table>
+            </div>
+        </t>
+    </template>

+ 107 - 0
static/src/reports/report_stock_move.xml

@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<template xml:space="preserve">
+    <t t-name="ReportStockMove">
+        <div class="report_view">
+            <div class="reporting_page_header">
+                <h1>Análisis de Movimientos de Stock</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">
+                <div class="card card-body">
+                    <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="current-location-origin">Ubicacion de origen: </label>
+                                        <select id="current-location-origin" class="form-control ui-autocomplete-input"  name="current-location-origin"></select>    
+                                    </div>
+                                     <div class="form-group">
+                                        <label for="current-location-destiny">Ubicacion de destino: </label>
+                                        <select id="current-location-destiny" class="form-control ui-autocomplete-input"  name="current-location-destiny"></select>    
+                                    </div>
+                                    <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> 
+                        </div>
+                    </div>
+                </div>
+            </div>
+            <div id="toolbar">
+                <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="picking_name" data-sortable="true">Referencia</th>
+                        <th data-field="origin_name" data-sortable="true">Origen</th>
+                        <th data-field="product_name" data-sortable="true">Producto</th>
+                        <th data-field="partner_name" data-sortable="true">Cliente / Proveedor</th>
+                        <th data-field="product_uom_qty">Cantidad</th>
+                        <th data-field="date_move" data-sortable="true">Fecha</th>
+                        <th data-field="location">Ubicacion de Origen</th>
+                        <th data-field="location_dest">Ubicacion de Destino</th>
+                        
+                    </tr>
+                </thead>
+            </table>
+            <canvas></canvas>
+            <div id="dialog"></div>
+        </div>
+    </t>
+</template>

+ 21 - 3
static/src/reports/report_vouchers.xml

@@ -4,7 +4,6 @@
         <div class="report_view">
             <div class="reporting_page_header">
                 <h1>Histórico de pagos</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>
@@ -16,7 +15,7 @@
                             <div class="panel panel-default">
                                 <div class="panel-heading">Fechas</div>
                                 <div class="panel-body">
-                                    <ul>
+                                    <ul class="list-unstyled">
                                         <li>
                                             <input type="radio" name="valores" id="X" value="X" checked="checked"/> 
                                             <label for="X">Sin Filtro</label>  
@@ -56,10 +55,29 @@
                             <div class="panel panel-default">
                                 <div class="panel-heading">Características</div>
                                 <div class="panel-body">
+                                    <h3>Tipo</h3>
+                                    <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="customer" value="customer"/> 
+                                            <label for="customer">Pagos de cliente</label>
+                                        </li>
+                                        <li>
+                                            <input type="radio" name="tipo" id="supplier" value="supplier"/>
+                                            <label for="supplier">Pagos a proveedores</label>
+                                        </li>
+                                    </ul>
+                                    <div class="form-group">
                                         <label for="current-journal">Metodo de pago: </label>
                                         <select id="current-journal" class="form-control ui-autocomplete-input"  name="current-journal"></select>    
+                                    </div>
+                                    <div class="form-group">
                                         <label for="partner">Buscar Cliente / Proveedor:</label>
-                                        <input id="partner" type="text" class="form-control ui-autocomplete-input" autocomplete="off" placeholder="Nombre/ CI/ Ruc"/>
+                                        <input id="partner" type="text" class="form-control ui-autocomplete-input" autocomplete="off" placeholder="Nombre/ CI/ Ruc"/>    
+                                    </div>
                                 </div>
                             </div> 
                         </div>

+ 24 - 9
templates.xml

@@ -12,19 +12,34 @@
                 <script type="text/javascript" src="/eiru_reporting/static/src/js/configuration_reporting.js" />
 
                 <!-- Reportes -->
+                <!-- Resumen de Ingresos -->
                 <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_resumen_ingresos.js" />
+                <!-- Resumen de egresos -->
                 <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_resumen_egresos.js" />
+                <!-- Historico de pagos -->
                 <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_vouchers.js" />
-                
-                <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_sales.js" />
+                <!-- Historico de facturas -->
+                <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_invoice_balance.js" />
+                <!-- Historico de ventas -->
+                <!-- <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_sales.js" /> -->
+                <!-- Historico de compras -->
+                <!-- <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_puchases.js" /> -->
+                <!-- Historico de gastos -->
+                <!-- <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_expenses.js" /> -->
+                <!-- Analisis de ventas -->
                 <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_sales_invoice _analysis.js" />
-
-                <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_puchases.js" />
-                <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_expenses.js" />
-                <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_stock_location.js" />
-                <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_invoice_utility.js" />
-                <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_stock_product.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" />
+                <!-- Analisis de gastos -->
+                <!-- <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_expenses_invoice _analysis.js" /> -->
+                <!-- Utilidad de facturas detalladas -->
+                <!-- <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_invoice_utility.js" /> -->
+                <!-- Listado de productos -->
+                <!-- <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_stock_product.js" /> -->
+                
+                <!-- <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_stock_location.js" /> -->
             </xpath>
         </template>