Browse Source

FIX ADD Agregado report de utilidad sobre precio de ventas

Sebas 6 năm trước cách đây
mục cha
commit
557170b334

+ 5 - 3
static/src/js/reports/report_pos.js

@@ -208,7 +208,7 @@ function report_pos(reporting){
         fetchPosOrder: function () {
             var self = this;
             var filter =[['state', 'in',['done','paid','invoiced']]];
-            var field =['id', 'partner_id', 'name', 'session_id', 'state', 'table_id', 'statement_ids','create_date','amount_total','user_id','amount_tax','sale_journal'];
+            var field =['id', 'partner_id', 'name', 'session_id', 'state', 'table_id', 'statement_ids','date_order','amount_total','user_id','amount_tax','sale_journal'];
             var defer = $.Deferred();
             var modules = self.checkModel('point_of_sale');
 
@@ -306,8 +306,9 @@ function report_pos(reporting){
                 order = self.getStatementLine(item.id);
                 store = self.getAccountJournal(item.sale_journal[0]);
                 if(order.length > 0 & store.length > 0){
-                    var utc = moment.utc(item.create_date,'YYYY-MM-DD h:mm:ss A');
+                    var utc = moment.utc(item.date_order,'YYYY-MM-DD h:mm:ss A');
                     var date = moment(utc._d).format('DD/MM/YYYY hh:mm A');
+                    var date_aux=moment(utc._d).format('YYYY-MM-DD');
                     data.push({
                         id : item.id,
                         number: item.name,
@@ -315,7 +316,7 @@ function report_pos(reporting){
                         partner: item.partner_id[1],
                         date_invoice: date,
                         amount_total: accounting.formatNumber(item.amount_total,0,".",","),
-                        date: date,
+                        date: date_aux,
                         partner_id : item.partner_id[0],
                         amount : item.amount_total,
                         journal_id: order[0].journal_id[0],
@@ -366,6 +367,7 @@ function report_pos(reporting){
                 $('#datepicker').css('display','block');
                 if (desde.length > 0){
                     var date= desde.split('/');
+                    console.log(date);
                     content = _.filter(content, function (inv){
                         return inv.date >= (date[2]+"-"+date[1]+"-"+date[0]);
                     });

+ 4 - 2
static/src/js/reports/report_pos_orders.js

@@ -455,13 +455,15 @@ function report_pos_orders(reporting){
 
                     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 : date,
+                        date_invoice: date,
+                        date : date_aux,
                         table_id : self.valorNull(place_id),
                         table_name : self.valorNull(place_name),
                         floor_id : floor,
@@ -695,7 +697,7 @@ function report_pos_orders(reporting){
                 styles: { overflow: 'linebreak', fontSize: 8, columnWidth: 'wrap'},
                 columnStyles: {
                         order_name: {halign:'left', fontStyle: 'bold'},
-                        date :{halign:'left' , columnWidth: '8px'},
+                        date_invoice :{halign:'left' , columnWidth: '8px'},
                         partner :{halign:'left' , columnWidth: '8px'},
                         category_name :{halign:'left', columnWidth: '8px'},
                         table_name :{halign:'left', columnWidth: '7px'},

+ 29 - 1
static/src/js/reports/report_purchases_invoice_analysis.js

@@ -23,6 +23,7 @@ function report_purchases_invoice_analysis (reporting){
             'click #D' : 'factSearch',
             'click #Z' : 'factSearch',
             'click #Y' : 'factSearch',
+            'change #current-category' : 'factSearch',
             'click #purchase' : 'factSearch',
             'click #expense' : 'factSearch',
             'change #current-store': 'factSearch',
@@ -133,6 +134,13 @@ function report_purchases_invoice_analysis (reporting){
                 return self.fecthProductProduct();
             }).then(function(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();
             }).then(function(ResCompany){
                 self.ResCompany = ResCompany;
@@ -208,12 +216,22 @@ function report_purchases_invoice_analysis (reporting){
                 return item.product_id[0];
             }));
             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) {
                 defer.resolve(results)
             });
             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(){
             var self = this;
             var defer = $.Deferred();
@@ -285,6 +303,7 @@ function report_purchases_invoice_analysis (reporting){
                 invoice = self.getAccountInvoice(item.id);
                 store = self.getAccountJournal(invoice.journal_id[0]);
                 producto =self.getProductProduct(item.product_id);
+                console.log(producto);
                 if (!producto){
                     producto={};
                     producto.standard_price=0;
@@ -310,6 +329,8 @@ function report_purchases_invoice_analysis (reporting){
                         date_create :moment(invoice.date_invoice).format("DD/MM/YYYY"),
                         amount : (item.quantity * item.price_unit),
                         partner_name : invoice.partner_id[1],
+                        categ_id: producto.categ_id[0],
+                        categ_name: producto.categ_id[1],
                         invoice_type : invoice_type,
                         store_id : store[0].store_ids[0]
                     });
@@ -321,6 +342,7 @@ function report_purchases_invoice_analysis (reporting){
         },
         factSearch: function(){
             var self = this;
+            var category = this.$el.find('#current-category').val();
             var today = moment().format('YYYY-MM-DD');
             var yesterday = moment().add(-1, 'days').format('YYYY-MM-DD');
             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){
                 return(map.amount);
             }),function(memo, num){

+ 3 - 2
static/src/js/reports/report_sale_pos_cab.js

@@ -437,7 +437,7 @@ function report_sale_pos_cab(reporting){
                         partner: item.partner_id[1],
                         date_invoice: moment(item.date_invoice).format("DD/MM/YYYY"),
                         amount_total: accounting.formatNumber(item.amount_total,0,".",","),
-                        date: item.date_invoice,
+                        date: moment(item.date_invoice).format("YYYY-MM-DD"),
                         partner_id : item.partner_id[0],
                         amount : item.amount_total,
                         journal_id: item.journal_id[0],
@@ -455,6 +455,7 @@ function report_sale_pos_cab(reporting){
                 if(order.length > 0 & store.length > 0){
                     var utc = moment.utc(item.create_date,'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,
@@ -464,7 +465,7 @@ function report_sale_pos_cab(reporting){
                         partner: item.partner_id[1],
                         date_invoice: date,
                         amount_total: accounting.formatNumber(item.amount_total,0,".",","),
-                        date: date,
+                        date: date_aux,
                         partner_id : item.partner_id[0],
                         amount : item.amount_total,
                         journal_id: order[0].journal_id[0],

+ 2 - 2
static/src/js/reports/report_ventas_pos_orders.js

@@ -461,7 +461,7 @@ function report_ventas_pos_orders(reporting){
                 order = self.getPosOrder(item.order_id[0]).shift();
                 var utc = moment.utc(item.create_date,'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');
                var store = self.getAccountJournal(order.sale_journal[0]);
 
                 if(store.length > 0 && producto.length > 0){
@@ -471,7 +471,7 @@ function report_ventas_pos_orders(reporting){
                         order_id : item.order_id[0],
                         ref: "",
                         order_name : item.order_id[1],
-                        date : date,
+                        date : date_aux,
                         date_order : date,
                         partner: order.partner_id[1],
                         product_id : item.product_id[0],

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

@@ -94,7 +94,7 @@
                 <thead>
                     <tr>
                         <th data-field="order_name" data-sortable="true">Pedido</th>
-                        <th data-field="date" data-sortable="true">Fecha</th>
+                        <th data-field="date_invoice" data-sortable="true">Fecha</th>
                         <th data-field="partner">Cliente</th>
                         <th data-field="category_name" data-sortable="true" >Categoria</th>
                         <th data-field="table_name">Lugar</th>

+ 4 - 0
static/src/reports/report_purchases_invoice_analysis.xml

@@ -63,6 +63,10 @@
                                     <label for="product">Buscar Producto</label>
                                     <input id="product" type="text" class="form-control ui-autocomplete-input" autocomplete="off" placeholder="Nombre/ Referencia/ Codigo de barras"/>
                                 </div>
+                                <div class="form-group">
+                                    <label for="current-category">Todas la categorias: </label>
+                                    <select id="current-category" class="form-control ui-autocomplete-input"  name="current-category"></select>
+                                </div>
                                 <div class="form-group">
                                     <label for="current-store">Sucursal: </label>
                                     <select id="current-store" class="form-control ui-autocomplete-input" name="store"></select>