Skip to content

Commit

Permalink
feat(e-invoicing): dispatch address (#28084)
Browse files Browse the repository at this point in the history
(cherry picked from commit cb97e95)

# Conflicts:
#	erpnext/regional/india/e_invoice/utils.py
  • Loading branch information
nextchamp-saqib authored and mergify-bot committed Oct 27, 2021
1 parent 27e9e47 commit c9154db
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
13 changes: 12 additions & 1 deletion erpnext/accounts/print_format/gst_e_invoice/gst_e_invoice.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ <h5 style="margin-bottom: 5px;">Seller</h5>

{%- if einvoice.ShipDtls -%}
{%- set shipping = einvoice.ShipDtls -%}
<h5 style="margin-bottom: 5px;">Shipping</h5>
<h5 style="margin-bottom: 5px;">Shipped From</h5>
<p>{{ shipping.Gstin }}</p>
<p>{{ shipping.LglNm }}</p>
<p>{{ shipping.Addr1 }}</p>
Expand All @@ -90,6 +90,17 @@ <h5 style="margin-bottom: 5px;">Buyer</h5>
{%- if buyer.Addr2 -%} <p>{{ buyer.Addr2 }}</p> {% endif %}
<p>{{ buyer.Loc }}</p>
<p>{{ frappe.db.get_value("Address", doc.customer_address, "gst_state") }} - {{ buyer.Pin }}</p>

{%- if einvoice.DispDtls -%}
{%- set dispatch = einvoice.DispDtls -%}
<h5 style="margin-bottom: 5px;">Dispatched From</h5>
{%- if dispatch.Gstin -%} <p>{{ dispatch.Gstin }}</p> {% endif %}
<p>{{ dispatch.LglNm }}</p>
<p>{{ dispatch.Addr1 }}</p>
{%- if dispatch.Addr2 -%} <p>{{ dispatch.Addr2 }}</p> {% endif %}
<p>{{ dispatch.Loc }}</p>
<p>{{ frappe.db.get_value("Address", doc.dispatch_address_name, "gst_state") }} - {{ dispatch.Pin }}</p>
{% endif %}
</div>
</div>
<div style="overflow-x: auto;">
Expand Down
2 changes: 1 addition & 1 deletion erpnext/regional/india/e_invoice/einv_template.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"Pos": "{buyer_details.place_of_supply}"
}},
"DispDtls": {{
"Nm": "{dispatch_details.company_name}",
"Nm": "{dispatch_details.legal_name}",
"Addr1": "{dispatch_details.address_line1}",
"Addr2": "{dispatch_details.address_line2}",
"Loc": "{dispatch_details.location}",
Expand Down
19 changes: 14 additions & 5 deletions erpnext/regional/india/e_invoice/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ def get_doc_details(invoice):
invoice_date=invoice_date
))

def validate_address_fields(address, is_shipping_address):
if ((not address.gstin and not is_shipping_address)
def validate_address_fields(address, skip_gstin_validation):
if ((not address.gstin and not skip_gstin_validation)
or not address.city
or not address.pincode
or not address.address_title
Expand All @@ -126,10 +126,10 @@ def validate_address_fields(address, is_shipping_address):
title=_('Missing Address Fields')
)

def get_party_details(address_name, is_shipping_address=False):
def get_party_details(address_name, skip_gstin_validation=False):
addr = frappe.get_doc('Address', address_name)

validate_address_fields(addr, is_shipping_address)
validate_address_fields(addr, skip_gstin_validation)

if addr.gst_state_number == 97:
# according to einvoice standard
Expand Down Expand Up @@ -434,8 +434,17 @@ def make_einvoice(invoice):
if invoice.gst_category == 'Overseas':
shipping_details = get_overseas_address_details(invoice.shipping_address_name)
else:
<<<<<<< HEAD
shipping_details = get_party_details(invoice.shipping_address_name, is_shipping_address=True)

=======
shipping_details = get_party_details(invoice.shipping_address_name, skip_gstin_validation=True)

dispatch_details = frappe._dict({})
if invoice.dispatch_address_name:
dispatch_details = get_party_details(invoice.dispatch_address_name, skip_gstin_validation=True)

>>>>>>> cb97e950e6 (feat(e-invoicing): dispatch address (#28084))
if invoice.is_pos and invoice.base_paid_amount:
payment_details = get_payment_details(invoice)

Expand All @@ -446,7 +455,7 @@ def make_einvoice(invoice):
eway_bill_details = get_eway_bill_details(invoice)

# not yet implemented
dispatch_details = period_details = export_details = frappe._dict({})
period_details = export_details = frappe._dict({})

einvoice = schema.format(
transaction_details=transaction_details, doc_details=doc_details, dispatch_details=dispatch_details,
Expand Down

0 comments on commit c9154db

Please sign in to comment.