deisy 6 년 전
부모
커밋
bee9465a5d
1개의 변경된 파일40개의 추가작업 그리고 41개의 파일을 삭제
  1. 40 41
      static/src/js/reports/report_salesman_commission.js

+ 40 - 41
static/src/js/reports/report_salesman_commission.js

@@ -1,4 +1,4 @@
-function report_salesman_commission(reporting){
+function report_salesman_commission(reporting) {
   "use strict";
 
   var model = openerp;
@@ -19,16 +19,18 @@ function report_salesman_commission(reporting){
       this._super(parent);
     },
 
-    start: function () {
+    start: function() {
       var table = this.$el.find('#table');
-      table.bootstrapTable({data : self.rowsData});
+      table.bootstrapTable({
+        data: self.rowsData
+      });
       var date = new model.eiru_reports.ReportDatePickerWidget(self);
       date.fecthFecha();
       this.fetchInitial();
-     },
+    },
 
     valorNull: function(dato) {
-      var valor = "";
+      var valor = 0;
       if (dato) {
         valor = dato;
       }
@@ -148,16 +150,11 @@ function report_salesman_commission(reporting){
       var defer = $.Deferred();
       var fields = ['id', 'name', 'store_id'];
       var user = self.$el.find('#current-user').val();
-      var store = self.$el.find('#current-store').val();
 
       var domain = [
         ['active', '=', true]
       ];
 
-      if(store && store != 9999999){
-        domain.push(['store_id','=', parseInt(store)]);
-      }
-
       if (user && user != 9999999) {
         domain.push(['id', '=', parseInt(user)]);
       }
@@ -235,7 +232,7 @@ function report_salesman_commission(reporting){
         ACCOUNT INVOICE
     ====================================================================*/
 
-    fetchAccountInvoice: function () {
+    fetchAccountInvoice: function() {
       var self = this;
       var defer = $.Deferred();
 
@@ -269,12 +266,12 @@ function report_salesman_commission(reporting){
         domain.push(['period_id', '=', parseInt(period)]);
       }
 
-      var field =['id', 'number', 'state','type','amount_total','user_id','company_id','period_id','date_invoice','journal_id', 'credito','contado'];
+      var field = ['id', 'number', 'state', 'type', 'amount_total', 'user_id', 'company_id', 'period_id', 'date_invoice', 'journal_id', 'credito', 'contado'];
       var AccountInvoice = new model.web.Model('account.invoice');
-      AccountInvoice.query(field).filter(domain).all().then(function (results) {
+      AccountInvoice.query(field).filter(domain).all().then(function(results) {
         defer.resolve(results);
       });
-        return defer;
+      return defer;
     },
 
 
@@ -388,8 +385,8 @@ function report_salesman_commission(reporting){
     getCommission: function(type) {
       var self = this;
       return _.map(_.filter(self.Commission, function(item) {
-          return item.sale_type == type
-      }), function(map){
+        return item.sale_type == type
+      }), function(map) {
         return map.sale_commission;
       })
     },
@@ -400,7 +397,7 @@ function report_salesman_commission(reporting){
     BuildTable: function() {
       var self = this;
       var data = [];
-      var x= 9999999;
+      var x = 9999999;
       var company = $('#current-company').val();
       var store = $('#current-store').val();
 
@@ -423,36 +420,38 @@ function report_salesman_commission(reporting){
         var contado_amount = self.getCommission("contado");
 
         var AccountInvoice = self.getAccountInvoice(i.id);
-        _.each(AccountInvoice, function(item){
-          if (item.credito == true){
+        _.each(AccountInvoice, function(item) {
+          if (item.credito == true) {
             suma_credito = suma_credito + item.amount_total;
           }
 
-          if (item.contado == true){
+          if (item.contado == true) {
             suma_contado = suma_contado + item.amount_total;
           }
         })
 
-        credito_commission = suma_credito * (credito_amount[0]/100);
-        contado_commission = suma_contado * (contado_amount[0]/100);
+        credito_commission = suma_credito * (credito_amount[0] / 100);
+        contado_commission = suma_contado * (contado_amount[0] / 100);
 
-        data.push({
-          user : i.name,
+        if (suma_contado > 0 || suma_credito > 0){
+          data.push({
+            user: i.name,
 
-          suma_credito : accounting.formatMoney(suma_credito, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
-          suma_contado : accounting.formatMoney(suma_contado, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
-          credito_commission : accounting.formatMoney(credito_commission, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
-          contado_commission : accounting.formatMoney(contado_commission, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+            suma_credito: accounting.formatMoney(suma_credito, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+            suma_contado: accounting.formatMoney(suma_contado, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+            credito_commission: accounting.formatMoney(credito_commission, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+            contado_commission: accounting.formatMoney(contado_commission, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
 
-          suma_credito_no_format : self.valorNull(suma_credito),
-          suma_contado_no_format : self.valorNull(suma_contado),
-          credito_commission_no_format : self.valorNull(credito_commission),
-          contado_commission_no_format : self.valorNull(contado_commission),
+            suma_credito_no_format: self.valorNull(suma_credito),
+            suma_contado_no_format: self.valorNull(suma_contado),
+            credito_commission_no_format: self.valorNull(credito_commission),
+            contado_commission_no_format: self.valorNull(contado_commission),
 
-          decimal_places: CurrencyBase.decimal_places,
-          thousands_separator: CurrencyBase.thousands_separator,
-          decimal_separator: CurrencyBase.decimal_separator,
-        });
+            decimal_places: CurrencyBase.decimal_places,
+            thousands_separator: CurrencyBase.thousands_separator,
+            decimal_separator: CurrencyBase.decimal_separator,
+          });
+        }
       })
 
       self.content = data;
@@ -466,7 +465,7 @@ function report_salesman_commission(reporting){
     /*====================================================================
         LOAD BOOTSTRAP TABLE
     ====================================================================*/
-    loadTable:function(rowsTable){
+    loadTable: function(rowsTable) {
       var self = this;
       self.rowsData = rowsTable;
       var table = this.$el.find('#table');
@@ -531,19 +530,19 @@ function report_salesman_commission(reporting){
             halign: 'left'
           },
           suma_contado: {
-            columnWidth: 30,
+            columnWidth: 40,
             halign: 'center'
           },
           contado_commission: {
-            columnWidth: 30,
+            columnWidth: 40,
             halign: 'center'
           },
           suma_credito: {
-            columnWidth: 30,
+            columnWidth: 40,
             halign: 'center'
           },
           contado_commission: {
-            columnWidth: 30,
+            columnWidth: 40,
             halign: 'center'
           },
         };