fix: conflicts
diff --git a/erpnext/regional/india/utils.py b/erpnext/regional/india/utils.py
index 0f9156a..f37b0e4 100644
--- a/erpnext/regional/india/utils.py
+++ b/erpnext/regional/india/utils.py
@@ -141,18 +141,24 @@
address_name = party_details.shipping_address or party_details.supplier_address
if address_name:
- address = frappe.db.get_value("Address", address_name, ["gst_state", "gst_state_number"], as_dict=1)
+ address = frappe.db.get_value("Address", address_name, ["gst_state", "gst_state_number", "gstin"], as_dict=1)
if address and address.gst_state and address.gst_state_number:
+ party_details.gstin = address.gstin
return cstr(address.gst_state_number) + "-" + cstr(address.gst_state)
@frappe.whitelist()
def get_regional_address_details(party_details, doctype, company, return_taxes=None):
-
if isinstance(party_details, string_types):
party_details = json.loads(party_details)
party_details = frappe._dict(party_details)
party_details.place_of_supply = get_place_of_supply(party_details, doctype)
+
+ if is_internal_transfer(party_details, doctype):
+ party_details.taxes_and_charges = ''
+ party_details.taxes = ''
+ return
+
if doctype in ("Sales Invoice", "Delivery Note", "Sales Order"):
master_doctype = "Sales Taxes and Charges Template"
@@ -167,7 +173,6 @@
elif doctype in ("Purchase Invoice", "Purchase Order", "Purchase Receipt"):
master_doctype = "Purchase Taxes and Charges Template"
-
get_tax_template_for_sez(party_details, master_doctype, company, 'Supplier')
get_tax_template_based_on_category(master_doctype, company, party_details)
@@ -196,6 +201,17 @@
if return_taxes:
return party_details
+def is_internal_transfer(party_details, doctype):
+ if doctype in ("Sales Invoice", "Delivery Note", "Sales Order"):
+ destination_gstin = party_details.company_gstin
+ elif doctype in ("Purchase Invoice", "Purchase Order", "Purchase Receipt"):
+ destination_gstin = party_details.supplier_gstin
+
+ if party_details.gstin == destination_gstin:
+ return True
+ else:
+ False
+
def get_tax_template_based_on_category(master_doctype, company, party_details):
if not party_details.get('tax_category'):
return
@@ -218,7 +234,6 @@
(not default_tax and not tax_category.gst_state):
default_tax = frappe.db.get_value(master_doctype,
{'disabled': 0, 'tax_category': tax_category.name}, 'name')
-
return default_tax
def get_tax_template_for_sez(party_details, master_doctype, company, party_type):
@@ -357,16 +372,13 @@
return exemptions
def get_ewb_data(dt, dn):
- if dt != 'Sales Invoice':
- frappe.throw(_('e-Way Bill JSON can only be generated from Sales Invoice'))
-
dn = dn.split(',')
ewaybills = []
for doc_name in dn:
doc = frappe.get_doc(dt, doc_name)
- validate_sales_invoice(doc)
+ validate_doc(doc)
data = frappe._dict({
"transporterId": "",
@@ -376,12 +388,14 @@
data.userGstin = data.fromGstin = doc.company_gstin
data.supplyType = 'O'
- if doc.gst_category in ['Registered Regular', 'SEZ']:
+ if dt == 'Delivery Note':
+ data.subSupplyType = 1
+ elif doc.gst_category in ['Registered Regular', 'SEZ']:
data.subSupplyType = 1
elif doc.gst_category in ['Overseas', 'Deemed Export']:
data.subSupplyType = 3
else:
- frappe.throw(_('Unsupported GST Category for e-Way Bill JSON generation'))
+ frappe.throw(_('Unsupported GST Category for E-Way Bill JSON generation'))
data.docType = 'INV'
data.docDate = frappe.utils.formatdate(doc.posting_date, 'dd/mm/yyyy')
@@ -535,12 +549,12 @@
return data
-def validate_sales_invoice(doc):
+def validate_doc(doc):
if doc.docstatus != 1:
- frappe.throw(_('e-Way Bill JSON can only be generated from submitted document'))
+ frappe.throw(_('E-Way Bill JSON can only be generated from submitted document'))
if doc.is_return:
- frappe.throw(_('e-Way Bill JSON cannot be generated for Sales Return as of now'))
+ frappe.throw(_('E-Way Bill JSON cannot be generated for Sales Return as of now'))
if doc.ewaybill:
frappe.throw(_('e-Way Bill already exists for this document'))
@@ -550,9 +564,9 @@
for fieldname in reqd_fields:
if not doc.get(fieldname):
- frappe.throw(_('{} is required to generate e-Way Bill JSON'.format(
+ frappe.throw(_('{} is required to generate E-Way Bill JSON').format(
doc.meta.get_label(fieldname)
- )))
+ ))
if len(doc.company_gstin) < 15:
frappe.throw(_('You must be a registered supplier to generate e-Way Bill'))