Browse Source

[ADD] nuevos filtros, historico de ventas, pagos y analisis de ventas

Rodney Enciso Arias 7 years ago
parent
commit
8e836a3efe

BIN
__init__.pyc


BIN
controllers.pyc


BIN
models.pyc


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

@@ -21,20 +21,35 @@ function configuration_reporting (instance, widget) {
                 action: 'ReportResumenEngreso'
             },
             {
-                title: 'Utilidad de facturas detalladas',
-                description: 'Permite visualizar la ganancia de cada ítem de las facturas detalladamente.',
-                action: 'ReportInvoiceUtility'
+                title: 'Histórico de Pagos',
+                description: 'Permite visualizar de todos los pagos.',
+                action: 'ReportVoucher'
             },
             {
-                title: 'Histórico de compras',
+                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',
+                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: 'Listado de productos',
                 description: 'Permite visualizar un listado de productos activos.',

+ 7 - 3
static/src/js/main.js

@@ -8,13 +8,17 @@ openerp.eiru_reporting = function (instance) {
     configuration_reporting(instance,reporting);
 
     // Lista de Reporte
-    report_invoice_utility(reporting);
-    report_resumen_engreso(reporting);
     report_resumen_ingresos(reporting);
+    report_resumen_engreso(reporting);
+    report_vouchers(reporting);
+    report_sales(reporting);
     report_puchases(reporting);
     report_expenses(reporting);
-    // report_stock_location(reporting);
+    report_sale_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');

+ 51 - 17
static/src/js/reports/report_resumen_ingresos.js

@@ -14,12 +14,12 @@ function report_resumen_ingresos (reporting){
         modules:[],
 
         events:{
-          'click #toolbar > button' : 'clickOnAction',
-          'change #current-journal': 'fectSearch',
-          'change #current-currency': 'fectSearch',
-          'change #from' : 'fectSearch',
-          'change #to': 'fectSearch',
-          'click #volver_btn': 'volver',
+            'click #toolbar > button' : 'clickOnAction',
+            'change #current-journal': 'fectSearch',
+            'change #current-currency': 'fectSearch',
+            'change #from' : 'fectSearch',
+            'change #to': 'fectSearch',
+            'click #volver_btn': 'volver',
         },
 
         init:function(parent){
@@ -328,8 +328,9 @@ function report_resumen_ingresos (reporting){
             table.bootstrapTable('load' ,rowsTable);
         },
         // Buscar
-        fectSearch: function(){
+        fectSearch: 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 journal =this.$el.find('#current-journal').val();
@@ -337,26 +338,59 @@ function report_resumen_ingresos (reporting){
             var newJournal= self.accountJournal; //copia del Diario
             var newVoucher= self.accountVoucher; //copia del Vouacher
 
+            // if ($('#A').is(":checked")){
+            //     newVoucher = _.filter(newVoucher, function (inv){
+            //         return inv.date == hoy;
+            //     });
+            // }
+
+            if ($('#Z').is(":checked")){
+                $('#datepicker').css('display','block');
+                if (desde.length > 0){
+                    var date= desde.split('/');
+                    newVoucher = _.filter(newVoucher, function (inv){
+                        return inv.date >= (date[2]+"-"+date[1]+"-"+date[0]);
+                    });
+                }
+                if (hasta.length > 0){
+                    var date= hasta.split('/');
+                    newVoucher = _.filter(newVoucher, function (inv){
+                        return inv.date <= (date[2]+"-"+date[1]+"-"+date[0]);
+                    });
+                }
+            }else{
+                $('#datepicker').css('display','none');
+            }
+
+
             if (journal != 9999999){
                 var botonChart =this.$el.find('#chart').attr("disabled", true);
-                 newJournal=_.filter(newJournal, function (inv){ return inv.id == journal});
+                newJournal=_.filter(newJournal, function (inv){ 
+                    return inv.id == journal
+                });
             }else {
                 var botonChart =this.$el.find('#chart').attr("disabled", false);
             }
 
             if(currency != 999){
-                 newVoucher=_.filter(newVoucher, function (inv){ return inv.currency_id[0] == currency});
+                newVoucher=_.filter(newVoucher, function (inv){ 
+                    return inv.currency_id[0] == currency
+                });
             }
 
-            if (desde){
-                 var date= desde.split('/')
-                 newVoucher=_.filter(newVoucher, function (inv){return inv.date >= (date[2]+"-"+date[1]+"-"+date[0])});
-            }
+            // if (desde){
+            //     var date= desde.split('/')
+            //     newVoucher=_.filter(newVoucher, function (inv){
+            //         return inv.date >= (date[2]+"-"+date[1]+"-"+date[0])
+            //     });
+            // }
 
-            if (hasta){
-                var date= hasta.split('/')
-                newVoucher=_.filter(newVoucher, function (inv){return inv.date <= (date[2]+"-"+date[1]+"-"+date[0])});
-           }
+            // if (hasta){
+            //     var date= hasta.split('/')
+            //     newVoucher=_.filter(newVoucher, function (inv){
+            //         return inv.date <= (date[2]+"-"+date[1]+"-"+date[0])
+            //     });
+            // }
             self.fecthDataVoucher(newVoucher,newJournal);
         },
         // volver

+ 348 - 0
static/src/js/reports/report_sales.js

@@ -0,0 +1,348 @@
+function report_sales(reporting){
+    "use strict";
+
+    var instance = openerp;
+
+    reporting.ReportSaleWidget = reporting.Base.extend({
+        template: 'ReportSale',
+        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',
+            'click-row.bs.table #table ' : 'ckickAnalysisDetail',
+        },
+        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();
+        },
+        ckickAnalysisDetail: 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,
+                });
+            }
+            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 =[['state', 'in',['open','paid']],['type', '=', 'out_invoice']];
+            var field =['id', 'type', 'number', 'origin', 'state', 'journal_id', 'currency_id', 'supplier_invoice_number','date_invoice','partner_id','amount_total','user_id','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']).filter([['active', '=', true], ['customer', '=', 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(invoices){
+            var self = this;
+            var AccountInvoice = self.AccountInvoice;
+            var data = [];
+            _.each(AccountInvoice, function(item){
+                data.push({
+                    id : item.id,
+                    number: item.number,
+                    origin: self.valorNull(item.origin),
+                    partner: item.partner_id[1],
+                    date_invoice: moment(item.date_invoice).format("DD/MM/YYYY"),
+                    amount_total: accounting.formatNumber(item.amount_total,2,".",","),
+                    residual: accounting.formatNumber(item.residual,2,".",","),
+                    date: item.date_invoice,
+                    partner_id : item.partner_id[0],
+                    amount : item.amount_total,
+                    total_residual : item.residual
+                });
+            });
+            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);
+                date[2] = '0'+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];
+                });
+            }
+            self.loadTable(content)
+        },
+        loadTable:function(rowsTable){
+            var self = this;
+            self.rowsData = rowsTable;
+            var table = this.$el.find('#table');
+            table.bootstrapTable('load',rowsTable);
+        },
+        getObjetPdf: function(rowsTable){
+            var self = this;
+            var rows=self.rowsData;
+            var amount = _.reduce(_.map(rows,function(map){
+                return(map.amount);
+            }),function(memo, num){
+                return memo + num;
+            },0);
+            var total_residual = _.reduce(_.map(rows,function(map){
+                return(map.total_residual);
+            }),function(memo, num){
+                return memo + num;
+            },0);
+            if (rows.length > 0){
+                rows.push({
+                    number: "Total",
+                    amount_total: accounting.formatNumber((amount),2,".",","),
+                    residual: accounting.formatNumber((total_residual),2,".",","),
+                    
+                });
+            }
+            // console.log(rows);
+            return rows;
+        },
+        clickOnAction: function (e) {
+            var self = this;
+            var rowsNew;
+            var action = self.$el.find(e.target).val();
+            var table = self.$el.find("#table");
+            var data2 = table.bootstrapTable('getVisibleColumns');
+            var getColumns=[];
+            var rows=[];
+            rowsNew = self.getObjetPdf();
+            if (action === 'pdf') {
+                var dataNEW = _.map(data2, function (val){
+                    return val.field;
+                });
+                _.each(rowsNew,function (item){
+                    rows.push(_.pick(item, dataNEW));
+                });
+                // Obtener los nombre de la Cabezera
+                _.each(_.map(data2,function(val){
+                        return val;
+                    }), function(item){
+                            getColumns.push([{
+                                        title: item.title,
+                                        dataKey: item.field
+                                    }]);
+                });
+                this.drawPDF(_.flatten(getColumns),rows);
+            }
+        },
+        drawPDF: function (getColumns,rows) {
+            var self = this;
+            var 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'},
+                    origin : {columnWidth: '8px'},
+                    partner : {columnWidth: '8px'},
+                    date_invoice : {columnWidth: '8px'},
+                    amount_total : {halign:'right',columnWidth: '8px'},
+                    residual : {halign:'right',columnWidth: '8px'},
+                },
+                margin: { top: 16, horizontal: 7},
+                addPageContent: function (data) {
+                    pdfDoc.setFontSize(12);
+                    pdfDoc.setFontStyle('bold');
+                    pdfDoc.setTextColor(40);
+                    pdfDoc.text('Histórico de Ventas ', data.settings.margin.left, 10);
+
+                    if(desde.length > 0 || hasta.length > 0){
+                        var fecha='';
+                        if(desde){
+                            fecha=fecha.concat(' Desde '+desde);
+                        }
+                        if (hasta){
+                            fecha=fecha.concat(' Hasta '+hasta);
+                        }
+                        pdfDoc.setFontSize(10);
+                        pdfDoc.setFontStyle('bold');
+                        pdfDoc.setTextColor(40)
+                        pdfDoc.text(fecha, data.settings.margin.left,14);
+                    }
+                    // FOOTER
+                    var str = "Pagina  " + data.pageCount;
+                    // Total page number plugin only available in jspdf v1.0+
+                    if (typeof pdfDoc.putTotalPages === 'function') {
+                        str = str + " de " + totalPagesExp;
+                    }
+                    pdfDoc.setFontSize(9);
+                    pdfDoc.setFontStyle('bold');
+                    pdfDoc.setTextColor(40);
+                    pdfDoc.text(str, data.settings.margin.left, pdfDoc.internal.pageSize.height - 5);
+                    }
+            });
+
+            if (typeof pdfDoc.putTotalPages === 'function') {
+                pdfDoc.putTotalPages(totalPagesExp);
+            }
+            pdfDoc.save('Histórico de ventas.pdf')
+        },
+    });
+}

+ 665 - 0
static/src/js/reports/report_sales_invoice _analysis.js

@@ -0,0 +1,665 @@
+function report_sale_invoice_analysis (reporting){
+    "use strict";
+
+    var model = openerp;
+
+    reporting.ReportSaleInvoiceAnalysisWidget = reporting.Base.extend({
+        template: 'ReportSaleInvoiceAnalysis',
+        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', '=', 'sale'], ['active', '=', true]]).all().then(function (results) {
+                defer.resolve(results);
+            });
+              return defer;
+        },
+        // Buscar Cambio de Monedas USD,PYG,ARG,BRL
+        fetchCurency: function () {
+            var defer = $.Deferred();
+            var currency_Rate = new model.web.Model('res.currency.rate');
+            var fields = ['id', 'name', 'currency_id', 'rate', 'create_date'];
+            var domain = [['currency_id', 'in', [166 , 20, 7, 3]]];
+            currency_Rate.query(fields).filter(domain).all().then(function (results) {
+                defer.resolve(results);
+            });
+            return defer;
+          },
+        // Invoice (FACTURAS)
+        fetchInvoiceV2: function () {
+            var filter ="[['state', 'in',['open','paid']],['type', '=', 'out_invoice']";
+            var journal_ids = _.flatten(_.map(this.accountJournal, function (item) {
+                return item.id;
+            }));
+            if (journal_ids){
+                filter=filter.concat(",['journal_id', 'in',["+journal_ids+"]]");
+            }
+            filter=filter.concat("]");
+            var field =['id', 'type', 'number', 'origin', '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]]).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;
+                }
+                // if (producto.type =="product"){
+                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_price : accounting.formatNumber((producto.standard_price),2, ".", ","),
+                        price_tot : accounting.formatNumber((item.quantity * (item.price_unit / invoice.rate)),2, ".", ","),
+                        standar_tot : accounting.formatNumber((item.quantity * producto.standard_price),2, ".", ","),
+                        utility : accounting.formatNumber(((item.quantity * (item.price_unit / invoice.rate)) - (item.quantity * producto.standard_price)),2, ".", ","),
+                        journal_id :(invoice.journal_id[0]),
+                        journal_name :(invoice.journal_id[1]),
+                        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 venta ', 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 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);
+
+          _.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
+                    }
+                },
+            });
+        },
+    });
+}

+ 418 - 0
static/src/js/reports/report_vouchers.js

@@ -0,0 +1,418 @@
+function report_vouchers (reporting){
+    "use strict";
+
+    var instance = openerp;
+
+    reporting.ReportVoucherWidget = reporting.Base.extend({
+        template: 'ReportVoucher',
+        AccountVoucher: [],
+        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 #current-journal' : 'factSearch',
+            'change #current-currency' : 'factSearch',
+            'change #from' : 'factSearch',
+            'change #to' : 'factSearch',
+            'click-row.bs.table #table ' : 'ckickAnalysisDetail',
+        },
+        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();
+        },
+        ckickAnalysisDetail: function(e, row, $element, field){
+            if (field == 'reference'){
+                this.do_action({
+                    name:"Factura",
+                    type: 'ir.actions.act_window',
+                    res_model: "account.invoice",
+                    views: [[false,'form']],
+                    target: 'new',
+                    domain: [['id','=', row.invoice_id]],
+                    context: {},
+                    flags: {'form': {'action_buttons': false, 'options': {'mode': 'view'}}},
+                    res_id: row.invoice_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.fetchAccountVoucher().then(function(AccountVoucher) {
+                return AccountVoucher;
+            }).then(function (AccountVoucher) {
+                self.AccountVoucher = AccountVoucher;
+                return self.fetchResPartner();
+            }).then(function(ResPartner){
+                self.ResPartner = ResPartner;
+                return self.fetchAccountInvoice();
+            }).then(function(AccountInvoice){
+                self.AccountInvoice = AccountInvoice;
+                return self.fetchAccountJournal();
+            }).then(function (AccountJournal) {
+                self.AccountJournal =AccountJournal;
+                self.$el.find('#current-journal').append('<option value="9999999">Todos los pagos</option>');
+                _.each(AccountJournal, function (item) {
+                    self.$el.find('#current-journal').append('<option value="' + item.id + '">' + item.name + '</option>');
+                });
+                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;
+            }
+        },
+        fetchAccountVoucher: function () {
+            var self = this;
+            var defer = $.Deferred();
+            var AccountVoucher = new instance.web.Model('account.voucher');
+            AccountVoucher.query(['id', 'number','reference','partner_id','journal_id','amount','date','number','type']).filter([['state', '=', 'posted']]).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]]).all().then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
+        fetchAccountInvoice: function () {
+            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){
+                defer.resolve(results);
+            });
+            return defer;
+        },
+        fetchAccountJournal: function () {
+            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){
+                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) {
+                return item.number == number;
+            });
+        },
+        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 AccountVoucher = self.AccountVoucher;
+            var invoice;
+            var amount_in;
+            var amount_out;
+            var data = [];
+            _.each(AccountVoucher, function(item){
+                invoice = self.getAccountInvoice(item.reference).shift();
+                if (item.type == 'payment') {
+                    amount_in = 0;
+                    amount_out = item.amount;
+                }else{
+                    amount_in = item.amount;
+                    amount_out = 0;
+                }
+                data.push({
+                    id : item.id,
+                    reference: item.reference,
+                    number: item.number,
+                    journal: item.journal_id[1],
+                    date_voucher: moment(item.date).format("DD/MM/YYYY"),
+                    partner: item.partner_id[1],
+                    amount_in: accounting.formatNumber(amount_in,2,".",","),
+                    amount_out: accounting.formatNumber(amount_out,2,".",","),
+                    date: item.date,
+                    journal_id: item.journal_id[0],
+                    partner_id: item.partner_id[0],
+                    invoice_id: invoice.id,
+                    in_amount:amount_in,
+                    out_amount:amount_out
+                });
+            });
+            self.content = data;
+            this.loadTable(data);
+        },
+        factSearch: function(){
+            var self = this;
+            var hoy = moment().format('YYYY-MM-DD');
+            var journal = this.$el.find('#current-journal').val();
+            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);
+                date[2] = '0'+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(journal != 9999999){
+                content = _.filter(content,function(inv){
+                    return inv.journal_id == journal;
+                });
+            }
+            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);
+        },
+        getObjetPdf: function(rowsTable){
+            var self = this;
+            var rowsPdf=[];
+            var rows=[];
+            var rows = self.rowsData;
+            var total_in = _.reduce(_.map(rows,function(map){
+                return(map.in_amount);
+            }),function(memo, num){
+                return memo + num;
+            },0);
+            var total_out = _.reduce(_.map(rows,function(map){
+                return(map.out_amount);
+            }),function(memo, num){
+                return memo + num;
+            },0);
+            if (rows.length > 0){
+                rows.push({
+                    reference: "Totales ",
+                    amount_in: accounting.formatNumber(total_in,2,".",","),
+                    amount_out: accounting.formatNumber(total_out,2,".",","),        
+                });
+            }
+            return rows;
+        },
+        clickOnAction: function (e) {
+            var self = this;
+            var rowsNew;
+            var action = self.$el.find(e.target).val();
+            var table = self.$el.find("#table");
+            var data2 = table.bootstrapTable('getVisibleColumns');
+            var getColumns=[];
+            var rows=[];
+            rowsNew = self.getObjetPdf();
+            if (action === 'pdf') {
+                var dataNEW = _.map(data2, function (val){
+                    return val.field;
+                });
+                _.each(rowsNew,function (item){
+                    rows.push(_.pick(item, dataNEW));
+                });
+                // Obtener los nombre de la Cabezera
+                _.each(_.map(data2,function(val){
+                        return val;
+                    }), function(item){
+                            getColumns.push([{
+                                        title: item.title,
+                                        dataKey: item.field
+                                    }]);
+                });
+                this.drawPDF(_.flatten(getColumns),rows);
+            }
+        },
+        drawPDF: function (getColumns,rows) {
+            var self = this;
+            var 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: {
+                    reference : {columnWidth: '8px'},
+                    number : {columnWidth: '8px'},
+                    journal_id : {columnWidth: '8px'},
+                    date_voucher : {columnWidth: '8px'},
+                    partner : {columnWidth: '8px'},
+                    amount_in : {halign:'right',columnWidth: '8px'},
+                    amount_out: {halign:'right',columnWidth: '8px'}
+                },
+                margin: { top: 16, horizontal: 7},
+
+                addPageContent: function (data) {
+                    pdfDoc.setFontSize(12);
+                    pdfDoc.setFontStyle('bold');
+                    pdfDoc.setTextColor(40);
+                    pdfDoc.text('Histórico de pagos ', 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('Histórico de pagos.pdf')
+        },
+    });
+}

+ 37 - 13
static/src/reports/report_resumen_egresos.xml

@@ -6,18 +6,43 @@
                 <h1>Resumen de Egreso</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">
+                                    <div id="datepicker" 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">
+                                    <label for="current-journal">Sucursal: </label>
+                                    <select id="current-journal" class="form-control ui-autocomplete-input"  name="journal"></select>
+                                    <br/>
+                                    <label for="current-currency">Moneda: </label>
+                                    <select id="current-currency" class="form-control ui-autocomplete-input"  name="currency"></select>     
+                                </div>
+                            </div> 
+                        </div>
+                    </div>
+                </div>
+            </div>
             <div id="toolbar">
-                <!-- <div class="col-sm-12"> -->
-                    <label for="current-journal">Sucursal: </label>
-                    <select id="current-journal" class=" ui-autocomplete-input"  name="journal"></select>
-                    <label for="current-currency">Moneda: </label>
-                    <select id="current-currency" class=" ui-autocomplete-input"  name="currency"></select>
-                    <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> -->
-                <button class="oe_button oe_form_button oe_highlight" value="pdf" id="pdf">Exportar a PDF</button>
+                <button class="oe_button oe_form_button oe_highlight" value="pdf" id="pdf">PDF</button>
                 <button class="oe_button oe_form_button oe_highlight" value="chart" id="chart">Graficar</button>
             </div>
             <table id="table"
@@ -38,8 +63,7 @@
                     </tr>
                 </thead>
             </table>
-            <div class="widget-content" id="grafico">
-            </div>
+            <div class="widget-content" id="grafico"></div>
             <div id="dialog"></div>
         </div>
     </t>

+ 63 - 40
static/src/reports/report_resumen_ingresos.xml

@@ -1,46 +1,69 @@
 <?xml version="1.0" encoding="UTF-8"?>
-  <template xml:space="preserve">
-      <t t-name="ReportResumenIngreso">
+    <template xml:space="preserve">
+        <t t-name="ReportResumenIngreso">
         <div class="report_view">
-          <div class="reporting_page_header">
-            <h1>Resumen de Ingreso</h1>
-            <div id="volver"></div>
-          </div>
-          <div id="toolbar">
-                <!-- <div class="col-sm-12"> -->
-                    <label for="current-journal">Sucursal: </label>
-                    <select id="current-journal" class=" ui-autocomplete-input"  name="journal"></select>
-                    <label for="current-currency">Moneda: </label>
-                    <select id="current-currency" class=" ui-autocomplete-input"  name="currency"></select>
-                    <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> -->
-            <button class="oe_button oe_form_button oe_highlight" value="pdf" id="pdf">Exportar a PDF</button>
-            <button class="oe_button oe_form_button oe_highlight" value="chart" id="chart">Graficar</button>
-        </div>
+            <div class="reporting_page_header">
+                <h1>Resumen de Ingreso</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">
+                                    <div id="datepicker" 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">
+                                    <label for="current-journal">Sucursal: </label>
+                                    <select id="current-journal" class="form-control ui-autocomplete-input"  name="journal"></select>
+                                    <br/>
+                                    <label for="current-currency">Moneda: </label>
+                                    <select id="current-currency" class="form-control ui-autocomplete-input"  name="currency"></select>     
+                                </div>
+                            </div> 
+                        </div>
+                    </div>
+                </div>
+            </div>
+            <div id="toolbar">
+                <button class="oe_button oe_form_button oe_highlight" value="pdf" id="pdf">PDF</button>
+                <button class="oe_button oe_form_button oe_highlight" value="chart" id="chart">Graficar</button>
+            </div>
         <table id="table"
-              data-classes="table table-hover table-condensed"
-              data-buttons-class="oe_button oe_form_button oe_highlight"
-              data-reorderable-columns="true"
-              data-height="auto"
-              data-pagination="false"
-              data-show-columns="true"
-              data-toolbar="#toolbar"
-              data-id-field="number"
-              data-row-style="rowStyle">
+            data-classes="table table-hover table-condensed"
+            data-buttons-class="oe_button oe_form_button oe_highlight"
+            data-reorderable-columns="true"
+            data-height="auto"
+            data-pagination="false"
+            data-show-columns="true"
+            data-toolbar="#toolbar"
+            data-id-field="number"
+            data-row-style="rowStyle">
             <thead >
-              <tr>
-                <th data-field="journal" class="sucursal" >Sucursal</th>
-                <th data-field="method" >Método de Pago</th>
-                <th data-field="amount" data-align="right" >Pagos de Cliente</th>
-              </tr>
+                <tr>
+                    <th data-field="journal" class="sucursal" >Sucursal</th>
+                    <th data-field="method" >Método de Pago</th>
+                    <th data-field="amount" data-align="right" >Pagos de Cliente</th>
+                </tr>
             </thead>
         </table>
-        <div class="widget-content" id="grafico">
-        </div>
-        <div id="dialog"></div>
-      </div>
-      </t>
-  </template>
+        <div class="widget-content" id="grafico"></div>
+        <div id="dialog"></div></div>
+    </t>
+</template>

+ 96 - 0
static/src/reports/report_sales.xml

@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<template xml:space="preserve">
+    <t t-name="ReportSale">
+        <div class="report_view">
+            <div class="reporting_page_header">
+                <h1>Histórico de Ventas</h1>
+                <div id="volver"></div>
+            </div>
+            <button type="button" class="oe_button oe_form_button oe_highlight" aria-label="Left Align" data-toggle="collapse" href="#collapseExample" aria-expanded="false" aria-controls="collapseExample">FILTRAR
+            </button>
+            <div class="collapse" id="collapseExample">
+                <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>
+                                        <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">
+                                    <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="number" data-sortable="true">Factura</th>
+                        <th data-field="origin">Referencia</th>
+                        <th data-field="partner">Cliente</th>
+                        <th data-field="date_invoice">Fecha</th>
+                        <th data-field="amount_total" data-sortable="true" data-align="right">Total</th>
+                        <th data-field="residual" data-sortable="true" data-align="right">A cobrar</th>
+                    </tr>
+                </thead>
+            </table>
+            <canvas></canvas>
+            <div id="dialog"></div>
+        </div>
+    </t>
+</template>

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

@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="UTF-8"?>
+  <template xml:space="preserve">
+      <t t-name="ReportSaleInvoiceAnalysis">
+        <div class="report_view">
+          <div class="reporting_page_header">
+            <h1>Análisis de facturas de venta</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>
+                                        <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">
+                                       <!--  <label for="current-journal">Metodo de pago: </label>
+                                        <select id="current-journal" class="form-control ui-autocomplete-input"  name="current-journal"></select>  -->   
+                                        <label for="partner">Buscar Cliente</label>
+                                        <input id="partner" type="text" class="form-control ui-autocomplete-input" autocomplete="off"/>
+                                        <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 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" >Cliente</th>
+                <th data-field="name" >Producto</th>
+                <th data-field="quantity" data-sortable="true" data-align="right">Cantidad</th>
+                <th data-field="price_unity" data-sortable="true" data-align="right">Precio Unitario</th>
+                <th data-field="standar_price" data-sortable="true" data-align="right">Precio de Costo</th>
+                <th data-field="price_tot" data-sortable="true" data-align="right">Total Venta</th>
+                <th data-field="standar_tot" data-sortable="true" data-align="right">Total Costo</th>
+                <th data-field="utility" data-sortable="true"  data-align="right">Utilidad</th>
+              </tr>
+            </thead>
+        </table>
+        <!-- <canvas></canvas> -->
+        <div class="widget-content" id="grafico"></div>
+        <div id="dialog"></div>
+      </div>
+      </t>
+  </template>

+ 99 - 0
static/src/reports/report_vouchers.xml

@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<template xml:space="preserve">
+    <t t-name="ReportVoucher">
+        <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>
+            <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>
+                                        <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">
+                                        <label for="current-journal">Metodo de pago: </label>
+                                        <select id="current-journal" class="form-control ui-autocomplete-input"  name="current-journal"></select>    
+                                        <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 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>
+                    <tr>
+                        <th data-field="reference" data-sortable="true">Factura</th>
+                        <th data-field="number">Nro. de pago</th>
+                        <th data-field="journal">Metodo de pago</th>
+                        <th data-field="date_voucher">Fecha</th>
+                        <th data-field="partner">Cliente/Proveedor</th>
+                        <th data-field="amount_in" data-sortable="true" data-align="right">Pagos de clientes</th>
+                        <th data-field="amount_out" data-sortable="true" data-align="right">Pagos a proveedores</th>
+                    </tr>
+                </thead>
+            </table>
+            <canvas></canvas>
+            <div id="dialog"></div>
+        </div>
+    </t>
+</template>

+ 7 - 2
templates.xml

@@ -12,12 +12,17 @@
                 <script type="text/javascript" src="/eiru_reporting/static/src/js/configuration_reporting.js" />
 
                 <!-- Reportes -->
-                <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_resumen_egresos.js" />
                 <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_resumen_ingresos.js" />
+                <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_resumen_egresos.js" />
+                <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" />
+                <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" />
 
             </xpath>