diff --git a/india_compliance/gst_india/overrides/test_transaction.py b/india_compliance/gst_india/overrides/test_transaction.py index ac8e3f545..207ff49d9 100644 --- a/india_compliance/gst_india/overrides/test_transaction.py +++ b/india_compliance/gst_india/overrides/test_transaction.py @@ -1151,3 +1151,23 @@ def test_so_and_po_after_item_update(self): }, doc.items[1], ) + + +class TestPlaceOfSupply(FrappeTestCase): + def test_pos_sales_invoice(self): + doc_args = { + "doctype": "Sales Invoice", + "customer": "_Test Registered Composition Customer", + } + + settings = ["Accounts Settings", None, "determine_address_tax_category_from"] + + # Shipping Address + frappe.db.set_value(*settings, "Shipping Address") + doc = create_transaction(**doc_args) + self.assertEqual(doc.place_of_supply, "24-Gujarat") + + # Billing Address + frappe.db.set_value(*settings, "Billing Address") + doc = create_transaction(**doc_args) + self.assertEqual(doc.place_of_supply, "29-Karnataka") diff --git a/india_compliance/gst_india/setup/__init__.py b/india_compliance/gst_india/setup/__init__.py index 7c941bb49..f18073a90 100644 --- a/india_compliance/gst_india/setup/__init__.py +++ b/india_compliance/gst_india/setup/__init__.py @@ -239,10 +239,6 @@ def set_default_accounts_settings(): """ Accounts Settings overridden by India Compliance - - Determine Address Tax Category From: - This is overriden to be Billing Address, since that's the correct - address for determining GST applicablility - - Automatically Add Taxes and Charges from Item Tax Template: This is overriden to be "No". Item Tax Templates are designed to have all GST Accounts and are primarily used for selection of tax rate. @@ -252,11 +248,7 @@ def set_default_accounts_settings(): show_accounts_settings_override_warning() frappe.db.set_single_value( - "Accounts Settings", - { - "determine_address_tax_category_from": "Billing Address", - "add_taxes_from_item_tax_template": 0, - }, + "Accounts Settings", "add_taxes_from_item_tax_template", 0 ) frappe.db.set_default("add_taxes_from_item_tax_template", 0) diff --git a/india_compliance/gst_india/setup/property_setters.py b/india_compliance/gst_india/setup/property_setters.py index 66e8f3e8f..21efb585d 100644 --- a/india_compliance/gst_india/setup/property_setters.py +++ b/india_compliance/gst_india/setup/property_setters.py @@ -83,7 +83,7 @@ def get_property_setters(*, include_defaults=False): "doctype": "Accounts Settings", "fieldname": "determine_address_tax_category_from", "property": "read_only", - "value": "1", + "value": "0", }, { "doctype": "Accounts Settings", diff --git a/india_compliance/gst_india/utils/__init__.py b/india_compliance/gst_india/utils/__init__.py index 554485ff1..f19d32533 100644 --- a/india_compliance/gst_india/utils/__init__.py +++ b/india_compliance/gst_india/utils/__init__.py @@ -387,10 +387,18 @@ def get_place_of_supply(party_details, doctype): :param party_details: A frappe._dict or document containing fields related to party """ + pos_basis = frappe.get_cached_value( + "Accounts Settings", "Accounts Settings", "determine_address_tax_category_from" + ) + + if pos_basis == "Shipping Address" and doctype in SALES_DOCTYPES: + # POS Basis Shipping Address is only applicable for Sales + pos_gstin = party_details.company_gstin + # fallback to company GSTIN for sales or supplier GSTIN for purchases # (in retail scenarios, customer / company GSTIN may not be set) - if doctype in SALES_DOCTYPES or doctype == "Payment Entry": + elif doctype in SALES_DOCTYPES or doctype == "Payment Entry": # for exports, Place of Supply is set using GST category in absence of GSTIN if party_details.gst_category == "Overseas": return get_overseas_place_of_supply(party_details) @@ -407,18 +415,18 @@ def get_place_of_supply(party_details, doctype): if gst_state_number and gst_state: return f"{gst_state_number}-{gst_state}" - party_gstin = party_details.billing_address_gstin or party_details.company_gstin + pos_gstin = party_details.billing_address_gstin or party_details.company_gstin elif doctype == "Stock Entry": - party_gstin = party_details.bill_to_gstin or party_details.bill_from_gstin + pos_gstin = party_details.bill_to_gstin or party_details.bill_from_gstin else: # for purchase, subcontracting order and receipt - party_gstin = party_details.company_gstin or party_details.supplier_gstin + pos_gstin = party_details.company_gstin or party_details.supplier_gstin - if not party_gstin: + if not pos_gstin: return - state_code = party_gstin[:2] + state_code = pos_gstin[:2] if state := get_state(state_code): return f"{state_code}-{state}" diff --git a/india_compliance/patches.txt b/india_compliance/patches.txt index a53eb6a5c..f5a5ac401 100644 --- a/india_compliance/patches.txt +++ b/india_compliance/patches.txt @@ -5,8 +5,8 @@ india_compliance.patches.v15.remove_duplicate_web_template [post_model_sync] india_compliance.patches.v14.set_default_for_overridden_accounts_setting execute:from india_compliance.gst_india.setup import create_custom_fields; create_custom_fields() #58 -execute:from india_compliance.gst_india.setup import create_property_setters; create_property_setters() #8 -execute:from india_compliance.income_tax_india.setup import create_custom_fields; create_custom_fields() #1 +execute:from india_compliance.gst_india.setup import create_property_setters; create_property_setters() #9 +execute:from india_compliance.income_tax_india.setup import create_custom_fields; create_custom_fields() #2 india_compliance.patches.post_install.remove_old_fields #2 india_compliance.patches.post_install.set_gst_tax_type india_compliance.patches.post_install.set_gst_tax_type_in_journal_entry