Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0] [FIX] account_payment_term_discount: Difference in rounding #724

Open
wants to merge 3 commits into
base: 14.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 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,10 @@ 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,8 @@ 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 +105,12 @@ 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
Loading