Skip to content

Commit

Permalink
TA#64546 [FIX] account_payment_term_discount: Difference in rounding
Browse files Browse the repository at this point in the history
  • Loading branch information
majouda committed May 31, 2024
1 parent 371c3b4 commit 09d641e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 4 additions & 1 deletion account_payment_term_discount/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from dateutil.relativedelta import relativedelta

from odoo import api, fields, models
from odoo.tools import float_round


class AccountMove(models.Model):
Expand Down Expand Up @@ -43,7 +44,9 @@ def _compute_discount_amt(self):
)
)
if discount_information[0] > 0.0:
invoice.discount_amt = abs(round(discount_information[0], 2))
rounding = invoice.currency_id.rounding
invoice.discount_amt = abs(float_round(
discount_information[0], rounding))
# If discount taken make disc amt to 0 as disc is no more valid
if invoice.discount_taken != 0:
invoice.discount_amt = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from odoo import _, api, fields, models
from odoo.exceptions import UserError
from odoo.tools import float_round


class AccountPaymentRegister(models.TransientModel):
Expand Down Expand Up @@ -45,7 +46,9 @@ def onchange_payment_amount(self):
payment_date = fields.Date.from_string(self.payment_date)
discount_amt = self.invoice_id.discount_amt

payment_difference = self.payment_difference
rounding = self.invoice_id.currency_id.rounding
payment_difference = float_round(
self.payment_difference, rounding)
self.payment_difference = 0.0

if payment_date <= till_discount_date:
Expand Down Expand Up @@ -103,9 +106,11 @@ def action_create_payments(self):
res = super().action_create_payments()
for payment in self:
if payment.payment_difference_handling == "reconcile":
rounding = payment.invoice_id.currency_id.rounding
payment.invoice_id.write(
{
"discount_taken": abs(payment.payment_difference),
"discount_taken": abs(float_round(
payment.payment_difference, rounding)),
"discount_amt": 0,
}
)
Expand Down

0 comments on commit 09d641e

Please sign in to comment.