Ver Fonte

[ADD] informe general de stock e informe de cuotas vencidas

Rodney Enciso Arias há 7 anos atrás
pai
commit
6e232160b9

BIN
__init__.pyc


BIN
controllers.pyc


BIN
models.pyc


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

@@ -39,6 +39,16 @@ function configuration_reporting (instance, widget) {
                 title: 'Listado de productos',
                 description: 'Permite visualizar un listado de productos activos.',
                 action: 'ReportStockProduct'
+            },
+            {
+                title: 'Analisis de Cuotas Vencidas',
+                description: 'Permite visualizar un listado de las cuotas vencidas',
+                action: 'ReportExpired'
+            },
+            {
+                title: 'Listado General de stock',
+                description: 'Permite visualizar un listado general de productos',
+                action: 'ReportStockGral'
             }
         ],
         start: function () {

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

@@ -13,6 +13,8 @@ openerp.eiru_reporting = function (instance) {
     report_resumen_ingresos(reporting);
     report_puchases(reporting);
     report_expenses(reporting);
+    report_expired(reporting);
+    report_stock_gral(reporting);
     // report_stock_location(reporting);
     report_stock_product(reporting);
 

+ 371 - 0
static/src/js/reports/report_expired.js

@@ -0,0 +1,371 @@
+function report_expired (reporting){
+    "use strict";
+
+    var instance = openerp;
+
+    reporting.ReportExpiredWidget = reporting.Base.extend({
+        template : 'ReportExpired',
+        content:[],
+        rowsData:[],
+        company:[],
+
+        events : {
+            'change #from' : 'factSearch',
+            'change #to' : 'factSearch',
+            'click div > button' : 'clickOnAction',
+            'change #current-journal': 'fecthSearch',
+            '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.fecthInitial();
+        },
+        ckickAnalysisDetail: function(e, row, $element,field){
+            if (field == 'number'){
+                this.do_action({
+                    name:"Factura",
+                    type: 'ir.actions.act_window',
+                    res_model: "account.invoice",
+                    views: [[false,'form']],
+                    target: 'new',
+                    domain: [['id','=', row.id]],
+                    context: {},
+                    flags: {'form': {'action_buttons': false, 'options': {'mode': 'view'}}},
+                    res_id: row.id,
+                });
+            }
+            e.stopImmediatePropagation();
+        },
+        fecthInitial: function(){
+            var self = this;
+            self.fecthMoveLine().then(function(MoveLine){
+                return MoveLine;
+            }).then(function(MoveLine){
+                self.MoveLine = _.filter(MoveLine, function(item) {
+                    return item.amount_residual > 0;
+                });
+                return self.fetchAccountInvoice();
+            }).then(function(AccountInvoice){
+                self.AccountInvoice = AccountInvoice;
+                return self.fetchResCompany();
+            }).then(function(ResCompany){
+                self.ResCompany = ResCompany;
+                return self.fetchAccountJournal();
+            }).then(function(AccountJournal){
+                self.AccountJournal = AccountJournal;
+                self.$el.find('#current-journal').append('<option value="9999999">TODAS LAS SUC.</option>');
+                _.each(AccountJournal, function (item) {
+                    self.$el.find('#current-journal').append('<option value="' + item.id + '">' + item.name + '</option>');
+                });
+                return self.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;
+            }
+        },
+        fecthMoveLine : function(){
+            var self = this;
+            var hoy = moment().format('YYYY-MM-DD');
+            var defer = $.Deferred();
+            var MoveLine = new instance.web.Model('account.move.line');
+            var fields = ['id','amount_residual', 'credit','date_maturity', 'invoice','ref', 'invoice', 'amount_residual_currency', 'currency_id'];
+            var domain =[['credit', '<=', 0], ['date_maturity', '<=', hoy]];
+            MoveLine.query(fields).filter(domain).all().then(function(results){
+                defer.resolve(results);
+            })
+            return defer;
+        },
+        fetchAccountInvoice: function() {
+            var self = this ;
+            var defer = $.Deferred()
+            var ref = _.map(self.MoveLine, function(map) {
+                return map.invoice[0];
+            });
+            var fields = ['id','currency_id','number','partner_id','journal_id'];
+            var domain = [['id', 'in', ref]];
+            var AccountInvoice = new instance.web.Model('account.invoice');
+            AccountInvoice.query(fields).filter(domain).all().then(function(results) {
+                defer.resolve(results);
+            });
+            return defer;
+        },
+        fetchResCompany: function() {
+            var self = this;
+            var defer = $.Deferred();
+            var fields = ['id','name', 'currency_id'];
+            var domain = [['id','=', 1]];
+            var ResCompany = new instance.web.Model('res.company');
+            ResCompany.query(fields).filter(domain).all().then(function (results) {
+                defer.resolve(results);
+            });
+            return defer;
+        },
+        fetchAccountJournal: function () {
+            var self = this;
+            var defer = $.Deferred();
+            var domain = [['type', '=', 'sale'],['active','=',true]];
+            var Journal = new instance.web.Model('account.journal');
+            Journal.query(['id', 'name']).filter(domain).all().then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
+        valorNull:function(dato){
+            var valor ="";
+            if (dato){
+                valor=dato;
+            }
+            return valor;
+        },
+        getMoveLine: function(id) {
+            var self = this;
+            return _.filter(self.MoveLine,function (item) {
+                return item.invoice[0] === id;
+            });
+        },
+        getJournal: function (id) {
+            var self = this;
+            return _.filter(self.AccountJournal,function (item) {
+                return item.id == id;
+            });
+        },
+        BuildTable: function () {
+            var self = this;
+            self.company = self.ResCompany.shift();
+            var data = [];
+            var invoice = self.AccountInvoice
+            var move;
+            var amount;
+            _.each(invoice, function(item){
+                move = self.getMoveLine(item.id).shift();
+                if (item.currency_id[0] ==  self.company.currency_id[0]) {
+                    amount = accounting.formatNumber(Math.round(move.amount_residual),2,'.',',');
+                }else{
+                    amount = accounting.formatNumber(move.amount_residual_currency,0,'.',',');
+                }
+                data.push({
+                    id : item.id,
+                    number : item.number,
+                    partner_id : item.partner_id[1],
+                    date_maturity : moment(move.date_maturity).format("DD/MM/YYYY"),
+                    currency_id : item.currency_id[1],
+                    amount : amount,
+                    value : move.amount_residual,
+                    journal_id : item.journal_id[0],
+                    date : move.date_maturity
+                });
+            });
+            self.content = data;
+            self.loadTable(data);
+        },
+        fecthSearch: function(){
+            var self = this;
+            var journal = this.$el.find('#current-journal').val();
+            var desde = this.$el.find('#from').val();
+            var hasta = this.$el.find('#to').val();
+            var content = self.content;
+            if (journal != 9999999){
+                content=_.filter(content, function (inv){
+                    return inv.journal_id == journal;
+                });
+            }
+            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]);
+                });
+            }
+            self.loadTable(content);
+        },
+        loadTable:function(rowsTable){
+            var self = this;
+            this.rowsData=rowsTable;
+            var table = this.$el.find('#table');
+            table.bootstrapTable('load' ,rowsTable);
+        },
+        clickOnAction: function (e) {
+            var self = this;
+            var rowsNew;
+            var action = self.$el.find(e.target).val();
+            var table = self.$el.find("#table");
+            var data2 = table.bootstrapTable('getVisibleColumns');
+            var getColumns=[];
+            var rows=[];
+            rowsNew = self.getObjetPdf();
+            if (action === 'pdf') {
+                var dataNEW = _.map(data2, function (val){
+                    return val.field;
+                });
+                _.each(rowsNew,function (item){
+                    rows.push(_.pick(item, dataNEW));
+                });
+                // Obtener los nombre de la Cabezera
+                _.each(_.map(data2,function(val){
+                        return val;
+                    }), function(item){
+                    getColumns.push([{
+                        title: item.title,
+                        dataKey: item.field
+                    }]);
+                });
+                this.drawPDF(_.flatten(getColumns),rows);
+            }
+        },
+        getObjetPdf: function(){
+            var self = this;
+            var rows=[];
+            var data = self.content;
+            var journal = this.$el.find('#current-journal').val();
+            var desde =this.$el.find('#from').val();
+            var hasta =this.$el.find('#to').val();
+
+            if (journal != 9999999){
+                data=_.filter(data, function (inv){
+                    return inv.journal_id == journal;
+                });
+            }
+            if (desde.length > 0){
+                var date= desde.split('/');
+                data = _.filter(data, function (inv){
+                    return inv.date >= (date[2]+"-"+date[1]+"-"+date[0]);
+                });
+            }
+            if (hasta.length > 0){
+                var date= desde.split('/');
+                data = _.filter(data, function (inv){
+                    return inv.date <= (date[2]+"-"+date[1]+"-"+date[0]);
+                });
+            }
+
+            var value = _.reduce(_.map(data,function(map){
+                return(map.value);
+            }),function(memo, num){
+                return memo + num;
+            },0);
+            
+            data.push({
+                number : 'Total',
+                amount : accounting.formatNumber(value,2,'.',',')
+            });
+            
+            rows = data;
+            
+            return rows;
+        },
+        drawPDF: function (getColumns,rows) {
+            var self = this;
+            var desde =(this.$el.find('#from').val());
+            var hasta =(this.$el.find('#to').val());
+            var journal = this.$el.find('#current-journal').val();
+            var totalPagesExp = "{total_pages_count_string}";
+            var pdfDoc = new jsPDF();
+
+            pdfDoc.autoTable(getColumns, rows, {
+                styles: { overflow: 'linebreak', fontSize: 8, columnWidth: 'wrap'},
+                columnStyles: {
+                    number : {columnWidth: '8px'},
+                    partner_id : {columnWidth: '8px'},
+                    date_maturity : {halign:'center',columnWidth: '8px'},
+                    currency_id : {halign:'center',columnWidth: '8px'},
+                    amount : {halign:'right',columnWidth: '8px'},
+                },
+                margin: { top: 30, horizontal: 7},
+
+                addPageContent: function (data) {
+                    pdfDoc.setFontSize(15);
+                    pdfDoc.setFontStyle('bold');
+                    pdfDoc.setTextColor(40);
+                    pdfDoc.text('Analisis de cuotas vencidas', 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, 130,20);
+                    }
+                    
+                    if(journal != 9999999){
+                        var sucursal = self.getJournal(journal).shift();
+                        sucursal = 'Sucursal:   ' + sucursal.name;
+                    }else{
+                        sucursal = 'Sucursal:   Todas las Sucursales';
+                    }
+                    pdfDoc.setFontSize(10);
+                    pdfDoc.setFontStyle('bold');
+                    pdfDoc.setTextColor(40)
+                    pdfDoc.text(sucursal, data.settings.margin.left,20);
+                    
+                    var total = 'Total en ' + self.company.currency_id[1] + ':  '+ rows[rows.length-1].amount;
+                    pdfDoc.setFontSize(10);
+                    pdfDoc.setFontStyle('bold');
+                    pdfDoc.setTextColor(40)
+                    pdfDoc.text(total, data.settings.margin.left,25);
+
+                    // 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('Analisis de cuotas vencidas')
+        },
+    });
+}

+ 477 - 0
static/src/js/reports/report_stock_gral.js

@@ -0,0 +1,477 @@
+function report_stock_gral (reporting){
+    "use strict";
+
+    var instance = openerp;
+
+    reporting.ReportStockGralWidget = reporting.Base.extend({
+        template : 'ReportStockGral',
+        stockLocation : [],
+        stockQuant : [],
+        productProduct : [],
+        productTemplate : [],
+        productBrand : [],
+        productCategory : [],
+        product:[],
+        content:[],
+
+        events : {
+            'click td > button' : 'clickOnAction',
+            'change #current-location': 'fecthSearch',
+            'change #current-category' : 'fecthSearch',
+            'change #current-brand' : 'fecthSearch',
+        },
+        init : function(parent){
+            this._super(parent);
+        },
+        start : function(){
+            var self = this;
+            var dato=[];
+            var table = this.$el.find('#table');
+            table.bootstrapTable({data : self.productProduct});
+            self.fecthInitial();
+        },
+        fecthInitial: function(){
+            var self = this;
+            self.fecthLocation().then(function(stockLocation){
+                self.stockLocation=stockLocation
+                return stockLocation;
+            }).then(function(stockLocation){
+                self.$el.find('#current-location').append('<option value="9999999">Todas las Ubicaciones.</option>');
+                _.each(stockLocation,function(item){
+                    self.$el.find('#current-location').append('<option value="' + item.id + '">' + item.location_id[1]+" / "+item.name + '</option>');
+                });
+                return self.fecthStockQuant();
+            }).then(function(stockQuant){
+                self.stockQuant = stockQuant;
+                return self.fecthProduct(stockQuant);
+            }).then(function(productProduct){
+                self.productProduct = productProduct;
+                return self.fecthCategoryChild();
+            }).then(function(categoryChild){
+                self.categoryChild = categoryChild;
+                return self.fecthProductBrand();
+            }).then(function(productBrand){
+                self.productBrand = productBrand;
+                self.$el.find('#current-brand').append('<option value="9999999">Todas las marcas</option>');
+                _.each(productBrand, function (item) {
+                    self.$el.find('#current-brand').append('<option value="' + item.id + '">' + item.name + '</option>');
+            });
+                return self.fecthCategory();
+            }).then(function(productCategory){
+                self.productCategory = productCategory;
+                self.$el.find('#current-category').append('<option value="9999999">Todas las cat.</option>');
+                _.each(productCategory, function (item) {
+                    self.$el.find('#current-category').append('<option value="' + item.id + '">' + item.name + '</option>');
+            });
+            return self.fecthProducto(self.stockQuant, self.stockLocation, self.productBrand);
+            });
+        },
+        // Ubicacion
+        fecthLocation : function(){
+            var self = this;
+            var defer = $.Deferred();
+            var location = new instance.web.Model('stock.location');
+            var fields = ['id', 'name', 'company_id', 'location_id'];
+            var domain =[['active', '=', true],['usage', '=', 'internal']];
+            location.query(fields).filter(domain).order_by('id').all().then(function(results){
+                defer.resolve(results);
+            })
+            return defer;
+        },
+        // quant
+        fecthStockQuant : function(){
+            var self = this;
+            var defer = $.Deferred();
+            var location = _.flatten(_.map(self.stockLocation,function(item){
+                return item.id;
+            }));
+            var company_id =(_.map(self.stockLocation, function(item){
+                return item.company_id[0];
+            })).shift();
+            var quant = new instance.web.Model('stock.quant');
+            var fields = ['id', 'product_id', 'qty', 'cost','location_id'];
+            var domain =[['company_id', '=', company_id],['location_id', 'in',location]];
+            quant.query(fields).filter(domain).all().then(function(results){
+                defer.resolve(results);
+            })
+            return defer;
+        },
+        // ProductProduct
+        fecthProduct: function(quant){
+            var defer = $.Deferred();
+            var productIDS = _.flatten(_.map(quant, function (item) {
+                return item.product_id[0];
+            }));
+            var ProductProduct =  new instance.web.Model('product.product');
+            var fields = ['id','name', 'standard_price','product_brand_id','categ_id','factory_reference'];
+            ProductProduct.query(fields).filter([['id', 'in', productIDS]]).all().then(function (results) {
+              defer.resolve(results)
+            });
+            return defer;
+        },
+        // Buscar Category
+        fecthCategory: function () {
+            var self = this;
+            var defer = $.Deferred();
+            var productCategory = new instance.web.Model('product.category');
+            productCategory.query(['id', 'name','parent_id','child_id']).filter([['parent_id', '=', 1]]).all().then(function (results) {
+                defer.resolve(results);
+            });
+            return defer;
+        },
+        fecthCategoryChild: function () {
+            var self = this;
+            var defer = $.Deferred();
+            var productCategoryChild = new instance.web.Model('product.category');
+            productCategoryChild.query(['id', 'name','child_id']).filter().all().then(function (results) {
+                defer.resolve(results);
+            });
+            return defer;
+        },
+        // Buscar marca
+        fecthProductBrand: function () {
+            var self = this;
+            var defer = $.Deferred();
+            var productBrand = new instance.web.Model('product.brand');
+            productBrand.query(['id', 'name']).filter().all().then(function (results) {
+                defer.resolve(results);
+            });
+            return defer;
+        },
+        // Verificar si los Valores no son nulos
+        valorNull:function(dato){
+            var valor ="";
+            if (dato){
+                valor=dato;
+            }
+            return valor;
+        },
+        // Union de objetos
+        fecthProducto : function(stockQuant,stockLocation){
+            var self = this;
+            var stock=[];
+            var Catdata=[];
+            var itemLocation;
+            var itemProduct;
+            var itemQuant;
+            var brand = this.$el.find('#current-brand').val();
+            var category = this.$el.find('#current-category').val();
+            var categories = self.categoryChild
+            var prodCategory = self.categoryChild
+            var product = self.productProduct;
+            var productProduct;
+            var categ;
+            var cat = 0;
+            var quant;
+            var valuation;
+            var prod = self.productProduct
+            var product;
+            var cat;
+            var newCategory;
+            var newProduct = [];
+            var otherCategory;
+            
+            categories = _.filter(categories, function(item){
+                return item.id == category;
+            });
+            if (category != 9999999) {    
+                Catdata.push({
+                    id : categories[0].id,
+                    name : categories[0].name,
+                    child_id : categories[0].child_id
+                });
+                cat = categories[0].child_id
+                for (var i = 0; i < cat.length; i++) {
+                    for (var j = 0; j< prodCategory.length; j++) {
+                        if(prodCategory[j].id === cat[i]){
+                            Catdata.push({
+                                id : prodCategory[j].id,
+                                name : prodCategory[j].name,
+                                child_id : prodCategory[j].child_id
+                            });
+                            newCategory = prodCategory[j];
+                            if (newCategory.child_id.length > 0) {
+                                for (var k = 0; k < newCategory.child_id.length; k++) {
+                                    for (var l = 0; l< prodCategory.length; l++) {
+                                        if(prodCategory[l].id === newCategory.child_id[k]){
+                                            Catdata.push({
+                                                id : prodCategory[l].id,
+                                                name : prodCategory[l].name,
+                                                child_id : prodCategory[l].child_id
+                                            });
+                                            otherCategory = prodCategory[l];
+                                            if (prodCategory[l].child_id.length > 0) {
+                                                for (var m = 0; m < otherCategory.child_id.length; m++) {
+                                                    for (var n = 0; n< prodCategory.length; n++) {
+                                                        if(prodCategory[n].id === otherCategory.child_id[m]){
+                                                            Catdata.push({
+                                                                id : prodCategory[n].id,
+                                                                name : prodCategory[n].name,
+                                                                child_id : prodCategory[n].child_id
+                                                            });
+                                                        }   
+                                                    }
+                                                }   
+                                            }  
+                                        }
+                                    }
+                                }  
+                            }
+                        }
+                    }
+                }
+                if (Catdata.length > 0) {
+                    for (var p = 0; p < product.length; p++) {
+                        for (var o = 0; o < Catdata.length; o++) {
+                            if (product[p].categ_id[0] == Catdata[o].id) {
+                                newProduct.push({
+                                    id: product[p].id,
+                                    factory_reference : product[p].factory_reference,
+                                    name: product[p].name,
+                                    categ_id: product[p].categ_id,
+                                    product_brand_id: product[p].product_brand_id,
+                                    standard_price: product[p].standard_price    
+                                });  
+                            }
+                        }
+                    }
+                    product = newProduct;
+                }        
+            }
+            
+
+            for (var i = 0; i < stockLocation.length; i++) {
+                itemLocation = stockLocation[i];
+                productProduct = self.getProductProduct(product, stockQuant, itemLocation.id);
+                for (var f = 0; f < productProduct.length; f++) {
+                    itemProduct = productProduct[f];
+                    if(itemProduct.product_brand_id[0] == brand || brand == 9999999){ 
+                        itemQuant = self.getQuantProduct(itemLocation.id, itemProduct.id, stockQuant);
+                        if (itemQuant.length > 0){ 
+                            cat = _.reduce(_.map(itemQuant,function(item){
+                            return item.qty;
+                            }),function(mamo, num){
+                                return mamo + num;
+                            },0);
+                            quant=itemQuant.shift();
+                            valuation = itemProduct.standard_price * cat
+                            stock.push({
+                                    factory_reference : itemProduct.factory_reference,
+                                    product : quant.product_id[1],
+                                    qty : cat,
+                                    brand_id : itemProduct.product_brand_id[0],
+                                    brand : itemProduct.product_brand_id[1],
+                                    category_id : itemProduct.categ_id[0],
+                                    category : itemProduct.categ_id[1],
+                                    standard_price : accounting.formatNumber(itemProduct.standard_price,2, ".", ","),
+                                    valuation : accounting.formatNumber(valuation,2, ".", ","),
+                                    value : valuation,
+                                    location :(itemLocation.location_id[1]+" / "+itemLocation.name)
+                            });
+                        }      
+                    }
+                }
+            }
+            self.content = stock;
+            self.loadTable(stock);
+        },
+        // Obtener Producto Por quant y locations
+        getProductProduct: function(productProduct, stockQuant, location_id){
+            var self = this;
+            var product_ids= _.flatten(_.map(_.filter(stockQuant,function(item){
+                return item.location_id[0] === location_id;
+            }),function(map){
+                return map.product_id[0];
+            }));    
+            return _.filter(productProduct,function(prod){return _.contains(product_ids, prod.id)});
+        },
+        // // Obtener  Qaunt  por productos
+        getQuantProduct: function(location_id, product_id, quantObjs){
+            var self = this;
+            var quantProduct = quantObjs;
+            if (location_id){
+                quantProduct = _.filter(quantProduct, function(item){
+                    return item.location_id[0] === location_id;
+                });
+            }
+            if (product_id){
+                quantProduct = _.filter(quantProduct, function(item){
+                    return item.product_id[0] === product_id;
+                });
+            }
+
+            return quantProduct;
+        },
+        getLocation: function (id) {
+            var self = this;
+            return _.filter(self.stockLocation,function (item) {
+                return item.id == id;
+            });
+        },
+        getBrand: function (id) {
+            var self = this;
+            return _.filter(self.productBrand,function (item) {
+                return item.id == id;
+            });
+        },
+        getCategory: function (id) {
+            var self = this;
+            return _.filter(self.productCategory,function (item) {
+                return item.id == id;
+            });
+        },
+        // Buscar
+        fecthSearch: function(){
+            var self = this;
+            var location =this.$el.find('#current-location').val();
+            var locationObjs = self.stockLocation;
+            var quantObjs = self.stockQuant;
+            var quant;
+            if (location != 9999999){
+                locationObjs=_.filter(locationObjs, function (inv){
+                    return inv.id == location;
+                });
+                quantObjs=_.filter(quantObjs, function (inv){
+                    return inv.location_id[0] == location;
+                });
+            }
+            self.fecthProducto(quantObjs,locationObjs);
+        },
+        // Generar la table
+        loadTable:function(rowsTable){
+            var self = this;
+            this.product=rowsTable;
+            var table = this.$el.find('#table');
+            table.bootstrapTable('load' ,rowsTable);
+        },
+        clickOnAction: function (e) {
+            var self = this;
+            var rowsNew;
+            var action = self.$el.find(e.target).val();
+            var table = self.$el.find("#table");
+            var data2 = table.bootstrapTable('getVisibleColumns');
+            var getColumns=[];
+            var rows=[];
+            rowsNew = self.getObjetPdf();
+            if (action === 'pdf') {
+                var dataNEW = _.map(data2, function (val){
+                    return val.field;
+                });
+                _.each(rowsNew,function (item){
+                    rows.push(_.pick(item, dataNEW));
+                });
+                // Obtener los nombre de la Cabezera
+                _.each(_.map(data2,function(val){
+                        return val;
+                    }), function(item){
+                    getColumns.push([{
+                        title: item.title,
+                        dataKey: item.field
+                    }]);
+                });
+                this.drawPDF(_.flatten(getColumns),rows);
+            }
+        },
+        getObjetPdf: function(){
+            var self = this;
+            var rows=[];
+            var data = self.content;
+            var value = _.reduce(_.map(data,function(map){
+                return(map.value);
+            }),function(memo, num){
+                return memo + num;
+            },0);
+            var qty = _.reduce(_.map(data,function(map){
+                return(map.qty);
+            }),function(memo, num){
+                return memo + num;
+            },0);
+            data.push({
+                factory_reference : 'Totales',
+                qty : qty,
+                valuation : accounting.formatNumber(value,2,'.',',')
+            });
+            
+            // console.log(data);
+            rows = data;
+            
+            return rows;
+        },
+        drawPDF: function (getColumns,rows) {
+            var self = this;
+            var brand = this.$el.find('#current-brand').val();
+            var category = this.$el.find('#current-category').val();
+            var location = this.$el.find('#current-location').val();
+            var totalPagesExp = "{total_pages_count_string}";
+            var pdfDoc = new jsPDF();
+
+            pdfDoc.autoTable(getColumns, rows, {
+                styles: { fontSize: 8, cellPadding: 0.5,},
+                columnStyles: {
+                    factory_reference : {columnWidth: '5px'},
+                    product : {columnWidth: '5px'},
+                    brand : {columnWidth: '5px'},
+                    qty : {align:'center', columnWidth: '3px'},
+                    standard_price : {halign:'right',columnWidth: '5px'},
+                    valuation : {halign:'right',columnWidth: '8px'},
+                },
+                margin: { top: 20, horizontal: 7},
+
+                addPageContent: function (data) {
+                    pdfDoc.setFontSize(13);
+                    pdfDoc.setFontStyle('bold');
+                    pdfDoc.setTextColor(40);
+                    pdfDoc.text('Listado general de stock', data.settings.margin.left, 8);
+                    
+                    if(location != 9999999){
+                        var sucursal = self.getLocation(location).shift();
+                        sucursal = 'Sucursal:   ' + sucursal.location_id[1];
+                    }else{
+                        sucursal = 'Sucursal:   Todas las Sucursales';
+                    }
+                    pdfDoc.setFontSize(10);
+                    pdfDoc.setFontStyle('bold');
+                    pdfDoc.setTextColor(40)
+                    pdfDoc.text(sucursal, data.settings.margin.left,15);
+
+                    if(brand != 9999999){
+                        var marca = self.getBrand(brand).shift();
+                        marca = 'Marca:   ' + marca.name;
+                    }else{
+                        marca = 'Marca:   Todas las Marcas';
+                    }
+                    pdfDoc.setFontSize(10);
+                    pdfDoc.setFontStyle('bold');
+                    pdfDoc.setTextColor(40)
+                    pdfDoc.text(marca, 85,15);
+
+                    if(category != 9999999){
+                        var categoria = self.getCategory(category).shift();
+                        categoria = 'Categoria:   ' + categoria.name;
+                    }else{
+                        categoria = 'Categoria:   Todas las Categorias';
+                    }
+                    pdfDoc.setFontSize(10);
+                    pdfDoc.setFontStyle('bold');
+                    pdfDoc.setTextColor(40)
+                    pdfDoc.text(categoria, 145,15);
+
+                    // FOOTER
+                    var str = "Pagina  " + data.pageCount;
+                    // Total page number plugin only available in jspdf v1.0+
+                    if (typeof pdfDoc.putTotalPages === 'function') {
+                        str = str + " de " + totalPagesExp;
+                    }
+                    pdfDoc.setFontSize(9);
+                    pdfDoc.setFontStyle('bold');
+                    pdfDoc.setTextColor(40);
+                    pdfDoc.text(str, data.settings.margin.left, pdfDoc.internal.pageSize.height - 5);
+                    }
+            });
+            if (typeof pdfDoc.putTotalPages === 'function') {
+                pdfDoc.putTotalPages(totalPagesExp);
+            }
+            pdfDoc.save('Listado General de Stock')
+        },
+    });
+}

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

@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<template xml:space="preserve">
+    <t t-name="ReportExpired">
+        <div class="report_view">
+            <div class="reporting_page_header">
+                <h1>Analisis de cuotas vencidas</h1>
+            </div>
+            <table class="table table-condensed">
+                <tbody>
+                    <tr>
+                        <td>
+                            <div class="form-group">
+                                <label for="current-journal">Sucursal: </label>
+                                <select id="current-journal" class=" ui-autocomplete-input form-control" name="current-journal"></select>
+                            </div>
+                        </td>
+                        <td></td>
+                        <td>
+                            <div class="form-group">
+                                <button class="oe_button oe_form_button oe_highlight form-control" value="pdf" id="pdf">Exportar a PDF</button>
+                            </div>
+                        </td>
+                        <td style="display:none;">
+                            <div class="form-group">
+                                <label for="from">Desde: </label>
+                                <input class="form-control" type="text"  id="from" name="from"/>
+                            </div>
+                        </td>
+                        <td style="display:none;">
+                            <div class="form-group">
+                                <label for="to" >Hasta: </label>
+                                <input class="form-control" type="text"  id="to" name="to" />
+                            </div>
+                        </td>
+                    </tr>
+                </tbody>
+            </table>
+            <table id="table"
+               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_id" data-sortable="true">Cliente</th>
+                    <th data-field="date_maturity" data-sortable="true" data-align="center">Vencimiento</th>
+                    <th data-field="currency_id" data-sortable="true" data-align="center">Moneda</th>
+                    <th data-field="amount" data-sortable="true" data-align="right">Monto</th>
+                    </tr>
+                </thead>
+            </table>
+        </div>
+    </t>
+</template>

+ 65 - 0
static/src/reports/report_stock_gral.xml

@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+    <template xml:space="preserve">
+        <t t-name="ReportStockGral">
+            <div class="report_view">
+                <div class="reporting_page_header">
+                    <h1>Listado de Stock Detallado</h1>
+                </div>
+                <table class="table table-condensed">
+                    <tbody>
+                        <tr>
+                            <td>
+                                <div class="form-group">
+                                    <label for="current-location">Sucursal: </label>
+                                    <select id="current-location" class=" ui-autocomplete-input form-control"  name="location"></select>
+                                </div>
+                            </td>
+                            <td>
+                                <div class="form-group">
+                                    <label for="current-brand">Marca: </label>
+                                    <select id="current-brand" class=" ui-autocomplete-input form-control"  name="brand"></select>
+                                </div>
+                            </td>
+                            <td>
+                                <div class="form-group">
+                                    <label for="current-category">Categoria:</label>
+                                    <select id="current-category" class="form-control ui-autocomplete-input" name="category"></select>
+                                </div>
+                            </td>
+                        </tr>
+                        <tr>
+                            <td></td>
+                            <td>
+                                <button class="oe_button oe_form_button oe_highlight" value="pdf" id="pdf">Exportar a PDF</button>
+                            </td>
+                            <td>
+                            </td>
+                        </tr>
+                    </tbody>
+                </table>
+                <table id="table"
+                       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="factory_reference" data-sortable="true" >Referencia</th>
+                            <th data-field="product" data-sortable="true" >Productos</th>
+                            <th data-field="brand" data-sortable="true" >Marca</th>
+                            <!-- <th data-field="category" data-sortable="true" >Categoria</th> -->
+                            <th data-field="qty" data-sortable="true" data-align="center">Cantidad</th>
+                            <th data-field="standard_price" data-sortable="true" data-align="right">Precio</th>
+                            <th data-field="valuation" data-sortable="true" data-align="right">valoración</th>
+                        </tr>
+                    </thead>
+                </table>
+            </div>
+        </t>
+    </template>

+ 2 - 1
templates.xml

@@ -19,7 +19,8 @@
                 <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_expenses.js" />
                 <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_stock_location.js" />
                 <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_stock_product.js" />
-
+                <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_expired.js" />
+                <script type="text/javascript" src="/eiru_reporting/static/src/js/reports/report_stock_gral.js" />
             </xpath>
         </template>