Browse Source

ADD-FIX añadido ranking de produccion, receta y utilidad pack de productos

Sebas 6 years ago
parent
commit
55c50fff5a

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

@@ -28,6 +28,11 @@ function configuration_reporting (instance, widget) {
                 description: 'Permite visualizar las facturas',
                 action: 'ReportInvoiceBalance'
             },
+            // {
+            //     title: 'Histórico de Movimiento de Banco',
+            //     description: 'Permite visualizar un histórico de Movimiento de Banco.',
+            //     action: 'ReportBankMovements'
+            // },
             {
                 title: 'Análisis de Ventas',
                 description: 'Permite realizar un analisis de las facturas de venta.',
@@ -138,6 +143,16 @@ function configuration_reporting (instance, widget) {
                 description: 'Permite realizar un analisis de los Productos más Fabricados.',
                 action: 'RankingMrpOrdersProductcy'
             },
+            {
+                title: 'Análisis de Pack de Productos',
+                description: 'Permite visualizar el análisis de pack de productos.',
+                action: 'ReportProductPack'
+            },
+            {
+                title: 'Análisis de Utilidad de Pack de Producto',
+                description: 'Análisis de Utilidad de Pack de Producto también sobre insumos.',
+                action: 'ReportProductPackUtilidad'
+            },
             {
                 title: 'Listado de Proyectos',
                 description: 'Permite visualizar un listado de proyectos.',

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

@@ -37,7 +37,10 @@ openerp.eiru_reporting = function (instance) {
         ranking_pos_orders_product_cy(reporting);
         ranking_sales_orders_product_cy(reporting);
         ranking_mrp_orders_product_cy(reporting);
+        report_product_pack_utilidad(reporting);
+        report_product_pack(reporting);
         ranking_purchases_orders_product_cy(reporting);
+        // report_bank_movements(reporting);
         report_pos_orders(reporting);
 
     } catch (e) {
@@ -46,7 +49,7 @@ openerp.eiru_reporting = function (instance) {
 
     }
 
-    // Todos los informes 
+    // Todos los informes
     instance.web.client_actions.add('eiru_reporting.action_report', 'instance.eiru_reporting.ReportingWidget');
 
     // ******************************************* Finanzas **********************************************************************
@@ -56,6 +59,8 @@ openerp.eiru_reporting = function (instance) {
     instance.web.client_actions.add('eiru_reporting.egreso_action_report', 'instance.eiru_reporting.ReportResumenEgresoWidget');
     // Historico de facturas
     instance.web.client_actions.add('eiru_reporting.invoice_action_report', 'instance.eiru_reporting.ReportInvoiceBalanceWidget');
+    // Historico de Movimiento de Banco
+    // instance.web.client_actions.add('eiru_reporting.bank_movements_action_report', 'instance.eiru_reporting.ReportBankMovementsWidget');
     // Historico de pagos
     instance.web.client_actions.add('eiru_reporting.voucher_action_report', 'instance.eiru_reporting.ReportVoucherWidget');
     // Listado de cuentas a cobrar Vencidas
@@ -74,15 +79,23 @@ openerp.eiru_reporting = function (instance) {
     instance.web.client_actions.add('eiru_reporting.productranking_action_report', 'instance.eiru_reporting.RankingSalesOrdersProductcyWidget');
 
     // ******************************************* Terminal de Ventas *************************************************************************
-    // Historico de ventas
-    instance.web.client_actions.add('eiru_reporting.point_of_sale_action_report', 'instance.eiru_reporting.ReportPosWidget');
     // Analisis de ventas
     instance.web.client_actions.add('eiru_reporting.point_of_sale_detail_action_report', 'instance.eiru_reporting.ReportPosOrdersWidget');
+
+    // Historico de ventas
+    instance.web.client_actions.add('eiru_reporting.point_of_sale_action_report', 'instance.eiru_reporting.ReportPosWidget');
+
     // Ranking de productos
     instance.web.client_actions.add('eiru_reporting.point_of_sale_ranking_action_report', 'instance.eiru_reporting.RankingPosOrdersProductcyWidget');
      // Ranking de clientes
     instance.web.client_actions.add('eiru_reporting.point_of_sale_customer_ranking_action_report', 'instance.eiru_reporting.ReportRankingPosOrdersCustomerWidget');
 
+    // Analisis de pack de productos
+    instance.web.client_actions.add('eiru_reporting.product_pack_action_report', 'instance.eiru_reporting.ReportProductPackWidget');
+
+    // Listado de produccion de pack utilidad
+    instance.web.client_actions.add('eiru_reporting.mrp_utilidad_action_report', 'instance.eiru_reporting.ReportProductPackUtilidadWidget');
+
     // ******************************************* Compras *************************************************************************
     // Analisis de compras
     instance.web.client_actions.add('eiru_reporting.purchase_detail_action_report', 'instance.eiru_reporting.ReportPurchaseInvoiceAnalysisWidget');

+ 612 - 0
static/src/js/reports/report_bank_movements.js

@@ -0,0 +1,612 @@
+function report_bank_movements (reporting){
+    "use strict";
+
+    var instance = openerp;
+
+    reporting.ReportBankMovementsWidget = reporting.Base.extend({
+        template: 'ReportBankMovements',
+        content:[],
+        rowsData :[],
+        events:{
+            'click #toolbar > button' : 'clickOnAction',
+
+            'click #X' : 'factSearch',
+            'click #A' : 'factSearch',
+            'click #B' : 'factSearch',
+            'click #C' : 'factSearch',
+            'click #D' : 'factSearch',
+            'click #Z' : 'factSearch',
+
+            'click #Y' : 'factSearch',
+            'click #sale' : 'factSearch',
+            'click #purchase' : 'factSearch',
+            'click #expense' : 'factSearch',
+
+            'click #W' : 'factSearch',
+            'click #open' : 'factSearch',
+            'click #paid' : 'factSearch',
+
+            'change #from' : 'factSearch',
+            'change #to' : 'factSearch',
+
+            'click-row.bs.table #table ' : 'clickAnalysisDetail',
+        },
+        init : function(parent){
+            this._super(parent);
+        },
+        start: function () {
+            var self = this;
+            var table = this.$el.find('#table');
+            table.bootstrapTable({data : self.rowsData});
+            this.fecthFecha();
+            this.submitForm();
+        },
+        clickAnalysisDetail: function(e, row, $element, field){
+            if (field == 'number'){
+                this.do_action({
+                    name:"Factura de proveedor",
+                    type: 'ir.actions.act_window',
+                    res_model: "account.invoice",
+                    views: [[false,'form']],
+                    target: 'new',
+                    domain: [['type', '=', 'in_invoice'],['id','=', row.id]],
+                    context: {},
+                    flags: {'form': {'action_buttons': false, 'options': {'mode': 'view'}}},
+                    res_id: row.id,
+                });
+            }
+            if (field == 'partner'){
+                this.do_action({
+                    name:"Registro",
+                    type: 'ir.actions.act_window',
+                    res_model: "res.partner",
+                    views: [[false,'form']],
+                    target: 'new',
+                    domain: [['id','=', row.partner_id]],
+                    context: {},
+                    flags: {'form': {'action_buttons': false, 'options': {'mode': 'view'}}},
+                    res_id: row.partner_id,
+                });
+            }
+            e.stopImmediatePropagation();
+        },
+        submitForm: function () {
+            var self = this;
+            self.fetchAccountInvoice().then(function(AccountInvoice) {
+                return AccountInvoice;
+            }).then(function (AccountInvoice) {
+                self.AccountInvoice = AccountInvoice;
+            //     return self.fecthResStore();
+            // }).then(function(ResStore){
+            //     self.ResStore = ResStore;
+            //     self.$el.find('#current-store').append('<option value="9999999">Todas las SUC.</option>');
+            //     _.each(ResStore,function(item){
+            //         self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+            //     });
+                 return self.fecthAccountJournal();
+            }).then(function(AccountJournal){
+                self.AccountJournal = AccountJournal;
+                return self.fetchResPartner();
+            }).then(function(ResPartner){
+                self.ResPartner = ResPartner;
+                self.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;
+            }
+        },
+
+        // fecthResStore: function(){
+        //     var self = this;
+        //     var defer = $.Deferred();
+        //     var field=['id', 'name'];
+        //     var ResStore = new instance.web.Model('res.store');
+        //     ResStore.query(field).all().then(function(results){
+        //         defer.resolve(results);
+        //     });
+        //     return defer;
+        // },
+
+        fecthAccountJournal: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var field = ['id', 'name'];
+            var domain = [['active','=',true],['type','in',['sale','purchase']]];
+            var AccountJournal = new instance.web.Model('account.journal');
+            AccountJournal.query(field).filter(domain).all().then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
+        fetchAccountInvoice: function () {
+            var self = this;
+            var filter = [['type','not in',['in_refund','out_refund']],['state','in',['open','paid']]];
+            var field = ['id', 'type', 'number', 'origin', 'state', 'journal_id', 'currency_id', 'supplier_invoice_number','date_invoice','partner_id','amount_total','user_id','type','residual'];
+            var defer = $.Deferred();
+            var AccountInvoice = new instance.web.Model('account.invoice');
+            AccountInvoice.query(field).filter(filter).all().then(function (results) {
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
+        fetchResPartner: function() {
+            var self = this;
+            var defer = $.Deferred();
+            var ResPartner = new instance.web.Model('res.partner');
+            ResPartner.query(['id', 'name', 'ruc', 'active']).filter([['active', '=', true]]).all().then(function (results) {
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
+        valorNull:function(dato){
+            var valor ="";
+            if (dato){
+                valor=dato;
+            }
+            return valor;
+        },
+
+        search: function () {
+            var self = this;
+            var results = self.ResPartner;
+            results = _.map(results, function (item) {
+                return {
+                        label: item.id + '-'+ item.name + ' ' + self.valorNull(item.ruc),
+                        value: item.id + '-'+ item.name + ' ' + self.valorNull(item.ruc)
+                }
+            });
+            self.$('#partner').autocomplete({
+                source: results,
+                minLength:0,
+                search: function(event, ui) {
+                    if (!(self.$('#partner').val())){
+                        self.factSearch();
+                    }
+                },
+                close: function( event, ui ) {
+                        self.factSearch();
+                },
+                select: function(event, ui) {
+                    self.factSearch();
+                }
+            });
+        },
+
+        getAccountJournal: function (id) {
+            var self = this;
+            return _.filter(self.AccountJournal,function (item) {
+                return item.id === id;
+            });
+        },
+
+        BuildTable: function(){
+            var self = this;
+            var data = [];
+            var AccountInvoice = self.AccountInvoice;
+            var amount_total_num;
+            var entry;
+            var egress;
+            var to_receive;
+            var to_pay;
+            var entry_num;
+            var egress_num;
+            var to_receive_num;
+            var to_pay_num;
+            var invoice_type;
+            _.each(AccountInvoice, function(item){
+                if (item.type == 'out_invoice') {
+                    entry = item.amount_total - item.residual;
+                    egress = 0;
+                    to_receive = item.residual;
+                    to_pay = 0;
+                    invoice_type = 'sale';
+                } else {
+                    entry = 0;
+                    egress = item.amount_total - item.residual;
+                    to_receive = 0;
+                    to_pay = item.residual;
+                    if (item.origin == false) {
+                        invoice_type = 'expense';
+                    } else {
+                        invoice_type = 'purchase';
+                    }
+                }
+                // var store_id = self.getAccountJournal(item.journal_id[0]);
+                // if(store_id.length > 0){
+                    data.push({
+                        id : item.id,
+                        number: item.number,
+                        partner: item.partner_id[1],
+                        date_invoice: moment(item.date_invoice).format("DD/MM/YYYY"),
+                        user: item.user_id[1],
+                        amount_total: accounting.formatNumber(item.amount_total,0,".",","),
+                        entry: accounting.formatNumber(entry,0,".",","),
+                        egress: accounting.formatNumber(egress,0,".",","),
+                        to_receive: accounting.formatNumber(to_receive,0,".",","),
+                        to_pay: accounting.formatNumber(to_pay,0,".",","),
+                        state: item.state,
+                        invoice_type: invoice_type,
+                        date: item.date_invoice,
+                        journal_id : item.journal_id[0],
+                        currency_id : item.currency_id[0],
+                        partner_id : item.partner_id[0],
+                        amount_total_num: item.amount_total,
+                        entry_num: entry,
+                        egress_num: egress,
+                        to_receive_num: to_receive,
+                        to_pay_num: to_pay,
+                        // store_id: store_id[0].store_ids[0],
+                    });
+                // }
+            });
+            self.content = data;
+            this.loadTable(data);
+        },
+
+        factSearch: function(){
+            var self = this;
+            var hoy = moment().format('YYYY-MM-DD');
+            var desde = this.$el.find('#from').val();
+            var hasta = this.$el.find('#to').val();
+            var partner = this.$el.find('#partner').val().split('-');
+            // var store = this.$el.find('#current-store').val();
+            var content = self.content;
+
+            if ($('#A').is(":checked")){
+                content = _.filter(content, function (inv){
+                    return inv.date == hoy;
+                });
+            }
+            if ($('#B').is(":checked")){
+                var date = hoy.split('-');
+                var ayer = date[2] - 1;
+                date.splice(2,0);
+                if(date[2] < 10){
+                    date[2] = '0'+ayer;
+                }else{
+                    date[2] = ayer;
+                }
+                content = _.filter(content, function (inv){
+                    return inv.date == date[0]+'-'+date[1]+'-'+date[2];
+                });
+            }
+            if ($('#C').is(":checked")){
+                var date = hoy.split('-');
+                content = _.filter(content, function (inv){
+                    var mes = inv.date.split('-');
+                    return mes[0]+'-'+mes[1] == date[0]+'-'+date[1];
+                });
+            }
+            if ($('#D').is(":checked")){
+                var date = hoy.split('-');
+                var mes = date[1] - 1;
+                var year;
+                date.splice(1,0);
+                if(date[1] == 1){
+                    date[1] = '12';
+                    year = date[0] - 1;
+                    date[0] = year;
+                }else{
+
+                    if(date[1] < 10){
+                        date[1] = '0'+mes;
+                    }else{
+                        date[1] = mes;
+                    }
+                }
+                content = _.filter(content, function (inv){
+                    var mes = inv.date.split('-');
+                    return mes[0]+'-'+mes[1] == date[0]+'-'+date[1];
+                });
+            }
+            if ($('#Z').is(":checked")){
+                $('#datepicker').css('display','block');
+                if (desde.length > 0){
+                    var date= desde.split('/');
+                    content = _.filter(content, function (inv){
+                        return inv.date >= (date[2]+"-"+date[1]+"-"+date[0]);
+                    });
+                }
+                if (hasta.length > 0){
+                    var date= hasta.split('/');
+                    content = _.filter(content, function (inv){
+                        return inv.date <= (date[2]+"-"+date[1]+"-"+date[0]);
+                    });
+                }
+            }else{
+                $('#datepicker').css('display','none');
+            }
+
+            if ($('#sale').is(":checked")){
+                content = _.filter(content, function (inv){
+                    return inv.invoice_type == 'sale';
+                });
+            }
+            if ($('#purchase').is(":checked")){
+                content = _.filter(content, function (inv){
+                    return inv.invoice_type == 'purchase';
+                });
+            }
+            if ($('#expense').is(":checked")){
+                content = _.filter(content, function (inv){
+                    return inv.invoice_type == 'expense';
+                });
+            }
+            if ($('#open').is(":checked")){
+                content = _.filter(content, function (inv){
+                    return inv.state == 'open';
+                });
+            }
+            if ($('#paid').is(":checked")){
+                content = _.filter(content, function (inv){
+                    return inv.state == 'paid';
+                });
+            }
+            if (partner != ""){
+                content = _.filter(content, function(inv){
+                    return inv.partner_id == partner[0];
+                });
+            }
+            // if(store != 9999999){
+            //     content=_.filter(content, function (inv){
+            //         return inv.store_id == store
+            //     });
+            // }
+
+            var amount_entry_num = _.reduce(_.map(content,function(map){
+                return(map.entry_num);
+            }),function(memo, num){
+                return memo + num;
+            },0);
+
+            var amount_egress_num = _.reduce(_.map(content,function(map){
+                return(map.egress_num);
+            }),function(memo, num){
+                return memo + num;
+            },0);
+
+            var amount_to_receive_num = _.reduce(_.map(content,function(map){
+                return(map.to_receive_num);
+            }),function(memo, num){
+                return memo + num;
+            },0);
+
+            var amount_to_pay_num = _.reduce(_.map(content,function(map){
+                return(map.to_pay_num);
+            }),function(memo, num){
+                return memo + num;
+            },0);
+
+            content.push({
+                number: "Total",
+                entry: accounting.formatNumber(amount_entry_num,0,".",","),
+                egress: accounting.formatNumber(amount_egress_num,0,".",","),
+                to_receive: accounting.formatNumber(amount_to_receive_num,0,".",","),
+                to_pay: accounting.formatNumber(amount_to_pay_num,0,".",","),
+            });
+
+
+            self.loadTable(content)
+        },
+
+        loadTable:function(rowsTable){
+            var self = this;
+            self.rowsData = rowsTable;
+            var table = this.$el.find('#table');
+            table.bootstrapTable('load',rowsTable);
+        },
+
+        getObjectPdf: function(rowsTable){
+            var self = this;
+            var rowsPdf=[];
+            var rows=[];
+            var rows = self.rowsData;
+
+            var amount_total_num = _.reduce(_.map(rows,function(map){
+                return(map.amount_total_num);
+            }),function(memo, num){
+                return memo + num;
+            },0);
+
+
+            var entry_num = _.reduce(_.map(rows,function(map){
+                return(map.entry_num);
+            }),function(memo, num){
+                return memo + num;
+            },0);
+
+            var egress_num = _.reduce(_.map(rows,function(map){
+                return(map.egress_num);
+            }),function(memo, num){
+                return memo + num;
+            },0);
+            var to_receive_num = _.reduce(_.map(rows,function(map){
+                return(map.to_receive_num);
+            }),function(memo, num){
+                return memo + num;
+            },0);
+            var to_pay_num = _.reduce(_.map(rows,function(map){
+                return(map.to_pay_num);
+            }),function(memo, num){
+                return memo + num;
+            },0);
+            if (rows.length > 0){
+                rows.push({
+                    number : 'Totales',
+                    partner : '',
+                    date : '',
+                    user : '',
+                    amount_total: accounting.formatNumber(amount_total_num,0,".",","),
+                    entry: accounting.formatNumber(entry_num,0,".",","),
+                    egress: accounting.formatNumber(egress_num,0,".",","),
+                    to_receive: accounting.formatNumber(to_receive_num,0,".",","),
+                    to_pay: accounting.formatNumber(to_pay_num,0,".",","),
+                });
+            }
+
+            return rows;
+        },
+
+        clickOnAction: function (e) {
+            var self = this;
+            var rowsNew;
+            var action = self.$el.find(e.target).val();
+            var table = self.$el.find("#table");
+            var data2 = table.bootstrapTable('getVisibleColumns');
+            var getColumns=[];
+            var rows=[];
+            rowsNew = self.getObjectPdf();
+            if (action === 'pdf') {
+                var dataNEW = _.map(data2, function (val){
+                    return val.field;
+                });
+                _.each(rowsNew,function (item){
+                    rows.push(_.pick(item, dataNEW));
+                });
+                _.each(_.map(data2,function(val){
+                        return val;
+                    }), function(item){
+                            getColumns.push([{
+                                        title: item.title,
+                                        dataKey: item.field
+                                    }]);
+                });
+                this.drawPDF(_.flatten(getColumns),rows);
+            }
+        },
+
+        drawPDF: function (getColumns,rows) {
+            var self = this;
+            var hoy = moment().format('DD/MM/YYYY');
+            var desde =(this.$el.find('#from').val());
+            var hasta =(this.$el.find('#to').val());
+            var totalPagesExp = "{total_pages_count_string}";
+            var pdfDoc = new jsPDF('l');
+
+            pdfDoc.autoTable(getColumns, rows, {
+                styles: { overflow: 'linebreak', fontSize: 8, columnWidth: 'wrap'},
+                columnStyles: {
+                    number : {columnWidth: '8px'},
+                    partner : {columnWidth: '8px'},
+                    date : {columnWidth: '8px'},
+                    user : {columnWidth: '6px'},
+                    entry: {halign:'right',columnWidth: '11px'},
+                    egress: {halign:'right',columnWidth: '9px'},
+                    to_receive: {halign:'right',columnWidth: '9px'},
+                    to_pay: {halign:'right',columnWidth: '8px'},
+                    amount_total: {halign:'right',columnWidth: '11px'},
+                },
+                margin: { top: 20, horizontal: 7},
+
+                addPageContent: function (data) {
+                    pdfDoc.setFontSize(12);
+                    pdfDoc.setFontStyle('bold');
+                    pdfDoc.setTextColor(40);
+                    pdfDoc.text('Histórico de Facturas', 80, 10);
+
+                    var tipo = '';
+                    if ($('#Y').is(":checked")){
+                        tipo = tipo.concat(' Tipo de factura : Todas las facturas' );
+                    }
+                    if ($('#sale').is(":checked")){
+                        tipo = tipo.concat(' Tipo de factura : Ventas' );
+                    }
+                    if ($('#purchase').is(":checked")){
+                        tipo = tipo.concat(' Tipo de factura : Compras' );
+                    }
+                    if ($('#expense').is(":checked")){
+                        tipo = tipo.concat(' Tipo de factura : Gastos' );
+                    }
+                    pdfDoc.setFontSize(9);
+                    pdfDoc.setFontStyle('normal');
+                    pdfDoc.setTextColor(40)
+                    pdfDoc.text(6,14,tipo);
+
+                    var fecha = '';
+                    if ($('#X').is(":checked")){
+                        fecha = fecha.concat(' Filtro de fecha : Sin Filtros' );
+                    }
+                    if ($('#A').is(":checked")){
+                        fecha = fecha.concat(' Filtro de fecha : Hoy' );
+                    }
+                    if ($('#B').is(":checked")){
+                        fecha = fecha.concat(' Filtro de fecha : Ayer' );
+                    }
+                    if ($('#C').is(":checked")){
+                        fecha = fecha.concat(' Filtro de fecha : Mes Actual' );
+                    }
+                    if ($('#D').is(":checked")){
+                        fecha = fecha.concat(' Filtro de fecha : Mes Pasado' );
+                    }
+                    if ($('#Z').is(":checked")){
+                        if(desde.length > 0 || hasta.length > 0){
+                            if(desde){
+                                fecha=fecha.concat(' Desde: '+ desde);
+                            }
+                            if (hasta){
+                                fecha=fecha.concat(' Hasta: '+ hasta);
+                            }
+                        }
+                    }
+                    pdfDoc.setFontSize(9);
+                    pdfDoc.setFontStyle('normal');
+                    pdfDoc.setTextColor(40)
+                    pdfDoc.text(6,18,fecha);
+
+                    pdfDoc.setFontSize(9);
+                    pdfDoc.setFontStyle('normal');
+                    pdfDoc.setTextColor(40)
+                    pdfDoc.text(150,14," Fecha de Expedición: " + hoy);
+
+                    var str = " Pagina  " + data.pageCount;
+                    if (typeof pdfDoc.putTotalPages === 'function') {
+                        str = str + " de " + totalPagesExp
+                    }
+                    pdfDoc.setFontSize(9);
+                    pdfDoc.setFontStyle('normal');
+                    pdfDoc.setTextColor(40);
+                    pdfDoc.text(175,pdfDoc.internal.pageSize.height - 5,str);
+                    }
+            });
+            if (typeof pdfDoc.putTotalPages === 'function') {
+                pdfDoc.putTotalPages(totalPagesExp);
+            }
+            pdfDoc.save('Histórico de Movimiento de Banco.pdf')
+        },
+    });
+}

+ 28 - 5
static/src/js/reports/report_product_pack.js

@@ -87,6 +87,26 @@ function report_product_pack (reporting) {
             return
         },
 
+        // Analisis Detallado
+        clickAnalysisDetail: function(e, row, $element, field){
+
+            if (field == 'product_main'){
+                this.do_action({
+                    name : "Registro de Producto",
+                    type : 'ir.actions.act_window',
+                    res_model : "product.product",
+                    views : [[false,'form']],
+                    target : 'new',
+                    domain : [['id','=', row.product_main_id]],
+                    context : {},
+                    flags : {'form': {'action_buttons': false, 'options': {'mode': 'view'}}},
+                    res_id : row.product_main_id,
+                });
+            }
+
+            e.stopImmediatePropagation();
+        },
+
         submitForm: function () {
             var self = this;
             self.fecthIrModuleModule().then(function(modules){
@@ -217,7 +237,6 @@ function report_product_pack (reporting) {
                             product_main: "",
                             product: itemProductPack[i].product_id[1],
                             qty: accounting.formatNumber(itemProductPack[i].quantity,3,".",","),
-                            //id: itemProductPack.parent_product_id[0],
                             countPack: itemProductPack[i].quantity,
                             product_main_id: itemProductPack[i].parent_product_id[0],
                         })
@@ -227,7 +246,8 @@ function report_product_pack (reporting) {
                     product_main: item.name_template,
                     product: "",
                     qty: "",
-                    countPack: ""
+                    countPack: "",
+                    product_main_id: item.id
                 });
                 // Generar Objeto Principal
                 rankingItem=rankingItem.concat(rankingCab);
@@ -242,11 +262,14 @@ function report_product_pack (reporting) {
         factSearch: function(){
             var self = this;
             var product = this.$el.find('#product').val().split('-');
+
             var content = self.content;
 
+
             if (product != ""){
                 content = _.filter(content, function(inv){
-                    return inv.parent_product_id[0] == product[0];
+                    return inv.product_main_id == product[0];
+                    //return inv.product_main_id == product;
                 });
             }
 
@@ -313,7 +336,7 @@ function report_product_pack (reporting) {
                     pdfDoc.setFontSize(12);
                     pdfDoc.setFontStyle('bold');
                     pdfDoc.setTextColor(40);
-                    pdfDoc.text('Listado Receta de Producto ', data.settings.margin.left, 10);
+                    pdfDoc.text('Listado de Receta de Pack de Producto ', data.settings.margin.left, 10);
                     // FOOTER
                     var str = "Pagina  " + data.pageCount;
                     // Total page number plugin only available in jspdf v1.0+
@@ -330,7 +353,7 @@ function report_product_pack (reporting) {
             if (typeof pdfDoc.putTotalPages === 'function') {
                 pdfDoc.putTotalPages(totalPagesExp);
             }
-            pdfDoc.save('Listado Receta de Producto.pdf')
+            pdfDoc.save('Listado de Receta de Pack de Producto.pdf')
         },
     });
 }

+ 40 - 40
static/src/js/reports/report_product_pack_utilidad.js

@@ -90,6 +90,26 @@ function report_product_pack_utilidad (reporting) {
             return
         },
 
+        // Analisis Detallado
+        clickAnalysisDetail: function(e, row, $element, field){
+
+            if (field == 'product_main'){
+                this.do_action({
+                    name : "Registro de Producto",
+                    type : 'ir.actions.act_window',
+                    res_model : "product.product",
+                    views : [[false,'form']],
+                    target : 'new',
+                    domain : [['id','=', row.product_main_id]],
+                    context : {},
+                    flags : {'form': {'action_buttons': false, 'options': {'mode': 'view'}}},
+                    res_id : row.product_main_id,
+                });
+            }
+
+            e.stopImmediatePropagation();
+        },
+
         fecthFecha: function() {
             var to;
             var dateFormat1 = "mm/dd/yy",
@@ -146,38 +166,6 @@ function report_product_pack_utilidad (reporting) {
             });
         },
 
-        fecthFecha: function() {
-            var to;
-            var dateFormat1 = "mm/dd/yy",
-                from = $( "#from" )
-                .datepicker({
-                  dateFormat: "dd/mm/yy",
-                  changeMonth: true,
-                  numberOfMonths: 1,
-                })
-                .on( "change", function() {
-                  to.datepicker( "option", "minDate", getDate(this), "dd/mm/yyyy");
-                });
-                to = $( "#to" ).datepicker({
-                dateFormat: "dd/mm/yy",
-                defaultDate: "+7d",
-                changeMonth: true,
-                numberOfMonths: 1,
-                })
-                .on( "change", function() {
-                    from.datepicker( "option", "maxDate", getDate(this));
-                });
-            function getDate( element ) {
-                var fechaSel =element.value.split('/');
-                var date;
-                try {
-                    date = $.datepicker.parseDate( dateFormat1, (fechaSel[1]+"/"+fechaSel[0]+"/"+fechaSel[2]));
-                } catch( error ) {
-                    date = null;
-                }
-                return date;
-            }
-        },
         // Modelos instalados
         fecthIrModuleModule: function(){
             var self = this;
@@ -242,7 +230,7 @@ function report_product_pack_utilidad (reporting) {
             var product_id = _.flatten(_.map(PosOrderLine,function (item) {
                 return item.product_id[0];
             }));
-            var fields = ['id', 'name','name_template', 'pack_line_ids','type', 'ean13','attribute_str', 'standard_price'];
+            var fields = ['id', 'name','name_template', 'pack_line_ids','type', 'ean13','attribute_str', 'standard_price', 'lst_price'];
             var domain = [['active', '=', true],['pack', '=', true]];
             var ProductProduct = new instance.web.Model('product.product');
             ProductProduct.query(fields).filter(domain).all().then(function (results) {
@@ -416,13 +404,17 @@ function report_product_pack_utilidad (reporting) {
                     if (itemProductPack.length > 0){
                         rankingItem.push({
                             product_main: "",
+                            price_venta: "",
                             price_costo: "",
                             product: itemProductPack[i].product_id[1],
-                            price_insumo: accounting.formatNumber(itemProductPack[i].price,2,".",","),
+                            price_insumo: accounting.formatNumber(itemProductPack[i].price,0,".",","),
                             qty_pos: cat,
                             qty: accounting.formatNumber(itemProductPack[i].quantity,3,".",","),
-                            subtotal_total: (itemProductPack[i].price*itemProductPack[i].quantity*cat),
+                            subtotal_total_venta: "",
+                            subtotal_total: accounting.formatNumber((itemProductPack[i].price*itemProductPack[i].quantity*cat),0,".",","),
                             subtotal: accounting.formatNumber(itemProductPack[i].subtotal,2,".",","),
+                            utilidad: "",
+                            //create_date: moment(itemLine.create_date).format("YYYY-MM-DD"),
                             countPack: itemProductPack[i].quantity,
                             product_main_id: itemProductPack[i].parent_product_id[0],
                         })
@@ -430,13 +422,17 @@ function report_product_pack_utilidad (reporting) {
                 }
                 rankingItem.unshift({
                     product_main: itemProduct.name_template,
-                    price_costo: itemProduct.standard_price,
+                    price_venta: accounting.formatNumber(itemProduct.lst_price,0,".",","),
+                    price_costo: accounting.formatNumber(itemProduct.standard_price,0,".",","),
                     product: "",
                     price_insumo: "",
                     qty_pos: cat,
                     qty: "",
-                    subtotal_total: (itemProduct.standard_price*cat),
-                    countPack: ""
+                    subtotal_total_venta: accounting.formatNumber((itemProduct.lst_price*cat),0,".",","),
+                    subtotal_total: accounting.formatNumber((itemProduct.standard_price*cat),0,".",","),
+                    utilidad: accounting.formatNumber(((itemProduct.lst_price*cat)-(itemProduct.standard_price*cat)),0,".",","),
+                    countPack: "",
+                    product_main_id: itemProduct.id
                 });
                     // Generar Objeto Principal
                     rankingItem=rankingItem.concat(rankingCab);
@@ -455,7 +451,7 @@ function report_product_pack_utilidad (reporting) {
 
             if (product != ""){
                 content = _.filter(content, function(inv){
-                    return inv.parent_product_id[0] == product[0];
+                    return inv.product_main_id == product[0];
                 });
             }
 
@@ -515,10 +511,14 @@ function report_product_pack_utilidad (reporting) {
                 columnStyles: {
                     product_main : {columnWidth: '6px'},
                     product : {columnWidth: '8px'},
-                    price : {halign:'right',columnWidth: '6px'},
+                    price_venta: {halign:'right',columnWidth: '6px'},
+                    price_costo: {halign:'right',columnWidth: '6px'},
+                    price_insumo : {halign:'right',columnWidth: '6px'},
                     qty_pos : {halign:'right',columnWidth: '5px'},
                     qty : {halign:'right',columnWidth: '5px'},
+                    subtotal_total_venta : {halign:'right',columnWidth: '6px'},
                     subtotal_total : {halign:'right',columnWidth: '6px'},
+                    utilidad : {halign:'right',columnWidth: '6px'},
                 },
                 margin: { top: 16, horizontal: 7},
                 addPageContent: function (data) {

+ 145 - 0
static/src/reports/report_bank_movements.xml

@@ -0,0 +1,145 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<template xml:space="preserve">
+    <t t-name="ReportBankMovements">
+        <div class="report_view">
+            <div class="reporting_page_header">
+                <h1>Histórico de Movimiento de Banco</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="col-xs-6">
+                                    <h3>Tipo</h3>
+                                    <ul class="list-unstyled">
+                                        <li>
+                                            <input type="radio" name="cateritica" id="Y" value="Y" checked="checked"/>
+                                            <label for="Y">Sin Filtro</label>
+                                        </li>
+                                        <li>
+                                            <input type="radio" name="cateritica" id="sale" value="sale"/>
+                                            <label for="sale">Factura de venta</label>
+                                        </li>
+                                        <li>
+                                            <input type="radio" name="cateritica" id="purchase" value="purchase"/>
+                                            <label for="purchase">Factura de compra</label>
+                                        </li>
+                                        <li>
+                                            <input type="radio" name="cateritica" id="expense" value="expense"/>
+                                            <label for="expense">Factura de gasto</label>
+                                        </li>
+                                    </ul>
+                                </div>
+                                <div class="col-xs-6">
+                                    <h3>Estado</h3>
+                                    <ul class="list-unstyled">
+                                        <li>
+                                            <input type="radio" name="estado" id="W" value="W" checked="checked"/>
+                                            <label for="W">Sin Filtro</label>
+                                        </li>
+                                        <li>
+                                            <input type="radio" name="estado" id="open" value="open"/>
+                                            <label for="open">Abierto</label>
+                                        </li>
+                                        <li>
+                                            <input type="radio" name="estado" id="paid" value="paid"/>
+                                            <label for="paid">Pagado</label>
+                                        </li>
+                                    </ul>
+                                </div>
+                                <div class="col-xs-12">
+                                    <div class="form-group">
+                                        <label for="partner">Buscar Cliente / Proveedor:</label>
+                                        <input id="partner" type="text" class="form-control ui-autocomplete-input" autocomplete="off" placeholder="Nombre/ CI/ Ruc"/>
+                                    </div>
+                                </div>
+                                <div class="col-xs-12">
+                                    <div class="form-group">
+                                         <label for="current-store">Sucursal: </label>
+                                        <select id="current-store" class="form-control ui-autocomplete-input" name="store"></select>
+                                    </div>
+                                </div>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+            </div>
+            <div id="toolbar">
+                <button class="oe_button oe_form_button oe_highlight btn-block" value="pdf">PDF</button>
+            </div>
+            <table id="table" class="table_paint_first_row"
+                data-pagination="true"
+                data-toggle="table"
+                data-reorderable-columns="true"
+                data-toolbar="#toolbar"
+                data-show-columns="true"
+                data-buttons-class="oe_button oe_form_button oe_highlight"
+                data-height="auto"
+                data-classes="table table-hover table-condensed"
+                data-row-style="rowStyle"
+                data-search="true">
+                <thead>
+                    <tr>
+                        <th data-field="number" data-sortable="true">Factura</th>
+                        <th data-field="partner">Cliente / Proveedor</th>
+                        <th data-field="date_invoice">Fecha</th>
+                        <th data-field="user">Responsable</th>
+                        <th data-field="amount_total" data-sortable="true" data-align="right">Valor</th>
+                        <th data-field="entry" data-sortable="true" data-align="right">Ingreso</th>
+                        <th data-field="egress" data-sortable="true" data-align="right">Egreso</th>
+                        <th data-field="to_receive" data-sortable="true" data-align="right">A Cobrar</th>
+                        <th data-field="to_pay" data-sortable="true" data-align="right">Por Pagar</th>
+                    </tr>
+                </thead>
+            </table>
+            <canvas></canvas>
+            <div id="dialog"></div>
+        </div>
+    </t>
+</template>

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

@@ -3,7 +3,7 @@
     <t t-name="ReportProductPack">
         <div class="report_view">
             <div class="reporting_page_header">
-                <h1>Analisis de Receta de Producto</h1>
+                <h1>Listado de Receta de Producto</h1>
                 <div id="volver"></div>
             </div>
             <div class="collapse" id="collapseExample">

+ 4 - 1
static/src/reports/report_product_pack_utilidad.xml

@@ -41,11 +41,14 @@
                     <tr>
                         <th data-field="product_main">Producto</th>
                         <th data-field="product">Insumo</th>
+                        <th data-field="price_venta" data-align="right">P.Venta</th>
                         <th data-field="price_costo" data-align="right">P.Costo</th>
                         <th data-field="price_insumo" data-align="right">P.C.Insumo</th>
                         <th data-field="qty_pos" data-sortable="true" data-align="right">Cant. Venta</th>
                         <th data-field="qty" data-sortable="true" data-align="right">Cantidad</th>
-                        <th data-field="subtotal_total" data-align="right">Subtotal</th>
+                        <th data-field="subtotal_total_venta" data-align="right">Total Venta</th>
+                        <th data-field="subtotal_total" data-align="right">Total Compra</th>
+                        <th data-field="utilidad" data-align="right">Utilidad</th>
                     </tr>
                 </thead>
             </table>

+ 2 - 2
templates.xml

@@ -73,8 +73,8 @@
                  <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_ranking_sales_orders_customer.js"/>
                  <!-- Ranking Supplier (Purchase)-->
                  <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_ranking_purchases_orders_supplier.js"/>
-                 <!-- Analisis de gastos -->
-                 <!-- <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_expenses_invoice _analysis.js" /> -->
+                 <!-- Analisis de bank movements  -->
+                 <!-- <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_bank_movements.js" /> -->
                  <!-- Utilidad de facturas detalladas -->
                  <!-- <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_invoice_utility.js" /> -->
                  <!-- Listado de utilidad por producto -->

+ 18 - 0
views/actions.xml

@@ -33,6 +33,12 @@
             <field name="tag">eiru_reporting.invoice_action_report</field>
         </record>
 
+		<!-- Historico de Movimiento de Banco -->
+	<!--	<record id="bank_movements_report_action" model="ir.actions.client">
+			<field name="name">Historico de Movimiento de Banco</field>
+			<field name="tag">eiru_reporting.bank_movements_action_report</field>
+		</record> -->
+
         <!-- Historico de pagos -->
          <record id="voucher_report_action" model="ir.actions.client">
             <field name="name">Historico de Pagos</field>
@@ -97,6 +103,18 @@
             <field name="tag">eiru_reporting.point_of_sale_customer_ranking_action_report</field>
         </record>
 
+		<!-- Analisis de Pack de Productos -->
+		<record id="product_pack_report_action" model="ir.actions.client">
+			<field name="name">Analisis de Pack de Productos</field>
+			<field name="tag">eiru_reporting.product_pack_action_report</field>
+		</record>
+
+		<!-- Analisis de Utilidad de Pack de Producto -->
+		<record id="mrp_utilidad_report_action" model="ir.actions.client">
+			<field name="name">Analisis de Utilidad de Pack de Producto</field>
+			<field name="tag">eiru_reporting.mrp_utilidad_action_report</field>
+		</record>
+
         <!-- *************************** Compras *************************** -->
 
         <!-- Analisis de facturas de compras -->

+ 16 - 8
views/menus.xml

@@ -24,14 +24,17 @@
 	        <!-- Historico de facturas -->
 	        <menuitem id="invoice_report_menu_submenu" parent="account_report_parent_menu" name="Historico de Facturas" action="invoice_report_action" sequence="2"/>
 
+            <!-- Historico de Movimiento de Bancos-->
+            <!-- <menuitem id="bank_movements_report_menu_submenu" parent="account_report_parent_menu" name="Historico de Movimiento de Banco" action="bank_movements_report_action" sequence="3"/> -->
+
 	        <!-- Historico de pagos -->
-	        <menuitem id="voucher_report_menu_submenu" parent="account_report_parent_menu" name="Historico de Pagos" action="voucher_report_action" sequence="3"/>
+	        <menuitem id="voucher_report_menu_submenu" parent="account_report_parent_menu" name="Historico de Pagos" action="voucher_report_action" sequence="4"/>
 
 	        <!-- Listado de cuentas a cobrar-->
-	        <menuitem id="account_pending_menu_submenu" parent="account_report_parent_menu" name="Cuentas a cobrar" action="account_pending_report_action" sequence="4"/>
+	        <menuitem id="account_pending_menu_submenu" parent="account_report_parent_menu" name="Cuentas a cobrar" action="account_pending_report_action" sequence="5"/>
 
 	        <!-- Listado de cuentas a cobrar (vencidos)-->
-	        <menuitem id="account_report_menu_submenu" parent="account_report_parent_menu" name="Cuentas a cobrar (Vencidos)" action="account_report_action" sequence="5"/>
+	        <menuitem id="account_report_menu_submenu" parent="account_report_parent_menu" name="Cuentas a cobrar (Vencidos)" action="account_report_action" sequence="6"/>
 
 	    <!-- Ventas Submenu -->
         <menuitem id="sale_report_parent_menu" name="Ventas" parent="eiru_report_main_menu" sequence="3"/>
@@ -48,19 +51,24 @@
 	    <!-- POS Submenu -->
         <menuitem id="point_of_sale_report_parent_menu" name="Terminal de Ventas" parent="eiru_report_main_menu" sequence="4"/>
 
+            <!-- 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" />
+
 	        <!-- 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" />
-
-			<!-- 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" />
-
 	        <!-- Ranking de productos -->
 	        <menuitem id="point_of_sale_ranking_report_menu_submenu" parent="point_of_sale_report_parent_menu" name="Ranking de productos" action="point_sale_ranking_report_action"/>
 
 	        <!-- Ranking de clientes -->
 	        <menuitem id="point_of_sale_customer_ranking_report_menu_submenu" parent="point_of_sale_report_parent_menu" name="Ranking de Clientes" action="point_sale_customer_ranking_report_action"/>
 
-	    <!-- Quinto Submenu -->
+            <!-- Analisis de pack de productos -->
+            <menuitem id="product_pack_report_menu_submenu" parent="point_of_sale_report_parent_menu" name="Analisis de Pack de Productos" action="product_pack_report_action"/>
+
+            <!-- Listado de produccion de pack utilidad -->
+            <menuitem id="mrp_utilidad_report_menu_submenu" parent="point_of_sale_report_parent_menu" name="Analisis de Utilidad de Pack de Producto" action="mrp_utilidad_report_action"/>
+
+        <!-- Quinto Submenu -->
         <menuitem id="purchase_report_parent_menu" name="Compras" parent="eiru_report_main_menu" sequence="5"/>
 
 	        <!-- Analisis de compras -->