Skip to content

Commit

Permalink
fix: minor changes as per review for gstin validation in subcontracting
Browse files Browse the repository at this point in the history
(cherry picked from commit c5f11f4)
  • Loading branch information
vorasmit authored and mergify[bot] committed Nov 26, 2024
1 parent 458ee1c commit 018a452
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,13 @@ def validate_doc_references(doc):

def validate_transaction(doc, method=None):
if doc.doctype == "Stock Entry":
company_address_field = "bill_from_address"
if not doc.is_return:
company_address_field = "bill_from_address"
company_gstin_field = "bill_from_gstin"
party_gstin_field = "bill_to_gstin"
gst_category_field = "bill_to_gst_category"
else:
company_address_field = "bill_to_address"
company_gstin_field = "bill_to_gstin"
party_gstin_field = "bill_from_gstin"
gst_category_field = "bill_from_gst_category"
Expand Down Expand Up @@ -504,5 +505,9 @@ def ignore_gst_validations_for_subcontracting(doc):
if doc.doctype != "Stock Entry":
return False

# ignore if company address is not set
if is_outward_stock_entry(doc) and not doc.bill_from_address:
return True

if doc.is_return and not doc.bill_to_address:
return True
12 changes: 7 additions & 5 deletions india_compliance/gst_india/overrides/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,9 @@ def validate_for_invalid_account_type(self):
if self.is_sales_transaction:
company_address_field = "company_address"
elif self.doc.doctype == "Stock Entry":
company_address_field = "bill_from_address"
company_address_field = (
"bill_to_address" if self.doc.is_return else "bill_from_address"
)
else:
company_address_field = "billing_address"

Expand Down Expand Up @@ -674,14 +676,14 @@ def validate_place_of_supply(doc):

def is_inter_state_supply(doc):
if doc.doctype == "Stock Entry":
gst_category = (
party_gst_category = (
doc.bill_from_gst_category if doc.is_return else doc.bill_to_gst_category
)

else:
gst_category = doc.gst_category
party_gst_category = doc.gst_category

return gst_category == "SEZ" or (
return party_gst_category == "SEZ" or (
doc.place_of_supply[:2] != get_source_state_code(doc)
)

Expand All @@ -703,7 +705,7 @@ def get_source_state_code(doc):
"gst_state_number",
)

return doc.bill_from_gstin[:2]
return (doc.bill_from_gstin or doc.bill_to_gstin)[:2]

if doc.gst_category == "Overseas":
return "96"
Expand Down

0 comments on commit 018a452

Please sign in to comment.