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

[FIX] Righe negative, note e sezioni in fattura fornitore con inversione contabile #4358

Open
wants to merge 2 commits into
base: 16.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
12 changes: 5 additions & 7 deletions l10n_it_reverse_charge/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@ def _compute_rc_flag(self):
for line in self:
move = line.move_id
# see invoice_line_ids field definition
is_invoice_line = line.display_type in (
"product",
"line_section",
"line_note",
)
is_invoice_line = line.display_type == "product"
is_rc = (
move.is_purchase_document()
and move.fiscal_position_id.rc_type_id
Expand Down Expand Up @@ -427,7 +423,8 @@ def generate_self_invoice(self):
)
if line_tax_ids and mapped_taxes:
rc_invoice_line["tax_ids"] = [(6, False, mapped_taxes.ids)]
rc_invoice_line["account_id"] = rc_type.transitory_account_id.id
if line.account_id:
rc_invoice_line["account_id"] = rc_type.transitory_account_id.id
rc_invoice_lines.append([0, False, rc_invoice_line])
if rc_invoice_lines:
inv_vals = self.rc_inv_vals(
Expand Down Expand Up @@ -497,7 +494,8 @@ def generate_supplier_self_invoice(self):
line_vals["tax_ids"] = [
(6, False, mapped_taxes.ids),
]
line_vals["account_id"] = rc_type.transitory_account_id.id
if inv_line.account_id:
line_vals["account_id"] = rc_type.transitory_account_id.id
invoice_line_vals.append((0, 0, line_vals))
supplier_invoice.write({"invoice_line_ids": invoice_line_vals})
self.rc_self_purchase_invoice_id = supplier_invoice.id
Expand Down
48 changes: 48 additions & 0 deletions l10n_it_reverse_charge/tests/test_rc.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,51 @@ def test_extra_EU_draft_and_reconfirm(self):

# Assert
self.assertEqual(invoice.state, "posted")

def test_description_lines(self):
"""A Reverse Charge Bill can be confirmed
when contains notes and sections."""
# Arrange: Create a Reverse Charge Bill with notes and sections
bill = self.create_invoice(
self.supplier_extraEU,
amounts=[100],
taxes=self.tax_0_pur,
post=False,
)
bill.invoice_line_ids = [
(
0,
0,
{
"display_type": "line_note",
"name": "Test note",
},
),
(
0,
0,
{
"display_type": "line_section",
"name": "Test section",
},
),
]

# Act
bill.action_post()

# Assert
self.assertEqual(bill.state, "posted")

def test_negative_lines(self):
"""A Reverse Charge Bill can be confirmed
when contains negative lines."""
# Arrange: Create a Reverse Charge Bill with negative lines
bill = self.create_invoice(
self.supplier_extraEU,
amounts=[100, -10],
taxes=self.tax_0_pur,
)

# Assert
self.assertEqual(bill.state, "posted")
Loading