|
@@ -289,31 +289,32 @@ function report_product_pack_pos (reporting) {
|
|
|
// Obtener facturas por cada clientes
|
|
|
getPosOrderLiners:function(product_id) {
|
|
|
var self = this;
|
|
|
+ var today = moment().format('YYYY-MM-DD');
|
|
|
+ var yesterday = moment().add(-1, 'days').format('YYYY-MM-DD');
|
|
|
+ var month = moment().format('YYYY-MM');
|
|
|
+ var last_month = moment().add(-1, 'months').format('YYYY-MM');
|
|
|
var desde = self.$el.find('#from').val();
|
|
|
var hasta = self.$el.find('#to').val();
|
|
|
var PosOrderLine = self.PosOrderLine;
|
|
|
- // Hoy
|
|
|
+
|
|
|
if ($('#A').is(":checked")){
|
|
|
PosOrderLine = _.filter(PosOrderLine, function (inv){
|
|
|
- return moment(inv.create_date).format('YYYY-MM-DD') == moment().format('YYYY-MM-DD');
|
|
|
+ return moment(inv.create_date).format('YYYY-MM-DD') == today;
|
|
|
});
|
|
|
}
|
|
|
- // Ayer
|
|
|
if ($('#B').is(":checked")){
|
|
|
PosOrderLine = _.filter(PosOrderLine, function (inv){
|
|
|
- return moment(inv.create_date).format('YYYY-MM-DD') == moment().add(-1,'days').format('YYYY-MM-DD');
|
|
|
+ return moment(inv.create_date).format('YYYY-MM-DD') == yesterday;
|
|
|
});
|
|
|
}
|
|
|
- // Mes Actual
|
|
|
if ($('#C').is(":checked")){
|
|
|
PosOrderLine = _.filter(PosOrderLine, function (inv){
|
|
|
- return moment(inv.create_date).format('MM') == moment().format('MM');
|
|
|
+ return moment(inv.create_date).format('YYYY-MM') == month;
|
|
|
});
|
|
|
}
|
|
|
- // Mes Pasado
|
|
|
if ($('#D').is(":checked")){
|
|
|
PosOrderLine = _.filter(PosOrderLine, function (inv){
|
|
|
- return moment(inv.create_date).format('MM') == moment().add(-1,'months').format('MM');
|
|
|
+ return moment(inv.create_date).format('YYYY-MM') == last_month;
|
|
|
});
|
|
|
}
|
|
|
// Rango de fechas
|
|
@@ -350,15 +351,16 @@ function report_product_pack_pos (reporting) {
|
|
|
var ProductProduct = self.ProductProduct;
|
|
|
var rankingCab = [];
|
|
|
var rankingItem = [];
|
|
|
- var cat = 0;
|
|
|
+
|
|
|
var itemProductPack;
|
|
|
var countSalesOrder = 0;
|
|
|
var attribute;
|
|
|
var lineUnik;
|
|
|
|
|
|
_.each(ProductProduct, function(item){
|
|
|
-
|
|
|
+ var cat = 0;
|
|
|
itemLine = self.getPosOrderLiners(item.id);
|
|
|
+
|
|
|
if (itemLine.length > 0) {
|
|
|
cat = _.reduce(_.map(itemLine, function (map) {
|
|
|
return map.qty
|
|
@@ -366,44 +368,46 @@ function report_product_pack_pos (reporting) {
|
|
|
return meno + num
|
|
|
}, 0);
|
|
|
}
|
|
|
- if(item.attribute_str){
|
|
|
- attribute = ' ' + item.attribute_str;
|
|
|
- }else{
|
|
|
- attribute = ' ';
|
|
|
+ if(item.attribute_str){
|
|
|
+ attribute = ' ' + item.attribute_str;
|
|
|
+ }else{
|
|
|
+ attribute = ' ';
|
|
|
+ }
|
|
|
+ if (cat > 0){
|
|
|
+ itemProductPack = self.getProductPack(item.id);
|
|
|
+
|
|
|
+ rankingItem.push({
|
|
|
+ product_main: item.name_template+ attribute,
|
|
|
+ product: "",
|
|
|
+ qty_pos: cat,
|
|
|
+ qty: "",
|
|
|
+ countPack: "",
|
|
|
+ product_main_id: item.id
|
|
|
+ });
|
|
|
+
|
|
|
+ for (var i = 0; i < itemProductPack.length; i++) {
|
|
|
+
|
|
|
+
|
|
|
+ if (itemProductPack.length > 0){
|
|
|
+ rankingItem.push({
|
|
|
+ product_main: "",
|
|
|
+ product: itemProductPack[i].product_id[1],
|
|
|
+ qty_pos: itemProductPack[i].quantity,
|
|
|
+ qty: accounting.formatNumber((itemProductPack[i].quantity*cat),3,".",","),
|
|
|
+ countPack: itemProductPack[i].quantity*cat,
|
|
|
+ product_main_id: itemProductPack[i].parent_product_id[0],
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // Generar Objeto Principal
|
|
|
+ rankingItem=rankingItem.concat(rankingCab);
|
|
|
}
|
|
|
- itemProductPack = self.getProductPack(item.id);
|
|
|
-
|
|
|
- rankingItem.push({
|
|
|
- product_main: item.name_template+ attribute,
|
|
|
- product: "",
|
|
|
- qty_pos: cat,
|
|
|
- qty: "",
|
|
|
- countPack: "",
|
|
|
- product_main_id: item.id
|
|
|
- });
|
|
|
-
|
|
|
- for (var i = 0; i < itemProductPack.length; i++) {
|
|
|
-
|
|
|
-
|
|
|
- if (itemProductPack.length > 0){
|
|
|
- rankingItem.push({
|
|
|
- product_main: "",
|
|
|
- product: itemProductPack[i].product_id[1],
|
|
|
- qty_pos: itemProductPack[i].quantity,
|
|
|
- qty: accounting.formatNumber((itemProductPack[i].quantity*cat),3,".",","),
|
|
|
- countPack: itemProductPack[i].quantity*cat,
|
|
|
- product_main_id: itemProductPack[i].parent_product_id[0],
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- // Generar Objeto Principal
|
|
|
- rankingItem=rankingItem.concat(rankingCab);
|
|
|
-
|
|
|
});
|
|
|
|
|
|
self.content = rankingItem;
|
|
|
+
|
|
|
self.loadTable(rankingItem);
|
|
|
|
|
|
},
|
|
@@ -436,6 +440,7 @@ function report_product_pack_pos (reporting) {
|
|
|
|
|
|
factSearch: function(){
|
|
|
var self = this;
|
|
|
+
|
|
|
var product = this.$el.find('#product').val().split('-');
|
|
|
var content = self.content;
|
|
|
|