Skip to content

Commit

Permalink
[ADD] account_cash_discount_write_off: add function for inheritance t…
Browse files Browse the repository at this point in the history
…o be able to change discount percentange
  • Loading branch information
AnizR committed Aug 2, 2024
1 parent 676f9a4 commit eda63bb
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions account_cash_discount_write_off/models/account_payment_line.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2018 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

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

Expand Down Expand Up @@ -41,6 +41,11 @@ def _check_cash_discount_write_off_creation(self):
== 0
)

@api.model
def _get_tax_invoice_tax_percentage(self, tax_move_line):
tax_invoice = tax_move_line.move_id
return tax_invoice.discount_percent

def get_cash_discount_writeoff_move_values(self):
self.ensure_one()
move_line = self.move_line_id
Expand Down Expand Up @@ -98,10 +103,11 @@ def get_cash_discount_writeoff_move_values(self):
]
)

for tax_move_line in tax_move_lines:
tax_invoice = tax_move_line.move_id
for tax_move_line in tax_move_lines:
amount = float_round(
abs(tax_move_line.balance) * tax_invoice.discount_percent / 100.0,
abs(tax_move_line.balance)
* self._get_tax_invoice_tax_percentage(tax_move_line)
/ 100.0,
precision_rounding=rounding,
)
if tax_move_line.credit > 0:
Expand Down

0 comments on commit eda63bb

Please sign in to comment.