|
@@ -181,7 +181,7 @@ function report_pos_orders(reporting){
|
|
return self.fecthPosCategory();
|
|
return self.fecthPosCategory();
|
|
}).then(function(PosCategory){
|
|
}).then(function(PosCategory){
|
|
self.PosCategory = PosCategory;
|
|
self.PosCategory = PosCategory;
|
|
- self.$el.find('#current-category').append('<option value="9999999">Todos las categorias</option>');
|
|
|
|
|
|
+ self.$el.find('#current-category').append('<option value="9999999">Todas las categorias</option>');
|
|
_.each(PosCategory, function (item) {
|
|
_.each(PosCategory, function (item) {
|
|
self.$el.find('#current-category').append('<option value="' + item.id + '">' + item.name + '</option>');
|
|
self.$el.find('#current-category').append('<option value="' + item.id + '">' + item.name + '</option>');
|
|
});
|
|
});
|
|
@@ -272,7 +272,7 @@ function report_pos_orders(reporting){
|
|
},
|
|
},
|
|
|
|
|
|
// Lineas de venta (Point Of Sale)
|
|
// Lineas de venta (Point Of Sale)
|
|
- fetchPosOrderLine: function () {
|
|
|
|
|
|
+ fetchPosOrderLine: function (PosOrder) {
|
|
var self = this;
|
|
var self = this;
|
|
var defer = $.Deferred();
|
|
var defer = $.Deferred();
|
|
var ids = _.flatten(_.map(self.PosOrder, function (item) {
|
|
var ids = _.flatten(_.map(self.PosOrder, function (item) {
|
|
@@ -327,10 +327,10 @@ function report_pos_orders(reporting){
|
|
},
|
|
},
|
|
|
|
|
|
// Productos
|
|
// Productos
|
|
- fetchProductProduct: function(){
|
|
|
|
|
|
+ fetchProductProduct: function(PosOrderLine){
|
|
var self = this;
|
|
var self = this;
|
|
var defer = $.Deferred();
|
|
var defer = $.Deferred();
|
|
- var porduct_ids = _.flatten(_.map(self.PosOrderLine, function (item) {
|
|
|
|
|
|
+ var porduct_ids = _.flatten(_.map(PosOrderLine, function (item) {
|
|
return item.product_id[0];
|
|
return item.product_id[0];
|
|
}));
|
|
}));
|
|
var fields = ['id','name', 'default_code', 'name_template','ean13','lst_price','pos_categ_id', 'standard_price','type','attribute_str'];
|
|
var fields = ['id','name', 'default_code', 'name_template','ean13','lst_price','pos_categ_id', 'standard_price','type','attribute_str'];
|
|
@@ -392,20 +392,18 @@ function report_pos_orders(reporting){
|
|
},
|
|
},
|
|
|
|
|
|
// Obtener las lineas de las Facturas
|
|
// Obtener las lineas de las Facturas
|
|
- getProductProduct: function(id){
|
|
|
|
|
|
+ getProductProduct: function(pro_id){
|
|
var self = this;
|
|
var self = this;
|
|
- //return _.find(self.ProductProduct, function(item){
|
|
|
|
- // return item.id == id;
|
|
|
|
- //});
|
|
|
|
- return _.filter(self.ProductProduct, function(item){
|
|
|
|
- return item.id === id;
|
|
|
|
|
|
+ return _.find(self.ProductProduct, function(prod){
|
|
|
|
+ return _.contains(pro_id, prod.id);
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
|
|
|
|
+
|
|
getPosCategory: function(id){
|
|
getPosCategory: function(id){
|
|
var self = this;
|
|
var self = this;
|
|
return _.filter(self.PosCategory, function(item){
|
|
return _.filter(self.PosCategory, function(item){
|
|
- return item.id == id;
|
|
|
|
|
|
+ return item.id === id;
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
|
|
@@ -420,26 +418,17 @@ function report_pos_orders(reporting){
|
|
var self = this;
|
|
var self = this;
|
|
var data = [];
|
|
var data = [];
|
|
var order;
|
|
var order;
|
|
- var producto = [];
|
|
|
|
|
|
+ var producto;
|
|
var category;
|
|
var category;
|
|
var item;
|
|
var item;
|
|
- var category_name;
|
|
|
|
- var category_id;
|
|
|
|
var store;
|
|
var store;
|
|
|
|
|
|
for (var i = 0; i < this.PosOrderLine.length; i++) {
|
|
for (var i = 0; i < this.PosOrderLine.length; i++) {
|
|
item = this.PosOrderLine[i];
|
|
item = this.PosOrderLine[i];
|
|
- producto = self.getProductProduct(item.product_id[0]);
|
|
|
|
|
|
+ producto = this.getProductProduct(item.product_id);
|
|
order = self.getPosOrder(item.order_id[0]).shift();
|
|
order = self.getPosOrder(item.order_id[0]).shift();
|
|
store = self.getAccountJournal(order.sale_journal[0]);
|
|
store = self.getAccountJournal(order.sale_journal[0]);
|
|
- category = self.getPosCategory(item.product_id[0]);
|
|
|
|
- if(category.length > 0){
|
|
|
|
- category_name = category[0].name;
|
|
|
|
- category_id = category[0].id;
|
|
|
|
- }else {
|
|
|
|
- category_name = '';
|
|
|
|
- category_id = '';
|
|
|
|
- }
|
|
|
|
|
|
+ //category = self.getPosCategory(item.product_id[0]);
|
|
var place_id;
|
|
var place_id;
|
|
var place_name;
|
|
var place_name;
|
|
var floor;
|
|
var floor;
|
|
@@ -450,40 +439,42 @@ function report_pos_orders(reporting){
|
|
place_name = order.table_id[1];
|
|
place_name = order.table_id[1];
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
- if(store.length > 0 && producto.length > 0){
|
|
|
|
-
|
|
|
|
- var utc = moment.utc(order.date_order,'YYYY-MM-DD h:mm:ss A');
|
|
|
|
- var date = moment(utc._d).format('DD/MM/YYYY h:mm A');
|
|
|
|
- var date_aux=moment(utc._d).format('YYYY-MM-DD');
|
|
|
|
-
|
|
|
|
- data.push({
|
|
|
|
- id : item.id,
|
|
|
|
- order_id : item.order_id[0],
|
|
|
|
- order_name : item.order_id[1],
|
|
|
|
- partner: order.partner_id[1],
|
|
|
|
- date_invoice: date,
|
|
|
|
- date : date_aux,
|
|
|
|
- table_id : self.valorNull(place_id),
|
|
|
|
- table_name : self.valorNull(place_name),
|
|
|
|
- floor_id : floor,
|
|
|
|
- product_id : item.product_id[0],
|
|
|
|
- product_name : item.product_id[1],
|
|
|
|
- qty : accounting.formatNumber(item.qty,0,".",","),
|
|
|
|
- price_unit : accounting.formatNumber(item.price_unit,0,".",","),
|
|
|
|
- standard_price : accounting.formatNumber((producto[0].standard_price),0, ".", ","),
|
|
|
|
- price_tot : accounting.formatNumber((item.qty * item.price_unit),0, ".", ","),
|
|
|
|
- standar_tot : accounting.formatNumber((item.qty * producto[0].standard_price),0, ".", ","),
|
|
|
|
- utility : accounting.formatNumber(((item.qty * item.price_unit) - (item.qty * producto[0].standard_price)),0, ".", ","),
|
|
|
|
- store_id : store[0].store_ids[0],
|
|
|
|
- qty_total : item.qty,
|
|
|
|
- price_tot_tot : ((item.qty * item.price_unit)),
|
|
|
|
- standar_tot_tot : ((item.qty * producto[0].standard_price)),
|
|
|
|
- utility_tot : (((item.qty * item.price_unit) - (item.qty * producto[0].standard_price))),
|
|
|
|
- category_name : category_name,
|
|
|
|
- partner_id : order.partner_id[0],
|
|
|
|
- category_id : category_id,
|
|
|
|
- });
|
|
|
|
|
|
+ if (producto != undefined){
|
|
|
|
+
|
|
|
|
+ if(store.length > 0){
|
|
|
|
+
|
|
|
|
+ var utc = moment.utc(order.date_order,'YYYY-MM-DD h:mm:ss A');
|
|
|
|
+ var date = moment(utc._d).format('DD/MM/YYYY h:mm A');
|
|
|
|
+ var date_aux=moment(utc._d).format('YYYY-MM-DD');
|
|
|
|
+
|
|
|
|
+ data.push({
|
|
|
|
+ id : item.id,
|
|
|
|
+ order_id : item.order_id[0],
|
|
|
|
+ order_name : item.order_id[1],
|
|
|
|
+ partner: order.partner_id[1],
|
|
|
|
+ date_invoice: date,
|
|
|
|
+ date : date_aux,
|
|
|
|
+ table_id : self.valorNull(place_id),
|
|
|
|
+ table_name : self.valorNull(place_name),
|
|
|
|
+ floor_id : floor,
|
|
|
|
+ product_id : item.product_id[0],
|
|
|
|
+ product_name : item.product_id[1],
|
|
|
|
+ qty : accounting.formatNumber(item.qty,0,".",","),
|
|
|
|
+ price_unit : accounting.formatNumber(item.price_unit,0,".",","),
|
|
|
|
+ standard_price : accounting.formatNumber((producto.standard_price),0, ".", ","),
|
|
|
|
+ price_tot : accounting.formatNumber((item.qty * item.price_unit),0, ".", ","),
|
|
|
|
+ standar_tot : accounting.formatNumber((item.qty * producto.standard_price),0, ".", ","),
|
|
|
|
+ utility : accounting.formatNumber(((item.qty * item.price_unit) - (item.qty * producto.standard_price)),0, ".", ","),
|
|
|
|
+ store_id : store[0].store_ids[0],
|
|
|
|
+ qty_total : item.qty,
|
|
|
|
+ price_tot_tot : ((item.qty * item.price_unit)),
|
|
|
|
+ standar_tot_tot : ((item.qty * producto.standard_price)),
|
|
|
|
+ utility_tot : (((item.qty * item.price_unit) - (item.qty * producto.standard_price))),
|
|
|
|
+ category_name : producto.pos_categ_id[1],
|
|
|
|
+ categ_id : (producto.pos_categ_id[0]),
|
|
|
|
+ partner_id : order.partner_id[0],
|
|
|
|
+ });
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
this.rowsData=data;
|
|
this.rowsData=data;
|
|
@@ -499,7 +490,7 @@ function report_pos_orders(reporting){
|
|
var last_month = moment().add(-1, 'months').format('YYYY-MM');
|
|
var last_month = moment().add(-1, 'months').format('YYYY-MM');
|
|
var floor =this.$el.find('#current-floor').val();
|
|
var floor =this.$el.find('#current-floor').val();
|
|
var table =this.$el.find('#current-table').val();
|
|
var table =this.$el.find('#current-table').val();
|
|
- var category = this.$el.find('#current-category').val();
|
|
|
|
|
|
+ var categ = this.$el.find('#current-category').val();
|
|
var store =this.$el.find('#current-store').val();
|
|
var store =this.$el.find('#current-store').val();
|
|
var desde =this.$el.find('#from').val();
|
|
var desde =this.$el.find('#from').val();
|
|
var hasta =this.$el.find('#to').val();
|
|
var hasta =this.$el.find('#to').val();
|
|
@@ -572,9 +563,9 @@ function report_pos_orders(reporting){
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
- if(category != 9999999){
|
|
|
|
- content = _.filter(content,function(inv){
|
|
|
|
- return inv.category_id == category;
|
|
|
|
|
|
+ if (categ != 9999999){
|
|
|
|
+ content =_.filter(content, function (inv){
|
|
|
|
+ return inv.categ_id == categ[0];
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|