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

test: fix test cases and related valiation for invalid item tax tempate #2825

Merged
merged 2 commits into from
Dec 6, 2024
Merged
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
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
Loading