|
@@ -23,6 +23,7 @@ function report_purchases_invoice_analysis (reporting){
|
|
'click #D' : 'factSearch',
|
|
'click #D' : 'factSearch',
|
|
'click #Z' : 'factSearch',
|
|
'click #Z' : 'factSearch',
|
|
'click #Y' : 'factSearch',
|
|
'click #Y' : 'factSearch',
|
|
|
|
+ 'change #current-category' : 'factSearch',
|
|
'click #purchase' : 'factSearch',
|
|
'click #purchase' : 'factSearch',
|
|
'click #expense' : 'factSearch',
|
|
'click #expense' : 'factSearch',
|
|
'change #current-store': 'factSearch',
|
|
'change #current-store': 'factSearch',
|
|
@@ -133,6 +134,13 @@ function report_purchases_invoice_analysis (reporting){
|
|
return self.fecthProductProduct();
|
|
return self.fecthProductProduct();
|
|
}).then(function(ProductProduct){
|
|
}).then(function(ProductProduct){
|
|
self.ProductProduct = ProductProduct;
|
|
self.ProductProduct = ProductProduct;
|
|
|
|
+ return self.fecthProductCategory();
|
|
|
|
+ }).then(function(ProductCategory){
|
|
|
|
+ self.ProductCategory = ProductCategory;
|
|
|
|
+ self.$el.find('#current-category').append('<option value="9999999">Todos las categorias</option>');
|
|
|
|
+ _.each(ProductCategory, function (item) {
|
|
|
|
+ self.$el.find('#current-category').append('<option value="' + item.id + '">' + item.name + '</option>');
|
|
|
|
+ });
|
|
return self.fecthResCompany();
|
|
return self.fecthResCompany();
|
|
}).then(function(ResCompany){
|
|
}).then(function(ResCompany){
|
|
self.ResCompany = ResCompany;
|
|
self.ResCompany = ResCompany;
|
|
@@ -208,12 +216,22 @@ function report_purchases_invoice_analysis (reporting){
|
|
return item.product_id[0];
|
|
return item.product_id[0];
|
|
}));
|
|
}));
|
|
var ProductProduct = new model.web.Model('product.product');
|
|
var ProductProduct = new model.web.Model('product.product');
|
|
- var fields = ['id','name', 'default_code', 'name_template','ean13', 'standard_price','type','attribute_str'];
|
|
|
|
|
|
+ var fields = ['id','name', 'default_code', 'name_template','ean13', 'standard_price','type','attribute_str', 'categ_id'];
|
|
ProductProduct.query(fields).filter([['id', 'in', porductIDS]]).all().then(function (results) {
|
|
ProductProduct.query(fields).filter([['id', 'in', porductIDS]]).all().then(function (results) {
|
|
defer.resolve(results)
|
|
defer.resolve(results)
|
|
});
|
|
});
|
|
return defer;
|
|
return defer;
|
|
},
|
|
},
|
|
|
|
+ fecthProductCategory: function(){
|
|
|
|
+ var self = this;
|
|
|
|
+ var defer = $.Deferred();
|
|
|
|
+ var fields = ['id','name'];
|
|
|
|
+ var ProductCategory = new model.web.Model('product.category');
|
|
|
|
+ ProductCategory.query(fields).filter([['type', '=', 'normal']]).all().then(function (results) {
|
|
|
|
+ defer.resolve(results)
|
|
|
|
+ });
|
|
|
|
+ return defer;
|
|
|
|
+ },
|
|
fecthResCompany: function(){
|
|
fecthResCompany: function(){
|
|
var self = this;
|
|
var self = this;
|
|
var defer = $.Deferred();
|
|
var defer = $.Deferred();
|
|
@@ -285,6 +303,7 @@ function report_purchases_invoice_analysis (reporting){
|
|
invoice = self.getAccountInvoice(item.id);
|
|
invoice = self.getAccountInvoice(item.id);
|
|
store = self.getAccountJournal(invoice.journal_id[0]);
|
|
store = self.getAccountJournal(invoice.journal_id[0]);
|
|
producto =self.getProductProduct(item.product_id);
|
|
producto =self.getProductProduct(item.product_id);
|
|
|
|
+ console.log(producto);
|
|
if (!producto){
|
|
if (!producto){
|
|
producto={};
|
|
producto={};
|
|
producto.standard_price=0;
|
|
producto.standard_price=0;
|
|
@@ -310,6 +329,8 @@ function report_purchases_invoice_analysis (reporting){
|
|
date_create :moment(invoice.date_invoice).format("DD/MM/YYYY"),
|
|
date_create :moment(invoice.date_invoice).format("DD/MM/YYYY"),
|
|
amount : (item.quantity * item.price_unit),
|
|
amount : (item.quantity * item.price_unit),
|
|
partner_name : invoice.partner_id[1],
|
|
partner_name : invoice.partner_id[1],
|
|
|
|
+ categ_id: producto.categ_id[0],
|
|
|
|
+ categ_name: producto.categ_id[1],
|
|
invoice_type : invoice_type,
|
|
invoice_type : invoice_type,
|
|
store_id : store[0].store_ids[0]
|
|
store_id : store[0].store_ids[0]
|
|
});
|
|
});
|
|
@@ -321,6 +342,7 @@ function report_purchases_invoice_analysis (reporting){
|
|
},
|
|
},
|
|
factSearch: function(){
|
|
factSearch: function(){
|
|
var self = this;
|
|
var self = this;
|
|
|
|
+ var category = this.$el.find('#current-category').val();
|
|
var today = moment().format('YYYY-MM-DD');
|
|
var today = moment().format('YYYY-MM-DD');
|
|
var yesterday = moment().add(-1, 'days').format('YYYY-MM-DD');
|
|
var yesterday = moment().add(-1, 'days').format('YYYY-MM-DD');
|
|
var month = moment().format('YYYY-MM');
|
|
var month = moment().format('YYYY-MM');
|
|
@@ -399,6 +421,12 @@ function report_purchases_invoice_analysis (reporting){
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if(category != 9999999){
|
|
|
|
+ content = _.filter(content,function(inv){
|
|
|
|
+ return inv.categ_id == category[0];
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
var amount_total_total = _.reduce(_.map(content,function(map){
|
|
var amount_total_total = _.reduce(_.map(content,function(map){
|
|
return(map.amount);
|
|
return(map.amount);
|
|
}),function(memo, num){
|
|
}),function(memo, num){
|