فهرست منبع

Modificar informes de cuentas

root 3 سال پیش
والد
کامیت
220029b264
1فایلهای تغییر یافته به همراه80 افزوده شده و 59 حذف شده
  1. 80 59
      static/src/js/reports/report_cuenta_resumen_dna.js

+ 80 - 59
static/src/js/reports/report_cuenta_resumen_dna.js

@@ -327,13 +327,13 @@ function report_cuenta_resumen_dna(reporting){
             if(date && date != 9999999){
 
                 if(desde){
-                    var date = desde.split('/')
+                    date = desde.split('/')
                     date = (date[2]+"-"+date[1]+"-"+date[0]);
                     domain.push(['date_invoice','>=',date]);
                 }
 
                 if(hasta){
-                    var date = hasta.split('/')
+                    date = hasta.split('/')
                     date = (date[2]+"-"+date[1]+"-"+date[0]);
                     domain.push(['date_invoice','<=',date]);
                 }
@@ -535,7 +535,7 @@ function report_cuenta_resumen_dna(reporting){
         },
 
 
-        getAccountInvoice:function() {
+        getAccountInvoice:function(id) {
             var self = this;
             var content = self.AccountInvoice;
             var company = self.$el.find('#current-company').val();
@@ -549,102 +549,124 @@ function report_cuenta_resumen_dna(reporting){
             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);
-                }));
-            }
+            content = _.flatten(_.filter(content,function (inv) {
+                return inv.id == 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;
+                content = _.flatten(_.filter(content,function (inv) {
+                    return inv.store_id == store;
                 }));
             }
-            if(type && type != 9999999){
-                if(type == 'tpv'){
-                    content = [];
+
+            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 inv.date >= date;
+                        }));
+                    }
+                    if(hasta){
+                        date = hasta.split('/');
+                        date = (date[2]+"-"+date[1]+"-"+date[0]);
+                        content = _.flatten(_.filter(content,function (inv) {
+                            return inv.date<= date;
+                        }));
+                    }
+                }
+                if(date == 'today'){
+                    var today = moment().format('YYYY-MM-DD');
+                    content = _.flatten(_.filter(content,function (inv) {
+                        return inv.date === today;
+                    }));
+                }
+                if(date == 'yesterday'){
+                    var yesterday = moment().add(-1,'days').format('YYYY-MM-DD');
+                    content = _.flatten(_.filter(content,function (inv) {
+                        return inv.date === 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;
+                    }));
                 }
             }
-            if(invoice_type && invoice_type != 9999999){
-              if (invoice_type == 'credit'){
-                content = _.flatten(_.filter(content,function (item) {
-                    return item.credito == true;
-                }));
+            return content;
+        },
 
-              }
+        getPosOrderLine: function (id) {
+            var self = this;
+            var content = self.PosOrderLine;
+            var state = self.$el.find('#current-state').val();
+            var date = self.$el.find('#current-date').val();
+            var desde = self.$el.find('#from').val();
+            var hasta = self.$el.find('#to').val();
 
-              if(invoice_type == 'cash'){
-                content = _.flatten(_.filter(content,function (item) {
-                    return item.contado == true;
-                }));
-              }
-            }
+            content = _.flatten(_.filter(content,function (inv) {
+                return inv.store_id == id;
+            }));
 
-            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;
+                            var utc = moment.utc(inv.date,'YYYY-MM-DD h:mm:ss A');
+                            utc = moment(utc._d).format('YYYY-MM-DD');
+                            return moment(utc).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;
+                            var utc = moment.utc(inv.date,'YYYY-MM-DD h:mm:ss A');
+                            utc = moment(utc._d).format('YYYY-MM-DD');
+                            return moment(utc).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;
+                        var utc = moment.utc(inv.date,'YYYY-MM-DD h:mm:ss A');
+                        utc = moment(utc._d).format('YYYY-MM-DD');
+                        return moment(utc).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;
+                        var utc = moment.utc(inv.date,'YYYY-MM-DD h:mm:ss A');
+                        utc = moment(utc._d).format('YYYY-MM-DD');
+                        return moment(utc).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;
+                        var utc = moment.utc(inv.date,'YYYY-MM-DD h:mm:ss A');
+                        utc = moment(utc._d).format('YYYY-MM-DD');
+                        return moment(utc).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;
+                        var utc = moment.utc(inv.date,'YYYY-MM-DD h:mm:ss A');
+                        utc = moment(utc._d).format('YYYY-MM-DD');
+                        return moment(utc).format('YYYY-MM') == lastMonth;
                     }));
                 }
             }
@@ -666,7 +688,6 @@ function report_cuenta_resumen_dna(reporting){
         ====================================================================*/
         BuildTable: function(){
           var self = this;
-
           var data = [];
 
           var company = $('#current-company').val();
@@ -682,7 +703,7 @@ function report_cuenta_resumen_dna(reporting){
           // _.each(AccountJournal,function(item) {
 
             // var AccountInvoice = self.getAccountInvoice(item.id);
-            var AccountInvoice = self.getAccountInvoice();
+            var AccountInvoice = self.AccountInvoice;
             _.each(AccountInvoice,function(item2) {
               if (item2.residual>0){
                     var description_product = '';