Skip to content

Commit

Permalink
[13.0][FIX] account_cash_discount_write_off: use correct tags when us…
Browse files Browse the repository at this point in the history
…ing refunds
  • Loading branch information
AnizR committed Jul 8, 2024
1 parent eafca90 commit c7028d0
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def get_cash_discount_writeoff_move_values(self):
tag_ids = []
if tax:
account = tax_move_line.account_id
is_refund = "refund" in tax_invoice.type
is_refund = "refund" in invoice.type
tax_vals = tax.compute_all(
tax_move_line.price_unit,
currency=tax_move_line.currency_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,48 @@ def test_cash_discount_with_write_off_with_taxes(self):
def test_cash_discount_with_refund(self):
woff_account = self.cash_discount_writeoff_account
woff_journal = self.cash_discount_writeoff_journal

expected_audit = "+II.D.1. for business purposes: base 17% (721)"
expected_refund_audit = "-II.D.1. for business purposes: base 17% (721)"

self.tax_17_p.invoice_repartition_line_ids.filtered(
lambda r: r.repartition_type == "tax"
).write(
{
"tag_ids": [
(
0,
False,
{
"name": expected_audit,
"applicability": "taxes",
"country_id": self.partner_agrolait.country_id.id,
},
)
],
"account_id": self.exp_account.id,
}
)

self.tax_17_p.refund_repartition_line_ids.filtered(
lambda r: r.repartition_type == "tax"
).write(
{
"tag_ids": [
(
0,
False,
{
"name": expected_refund_audit,
"applicability": "taxes",
"country_id": self.partner_agrolait.country_id.id,
},
)
],
"account_id": self.exp_account.id,
}
)

self.company.write(
{
"default_cash_discount_writeoff_account_id": woff_account.id,
Expand Down Expand Up @@ -292,3 +334,25 @@ def test_cash_discount_with_refund(self):
payment_order.generated2uploaded()

self.assertEqual(invoice.invoice_payment_state, "paid")

discount_writeoff_move_lines = self.MoveLine.search(
[("journal_id", "=", self.cash_discount_writeoff_journal.id)]
)

self.assertEqual(len(discount_writeoff_move_lines), 5)
tax_10_move_line = self.MoveLine.search(
[("id", "in", discount_writeoff_move_lines.ids), ("tag_ids", "!=", False),]
)

self.assertEqual(len(tax_10_move_line), 2)

credit_line = tax_10_move_line.filtered(lambda r: r.credit > 0)
self.assertEqual(len(credit_line), 1)
tag_credit = credit_line.tag_ids

debit_line = tax_10_move_line.filtered(lambda r: r.debit > 0)
self.assertEqual(len(debit_line), 1)
tag_debit = debit_line.tag_ids

self.assertEqual(tag_credit, tag_debit)
self.assertEqual(tag_credit.name, expected_audit)

0 comments on commit c7028d0

Please sign in to comment.