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