Bladeren bron

[FIX] imprimir la moneda de la compania

Adrielso 7 jaren geleden
bovenliggende
commit
d6ae5be2c7
1 gewijzigde bestanden met toevoegingen van 45 en 11 verwijderingen
  1. 45 11
      static/src/js/eiru_reporting.js

+ 45 - 11
static/src/js/eiru_reporting.js

@@ -191,6 +191,7 @@ openerp.eiru_reporting = function (instance, local) {
          rowsDate :[],
          rowOrigin:[],
          accountJournal:[],
+         resCompany:[],
 
         events:{
           'click #toolbar > button' : 'clickOnAction',
@@ -238,10 +239,25 @@ openerp.eiru_reporting = function (instance, local) {
                 return self.fecthProduct(invoiceLines);
             }).then(function(productProduct){
                 self.productProduct = productProduct;
+                return self.fecthComanyCurrency();
+            }).then(function(resCompany){
+                self.resCompany = resCompany;
                 return self.invoice_Currency();
             });
             return false;
         },
+        // company_curency
+        fecthComanyCurrency: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var currency = new instance.web.Model('res.company');
+            var field=['id', 'currency_id'];
+            var domain=[['id','=',1]];
+            currency.query(field).filter(domain).all().then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
         // Fecha
         fecthFecha: function() {
             var to;
@@ -524,8 +540,11 @@ openerp.eiru_reporting = function (instance, local) {
 
             rowsPdf=rows;
 
+            var company = _.map(self.resCompany, function (map) {
+                return map.currency_id[1];
+            });
             rowsPdf.push({ number : "  ",
-                        name : "TOTAL  USD  ",
+                        name : "TOTAL "+company,
                         quantity: accounting.formatNumber(quantity,0, ".", ","),
                         price_unity : accounting.formatNumber(precio_unit,2, ".", ","),
                         standar_price : accounting.formatNumber(precio_cost,2, ".", ","),
@@ -535,7 +554,7 @@ openerp.eiru_reporting = function (instance, local) {
                     });
 
             rowsPdf.unshift({ number : "  ",
-                        name : "TOTAL  USD  ",
+                        name : "TOTAL "+company,
                         quantity: accounting.formatNumber(quantity,0, ".", ","),
                         price_unity : accounting.formatNumber(precio_unit,2, ".", ","),
                         standar_price : accounting.formatNumber(precio_cost,2, ".", ","),
@@ -621,6 +640,9 @@ openerp.eiru_reporting = function (instance, local) {
         },
         // Chart
         drawChart: function (dataHeader,dataBody) {
+            var company = _.map(self.resCompany, function (map) {
+                return map.currency_id[1];
+            });
             var barChart = new Chart(this.$el.find('canvas'), {
               // type:"doughnut",
 
@@ -629,7 +651,7 @@ openerp.eiru_reporting = function (instance, local) {
                     labels: dataHeader,
                     datasets: [
                         {
-                            label: "Utilidad USD",
+                            label: "Utilidad "+company,
                             backgroundColor: [
                                 'rgba(255, 99, 132, 0.2)',
                                 'rgba(54, 162, 235, 0.2)',
@@ -1456,7 +1478,7 @@ openerp.eiru_reporting = function (instance, local) {
         accountJournal:[],
         dataVoucher:[],
         currencyRate:[],
-
+        resCompany:[],
         events:{
           'click #toolbar > button' : 'clickOnAction',
           'change #current-journal': 'fectSearch',
@@ -1530,10 +1552,25 @@ openerp.eiru_reporting = function (instance, local) {
                 return self.fecthVoucher();
             }).then(function(accountVoucher){
                 self.accountVoucher =accountVoucher;
+                return self.fecthComanyCurrency();
+            }).then(function(resCompany){
+                self.resCompany = resCompany;
                 return self.fecthDataVoucher(self.accountVoucher,self.accountJournal);
             });
             return false;
         },
+        // company_curency
+        fecthComanyCurrency: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var currency = new instance.web.Model('res.company');
+            var field=['id', 'currency_id'];
+            var domain=[['id','=',1]];
+            currency.query(field).filter(domain).all().then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
         // Journal
         fecthJournalStore: function(){
             var self = this;
@@ -1635,10 +1672,13 @@ openerp.eiru_reporting = function (instance, local) {
                                         })
                     }
                 }
+                var company = _.map(self.resCompany, function (map) {
+                    return map.currency_id[1];
+                });
                 sumaAmountTot=_.reduce(_.map(voucherObjectItem,function(item){return (item.amountBase)}), function(memo, num){ return memo + num; },0);
                 total=total+sumaAmountTot;
                 voucherObjectItem.push({journal : " ",
-                                        method  :"Total Dolares",
+                                        method  :"Total "+ company,
                                         amount  : accounting.formatNumber(self.valorNull(sumaAmountTot),2, ".", ","),
                                         currency_name : "",
                                         currency_id : "",
@@ -1867,12 +1907,6 @@ openerp.eiru_reporting = function (instance, local) {
         },
     });
 
-
-
-
-
-
-
     local.ReportStockLocationWidget = instance.Widget.extend({
         template : 'ReportStockLocation',
         stockLocation : [],