Skip to content

Commit

Permalink
[FIX] account_banking_ach_discount: Only generate write-off if
Browse files Browse the repository at this point in the history
there's an amout to write-off and a write-off account
  • Loading branch information
JordiBForgeFlow committed Jun 28, 2024
1 parent ef21873 commit 8797228
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions account_banking_ach_discount/models/account_payment_line.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Copyright (C) 2019 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models
from odoo import _, models
from odoo.exceptions import UserError
from odoo.tools.float_utils import float_is_zero


class AccountPaymentOrder(models.Model):
Expand All @@ -16,11 +18,22 @@ def _prepare_account_payment_vals(self):
payment_difference = self.payment_difference
if self.payment_type == "outbound":
payment_difference *= -1
write_off_line_vals = {
"account_id": self.writeoff_account_id.id,
"name": note,
"amount_currency": payment_difference,
"balance": payment_difference,
}
values["write_off_line_vals"] = [write_off_line_vals]
if not float_is_zero(
payment_difference, precision_digits=self.currency_id.decimal_places
):
if not self.writeoff_account_id:
raise UserError(
_(
"A payment difference was found, "
"but you need to indicicate a corresponding "
"writeoff account."
)
)
write_off_line_vals = {
"account_id": self.writeoff_account_id.id,
"name": note,
"amount_currency": payment_difference,
"balance": payment_difference,
}
values["write_off_line_vals"] = [write_off_line_vals]
return values

0 comments on commit 8797228

Please sign in to comment.