Explorar o código

Retoque de informe resumen de cuenta agregando servicio

root %!s(int64=3) %!d(string=hai) anos
pai
achega
7cb7e2e0b0

+ 149 - 9
static/src/js/reports/report_cuenta_resumen_dna.js

@@ -275,10 +275,13 @@ function report_cuenta_resumen_dna(reporting){
         ====================================================================*/
         fetchAccountInvoice: function () {
             var self = this;
+              var content = self.AccountInvoice;
             var store = self.$el.find('#current-store').val();
             var period = self.$el.find('#current-period').val();
             var company = self.$el.find('#current-company').val();
+            var state = self.$el.find('#current-state').val();
             var journal = self.$el.find('#current-journal').val();
+            var invoice_type = self.$el.find('#current-invoice-type').val();
             var date = self.$el.find('#current-date').val();
             var desde = self.$el.find('#from').val();
             var hasta = self.$el.find('#to').val();
@@ -312,6 +315,11 @@ function report_cuenta_resumen_dna(reporting){
             if(period && period != 9999999){
                 domain.push(['period_id','=',parseInt(period)]);
             }
+            if(state && state != 9999999){
+                if(state == 'open'){
+                    content = [];
+                }
+            }
 
             if(date && date != 9999999){
 
@@ -512,11 +520,127 @@ function report_cuenta_resumen_dna(reporting){
         /*====================================================================
             GET ACCOUNT INVOICE
         ====================================================================*/
-        getAccountInvoice: function (id) {
-          var self = this;
-          return _.filter(self.AccountInvoice,function (item) {
-            return item.journal_id[0] === id;
-          });
+        // getAccountInvoice: function (id) {
+        //   var self = this;
+        //   return _.filter(self.AccountInvoice,function (item) {
+        //     return item.journal_id[0] === id;
+        //   });
+        // },
+
+        getAccountInvoice:function() {
+            var self = this;
+            var content = self.AccountInvoice;
+            var company = self.$el.find('#current-company').val();
+            var store = self.$el.find('#current-store').val();
+            var state = self.$el.find('#current-state').val();
+            var type = self.$el.find('#current-type').val();
+            var invoice_type = self.$el.find('#current-invoice-type').val();
+            var journal = self.$el.find('#current-journal').val();
+            var user = self.$el.find('#current-user').val();
+            var date = self.$el.find('#current-date').val();
+            var desde = self.$el.find('#from').val();
+            var hasta = self.$el.find('#to').val();
+
+            if((store && store == 9999999)||(company && company == 9999999)){
+                var store_ids = _.flatten(_.map(self.ResStore, function (item) {
+                    return item.id;
+                }));
+                var company_ids = _.flatten(_.map(self.ResCompany, function (item) {
+                    return item.id;
+                }));
+                content = _.flatten(_.filter(content,function (item) {
+                    return _.contains(store_ids, item.store_id) && _.contains(company_ids, item.company_id);
+                }));
+            }
+
+            if(company && company != 9999999){
+                content = _.flatten(_.filter(content,function (item) {
+                    return item.company_id == company;
+                }));
+            }
+            if(store && store != 9999999){
+                content = _.flatten(_.filter(content,function (item) {
+                    return item.store_id == store;
+                }));
+            }
+            if(state && state != 9999999){
+                content = _.flatten(_.filter(content,function (item) {
+                    return item.state == state;
+                }));
+            }
+            if(type && type != 9999999){
+                if(type == 'tpv'){
+                    content = [];
+                }
+            }
+            if(invoice_type && invoice_type != 9999999){
+              if (invoice_type == 'credit'){
+                content = _.flatten(_.filter(content,function (item) {
+                    return item.credito == true;
+                }));
+
+              }
+
+              if(invoice_type == 'cash'){
+                content = _.flatten(_.filter(content,function (item) {
+                    return item.contado == true;
+                }));
+              }
+            }
+
+            if(journal && journal != 9999999){
+                content = _.flatten(_.filter(content,function (item) {
+                    return item.journal_id == journal;
+                }));
+            }
+            if(user && user != 9999999){
+                content = _.flatten(_.filter(content,function (item) {
+                    return item.user_id == user;
+                }));
+            }
+            if(date && date != 9999999){
+                if(date == 'range'){
+                    if(desde){
+                        date = desde.split('/');
+                        date = (date[2]+"-"+date[1]+"-"+date[0]);
+                        content = _.flatten(_.filter(content,function (inv) {
+                            return moment(inv.date).format('YYYY-MM-DD') >= date;
+                        }));
+                    }
+                    if(hasta){
+                        date = hasta.split('/');
+                        date = (date[2]+"-"+date[1]+"-"+date[0]);
+                        content = _.flatten(_.filter(content,function (inv) {
+                            return moment(inv.date).format('YYYY-MM-DD') <= date;
+                        }));
+                    }
+                }
+                if(date == 'today'){
+                    var today = moment().format('YYYY-MM-DD');
+                    content = _.flatten(_.filter(content,function (inv) {
+                        return moment(inv.date).format('YYYY-MM-DD') === today;
+                    }));
+                }
+                if(date == 'yesterday'){
+                    var yesterday = moment().add(-1,'days').format('YYYY-MM-DD');
+                    content = _.flatten(_.filter(content,function (inv) {
+                        return moment(inv.date).format('YYYY-MM-DD') === yesterday;
+                    }));
+                }
+                if(date == 'currentMonth'){
+                    var currentMonth = moment().format('YYYY-MM');
+                    content = _.flatten(_.filter(content,function (inv) {
+                        return moment(inv.date).format('YYYY-MM') === currentMonth;
+                    }));
+                }
+                if(date == 'lastMonth'){
+                    var lastMonth = moment().add(-1,'months').format('YYYY-MM');
+                    content = _.flatten(_.filter(content,function (inv) {
+                        return moment(inv.date).format('YYYY-MM') === lastMonth;
+                    }));
+                }
+            }
+            return content;
         },
 
       /*====================================================================
@@ -546,10 +670,11 @@ function report_cuenta_resumen_dna(reporting){
             var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
           };
 
-          var AccountJournal = self.AccountJournal;
-          _.each(AccountJournal,function(item) {
+          // var AccountJournal = self.AccountJournal;
+          // _.each(AccountJournal,function(item) {
 
-            var AccountInvoice = self.getAccountInvoice(item.id);
+            // var AccountInvoice = self.getAccountInvoice(item.id);
+            var AccountInvoice = self.getAccountInvoice();
             _.each(AccountInvoice,function(item2) {
               var description_product = '';
               if(item2.is_anticipo == false){
@@ -604,7 +729,7 @@ function report_cuenta_resumen_dna(reporting){
 
                       });
               }
-            });
+            // });
           });
 
           self.content = data;
@@ -716,6 +841,8 @@ function report_cuenta_resumen_dna(reporting){
           var store = self.$el.find('#current-store').val();
           var journal = self.$el.find('#current-journal').val();
           var period = self.$el.find('#current-period').val();
+          var state = self.$el.find('#current-state').val();
+          var invoice_type = self.$el.find('#current-invoice-type').val();
           var date = self.$el.find('#current-date').val();
           var desde = self.$el.find('#from').val();
           var hasta = self.$el.find('#to').val();
@@ -731,6 +858,12 @@ function report_cuenta_resumen_dna(reporting){
               value: ResCompany[0].name,
             });
           }
+          if(state && state != 9999999){
+              filter.push({
+                  title: 'Estado',
+                  value: $('#current-state option:selected').text(),
+              });
+          }
 
           if(store && store != 9999999){
             var ResStore =  _.filter(self.ResStore,function (item) {
@@ -764,6 +897,13 @@ function report_cuenta_resumen_dna(reporting){
           //   });
           // }
 
+          if(invoice_type && invoice_type != 9999999){
+              filter.push({
+                  title: 'Tipo de Factura',
+                  value: $('#current-invoice-type option:selected').text(),
+              });
+          }
+
           if(period && period != 9999999){
 
             var AccountPeriod =  _.filter(self.AccountPeriod,function (item) {

+ 15 - 4
static/src/reports/report_cuenta_resumen_dna.xml

@@ -16,12 +16,23 @@
                         <select id="current-store" class="form-control form-control-sm">
                         </select>
                     </div>
-                    <!-- <div class="col-lg-3 journal filter-style">
-                        <label>Vendedor</label>
-                        <select id="current-journal" class="form-control form-control-sm">
+                    <div class="col-lg-3 invoice-type filter-style">
+                        <label>Tipo de Factura</label>
+                        <select id="current-invoice-type" class="form-control form-control-sm">
+                            <option value="9999999">Todos los tipos</option>
+                            <option value="credit">Crédito</option>
+                            <option value="cash">Contado</option>
                         </select>
-                    </div> -->
+                    </div>
 
+                    <div class="col-lg-3 filter-style">
+                        <label>Estado</label>
+                        <select id="current-state" class="form-control form-control-sm">
+                            <option value="9999999">Todos los estados</option>
+                            <option value="open">Abierto</option>
+                            <option value="paid">Pagado</option>
+                        </select>
+                    </div>
 
                     <div class="col-lg-3 filter-style">
                         <label>Periodo</label>