Browse Source

Agregar fecha de pago en informe de cuentas

root 3 năm trước cách đây
mục cha
commit
f089e3556b

+ 1 - 0
models.py

@@ -125,6 +125,7 @@ class AccountVoucher(models.Model):
 				'journal_id': voucher.journal_id.id,
 				'amount': voucher.amount,
 				'reference' : voucher.reference,
+				'date': voucher.date,
 			})
 
 		return values

BIN
models.pyc


+ 37 - 3
static/src/js/reports/report_cuenta_resumen_dna.js

@@ -169,6 +169,9 @@ function report_cuenta_resumen_dna(reporting){
                 return self.fetchAccountInvoiceLine();
             }).then(function (AccountInvoiceLine){
                 self.AccountInvoiceLine = AccountInvoiceLine;
+                return self.fetchAccountVoucher();
+            }).then(function (AccountVoucher){
+                self.AccountVoucher = AccountVoucher;
                 return self.BuildTable();
             });
         },
@@ -401,6 +404,17 @@ function report_cuenta_resumen_dna(reporting){
         },
 
 
+        fetchAccountVoucher: function () {
+              var self = this;
+              var defer = $.Deferred();
+              var AccountVoucher = new model.web.Model('account.voucher');
+              AccountVoucher.query(['id', 'number','reference','partner_id','date','number','type']).filter([['state', '=', 'posted']]).all().then(function(results){
+                  defer.resolve(results);
+              });
+              return defer;
+          },
+
+
         /*====================================================================
             UPDATE SELECTIONS
         ====================================================================*/
@@ -513,6 +527,13 @@ function report_cuenta_resumen_dna(reporting){
             })
         },
 
+        getAccountVoucher: function (id) {
+            var self = this;
+            return _.filter(self.AccountVoucher,function (item) {
+                return item.reference === id;
+            });
+        },
+
 
         getAccountInvoice:function() {
             var self = this;
@@ -665,6 +686,7 @@ function report_cuenta_resumen_dna(reporting){
             _.each(AccountInvoice,function(item2) {
               var description_product = '';
               var date_pay = '';
+              var date = '';
               if(item2.is_anticipo == false){
               var total_sale = 0;
               var forma = 'Contado';
@@ -680,6 +702,15 @@ function report_cuenta_resumen_dna(reporting){
                if (item2.date_pay){
                   date_pay = item2.date_pay
                };
+               var voucher = self.getAccountVoucher(item2.number).shift();
+
+               if (voucher != null){
+                    date = voucher.date
+                }else{
+                      date = ''
+                }
+
+
                var AccountInvoiceLine = self.getAccountInvoiceLine(item2.id);
                _.each(AccountInvoiceLine, function(line_item){
                   description_product = description_product + " " + line_item.product_id.name
@@ -687,6 +718,7 @@ function report_cuenta_resumen_dna(reporting){
 
                     var partner= self.getResPartner(item2.partner_id[0]);
                     var currency = self.getResCurrency(item2.company_currency[0]).shift();
+
                       data.push({
                         //IDS
                         invoice_id : item2.id,
@@ -702,6 +734,7 @@ function report_cuenta_resumen_dna(reporting){
                         supplier_invoice_number: self.valorNull(item2.supplier_invoice_number),
                         forma: forma,
                         date_pay:  moment(date_pay).format('DD/MM/YYYY'),
+                        date_pago:  moment(date).format('DD/MM/YYYY'),
                         product_name: description_product,
                         amount_total: accounting.formatMoney(item2.amount_total_currency, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
                         amount_pagado:accounting.formatMoney(item2.amount_total - item2.residual,'',CurrencyBase.decimal_places,CurrencyBase.thousands_separator,CurrencyBase.decimal_separator),
@@ -720,7 +753,7 @@ function report_cuenta_resumen_dna(reporting){
 
                       });
               }
-            // });
+
           });
 
           self.content = data;
@@ -797,12 +830,13 @@ function report_cuenta_resumen_dna(reporting){
                   partner_email: {columnWidth: 34, halign:'left'},
                   invoice_name : {columnWidth: 25, halign:'center'},
                   supplier_invoice_number : {columnWidth: 24, halign:'center'},
-                  forma: {columnWidth: 20, halign:'left'},
+                  forma: {columnWidth: 19, halign:'left'},
                   date_pay: {columnWidth: 23, halign:'center'},
-                  product_name: {columnWidth: 23, halign:'left'},
+                  product_name: {columnWidth: 22, halign:'left'},
                   amount_total: {columnWidth: 20, halign:'right'},
                   amount_pagado : {columnWidth: 20, halign:'right'},
                   amount_residual : {columnWidth: 18, halign:'right'},
+                  date_pago: {columnWidth: 22, halign:'center'},
                   user_name : {columnWidth: 19, halign:'center'},
 
                 };

+ 1 - 0
static/src/reports/report_cuenta_resumen_dna.xml

@@ -115,6 +115,7 @@
                           <th data-field="amount_total" data-footer-formatter="totalTotalFormatter" data-align="right">Monto Total</th>
                           <th data-field="amount_pagado" data-footer-formatter="totalPagadoFormatter" data-align="right">Monto Pagado</th>
                           <th data-field="amount_residual" data-footer-formatter="totalResidualFormatter" data-align="right">Saldo</th>
+                          <th data-field="date_pago" data-align="center">Fecha Ult.Pago</th>
                           <th data-field="user_name" data-align="left">Vendedor</th>
                         </tr>
                       </thead>