fix(regional): remove shipping address GSTIN validation for e-invoice (#25133)

Co-authored-by: Saqib <nextchamp.saqib@gmail.com>
This commit is contained in:
bhavesh95863
2021-04-02 15:05:07 +05:30
committed by GitHub
parent 9cc129c400
commit 15af590482

View File

@@ -86,10 +86,10 @@ def get_doc_details(invoice):
invoice_date=invoice_date invoice_date=invoice_date
)) ))
def get_party_details(address_name): def get_party_details(address_name, company_address=None, billing_address=None, shipping_address=None):
d = frappe.get_all('Address', filters={'name': address_name}, fields=['*'])[0] d = frappe.get_all('Address', filters={'name': address_name}, fields=['*'])[0]
if (not d.gstin if ((not d.gstin and not shipping_address)
or not d.city or not d.city
or not d.pincode or not d.pincode
or not d.address_title or not d.address_title
@@ -107,13 +107,16 @@ def get_party_details(address_name):
# according to einvoice standard # according to einvoice standard
pincode = 999999 pincode = 999999
return frappe._dict(dict( party_address_details = frappe._dict(dict(
gstin=d.gstin, legal_name=d.address_title, legal_name=d.address_title,
location=d.city, pincode=d.pincode, location=d.city, pincode=d.pincode,
state_code=d.gst_state_number, state_code=d.gst_state_number,
address_line1=d.address_line1, address_line1=d.address_line1,
address_line2=d.address_line2 address_line2=d.address_line2
)) ))
if d.gstin:
party_address_details.gstin = d.gstin
return party_address_details
def get_gstin_details(gstin): def get_gstin_details(gstin):
if not hasattr(frappe.local, 'gstin_cache'): if not hasattr(frappe.local, 'gstin_cache'):
@@ -322,12 +325,12 @@ def make_einvoice(invoice):
item_list = get_item_list(invoice) item_list = get_item_list(invoice)
doc_details = get_doc_details(invoice) doc_details = get_doc_details(invoice)
invoice_value_details = get_invoice_value_details(invoice) invoice_value_details = get_invoice_value_details(invoice)
seller_details = get_party_details(invoice.company_address) seller_details = get_party_details(invoice.company_address, company_address=1)
if invoice.gst_category == 'Overseas': if invoice.gst_category == 'Overseas':
buyer_details = get_overseas_address_details(invoice.customer_address) buyer_details = get_overseas_address_details(invoice.customer_address)
else: else:
buyer_details = get_party_details(invoice.customer_address) buyer_details = get_party_details(invoice.customer_address, billing_address=1)
place_of_supply = get_place_of_supply(invoice, invoice.doctype) place_of_supply = get_place_of_supply(invoice, invoice.doctype)
if place_of_supply: if place_of_supply:
place_of_supply = place_of_supply.split('-')[0] place_of_supply = place_of_supply.split('-')[0]
@@ -340,7 +343,7 @@ def make_einvoice(invoice):
if invoice.gst_category == 'Overseas': if invoice.gst_category == 'Overseas':
shipping_details = get_overseas_address_details(invoice.shipping_address_name) shipping_details = get_overseas_address_details(invoice.shipping_address_name)
else: else:
shipping_details = get_party_details(invoice.shipping_address_name) shipping_details = get_party_details(invoice.shipping_address_name, shipping_address=1)
if invoice.is_pos and invoice.base_paid_amount: if invoice.is_pos and invoice.base_paid_amount:
payment_details = get_payment_details(invoice) payment_details = get_payment_details(invoice)
@@ -833,4 +836,4 @@ def generate_eway_bill(doctype, docname, **kwargs):
@frappe.whitelist() @frappe.whitelist()
def cancel_eway_bill(doctype, docname, eway_bill, reason, remark): def cancel_eway_bill(doctype, docname, eway_bill, reason, remark):
gsp_connector = GSPConnector(doctype, docname) gsp_connector = GSPConnector(doctype, docname)
gsp_connector.cancel_eway_bill(eway_bill, reason, remark) gsp_connector.cancel_eway_bill(eway_bill, reason, remark)