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 all commits
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
2 changes: 1 addition & 1 deletion account_payment_term_discount/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def _compute_discount_amt(self):
)
)
if discount_information[0] > 0.0:
invoice.discount_amt = abs(round(discount_information[0], 2))
invoice.discount_amt = abs(discount_information[0])
# 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
8 changes: 6 additions & 2 deletions account_payment_term_discount/models/account_payment_term.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
)

if line.discount and payment_date <= till_discount_date:
payment_discount = round((amount * line.discount) / 100.0, 2)
payment_discount = (amount * line.discount) / 100.0
if invoice.move_type in ("out_invoice", "in_refund"):
discount_account_id = line.discount_expense_account_id.id
else:
Expand Down Expand Up @@ -87,16 +87,20 @@
discount_income_account_id = fields.Many2one(
"account.account",
string="Discount on Purchases Account",
ondelete="restrict",
company_dependent=True,
help="This account will be used to post the discount on purchases.",
)
discount_expense_account_id = fields.Many2one(
"account.account",
string="Discount on Sales Account",
ondelete="restrict",
company_dependent=True,
help="This account will be used to post the discount on sales.",
)

@api.onchange("discount")
def OnchangeDiscount(self):
if not self.discount:
return {}
self.value_amount = round(1 - (self.discount / 100.0), 2)
self.value_amount = 1 - (self.discount / 100.0)

Check warning on line 106 in account_payment_term_discount/models/account_payment_term.py

View check run for this annotation

Codecov / codecov/patch

account_payment_term_discount/models/account_payment_term.py#L106

Added line #L106 was not covered by tests
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ 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
self.payment_difference = 0.0

Expand Down
Loading