diff --git a/addons/account/models/account_move_line.py b/addons/account/models/account_move_line.py index 8f5c5a80d00..7e51a0b3783 100644 --- a/addons/account/models/account_move_line.py +++ b/addons/account/models/account_move_line.py @@ -1006,12 +1006,13 @@ class AccountMoveLine(models.Model): for percentages in percentages_to_apply: percentage = percentages['discount_percentage'] / 100 line_percentage = percentages['term_percentage'] + taxes = line.tax_ids.filtered(lambda t: t.amount_type != 'fixed') epd_needed_vals = epd_needed.setdefault( frozendict({ 'move_id': line.move_id.id, 'account_id': line.account_id.id, 'analytic_distribution': line.analytic_distribution, - 'tax_ids': [Command.set(line.tax_ids.ids)], + 'tax_ids': [Command.set(taxes.ids)], 'tax_tag_ids': [Command.set(line.tax_tag_ids.ids)], 'display_type': 'epd', }), diff --git a/addons/account/tests/test_early_payment_discount.py b/addons/account/tests/test_early_payment_discount.py index 7d44856fea9..27cc2a16213 100644 --- a/addons/account/tests/test_early_payment_discount.py +++ b/addons/account/tests/test_early_payment_discount.py @@ -60,6 +60,42 @@ class TestAccountEarlyPaymentDiscount(AccountTestInvoicingCommon): fields.Date.from_string('2019-01-11') or False ) + # ========================== Tests Taxes Amounts ============================= + def test_fixed_tax_amount_discounted_payment_mixed(self): + self.env.company.early_pay_discount_computation = 'mixed' + fixed_tax = self.env['account.tax'].create({ + 'name': 'Test 0.05', + 'amount_type': 'fixed', + 'amount': 0.05, + }) + + invoice = self.env['account.move'].create({ + 'move_type': 'out_invoice', + 'partner_id': self.partner_a.id, + 'invoice_date': '2019-01-01', + 'date': '2019-01-01', + 'invoice_line_ids': [Command.create({ + 'name': 'line', + 'price_unit': 1000.0, + 'tax_ids': [Command.set(self.product_a.taxes_id.ids + fixed_tax.ids)], + })], + 'invoice_payment_term_id': self.early_pay_mixed_5_10.id, + }) + self.assertInvoiceValues(invoice, [ + # pylint: disable=bad-whitespace + {'display_type': 'epd', 'balance': -75.0}, + {'display_type': 'epd', 'balance': 75.0}, + {'display_type': 'product', 'balance': -1000.0}, + {'display_type': 'tax', 'balance': -138.75}, + {'display_type': 'tax', 'balance': -0.05}, + {'display_type': 'payment_term', 'balance': 569.4}, + {'display_type': 'payment_term', 'balance': 569.4}, + ], { + 'amount_untaxed': 1000.0, + 'amount_tax': 138.8, + 'amount_total': 1138.8, + }) + # ========================== Tests Payment Register ========================== def test_register_discounted_payment_on_single_invoice(self): self.company_data['company'].early_pay_discount_computation = 'included'