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 based on account settings #2647

Merged
22 changes: 19 additions & 3 deletions india_compliance/gst_india/overrides/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,11 +823,16 @@ def get_gst_details(party_details, doctype, company, *, update_place_of_supply=F
is_sales_transaction = doctype in SALES_DOCTYPES or doctype == "Payment Entry"
party_details = frappe.parse_json(party_details)
gst_details = frappe._dict()
address = frappe.db.get_single_value(
"Accounts Settings", "determine_address_tax_category_from"
)

# Party/Address Defaults
if is_sales_transaction:
company_gstin_field = "company_gstin"
party_gstin_field = "billing_address_gstin"
party_gstin_field = (
"billing_address_gstin" if address == "Billing Address" else "company_gstin"
)
party_address_field = "customer_address"
gst_category_field = "gst_category"

Expand Down Expand Up @@ -1493,13 +1498,24 @@ def validate_transaction(doc, method=None):

validate_overseas_gst_category(doc)

address = frappe.db.get_single_value(
Sanket322 marked this conversation as resolved.
Show resolved Hide resolved
"Accounts Settings", "determine_address_tax_category_from"
)
if is_sales_transaction := doc.doctype in SALES_DOCTYPES:
validate_hsn_codes(doc)
validate_sales_reverse_charge(doc)
gstin = doc.billing_address_gstin
gstin = (
doc.billing_address_gstin
if address == "Billing Address"
else doc.company_gstin
)
elif doc.doctype == "Payment Entry":
is_sales_transaction = True
gstin = doc.billing_address_gstin
gstin = (
doc.billing_address_gstin
if address == "Billing Address"
else doc.company_gstin
)
else:
gstin = doc.supplier_gstin

Expand Down
9 changes: 8 additions & 1 deletion india_compliance/gst_india/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,14 @@ 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
address = frappe.db.get_single_value(
"Accounts Settings", "determine_address_tax_category_from"
)
party_gstin = (
party_details.billing_address_gstin
if address == "Billing Address"
else party_details.company_gstin
)

elif doctype == "Stock Entry":
party_gstin = party_details.bill_to_gstin or party_details.bill_from_gstin
Expand Down
Loading