소스 검색

FIX ADD Agregado filtros de metodo de pago, vendedor y campos en analisis de ventas e historico de ventas

Sebas 6 년 전
부모
커밋
99cd011d00
2개의 변경된 파일54개의 추가작업 그리고 63개의 파일을 삭제
  1. 52 61
      static/src/js/reports/report_pos_orders.js
  2. 2 2
      static/src/reports/report_pos_orders.xml

+ 52 - 61
static/src/js/reports/report_pos_orders.js

@@ -181,7 +181,7 @@ function report_pos_orders(reporting){
                 return self.fecthPosCategory();
             }).then(function(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) {
                     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)
-        fetchPosOrderLine: function () {
+        fetchPosOrderLine: function (PosOrder) {
             var self = this;
             var defer = $.Deferred();
             var ids = _.flatten(_.map(self.PosOrder, function (item) {
@@ -327,10 +327,10 @@ function report_pos_orders(reporting){
         },
 
         // Productos
-        fetchProductProduct: function(){
+        fetchProductProduct: function(PosOrderLine){
             var self = this;
             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];
             }));
             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
-        getProductProduct: function(id){
+        getProductProduct: function(pro_id){
             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){
             var self = this;
             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 data = [];
             var order;
-            var producto = [];
+            var producto;
             var category;
             var item;
-            var category_name;
-            var category_id;
             var store;
 
             for (var i = 0; i < this.PosOrderLine.length; 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();
                 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_name;
                 var floor;
@@ -450,40 +439,42 @@ function report_pos_orders(reporting){
                     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;
@@ -499,7 +490,7 @@ function report_pos_orders(reporting){
             var last_month = moment().add(-1, 'months').format('YYYY-MM');
             var floor =this.$el.find('#current-floor').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 desde =this.$el.find('#from').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];
                 });
             }
 

+ 2 - 2
static/src/reports/report_pos_orders.xml

@@ -56,7 +56,7 @@
                             <div class="panel-body">
                                 <div class="form-group">
                                     <label for="current-category">Todas las categorias: </label>
-                                    <select id="current-category" class="form-control ui-autocomplete-input"  name="current-category"></select>
+                                    <select id="current-category" class="form-control ui-autocomplete-input"  name="category"></select>
                                     <label for="current-floor">Ubicacion: </label>
                                     <select id="current-floor" class="form-control ui-autocomplete-input"  name="floor"></select>
                                     <label for="current-table">Lugar: </label>
@@ -95,7 +95,7 @@
                     <tr>
                         <th data-field="order_name" data-sortable="true">Pedido</th>
                         <th data-field="date_invoice" data-sortable="true">Fecha</th>
-                        <th data-field="partner">Cliente</th>
+                        <th data-field="partner" data-sortable="true">Cliente</th>
                         <th data-field="category_name" data-sortable="true" >Categoria</th>
                         <th data-field="table_name">Lugar</th>
                         <th data-field="product_name" data-sortable="true">Productos</th>