Forráskód Böngészése

FIX ADD Agregado report de utilidad sobre precio de ventas athletic

Sebas 6 éve
szülő
commit
cdfd7165b6

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

@@ -83,6 +83,11 @@ function configuration_reporting (instance, widget) {
                 description: 'Permite visualizar de forma global los ingresos obtenidos por la empresa. Tanto ventas normales y punto de ventas',
                 action: 'ReportVentasPosOrders'
             },
+            {
+                title: 'Analisis de ventas por porcentaje',
+                description: 'Permite visualizar los porcentajes de utilidad de acuerdo a la diferencia de precio de venta y precio vendido',
+                action: 'ReportInvoiceDifventa'
+            },
             {
                 title: 'Ranking Productos más Vendidos',
                 description: 'Permite realizar un analisis de los Productos más Vendidos.',

+ 4 - 0
static/src/js/main.js

@@ -15,6 +15,7 @@ openerp.eiru_reporting = function (instance) {
         report_resumen_egresos(reporting);
         report_vouchers(reporting);
         report_invoice_balance(reporting);
+        report_invoice_difventa(reporting);
         report_utilidad_producto(reporting);
         report_sales_invoice_analysis(reporting);
         report_purchases_invoice_analysis(reporting);
@@ -108,6 +109,9 @@ openerp.eiru_reporting = function (instance) {
     // Analisis de pos y ventas
      instance.web.client_actions.add('eiru_reporting.point_venta_action_report', 'instance.eiru_reporting.ReportVentasPosOrdersWidget');
 
+     // Analisis de diferencia de precios de venta porcentaje
+     instance.web.client_actions.add('eiru_reporting.difventa_action_report', 'instance.eiru_reporting.ReportInvoiceDifventaWidget');
+
     // Ranking de productos
     instance.web.client_actions.add('eiru_reporting.point_of_sale_ranking_action_report', 'instance.eiru_reporting.RankingPosOrdersProductcyWidget');
      // Ranking de clientes

+ 565 - 0
static/src/js/reports/report_invoice_difventa.js

@@ -0,0 +1,565 @@
+function report_invoice_difventa (reporting){
+    "use strict";
+
+    var model = openerp;
+
+    reporting.ReportInvoiceDifventaWidget = reporting.Base.extend({
+        template: 'ReportInvoiceDifventa',
+        invoices: [],
+        invoiceLines: [],
+        productProduct:[],
+        Currency:[],
+        rowsData :[],
+        content :[],
+        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-store': 'fectSearch',
+            'change #product': '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 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 == '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,
+            });
+        },
+         // 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;
+            }
+        },
+
+        // Cansultar
+        submitForm: function () {
+            var self = this;
+            this.fetchCurency().then(function(Currency) {
+                self.Currency = Currency;
+                return Currency;
+            }).then(function (Currency) {
+               return self.fecthResStore();
+            }).then(function(ResStore){
+                self.ResStore = ResStore;
+                self.$el.find('#current-store').append('<option value="9999999">Todas las SUC.</option>');
+                _.each(ResStore,function(item){
+                    self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+                });
+                 return self.fecthAccountJournal();
+            }).then(function(AccountJournal){
+                self.AccountJournal = AccountJournal;
+                return self.fetchInvoiceV2();
+            }).then(function (invoices){
+                self.invoices = invoices;
+                return self.fetchInvoiceLine(invoices);
+            }).then(function (invoiceLines) {
+                self.invoiceLines = invoiceLines;
+                return self.fecthProduct(invoiceLines);
+            }).then(function(ProductProduct){
+                self.ProductProduct = ProductProduct;
+                return self.fecthCompanyCurrency();
+            }).then(function(resCompany){
+                self.resCompany = resCompany;
+                self.searchProduct();
+                return self.invoice_Currency();
+            });
+        },
+
+        fecthResStore: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var field=['id', 'name'];
+            var ResStore = new model.web.Model('res.store');
+            ResStore.query(field).all().then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
+        valorNull:function(dato){
+            var valor ="";
+            if (dato){
+                valor=dato;
+            }
+            return valor;
+        },
+
+        searchProduct: function () {
+            var self = this;
+            var results = self.ProductProduct;
+            results = _.map(results, function (item) {
+                return {
+                    label: item.id + '- '+ ' [ ' + self.valorNull(item.default_code) + ' - ' + self.valorNull(item.ean13) + ' ] ' + item.name + ' ( ' +  self.valorNull(item.attribute_str) + ' ) ' ,
+                    value: item.id + '- '+ ' [ ' + self.valorNull(item.default_code) + ' - ' + self.valorNull(item.ean13) + ' ] ' + item.name + ' ( ' +  self.valorNull(item.attribute_str) + ' ) '
+                }
+            });
+            self.$('#product').autocomplete({
+                source: results,
+                minLength:0,
+                search: function(event, ui) {
+                    if (!(self.$('#product').val())){
+                        self.fectSearch();
+                    }
+                },
+                close: function( event, ui ) {
+                        self.fectSearch();
+                },
+                select: function(event, ui) {
+                    self.fectSearch();
+                }
+            });
+        },
+
+        fecthAccountJournal: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var field = ['id', 'name','store_ids'];
+            var domain = [['active','=',true],['type','in',['sale','purchase']]];
+            var AccountJournal = new model.web.Model('account.journal');
+            AccountJournal.query(field).filter(domain).all().then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
+        fecthCompanyCurrency: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var currency = new model.web.Model('res.company');
+            var field=['id', 'currency_id'];
+            var domain=[['id','=',1]];
+            currency.query(field).filter(domain).all().then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
+        // Buscar Cambio de Monedas USD,PYG,ARG,BRL
+        fetchCurency: function () {
+            var defer = $.Deferred();
+            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 self = this;
+            var filter ="[['state', 'in',['open','paid']],['type', '=', 'out_invoice']";
+            var journal_ids = _.flatten(_.map(self.AccountJournal, function (item) {
+                return item.id;
+            }));
+            if (journal_ids){
+                filter=filter.concat(",['journal_id', 'in',["+journal_ids+"]]");
+            }
+            filter=filter.concat("]");
+            var field =['id', 'type', 'number', 'origin', '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;
+        },
+
+        // Product Product
+        fecthProduct: function(invoiceLines){
+            var defer = $.Deferred();
+            var porductIDS = _.flatten(_.map(invoiceLines, function (item) {
+                return item.product_id[0];
+            }));
+            var ProductProduct =  new model.web.Model('product.product');
+            var fields = ['id','name', 'default_code', 'name_template','ean13', 'lst_price','type','attribute_str'];
+            ProductProduct.query(fields).filter([['id', 'in', porductIDS]]).all().then(function (results) {
+                defer.resolve(results)
+            });
+            return defer;
+        },
+
+        // Obtener Monedas de la Factura
+        getCurrency: function (id){
+            return _.find(this.Currency,function (curr) {
+                return _.contains(curr.currency_id,id);
+            });
+        },
+
+        // Actualizar cambio de las moneda de Factura
+        invoice_Currency: function(){
+            for (var i = 0; i < this.invoices.length; i++) {
+                var currency_new;
+                var item = this.invoices[i];
+                var id = item.currency_id[0];
+                currency_new = this.getCurrency(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){
+            var self = this;
+            return _.find(self.ProductProduct, function(prod){
+                return _.contains(pro_id, prod.id);
+            });
+        },
+
+        getAccountJournal: function (id) {
+            var self = this;
+            return _.filter(self.AccountJournal,function (item) {
+                return item.id === id;
+            });
+        },
+
+        fectUtility: function(){
+            var self = this;
+            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;
+                }
+                var store_id = self.getAccountJournal(invoice.journal_id[0]);
+                if(store_id.length > 0){
+                    data.push({
+                        id : invoice.id,
+                        number : (invoice.number),
+                        id_product : producto.id,
+                        name : (item.name),
+                        quantity : accounting.formatNumber((item.quantity),0, ".", ","),
+                        price_unity : accounting.formatNumber((producto.lst_price),2, ".", ","),
+                        standar_price : accounting.formatNumber((item.price_unit / invoice.rate),2, ".", ","),
+                        utility : accounting.formatNumber(((item.price_unit / invoice.rate) - (producto.lst_price)),2, ".", ","),
+                        utility_porc: accounting.formatNumber(((((item.price_unit / invoice.rate)*100)/(producto.lst_price))-100),0, ".", ","),
+                        journal_id :(invoice.journal_id[0]),
+                        journal_name :(invoice.journal_id[1]),
+                        date_create :moment(invoice.date_invoice).format("DD/MM/YYYY"),
+                        date_invoice : (invoice.date_invoice),
+                        store_id : store_id[0].store_ids[0],
+                    });
+                }
+
+          }
+          self.content = data;
+          this.loadTable(data);
+        },
+
+        fectSearch: function(){
+            var self = this;
+            var today = moment().format('YYYY-MM-DD');
+            var yesterday = moment().add(-1, 'days').format('YYYY-MM-DD');
+            var month = moment().format('YYYY-MM');
+            var last_month = moment().add(-1, 'months').format('YYYY-MM');
+            var product = this.$el.find('#product').val().split('-');
+            var desde =this.$el.find('#from').val();
+            var hasta =this.$el.find('#to').val();
+            var store = this.$el.find('#current-store').val();
+            var content = self.content;
+
+            if ($('#A').is(":checked")){
+                content = _.filter(content, function (inv){
+                    return moment(inv.date_invoice).format('YYYY-MM-DD') == today;
+                });
+            }
+            if ($('#B').is(":checked")){
+                content = _.filter(content, function (inv){
+                    return moment(inv.date_invoice).format('YYYY-MM-DD') == yesterday;
+                });
+            }
+            if ($('#C').is(":checked")){
+                content = _.filter(content, function (inv){
+                    return moment(inv.date_invoice).format('YYYY-MM') == month;
+                });
+            }
+            if ($('#D').is(":checked")){
+                content = _.filter(content, function (inv){
+                    return moment(inv.date_invoice).format('YYYY-MM') == last_month;
+                });
+            }
+
+            if ($('#Z').is(":checked")){
+                $('#datepicker').css('display','block');
+                if (desde.length > 0){
+                    var date= desde.split('/');
+                    content = _.filter(content, function (inv){
+                        return inv.date_invoice >= (date[2]+"-"+date[1]+"-"+date[0]);
+                    });
+                }
+                if (hasta.length > 0){
+                    var date= hasta.split('/');
+                    content = _.filter(content, function (inv){
+                        return inv.date_invoice <= (date[2]+"-"+date[1]+"-"+date[0]);
+                    });
+                }
+            }else{
+                $('#datepicker').css('display','none');
+            }
+
+            if (product != ""){
+                content = _.filter(content, function(inv){
+                    return inv.id_product == product[0];
+                });
+            }
+
+            if(store != 9999999){
+                content =_.filter(content, function (inv){
+                    return inv.store_id == store;
+                });
+            }
+
+            self.loadTable(content)
+        },
+
+        loadTable:function(rowsTable){
+            var self = this;
+            self.rowsData = rowsTable;
+            var table = this.$el.find('#table');
+            table.bootstrapTable('load', rowsTable);
+        },
+
+        getObjetPdf: function(rowsTable){
+            var self = this;
+            var rows=self.rowsData;
+
+            return rows;
+        },
+
+        clickOnAction: function (e) {
+            var self = this;
+            var rowsNew;
+            var action = this.$el.find(e.target).val();
+            var getColumns=[];
+            var rows=[];
+            rowsNew = self.getObjetPdf();
+            var table = this.$el.find("#table");
+            var data2 = table.bootstrapTable('getVisibleColumns');
+            if (action === 'pdf') {
+                var dataNEW = _.map(data2, function (val){ return val.field});
+                _.each(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
+                                }]);
+                });
+                // Llamar al pdf
+                this.drawPDF(_.flatten(getColumns),rows)
+            }
+            if (action === 'chart'){
+                var suc = this.$el.find('#current-journal').val();
+                if (suc == 9999999){
+                    self.fectCharFilter();
+                }else{
+                    $("#dialog" ).dialog({
+                        autoOpen: true,
+                        resizable: false,
+                        modal: true,
+                        title: 'Atención',
+                        open: function() {
+                            $(this).html('Para Generar el Gráfico debes Seleccionar todas las Sucursales');
+                        },
+                        show: {
+                            effect: "shake",
+                            duration: 300
+                        },
+                        hide: {
+                            effect: "fade",
+                            duration: 300
+                        },
+                        buttons: {
+                            Aceptar: function() {
+                                $(this).dialog('close');
+                            }
+                        }
+                    });
+                }
+            }
+        },
+
+        drawPDF: function (getColumns,rows) {
+            var self = this;
+            var rowsPdf=[];
+            var sucusal = this.sucDescrip = this.$el.find('#current-journal option:selected').text();
+            var desde =(this.$el.find('#from').val());
+            var hasta =(this.$el.find('#to').val());
+            var totalPagesExp = "{total_pages_count_string}";
+            var pdfDoc = new jsPDF('l');
+
+            var company = _.map(self.resCompany, function (map) {
+                return map.currency_id[1];
+            });
+
+
+            pdfDoc.autoTable(getColumns, rows, {
+                styles: { overflow: 'linebreak', fontSize: 8, columnWidth: 'wrap'},
+                columnStyles: {
+                              number: {columnWidth: '13px'},
+                              date_create :{columnWidth: '13px'},
+                              name :{columnWidth: '8px'},
+                              quantity :{halign:'right',columnWidth: '5px'},
+                              price_unity : {halign:'right',columnWidth: '16px'},
+                              standar_price : {halign:'right',columnWidth: '8px'},
+                              utility : {halign:'right',columnWidth: '9px'},
+                              utility_porc : {halign:'right',columnWidth: '9px'},
+                          },
+                margin: { top: 16, horizontal: 7},
+                addPageContent: function (data) {
+                    pdfDoc.setFontSize(12);
+                    pdfDoc.setFontStyle('bold');
+                    pdfDoc.setTextColor(40);
+                    pdfDoc.text('Análisis de utilidad - diferencia de precios', 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 utilidad - diferencia de precios.pdf')
+        },
+
+    });
+}

+ 6 - 5
static/src/js/reports/report_product_pack_utilidad.js

@@ -9,7 +9,8 @@ function report_product_pack_utilidad (reporting) {
         PosOrderLine: [],
         PosOrder: [],
         invoiceLine: [],
-        productProduct: [],
+        ProductProduct: [],
+        rowsData: [],
         productPack: [],
         productAtributo: [],
         ranking: [],
@@ -183,6 +184,7 @@ function report_product_pack_utilidad (reporting) {
         fecthPosOrder: function() {
             var self = this;
             var defer = $.Deferred();
+            var hoy = moment().format('2018-05-24');
             var modules = self.checkModel('point_of_sale');
 
             if (modules.length <= 0){
@@ -191,8 +193,7 @@ function report_product_pack_utilidad (reporting) {
             }
 
             var fields = ['id', 'lines', 'date_order'];
-        //    var domain = [['date_order', '>=', desde], ['date_order', '<', hasta], ['state', 'in', ['paid','done','invoiced']]];
-            var domain = [ ['state', 'in', ['paid','done','invoiced']]];
+            var domain = [ ['state', 'in', ['paid','done','invoiced']],['date_order','>=', hoy]];
             var PosOrder = new instance.web.Model('pos.order');
             PosOrder.query(fields).filter(domain).all().then(function (results) {
                 defer.resolve(results);
@@ -267,7 +268,7 @@ function report_product_pack_utilidad (reporting) {
         getProductPack: function(id){
             var self = this;
             return _.filter(self.productPack,function (item) {
-                return item.parent_product_id[0] == id;
+                return item.id == id;
             });
         },
 
@@ -434,7 +435,7 @@ function report_product_pack_utilidad (reporting) {
                     countPack: "",
                     product_main_id: itemProduct.id
                 });
-                    // Generar Objeto Principal
+                    Generar Objeto Principal
                     rankingItem=rankingItem.concat(rankingCab);
 
             }

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

@@ -196,7 +196,7 @@ function report_sales_invoice_analysis (reporting){
 
         searchProduct: function () {
             var self = this;
-            var results = self.productProduct;
+            var results = self.ProductProduct;
             results = _.map(results, function (item) {
                 return {
                     label: item.id + '- '+ ' [ ' + self.valorNull(item.default_code) + ' - ' + self.valorNull(item.ean13) + ' ] ' + item.name + ' ( ' +  self.valorNull(item.attribute_str) + ' ) ' ,
@@ -353,7 +353,6 @@ function report_sales_invoice_analysis (reporting){
 
         getAccountJournal: function (id) {
             var self = this;
-            // console.log(id);
             return _.filter(self.AccountJournal,function (item) {
                 return item.id === id;
             });

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

@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+  <template xml:space="preserve">
+      <t t-name="ReportInvoiceDifventa">
+        <div class="report_view">
+          <div class="reporting_page_header">
+            <h1>Análisis de utilidad - diferencia de precios</h1>
+            <div id="volver"></div>
+          </div>
+          <button type="button" class="oe_button oe_form_button oe_highlight" aria-label="Left Align" data-toggle="collapse" href="#collapseExample" aria-expanded="false" aria-controls="collapseExample">FILTRAR
+            </button>
+            <div class="collapse" id="collapseExample">
+                <br/>
+                <div class="row">
+                    <div class="col-xs-6">
+                        <div class="panel panel-default">
+                            <div class="panel-heading">Fechas</div>
+                            <div class="panel-body">
+                                <ul class="list-unstyled">
+                                    <li>
+                                        <input type="radio" name="valores" id="X" value="X" checked="checked"/>
+                                        <label for="X">Sin Filtro</label>
+                                    </li>
+                                    <li>
+                                        <input type="radio" name="valores" id="A" value="A"/>
+                                        <label for="A">Hoy</label>
+                                    </li>
+                                    <li>
+                                        <input type="radio" name="valores" id="B" value="B"/>
+                                        <label for="B">Ayer</label>
+                                    </li>
+                                    <li>
+                                        <input type="radio" name="valores" id="C" value="C"/>
+                                        <label for="C">Mes Actual</label>
+                                    </li>
+                                    <li>
+                                        <input type="radio" name="valores" id="D" value="D"/>
+                                        <label for="D">Mes Pasado</label>
+                                    </li>
+                                    <li>
+                                        <input type="radio" name="valores" id="Z" value="Z"/>
+                                        <label for="Z">Busqueda Avanzada</label>
+                                    </li>
+                                </ul>
+                                <div id="datepicker" style="display:none;" class="container">
+                                    <label for="from">Desde: </label>
+                                    <input type="text"  id="from" name="from"/>
+                                    <label for="to" >Hasta: </label>
+                                    <input type="text"  id="to" name="to" />
+                                </div>
+
+                            </div>
+                        </div>
+                    </div>
+                    <div class="col-xs-6">
+                        <div class="panel panel-default">
+                            <div class="panel-heading">Características</div>
+                            <div class="panel-body">
+
+                                <div class="form-group">
+                                    <label for="product">Buscar Producto</label>
+                                    <input id="product" type="text" class="form-control ui-autocomplete-input" autocomplete="off" placeholder="Nombre/ Referencia/ Codigo de barras"/>
+                                </div>
+                                <div class="form-group">
+                                    <label for="current-store">Sucursal: </label>
+                                    <select id="current-store" class="form-control ui-autocomplete-input" name="store"></select>
+                                </div>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+            </div>
+          <div id="toolbar">
+            <button class="oe_button oe_form_button oe_highlight" value="pdf">PDF</button>
+        </div>
+        <table id="table" class="table_paint_first_row"
+            data-pagination="true"
+            data-toggle="table"
+            data-reorderable-columns="true"
+            data-toolbar="#toolbar"
+            data-show-columns="true"
+            data-buttons-class="oe_button oe_form_button oe_highlight"
+            data-height="auto"
+            data-classes="table table-hover table-condensed"
+            data-row-style="rowStyle"
+            data-search="true">
+            <thead>
+              <tr>
+                <th data-field="number" data-sortable="true">Factura</th>
+                <th data-field="date_create" data-sortable="true">Fecha</th>
+                <th data-field="name" data-sortable="true">Producto</th>
+                <th data-field="quantity" data-sortable="true" data-align="right">Cant.</th>
+                <th data-field="price_unity" data-sortable="true" data-align="right">Precio Venta</th>
+                <th data-field="standar_price" data-sortable="true" data-align="right">Precio Vendido</th>
+                <th data-field="utility" data-sortable="true"  data-align="right">Utilidad</th>
+                <th data-field="utility_porc" data-sortable="true"  data-align="right">% Utilidad</th>
+              </tr>
+            </thead>
+        </table>
+        <!-- <canvas></canvas> -->
+
+        <div id="dialog"></div>
+      </div>
+      </t>
+  </template>

+ 13 - 12
static/src/reports/report_purchases_invoice_analysis.xml

@@ -54,6 +54,19 @@
                         <div class="panel panel-default">
                             <div class="panel-heading">Características</div>
                             <div class="panel-body">
+
+                                <div class="form-group">
+                                    <label for="partner">Buscar Proveedor</label>
+                                    <input id="partner" type="text" class="form-control ui-autocomplete-input" autocomplete="off"/>
+                                </div>
+                                <div class="form-group">
+                                    <label for="product">Buscar Producto</label>
+                                    <input id="product" type="text" class="form-control ui-autocomplete-input" autocomplete="off" placeholder="Nombre/ Referencia/ Codigo de barras"/>
+                                </div>
+                                <div class="form-group">
+                                    <label for="current-store">Sucursal: </label>
+                                    <select id="current-store" class="form-control ui-autocomplete-input" name="store"></select>
+                                </div>
                                 <ul class="list-unstyled">
                                     <li>
                                         <input type="radio" name="tipo" id="Y" value="Y" checked="checked"/>
@@ -68,18 +81,6 @@
                                         <label for="expense">Facturas de gasto</label>
                                     </li>
                                 </ul>
-                                <div class="form-group">
-                                    <label for="partner">Buscar Proveedor</label>
-                                    <input id="partner" type="text" class="form-control ui-autocomplete-input" autocomplete="off"/>
-                                </div>
-                                <div class="form-group">
-                                    <label for="product">Buscar Producto</label>
-                                    <input id="product" type="text" class="form-control ui-autocomplete-input" autocomplete="off" placeholder="Nombre/ Referencia/ Codigo de barras"/>
-                                </div>
-                                <div class="form-group">
-                                    <label for="current-store">Sucursal: </label>
-                                    <select id="current-store" class="form-control ui-autocomplete-input" name="store"></select>
-                                </div>
                             </div>
                         </div>
                     </div>

+ 4 - 5
static/src/reports/report_rrhh.xml

@@ -54,6 +54,10 @@
                         <div class="panel panel-default">
                             <div class="panel-heading">Características</div>
                             <div class="panel-body">
+                                <div class="form-group">
+                                    <label for="personal">Buscar Personal:</label>
+                                    <input id="personal" type="text" class="form-control ui-autocomplete-input" autocomplete="off" placeholder="Nombre/ CI"/>
+                                </div>
                                 <h3>Estado</h3>
                                  <ul class="list-unstyled">
                                     <li>
@@ -70,11 +74,6 @@
                                     </li>
 
                                 </ul>
-
-                                <div class="form-group">
-                                    <label for="personal">Buscar Personal:</label>
-                                    <input id="personal" type="text" class="form-control ui-autocomplete-input" autocomplete="off" placeholder="Nombre/ CI"/>
-                                </div>
                             </div>
                         </div>
                     </div>

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

@@ -90,7 +90,7 @@
               <tr>
                 <th data-field="number" data-sortable="true">Factura</th>
                 <th data-field="date_create" data-sortable="true">Fecha</th>
-                <th data-field="partner_name" >Cliente</th>
+                <th data-field="partner_name" data-sortable="true">Cliente</th>
                 <th data-field="name" >Producto</th>
                 <th data-field="quantity" data-sortable="true" data-align="right">Cant.</th>
                 <th data-field="price_unity" data-sortable="true" data-align="right">Precio Venta</th>

+ 8 - 10
static/src/reports/report_stock_original.xml

@@ -19,6 +19,14 @@
                                             <div class="panel panel-default">
                                                 <div class="panel-heading">Características</div>
                                                 <div class="panel-body">
+                                                    <div class="form-group">
+                                                        <label for="current-location">Todas las Ubicaciones: </label>
+                                                        <select id="current-location" class="form-control ui-autocomplete-input"  name="current-location"></select>
+                                                    </div>
+                                                    <div class="form-group">
+                                                        <label for="current-category">Todas la categorias: </label>
+                                                        <select id="current-category" class="form-control ui-autocomplete-input"  name="current-category"></select>
+                                                    </div>
                                                     <h3>Stock</h3>
                                                     <ul class="list-unstyled">
                                                         <li>
@@ -35,16 +43,6 @@
                                                         </li>
 
                                                     </ul>
-
-                                                    <div class="form-group">
-                                                        <label for="current-location">Todas las Ubicaciones: </label>
-                                                        <select id="current-location" class="form-control ui-autocomplete-input"  name="current-location"></select>
-                                                    </div>
-                                                    <div class="form-group">
-                                                        <label for="current-category">Todas la categorias: </label>
-                                                        <select id="current-category" class="form-control ui-autocomplete-input"  name="current-category"></select>
-                                                    </div>
-
                                             </div>
                                         </div>
 

+ 3 - 0
templates.xml

@@ -30,6 +30,9 @@
                 <!-- Analisis de ventas -->
                 <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_sales_invoice_analysis.js" />
 
+                <!-- Historico de utilidad sobre precio de venta -->
+                <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_invoice_difventa.js" />
+
                 <!-- Análisis de contrato -->
                 <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_contratocliente.js"/>
 

+ 6 - 0
views/actions.xml

@@ -122,6 +122,12 @@
 			<field name="tag">eiru_reporting.point_venta_action_report</field>
 		</record>
 
+		<!-- Historico de facturas por diferencia de precios -->
+		<record id="difventa_report_action" model="ir.actions.client">
+			<field name="name">Historico de Utilidad sobre Precios</field>
+			<field name="tag">eiru_reporting.difventa_action_report</field>
+		</record>
+
         <!-- Ranking de productos mas vendidos -->
         <record id="point_sale_ranking_report_action" model="ir.actions.client">
             <field name="name">Ranking de Productos</field>

+ 10 - 6
views/menus.xml

@@ -31,25 +31,28 @@
         <menuitem id="sale_report_parent_menu" name="Ventas" parent="eiru_report_main_menu" sequence="2"/>
 
             <!-- Historico de ventas -->
-            <menuitem id="sale_order_menu_submenu" parent="sale_report_parent_menu" name="Historico de Ventas" action="sale_order_report_action" sequence="0"/>
+            <menuitem id="sale_order_menu_submenu" parent="sale_report_parent_menu" name="Historico de ventas" action="sale_order_report_action" sequence="0"/>
 
 	        <!-- Analisis de facturas de ventas -->
-	        <menuitem id="sale_report_menu_submenu" parent="sale_report_parent_menu" name="Analisis Ventas" action="sale_report_action" sequence="1"/>
+	        <menuitem id="sale_report_menu_submenu" parent="sale_report_parent_menu" name="Analisis de ventas" action="sale_report_action" sequence="1"/>
+
+            <!-- Historico de utilidad sobre precio de venta -->
+            <menuitem id="difventa_report_menu_submenu" parent="sale_report_parent_menu" name="Historico de porcentaje utilidad de precio" action="difventa_report_action" sequence="2"/>
 
             <!-- Analisis de contratos de clientes -->
-            <menuitem id="contratocliente_report_menu_submenu" parent="sale_report_parent_menu" name="Analisis Contratos de Clientes" action="contratocliente_report_action" sequence="2"/>
+            <menuitem id="contratocliente_report_menu_submenu" parent="sale_report_parent_menu" name="Analisis contratos de clientes" action="contratocliente_report_action" sequence="3"/>
 
             <!-- Ranking de clientes con mas compras -->
-            <menuitem id="saleranking_report_menu_submenu" parent="sale_report_parent_menu" name="Ranking de clientes con mas compras" action="sale_customer_ranking_report_action" sequence="3"/>
+            <menuitem id="saleranking_report_menu_submenu" parent="sale_report_parent_menu" name="Ranking de clientes con mas compras" action="sale_customer_ranking_report_action" sequence="4"/>
 
             <!-- Ranking de productos mas vendidos -->
-            <menuitem id="productranking_report_menu_submenu" parent="sale_report_parent_menu" name="Ranking de productos mas vendidos" action="productranking_report_action" sequence="4"/>
+            <menuitem id="productranking_report_menu_submenu" parent="sale_report_parent_menu" name="Ranking de productos mas vendidos" action="productranking_report_action" sequence="5"/>
 
 	    <!-- POS Submenu -->
         <menuitem id="point_of_sale_report_parent_menu" name="TPV" parent="eiru_report_main_menu" sequence="3"/>
 
             <!-- Analisis de ventas -->
-            <menuitem id="point_of_sale_detail_report_menu_submenu" parent="point_of_sale_report_parent_menu" name="Analisis de Ventas" action="point_sale_detail_report_action" />
+            <menuitem id="point_of_sale_detail_report_menu_submenu" parent="point_of_sale_report_parent_menu" name="Analisis de ventas" action="point_sale_detail_report_action" />
 
 	        <!-- Historico de ventas -->
 	        <menuitem id="point_of_sale_report_menu_submenu" parent="point_of_sale_report_parent_menu" name="Historico de Ventas" action="point_sale_report_action" />
@@ -69,6 +72,7 @@
             <!-- Historico de ventas y pos -->
             <menuitem id="sale_pos_order_menu_submenu" parent="posventa_report_parent_menu" name="Historico de Ventas" action="sale_pos_order_report_action" sequence="1"/>
 
+
         <!-- Quinto Submenu -->
 
         <menuitem id="account_report_parent_menu" name="Finanzas" parent="eiru_report_main_menu" sequence="5"/>