From edb8a36c7312d202d34b1f868bfed60d023eb76c Mon Sep 17 00:00:00 2001 From: Sanket322 Date: Thu, 14 Nov 2024 15:23:43 +0530 Subject: [PATCH 1/3] fix: allow setting pos from shipping address based on account settings --- india_compliance/gst_india/utils/__init__.py | 25 ++++++++++---------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/india_compliance/gst_india/utils/__init__.py b/india_compliance/gst_india/utils/__init__.py index 79cd7ab3a..c700c0e08 100644 --- a/india_compliance/gst_india/utils/__init__.py +++ b/india_compliance/gst_india/utils/__init__.py @@ -391,31 +391,32 @@ def get_place_of_supply(party_details, doctype): "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) - - elif doctype in SALES_DOCTYPES or doctype == "Payment Entry": + if 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) - if ( - party_details.gst_category == "Unregistered" - and party_details.customer_address - ): + address = ( + party_details.shipping_address_name or party_details.company_address + if pos_basis == "Shipping Address" and doctype != "Payment Entry" + else party_details.customer_address + ) + if party_details.gst_category == "Unregistered" and address: gst_state_number, gst_state = frappe.db.get_value( "Address", - party_details.customer_address, + address, ("gst_state_number", "gst_state"), ) if gst_state_number and gst_state: return f"{gst_state_number}-{gst_state}" - pos_gstin = party_details.billing_address_gstin or party_details.company_gstin + pos_gstin = ( + frappe.db.get_value("Address", party_details.shipping_address_name, "gstin") + if pos_basis == "Shipping Address" + else party_details.billing_address_gstin + ) or party_details.company_gstin elif doctype == "Stock Entry": pos_gstin = party_details.bill_to_gstin or party_details.bill_from_gstin From 43d1bca7ae98556b24f67e5ff3dd927c45bcfaed Mon Sep 17 00:00:00 2001 From: Sanket322 Date: Thu, 14 Nov 2024 15:47:56 +0530 Subject: [PATCH 2/3] fix: minor UI change --- india_compliance/gst_india/setup/property_setters.py | 8 +++++++- india_compliance/patches.txt | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/india_compliance/gst_india/setup/property_setters.py b/india_compliance/gst_india/setup/property_setters.py index 21efb585d..ecb904deb 100644 --- a/india_compliance/gst_india/setup/property_setters.py +++ b/india_compliance/gst_india/setup/property_setters.py @@ -91,11 +91,17 @@ def get_property_setters(*, include_defaults=False): "property": "read_only", "value": "1", }, + { + "doctype": "Accounts Settings", + "fieldname": "add_taxes_from_item_tax_template", + "property": "description", + "value": "Overridden by India Compliance", + }, { "doctype": "Accounts Settings", "fieldname": "tax_settings_section", "property": "label", - "value": "Tax Settings (Overridden by India Compliance)", + "value": "Tax Settings", }, { "doctype": "Accounts Settings", diff --git a/india_compliance/patches.txt b/india_compliance/patches.txt index 4840d66eb..9ba00fa85 100644 --- a/india_compliance/patches.txt +++ b/india_compliance/patches.txt @@ -5,7 +5,7 @@ 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() #59 -execute:from india_compliance.gst_india.setup import create_property_setters; create_property_setters() #9 +execute:from india_compliance.gst_india.setup import create_property_setters; create_property_setters() #10 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 From 23f6b9f2e7851e8ddafa105421b71f95b3706d8a Mon Sep 17 00:00:00 2001 From: Sanket322 Date: Thu, 14 Nov 2024 16:09:55 +0530 Subject: [PATCH 3/3] fix: test case --- india_compliance/gst_india/overrides/test_transaction.py | 1 + 1 file changed, 1 insertion(+) diff --git a/india_compliance/gst_india/overrides/test_transaction.py b/india_compliance/gst_india/overrides/test_transaction.py index 2ff66ce97..28c57fb1b 100644 --- a/india_compliance/gst_india/overrides/test_transaction.py +++ b/india_compliance/gst_india/overrides/test_transaction.py @@ -1246,6 +1246,7 @@ def test_pos_sales_invoice(self): doc_args = { "doctype": "Sales Invoice", "customer": "_Test Registered Composition Customer", + "shipping_address_name": "_Test Indian Registered Company-Billing", } settings = ["Accounts Settings", None, "determine_address_tax_category_from"]