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

fix: pos from shipping address based on account settings #2722

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions india_compliance/gst_india/overrides/test_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
8 changes: 7 additions & 1 deletion india_compliance/gst_india/setup/property_setters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
25 changes: 13 additions & 12 deletions india_compliance/gst_india/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion india_compliance/patches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down