Explorar el Código

Agregar campo a account interes

sebas hace 4 años
padre
commit
b5dae31d43

+ 0 - 0
.gitignore


+ 0 - 0
__init__.py


+ 0 - 0
__openerp__.py


+ 0 - 0
models/__init__.py


+ 7 - 2
models/account_interest.py

@@ -3,7 +3,7 @@ from openerp import models, fields, tools, api
 import openerp.addons.decimal_precision as dp
 from datetime import datetime
 from openerp.exceptions import ValidationError
-
+import pdb
 import logging
 _logger = logging.getLogger(__name__)
 
@@ -19,6 +19,7 @@ class AccountInterest(models.Model):
     ## factura
     invoice_id = fields.Many2one('account.invoice', string='Invoice Reference', ondelete='restrict', index=True)
     reference = fields.Char(string='Invoice Reference', help="Invoice Reference")
+    # cuota_nro = fields.Char(string='N° Cuota', help="N° Cuota")
     ## Currency
     currency_id = fields.Many2one('res.currency', string="Currency", help="Moneda de la operación")
     ## Line
@@ -44,6 +45,7 @@ class AccountInterest(models.Model):
         moves_ids = map(lambda x: x.move_line_id.id, interestLine)
 
         invoiceNumber = ""
+
         invoice = self.env['account.invoice'].search([('id', 'in', invoice_ids)])
         if (invoice):
             for invoiceN in invoice:
@@ -109,6 +111,8 @@ class accountInvoiceInterest(models.Model):
 
             for line in interestLine:
                 lineInvoice = self.env['account.invoice'].browse(line.invoice.id)
+                # if (lineInvoice):
+                #     lineInvoice.write({'cuota_nro': lineInvoice.cuota_nro})
                 if (not lineInvoice):
                     state = {'state': 'open'}
 
@@ -185,6 +189,7 @@ class AccountInterestLine(models.Model):
     amount_residual = fields.Float('amount', digits_compute=dp.get_precision('Account'), required=True, help="Monto del pago")
     amount_interest = fields.Float('amount', digits_compute=dp.get_precision('Account'), required=True, help="Monto del pago")
     date_maturity = fields.Date()
+    expired_daystot = fields.Integer('Expired Days Total ')
     expired_days = fields.Integer('Expired Days ')
     invoice = fields.Many2one('account.invoice', string='Invoice Reference', index=True)
     reference = fields.Char(string='Invoice Reference', help="Invoice Reference")
@@ -203,4 +208,4 @@ class accountMoveLineInterest(models.Model):
     _inherit = 'account.move.line'
 
     interest_line_ids = fields.One2many('account.interest.line', 'move_line_id', string=' Account Interest Line')
-    date_interest = fields.Date("Date interés", help="Fecha de la facturación de os interés")
+    date_interest = fields.Date("Date interés", help="Fecha de la facturación de los intereses")

+ 0 - 0
models/account_interest_config.py


+ 8 - 2
models/eiru_account_interest.py

@@ -130,9 +130,11 @@ class EiruAccountInterest(models.Model):
                 return False
 
             expiredDays = dateServer - self._convert_str_to_datetime(line.date_maturity)
+            expiredDaystot = dateServer - self._convert_str_to_datetime(line.date_maturity)
             if (line.date_interest):
                 expiredDays = dateServer - self._convert_str_to_datetime(line.date_interest)
 
+
             if ((line.amount_residual <= 0) or (expiredDays.days <= 0)):
                 continue
 
@@ -142,7 +144,7 @@ class EiruAccountInterest(models.Model):
                 return {'state': False}
 
             ''' verify account.interest.line '''
-            interrstLine = self.eiru_create_account_interest_lines(accountInvoice.id, accountInterest.id, line.id, expiredDays.days)
+            interrstLine = self.eiru_create_account_interest_lines(accountInvoice.id, accountInterest.id, line.id, expiredDays.days, expiredDaystot.days)
             if (not interrstLine):
                 return {'state': False}
 
@@ -164,6 +166,7 @@ class EiruAccountInterest(models.Model):
             accountInterest = self.env['account.interest'].create({
                 'invoice_id': accountInvoice.id,
                 'customer_id': accountInvoice.commercial_partner_id.id if(accountInvoice.commercial_partner_id) else accountInvoice.partner_id.id,
+            #    'cuota_nro': accountInvoice.cuota_nro,
                 'date': dateServer,
                 'currency_id': accountInvoice.currency_id.id,
                 'reference': accountInvoice.number,
@@ -174,7 +177,7 @@ class EiruAccountInterest(models.Model):
     '''
         create / write
     '''
-    def eiru_create_account_interest_lines(self, invoiceId, interestID, moveId, expiredDays):
+    def eiru_create_account_interest_lines(self, invoiceId, interestID, moveId, expiredDays, expiredDaystot):
         _logger.info('Verify account interest Line')
         decimal_precision = self.env['decimal.precision'].precision_get('Account')
         accountInvoice = self.env['account.invoice'].browse(invoiceId)
@@ -188,6 +191,7 @@ class EiruAccountInterest(models.Model):
         if (not decimalPlaces):
             decimalPlaces = 0
 
+        # cuota_nro = accountInvoice.cuota_nro
         amount = (moveLine.amount_currency or moveLine.debit or 0.0)
         amount_residual = (moveLine.amount_residual_currency or moveLine.amount_residual or 0.0)
 
@@ -195,8 +199,10 @@ class EiruAccountInterest(models.Model):
             'move_line_id': moveLine.id,
             'amount': round(amount, decimalPlaces),
             'date_maturity': moveLine.date_maturity,
+            'expired_daystot': expiredDaystot,
             'expired_days': expiredDays,
             'amount_residual': round(amount_residual,decimalPlaces),
+        #    'cuota_nro': accountInvoice.cuota_nro,
             'amount_interest': round((expiredDays * (amount_residual * (interestConfig.interest_rate / 100))),decimalPlaces),
             'interest_id': accountInterest.id,
         }

+ 0 - 0
security/ir.model.access.csv


+ 0 - 0
static/description/icon.png


+ 0 - 0
static/src/css/style.css


+ 2 - 1
static/src/js/account_interest_invoice.js

@@ -62,7 +62,7 @@
         /* GET account.interest.line */
         fetchAccountInterestLine: function(id) {
             var interestLine = new openerp.web.Model('account.interest.line');
-            var fields = ['id','interest_id','amount_interest','date_maturity','expired_days','state'];
+            var fields = ['id','interest_id','amount_interest','date_maturity','expired_daystot','expired_days','state'];
             var domain = [['interest_id', '=', id],['state', '=', 'open']];
             return interestLine.query(fields).filter(domain).order_by('date_maturity').all();
         },
@@ -84,6 +84,7 @@
                     'amountInterestformat': instanceWeb.formatCurrency(item.amount_interest, currency),
                     'date_maturity': item.date_maturity,
                     'dateMaturity': moment(item.date_maturity).format("DD-MM-YYYY"),
+                    'expired_daystot': item.expired_daystot,
                     'expired_days': item.expired_days,
                     'state': item.state,
                 });

+ 0 - 0
static/src/js/verify_interest_invoice.js


+ 0 - 0
static/src/js/verify_interest_invoice_status.js


+ 0 - 0
static/src/js/verify_interest_partner.js


+ 0 - 0
static/src/xml/account_interest_invoice.xml


+ 0 - 0
static/src/xml/modal/modal_account_interest_invoice.xml


+ 0 - 0
static/src/xml/verify_interest_invoice_status.xml


+ 3 - 1
views/account_interest.xml

@@ -30,6 +30,7 @@
                                 <field name="lines_ids" >
                                     <tree colors="blue:state == 'invoiced'; red:state == 'open'; red:state =='invoice_cancel'; red:state =='invoice_draft'; gray:state == 'discount'; black:state == 'paid'" string="Detalles de la deuda" editable="bottom" create="false" delete="false">
                                         <field name="date_maturity" string="Vencimiento"/>
+                                        <!-- <field name="cuota_nro" string="Nro cuota"/> -->
                                         <field name="amount" string="Monto de la cuota"/>
                                         <field name="amount_residual" string="Saldo pendiente"/>
                                         <field name="expired_days" string="Días atrasados"/>
@@ -57,7 +58,8 @@
 					<field name="name" string="Nombre" />
 					<field name="date" string="Fecha"/>
 					<field name="customer_id" string="Cliente"/>
-					<field name="invoice_id" string="Nº Factura"/>
+					<!-- <field name="cuota_nro" string="Nº Cuota"/> -->
+          <field name="invoice_id" string="Nº Factura"/>
 					<field name="currency_id" string="Moneda"/>
 					<field name="state" string="Estado"/>
 				</tree>

+ 0 - 0
views/account_interest_config.xml


+ 0 - 0
views/account_invoice_interst.xml


+ 0 - 0
views/data_decimal_precision_interest.xml


+ 0 - 0
views/eiru_verify_interest.xml


+ 0 - 0
views/templates.xml