Selaa lähdekoodia

[FIX] Indentación de codigo widget compras del mes

adrielso 7 vuotta sitten
vanhempi
commit
6514723027
1 muutettua tiedostoa jossa 58 lisäystä ja 47 poistoa
  1. 58 47
      static/src/js/widgets/monthly_purchases.js

+ 58 - 47
static/src/js/widgets/monthly_purchases.js

@@ -1,14 +1,14 @@
 function monthly_purchases(widget) {
     "use strict";
 
-    var model= openerp;
+    var model = openerp;
 
     widget.MonthlyPurchasesWidget = widget.Base.extend({
         template: 'MonthlyPurchases',
-        accountVoucher:[],
-        accountInvoice:[],
-        resCurrecy :[],
-        resCompany:[],
+        accountVoucher: [],
+        accountInvoice: [],
+        resCurrecy: [],
+        resCompany: [],
 
         events: {
             'click a': 'showCustomers',
@@ -17,7 +17,7 @@ function monthly_purchases(widget) {
 
         init: function (parent) {
             this._super(parent, {
-                width : 3,
+                width: 3,
                 height: 2
             });
         },
@@ -27,7 +27,7 @@ function monthly_purchases(widget) {
             self.fetchInitial();
         },
 
-        fetchInitial: function(){
+        fetchInitial: function() {
             var self = this;
             self.$el.find('#morosidad').block({
                 message: null,
@@ -35,6 +35,7 @@ function monthly_purchases(widget) {
                     backgroundColor: '#FAFAFA'
                 }
             });
+
             self.$el.find('.widget-content.widget-loading').css('display','flex');
 
             self.fetchAccountVoucher().then(function (accountVoucher) {
@@ -42,54 +43,56 @@ function monthly_purchases(widget) {
             }).then(function (accountVoucher) {
                 self.accountVoucher = accountVoucher;
                 return self.fetchAccountInvoice(accountVoucher);
-            }).then(function(accountInvoice){
+            }).then(function(accountInvoice) {
                 self.accountInvoice = accountInvoice;
                 return self.fetchResCompany();
-            }).then(function(resCompany){
+            }).then(function(resCompany) {
                 self.resCompany = resCompany;
                 return self.fetchResCurrecy();
-            }).then(function(resCurrecy){
+            }).then(function(resCurrecy) {
                 self.resCurrecy = resCurrecy;
                 return self.fetchReduceVoucher();
             });
         },
         // Account Voucher Pagos a facturas Proveedores
-        fetchAccountVoucher: function(){
+        fetchAccountVoucher: function() {
             var self = this;
             var defer = $.Deferred();
-            var desde =moment().format('YYYY-MM-01');
-            var hasta =moment().add(1,'months').format('YYYY-MM-01');
+            var desde = moment().format('YYYY-MM-01');
+            var hasta = moment().add(1,'months').format('YYYY-MM-01');
             var fields = ['id', 'amount', 'currency_id', 'payment_rate_currency_id', 'reference'];
-            var domain= [['type', '=', 'payment'],['state', '=', 'posted'],['date', '>=',desde],['date','<',hasta]];
+            var domain = [['type', '=', 'payment'],['state', '=', 'posted'],['date', '>=',desde],['date','<',hasta]];
             var accountVoucher = new model.web.Model('account.voucher');
 
-            accountVoucher.query(fields).filter(domain).all().then(function(results){
+            accountVoucher.query(fields).filter(domain).all().then(function(results) {
                 defer.resolve(results);
             });
 
             return defer;
         },
         // invoice
-        fetchAccountInvoice:function(voucher){
+        fetchAccountInvoice:function(voucher) {
             var self = this;
             var defer = $.Deferred();
-            var number = _.map(voucher,function(map){return map.reference});
+            var number = _.map(voucher,function(map) {
+                return map.reference;
+            });
             var fields = ['id','number','date_invoice','origin'];
             var domain = [['type', '=', 'in_invoice'],['origin', '!=', false ],['number', 'in', number]];
-            var accountInvoice= new model.web.Model('account.invoice');
+            var accountInvoice = new model.web.Model('account.invoice');
 
-            accountInvoice.query(fields).filter(domain).all().then(function(results){
+            accountInvoice.query(fields).filter(domain).all().then(function(results) {
                 defer.resolve(results);
             });
 
             return defer;
         },
         //Comapnia
-        fetchResCompany: function(){
+        fetchResCompany: function() {
             var self = this;
             var defer = $.Deferred();
-            var fields =['id','name', 'currency_id', 'logo'];
-            var domain =[['id', '=', 1]];
+            var fields = ['id','name', 'currency_id', 'logo'];
+            var domain = [['id', '=', 1]];
             var resCompany = new model.web.Model('res.company');
 
             resCompany.query(fields).filter(domain).all().then(function (results) {
@@ -99,14 +102,14 @@ function monthly_purchases(widget) {
             return defer;
         },
         // Res currecy
-        fetchResCurrecy : function(){
+        fetchResCurrecy : function() {
             var self = this;
             var defer = $.Deferred();
-            var fields =['id','name', 'symbol', 'rate_silent', 'base', 'decimal_separator', 'decimal_places', 'thousands_separator', 'symbol_position'];
-            var domain =[['active','=', true]];
+            var fields = ['id','name', 'symbol', 'rate_silent', 'base', 'decimal_separator', 'decimal_places', 'thousands_separator', 'symbol_position'];
+            var domain = [['active','=', true]];
             var resCurrecy = new model.web.Model('res.currency');
 
-            resCurrecy.query(fields).filter(domain).all().then(function(results){
+            resCurrecy.query(fields).filter(domain).all().then(function(results) {
                 defer.resolve(results);
             });
 
@@ -115,7 +118,7 @@ function monthly_purchases(widget) {
 
         fetchReduceVoucher: function () {
             var self = this
-            var voucher=[];
+            var voucher = [];
             var newVoucher = self.getVoucherInvoice();
             var itemVoucher;
             var currencyVoucher;
@@ -127,16 +130,17 @@ function monthly_purchases(widget) {
                 itemVoucher = newVoucher[i];
                 currencyVoucher = self.getCurrency(itemVoucher.payment_rate_currency_id[0]).shift();
 
-                if(!currencyVoucher){
-                    currencyVoucher={};
-                    currencyVoucher.rate=currencyBase.rate_silent;
+                if(!currencyVoucher) {
+                    currencyVoucher = {};
+                    currencyVoucher.rate = currencyBase.rate_silent;
                 }
-                voucher.push({  ammount : itemVoucher.amount,
-                                amount_rate :(itemVoucher.amount* (currencyBase.rate_silent/currencyVoucher.rate_silent))
-                            });
+                voucher.push({
+                    ammount: itemVoucher.amount,
+                    amount_rate: (itemVoucher.amount* (currencyBase.rate_silent/currencyVoucher.rate_silent))
+                });
             }
 
-            if (voucher.length > 0){
+            if (voucher.length > 0) {
                 cat = _.reduce(_.map(voucher, function (map) {
                     return map.amount_rate;
                 }), function (memo, num) {
@@ -145,7 +149,7 @@ function monthly_purchases(widget) {
             }
 
             self.$el.find('.widget-content.widget-loading').css('display','none');
-            self.$el.find('.widget-content').find('a').text(accounting.formatMoney(cat, currencyBase.symbol, currencyBase.decimal_places, currencyBase.thousands_separator, currencyBase.decimal_separator))
+            self.$el.find('.widget-content').find('a').text(accounting.formatMoney(cat, currencyBase.symbol, currencyBase.decimal_places, currencyBase.thousands_separator, currencyBase.decimal_separator));
             self.$el.find('#morosidad').unblock();
         },
         // Obtener la moneda
@@ -156,14 +160,14 @@ function monthly_purchases(widget) {
             })
         },
         // obtneer los pagos con origin
-        getVoucherInvoice:function(){
+        getVoucherInvoice:function() {
             var self = this;
-            var number =    _.map(self.accountInvoice, function(map){
-                                return map.number;
-                            });
-            return  _.flatten(_.filter(self.accountVoucher,function(item){
-                        return _.contains(number,item.reference);
-                    }));
+            var number = _.map(self.accountInvoice, function(map) {
+                return map.number;
+            });
+            return  _.flatten(_.filter(self.accountVoucher,function(item) {
+                return _.contains(number,item.reference);
+            }));
         },
         // modal
         showCustomers: function (e) {
@@ -173,20 +177,27 @@ function monthly_purchases(widget) {
                 model.web.notification.do_warn("Atención","Sin datos");
                 return
             }
-            var hoy =moment().format('YYYY-MM-DD');
-            var desde =moment().format('YYYY-MM-01');
-            var hasta =moment().add(1,'months').format('YYYY-MM-01');
+            var hoy = moment().format('YYYY-MM-DD');
+            var desde = moment().format('YYYY-MM-01');
+            var hasta = moment().add(1,'months').format('YYYY-MM-01');
             var number = _.map(self.accountInvoice,function(map){return map.number});
 
             this.do_action({
-                name:"Listado de compras del mes",
+                name: "Listado de compras del mes",
                 type: 'ir.actions.act_window',
                 res_model: "account.voucher",
                 views: [[false, 'list'],[false,'form']],
                 target: 'new',
                 domain: [['type', '=', 'payment'],['state', '=', 'posted'],['date', '>=',desde],['date','<',hasta],['reference','in',number]],
                 context: {},
-                flags: {'form': {'action_buttons': false, 'options': {'mode': 'view'}}},
+                flags: {
+                    'form': {
+                        'action_buttons': false,
+                        'options': {
+                            'mode': 'view'
+                        }
+                    }
+                },
             });
         }
     });