Browse Source

[FIX] poner simbolo de la moneda

Adrielso 7 years ago
parent
commit
e9758eaf1b

+ 33 - 3
static/src/js/widgets/expired_account_counters.js

@@ -8,6 +8,7 @@ function expired_account_counters (widget) {
         resPartner : [],
         moveLine : [],
         resCompany : [],
+        resCurrecy :[],
 
         events: {
             'click a': 'showCustomers',
@@ -43,6 +44,9 @@ function expired_account_counters (widget) {
                 return self.fetchResCompany();
             }).then(function (resCompany){
                 self.resCompany = resCompany;
+                return self.fetchResCurrecy(resCompany);
+            }).then(function (resCurrecy){
+                self.resCurrecy = resCurrecy;
                 return self.fetchReduceMoveLine();
             });
         },
@@ -89,14 +93,35 @@ function expired_account_counters (widget) {
             });
             return defer;
         },
+        // Res currecy
+        fetchResCurrecy : function(company){
+            var self = this;
+            var defer = $.Deferred();
+
+            var id_curency = _.flatten(_.map(company,function(map){
+                return map.currency_id[0];
+            }));
+
+            var fields =['id','name', 'symbol'];
+            var domain =[['id','=',id_curency]];
+            var resCurrecy = new model.web.Model('res.currency');
+
+            resCurrecy.query(fields).filter(domain).all().then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
         // Reduce Move line
         fetchReduceMoveLine: function () {
             var self = this;
             var residual =0;
+
             var company = _.map(self.resCompany, function (map) {
                 return map.currency_id[1]
             });
 
+            var moneda = self.resCurrecy.shift();
+
             if (self.moveLine.length > 0){
                 residual = _.reduce(_.map(self.moveLine, function (map) {
                     return map.amount_residual;
@@ -104,9 +129,14 @@ function expired_account_counters (widget) {
                     return memo + num;
                 });
             }
+            if (moneda.id != 166){
+                residual=accounting.formatNumber(residual,2, ".", ",");
+            }else {
+                residual=accounting.formatNumber(residual, ",", ".");
+            }
 
             self.$el.find('.widget-content.widget-loading').css('display','none');
-            self.$el.find('.widget-content').find('a').text(accounting.formatNumber(residual,2, ".", ",")).append(" <small>"+company+"</small>");
+            self.$el.find('.widget-content').find('a').text(residual).append(" <small>"+moneda.symbol+"</small>");
             self.$el.find('.grid-stack-item-content dashboard').unblock();
         },
 
@@ -116,7 +146,7 @@ function expired_account_counters (widget) {
             var move_id = _.flatten(_.map(self.moveLine, function (map) {
                 return map.id;
             }));
-        console.log(    this.do_action({
+            this.do_action({
                 name:"Listado de clientes con deudas atrasadas",
                 type: 'ir.actions.act_window',
                 res_model: "res.partner",
@@ -124,7 +154,7 @@ function expired_account_counters (widget) {
                 target: 'new',
                 domain: [['unreconciled_aml_ids', 'in', move_id]],
                 context: {},
-            }));
+            });
         }
     });
 }

+ 30 - 2
static/src/js/widgets/expired_account_counters_now.js

@@ -8,7 +8,7 @@ function expired_account_counters_now (widget) {
         resPartner : [],
         moveLine : [],
         resCompany : [],
-
+        resCompany :[],
         events: {
             'click a': 'showCustomers',
             'click h2': 'showCustomers',
@@ -43,6 +43,9 @@ function expired_account_counters_now (widget) {
                 return self.fetchResCompany();
             }).then(function(resCompany){
                 self.resCompany=resCompany;
+                return self.fetchResCurrecy(resCompany);
+            }).then(function(resCurrecy){
+                self.resCompany= resCurrecy;
                 return self.fetchReduceMoveLine();
             });
         },
@@ -90,10 +93,29 @@ function expired_account_counters_now (widget) {
             });
             return defer ;
         } ,
+        // Res currecy
+        fetchResCurrecy : function(company){
+            var self = this;
+            var defer = $.Deferred();
+
+            var id_curency = _.flatten(_.map(company,function(map){
+                return map.currency_id[0];
+            }));
+
+            var fields =['id','name', 'symbol'];
+            var domain =[['id','=',id_curency]];
+            var resCurrecy = new model.web.Model('res.currency');
+
+            resCurrecy.query(fields).filter(domain).all().then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
         // Reduce Move line
         fetchReduceMoveLine: function () {
             var self = this;
             var residual =0;
+            var moneda =self.resCompany.shift();
             var company = _.map(self.resCompany, function(map){
                 return map.currency_id[1];
             });
@@ -106,8 +128,14 @@ function expired_account_counters_now (widget) {
                 });
             }
 
+            if (moneda.id !=166){
+                residual= accounting.formatNumber(residual,2, ".", ",");
+            }else{
+                residual= accounting.formatNumber(residual,",", ".");
+            }
+
             self.$el.find('.widget-content.widget-loading').css('display','none');
-            self.$el.find('.widget-content').find('a').text(accounting.formatNumber(residual,2, ".", ",")).append(' <small>'+company+'</small>');
+            self.$el.find('.widget-content').find('a').text(residual).append(' <small>'+moneda.symbol+'</small>');
             // self.$el.find('.widget-footer').find('span').text("Monto en " + company);
             self.$el.find('#morosidad').unblock()
         },

+ 31 - 1
static/src/js/widgets/monthly_expenses.js

@@ -49,6 +49,9 @@ function monthly_expenses(widget) {
                 return self.fetchResCompany();
             }).then(function(resCompany){
                 self.resCompany = resCompany;
+                return self.fetchResCurrecy(resCompany);
+            }).then(function(resCurrecy){
+                self.resCurrecy = resCurrecy;
                 return self.fetchReduceVoucher();
             });
         },
@@ -103,7 +106,24 @@ function monthly_expenses(widget) {
 
             return defer;
         },
+        // Res currecy
+        fetchResCurrecy : function(company){
+            var self = this;
+            var defer = $.Deferred();
+
+            var id_curency = _.flatten(_.map(company,function(map){
+                return map.currency_id[0];
+            }));
+
+            var fields =['id','name', 'symbol'];
+            var domain =[['id','=',id_curency]];
+            var resCurrecy = new model.web.Model('res.currency');
 
+            resCurrecy.query(fields).filter(domain).all().then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
         fetchReduceVoucher: function () {
             var self = this;
             var newVoucher;
@@ -112,6 +132,7 @@ function monthly_expenses(widget) {
             var itemVoucher;
             var itemCurrencyRate;
             var company;
+            var moneda = self.resCurrecy.shift();
             newVoucher = self.getVoucherInvoice();
             for (var i = 0; i < newVoucher.length; i++) {
                 itemVoucher = newVoucher[i];
@@ -124,6 +145,7 @@ function monthly_expenses(widget) {
                                 amount_rate :(itemVoucher.amount/itemCurrencyRate.rate)
                             });
             }
+
             if (voucher.length > 0){
                 cat = _.reduce(_.map(voucher, function (map) {
                     return map.amount_rate;
@@ -131,11 +153,19 @@ function monthly_expenses(widget) {
                     return memo + num;
                 });
             }
+
             company = _.map(self.resCompany, function (map) {
                 return map.currency_id[1];
             });
+
+            if (moneda.id != 166){
+                cat = accounting.formatNumber(cat,2, ".", ",");
+            }else {
+                cat = accounting.formatNumber(cat, ",", ".");
+            }
+
             self.$el.find('.widget-content.widget-loading').css('display','none');
-            self.$el.find('.widget-content').find('a').text(accounting.formatNumber(cat,2, ".", ",")).append(' <small>'+company+'</small>');
+            self.$el.find('.widget-content').find('a').text(cat).append(' <small>'+moneda.symbol+'</small>');
             self.$el.find('#morosidad').unblock();
         },
         getCutrrencyRate: function (currency_id) {

+ 28 - 1
static/src/js/widgets/monthly_purchases.js

@@ -46,6 +46,9 @@ function monthly_purchases(widget) {
                 return self.fetchResCompany();
             }).then(function(resCompany){
                 self.resCompany = resCompany;
+                return self.fetchResCurrecy(resCompany);
+            }).then(function(resCurrecy){
+                self.resCurrecy = resCurrecy;
                 return self.fetchReduceVoucher();
 
             });
@@ -101,6 +104,24 @@ function monthly_purchases(widget) {
 
             return defer;
         },
+        // Res currecy
+        fetchResCurrecy : function(company){
+            var self = this;
+            var defer = $.Deferred();
+
+            var id_curency = _.flatten(_.map(company,function(map){
+                return map.currency_id[0];
+            }));
+
+            var fields =['id','name', 'symbol'];
+            var domain =[['id','=',id_curency]];
+            var resCurrecy = new model.web.Model('res.currency');
+
+            resCurrecy.query(fields).filter(domain).all().then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
 
         fetchReduceVoucher: function () {
             var self = this;
@@ -110,6 +131,7 @@ function monthly_purchases(widget) {
             var itemVoucher;
             var itemCurrencyRate;
             var company;
+            var moneda = self.resCurrecy.shift();
             newVoucher = self.getVoucherInvoice();
             for (var i = 0; i < newVoucher.length; i++) {
                 itemVoucher = newVoucher[i];
@@ -133,8 +155,13 @@ function monthly_purchases(widget) {
                 return map.currency_id[1];
             });
 
+            if (moneda.id != 166){
+                cat = accounting.formatNumber(cat,2, ".", ",");
+            }else{
+                cat = accounting.formatNumber(cat, ",", ".");
+            }
             self.$el.find('.widget-content.widget-loading').css('display','none');
-            self.$el.find('.widget-content').find('a').text(accounting.formatNumber(cat,2, ".", ",")).append(' <small>'+company+'</small>');
+            self.$el.find('.widget-content').find('a').text(cat).append(' <small>'+moneda.symbol+'</small>');
             // self.$el.find('.widget-footer').find('span').text("Monto en "+ company);
             self.$el.find('#morosidad').unblock();
         },

+ 29 - 1
static/src/js/widgets/payments_today_counters.js

@@ -39,6 +39,9 @@ function payments_today_counters (widget) {
                 return self.fetchResCompany();
             }).then(function (resCompany) {
                 self.resCompany = resCompany;
+                return self.fetchResCurrecy(resCompany);
+            }).then(function(resCurrecy){
+                self.resCurrecy = resCurrecy;
                 return self.fetchCurrency();
             }).then(function (currencyRate) {
                 self.currencyRate = currencyRate;
@@ -85,6 +88,24 @@ function payments_today_counters (widget) {
 
             return defer;
         },
+        // Res currecy
+        fetchResCurrecy : function(company){
+            var self = this;
+            var defer = $.Deferred();
+
+            var id_curency = _.flatten(_.map(company,function(map){
+                return map.currency_id[0];
+            }));
+
+            var fields =['id','name', 'symbol'];
+            var domain =[['id','=',id_curency]];
+            var resCurrecy = new model.web.Model('res.currency');
+
+            resCurrecy.query(fields).filter(domain).all().then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
         //   voucherCurrencyRate
         fetchVoucherCurrency: function () {
             var self = this;
@@ -118,6 +139,7 @@ function payments_today_counters (widget) {
             var company = _.map(self.resCompany, function (map) {
                 return map.currency_id[1];
             });
+            var moneda = self.resCurrecy.shift();
             if (newVoucher.length > 0) {
                 residual = _.reduce(_.map(newVoucher, function (map) {
                     return map.amount_rate;
@@ -126,8 +148,14 @@ function payments_today_counters (widget) {
                 });
             }
 
+            if (moneda.id != 166){
+                residual = accounting.formatNumber(residual, 2, ".", ",");
+            }else{
+                residual = accounting.formatNumber(residual, 2, ".", ",");
+            }
+
             self.$el.find('.widget-content.widget-loading').css('display','none');
-            self.$el.find('.widget-content').find('a').text(accounting.formatNumber(residual, 2, ".", ",")).append(' <small>'+company+'</small>');
+            self.$el.find('.widget-content').find('a').text(residual).append(' <small>'+moneda.symbol+'</small>');
             // self.$el.find('.widget-footer').find('span').text("Monto en "+ company);
             self.$el.find('#morosidad').unblock();
         },

+ 0 - 1
static/src/js/widgets/ranking_sales_product.js

@@ -112,7 +112,6 @@ function ranking_sales_product (widget) {
                             return meno + num
                         }, 0);
                         lineUnik = itemLine.shift();
-                        console.log(lineUnik);
                         ranking.push({
                             product: lineUnik.product_id[1],
                             qty: cat,

+ 29 - 1
static/src/js/widgets/voucher_today_counters.js

@@ -39,6 +39,9 @@ function voucher_today_counters (widget) {
                 return self.fetchResCompany();
             }).then(function (resCompany) {
                 self.resCompany = resCompany;
+                return self.fetchResCurrecy(resCompany);
+            }).then(function(resCurrecy){
+                self.resCurrecy = resCurrecy;
                 return self.fetchCurrency();
             }).then(function (currencyRate) {
                 self.currencyRate = currencyRate;
@@ -85,6 +88,24 @@ function voucher_today_counters (widget) {
 
             return defer;
         },
+        // Res currecy
+        fetchResCurrecy : function(company){
+            var self = this;
+            var defer = $.Deferred();
+
+            var id_curency = _.flatten(_.map(company,function(map){
+                return map.currency_id[0];
+            }));
+
+            var fields =['id','name', 'symbol'];
+            var domain =[['id','=',id_curency]];
+            var resCurrecy = new model.web.Model('res.currency');
+
+            resCurrecy.query(fields).filter(domain).all().then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
         //   voucherCurrencyRate
         fetchVoucherCurrency: function () {
             var self = this;
@@ -115,6 +136,7 @@ function voucher_today_counters (widget) {
         fetchReduceMoveLine: function (newVoucher) {
             var self = this;
             var residual =0;
+            var moneda = self.resCurrecy.shift();
             var company = _.map(self.resCompany, function (map) {
                 return map.currency_id[1];
             });
@@ -126,8 +148,14 @@ function voucher_today_counters (widget) {
                 });
             }
 
+            if (moneda.id !=166){
+                residual = accounting.formatNumber(residual, 2, ".", ",");
+            }else{
+                residual = accounting.formatNumber(residual, ",", ".");
+            }
+
             self.$el.find('.widget-content.widget-loading').css('display','none');
-            self.$el.find('.widget-content').find('a').text(accounting.formatNumber(residual, 2, ".", ",")).append(' <small>'+company+'</small>');
+            self.$el.find('.widget-content').find('a').text(residual).append(' <small>'+moneda.symbol+'</small>');
             // self.$el.find('.widget-footer').find('span').text("Monto en "+ company);
             self.$el.find('#morosidad').unblock();
         },