Skip to content

Commit

Permalink
fix: add test case for items with different tax templates
Browse files Browse the repository at this point in the history
  • Loading branch information
vishakhdesai committed Jan 24, 2025
1 parent c4a0972 commit 4e56cb4
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions india_compliance/gst_india/overrides/test_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,17 +199,37 @@ def test_validate_item_tax_template(self):
item_tax_template.save()

def test_transaction_for_items_with_duplicate_taxes(self):
# Should not allow same item in invoice with multiple taxes
doc = create_transaction(**self.transaction_details, do_not_save=True)

# Should not allow same item in invoice with multiple taxes if any of the tax row has dont_recompute_tax set to 1
doc = create_transaction(
**self.transaction_details, do_not_save=True, is_in_state=True
)
append_item(doc, frappe._dict(item_tax_template="GST 28% - _TIRC"))
doc.taxes[0].dont_recompute_tax = 1

self.assertRaisesRegex(
frappe.exceptions.ValidationError,
re.compile(r"^(Cannot use different Item Tax Templates in different.*)$"),
doc.insert,
)

def test_transaction_for_items_with_different_tax_templates(self):
doc = create_transaction(
**self.transaction_details, do_not_save=True, is_in_state=True
)
append_item(doc, frappe._dict(item_tax_template="GST 28% - _TIRC"))
doc.insert()

# Verify that taxes and amounts are set correctly in both items
self.assertEqual(doc.items[0].cgst_rate, 9)
self.assertEqual(doc.items[0].sgst_rate, 9)
self.assertEqual(doc.items[0].cgst_amount, 9)
self.assertEqual(doc.items[0].sgst_amount, 9)

self.assertEqual(doc.items[1].cgst_rate, 14)
self.assertEqual(doc.items[1].sgst_rate, 14)
self.assertEqual(doc.items[1].cgst_amount, 14)
self.assertEqual(doc.items[1].sgst_amount, 14)

def test_place_of_supply_is_set(self):
doc = create_transaction(**self.transaction_details)

Expand Down

0 comments on commit 4e56cb4

Please sign in to comment.