mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-16 02:11:39 +00:00
feat(regional): Auto state wise taxation for GST India (#19469)
* feat(regional): Auto state wise taxation for GST India * fix: Update gst category on addition of GSTIN * fix: Codacy and travis fixes * fix: Travis * fix(test): Update GST category only if GSTIN field available * fix: Test Cases * fix: Do not skip accounts if place of supply is not present * fix: Auto GST taxation for SEZ Party types * fix: Automatic taxation for multi state * fix: Codacy and travis fixes * fix: Auto GST template selection in Sales Order * fix: Move inter state check and source state to tax category * fix: Remove unique check from tax template * fix: Remove unique check from tax template * fix: Address fetching logic in Sales * fix: fecth tax template on company address change * fix: fetch company gstin on address change * fix: company_gstin set value fix * fix: Mutiple fixes and code refactor * fix: Add missing semicolon * fix: Company address fetching in sales invoice * fix: Remove print statement * fix: Import functools * fix: Naming fixes and code cleanup * fix: Iteritems compatibility for python 3
This commit is contained in:
@@ -14,6 +14,8 @@ from frappe.model.document import Document
|
||||
from frappe.contacts.address_and_contact import load_address_and_contact
|
||||
from frappe.utils.nestedset import NestedSet
|
||||
|
||||
import functools
|
||||
|
||||
class Company(NestedSet):
|
||||
nsm_parent_field = 'parent_company'
|
||||
|
||||
@@ -560,3 +562,26 @@ def get_timeline_data(doctype, name):
|
||||
return json.loads(history) if history and '{' in history else {}
|
||||
|
||||
return date_to_value_dict
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_default_company_address(name, sort_key='is_primary_address', existing_address=None):
|
||||
if sort_key not in ['is_shipping_address', 'is_primary_address']:
|
||||
return None
|
||||
|
||||
out = frappe.db.sql(""" SELECT
|
||||
addr.name, addr.%s
|
||||
FROM
|
||||
`tabAddress` addr, `tabDynamic Link` dl
|
||||
WHERE
|
||||
dl.parent = addr.name and dl.link_doctype = 'Company' and
|
||||
dl.link_name = %s and ifnull(addr.disabled, 0) = 0
|
||||
""" %(sort_key, '%s'), (name)) #nosec
|
||||
|
||||
if existing_address:
|
||||
if existing_address in [d[0] for d in out]:
|
||||
return existing_address
|
||||
|
||||
if out:
|
||||
return sorted(out, key = functools.cmp_to_key(lambda x,y: cmp(y[1], x[1])))[0][0]
|
||||
else:
|
||||
return None
|
||||
Reference in New Issue
Block a user