Skip to content

Commit

Permalink
Merge pull request #2825 from vorasmit/fix-tests
Browse files Browse the repository at this point in the history
test: fix test cases and related valiation for invalid item tax tempate
  • Loading branch information
vorasmit authored Dec 6, 2024
2 parents a82287c + 5f16ec2 commit d4f5226
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def test_standalone_stock_entry(self):

self.assertRaisesRegex(
frappe.ValidationError,
re.compile(r"(.*GST Category is a mandatory field for GST Transactions.*)"),
re.compile(r"(.*is a mandatory field for GST Transactions.*)"),
se.save,
)

Expand Down
2 changes: 1 addition & 1 deletion india_compliance/gst_india/overrides/test_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ def test_purchase_from_unregistered_supplier(self):

def test_invalid_charge_type_as_actual(self):
doc = create_transaction(**self.transaction_details, do_not_save=True)
_append_taxes(doc, ["CGST", "SGST"], charge_type="Actual", tax_amount=9)
_append_taxes(doc, ["CGST", "SGST"], charge_type="Actual", tax_amount=9, rate=0)

self.assertRaisesRegex(
frappe.exceptions.ValidationError,
Expand Down
5 changes: 4 additions & 1 deletion india_compliance/gst_india/overrides/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from india_compliance.gst_india.doctype.gstin.gstin import get_and_validate_gstin_status
from india_compliance.gst_india.utils import (
get_all_gst_accounts,
get_gst_account_by_item_tax_template,
get_gst_account_gst_tax_type_map,
get_gst_accounts_by_type,
get_hsn_settings,
Expand Down Expand Up @@ -545,8 +546,10 @@ def validate_missing_accounts_in_item_tax_template(self):
if not row.item_tax_template:
continue

template_rows = get_gst_account_by_item_tax_template(row.item_tax_template)

for account in self.used_accounts:
if account in row.item_tax_rate:
if account in template_rows:
continue

frappe.msgprint(
Expand Down
9 changes: 9 additions & 0 deletions india_compliance/gst_india/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,15 @@ def get_gst_accounts_by_tax_type(company, tax_type, throw=True):
)


@frappe.request_cache
def get_gst_account_by_item_tax_template(item_tax_template):
return frappe.get_all(
"Item Tax Template Detail",
filters={"parent": item_tax_template},
pluck="tax_type",
)


def get_gst_account_gst_tax_type_map():
"""
- Returns gst_account by tax_type for all the companies
Expand Down

0 comments on commit d4f5226

Please sign in to comment.