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

feat(e-invoicing): dispatch address #28084

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -68,7 +68,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 @@ -86,6 +86,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
16 changes: 10 additions & 6 deletions erpnext/regional/india/e_invoice/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,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 @@ -151,10 +151,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 @@ -443,7 +443,11 @@ def make_einvoice(invoice):
if invoice.gst_category == 'Overseas':
shipping_details = get_overseas_address_details(invoice.shipping_address_name)
else:
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)

if invoice.is_pos and invoice.base_paid_amount:
payment_details = get_payment_details(invoice)
Expand All @@ -455,7 +459,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