Skip to content

Commit

Permalink
[FIX] l10n_mx_cfdi_account: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
EdgarRetes committed Nov 15, 2024
1 parent e2cd3b8 commit d0cdeb5
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 24 deletions.
7 changes: 7 additions & 0 deletions l10n_mx_cfdi_account/tests/test_account_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,20 @@ def setUp(self):
}
)

self.tax_group = self.env["account.tax.group"].search([("name", "=", "IVA")], limit=1)
if not self.tax_group:
self.tax_group = self.env["account.tax.group"].create({
"name": "IVA",
})

self.tax = self.env["account.tax"].create(
{
"name": "IVA",
"amount": 10,
"amount_type": "percent",
"type_tax_use": "sale",
"country_id": self.env.ref("base.mx").id,
"tax_group_id": self.tax_group.id,
# Add other required fields here
}
)
Expand Down
61 changes: 37 additions & 24 deletions l10n_mx_cfdi_account/tests/test_account_tax.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,53 @@
class TestAccountTax(TransactionCase):
def setUp(self):
super().setUp()
self.tax_isr = self.env["account.tax"].create(
{
"name": "ISR Tax",
# Add other required fields here
}
)
self.tax_iva = self.env["account.tax"].create(
{
"name": "IVA Tax",
# Add other required fields here
}
)
self.tax_ieps = self.env["account.tax"].create(
{
"name": "IEPS Tax",
# Add other required fields here
}
)
self.tax_group = self.env["account.tax.group"].create({
"name": "IVA",
"sequence": 1,
})

self.tax_isr = self.env["account.tax"].create({
"name": "ISR Tax",
"amount": 10.0,
"amount_type": "percent",
"type_tax_use": "sale",
"tax_group_id": self.tax_group.id,
})
self.tax_iva = self.env["account.tax"].create({
"name": "IVA Tax",
"amount": 16.0,
"amount_type": "percent",
"type_tax_use": "sale",
"tax_group_id": self.tax_group.id,
})
self.tax_ieps = self.env["account.tax"].create({
"name": "IEPS Tax",
"amount": 8.0,
"amount_type": "percent",
"type_tax_use": "sale",
"tax_group_id": self.tax_group.id,
})

def test_extract_l10n_mx_tax_code(self):
self.assertEqual(self.tax_isr.extract_l10n_mx_tax_code(), "ISR")
self.assertEqual(self.tax_iva.extract_l10n_mx_tax_code(), "IVA")
self.assertEqual(self.tax_ieps.extract_l10n_mx_tax_code(), "IEPS")

tax_without_code = self.env["account.tax"].create({
"name": "Test Tax",
"amount": 5.0,
"amount_type": "percent",
"type_tax_use": "sale",
"tax_group_id": self.tax_group.id,
})

with self.assertRaises(UserError):
self.env["account.tax"].create(
{
"name": "Test Tax",
# Add other required fields here
}
).extract_l10n_mx_tax_code()
tax_without_code.extract_l10n_mx_tax_code()

def test_extract_is_retention(self):
self.assertFalse(self.tax_isr.extract_is_retention())
self.assertFalse(self.tax_iva.extract_is_retention())
self.assertFalse(self.tax_ieps.extract_is_retention())

tax_retention = self.env.ref("l10n_mx.1_tax2")
self.assertTrue(tax_retention.extract_is_retention())

0 comments on commit d0cdeb5

Please sign in to comment.