Sales Invoice Header for India

I wanted to share a custom print format for the Sales Invoice header that I developed with help from Claude.ai. This template is specifically designed for Indian businesses, fully compatible with GST requirements while maintaining a clean, space-efficient layout.

Key Features:

  • Fully compliant with Indian GST requirements
  • GSTIN display for both shipping and billing addresses
  • e-Invoice QR code and IRN integration
  • Place of Supply field included
  • e-Way Bill details support
  • 3-column layout with equal widths
  • Shows “DRAFT” for unsubmitted invoices
  • Compact design that saves vertical space
  • Optimized for black and white printing
  • Contact details integrated with shipping address
  • All details in the right column are in separate bordered rows for clarity

You can copy the code below and create a new print format in ERPNext. Just create a new print format for Sales Invoice, set it as custom HTML, and paste this code at the beginning.

<style>
.invoice-header {
    margin: 0;
    padding: 0;
}
.header-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 1em;
}
.header-table td {
    padding: 6px;
    border: 1.5px solid #000;
    vertical-align: top;
}
.col-1, .col-2, .col-3 {
    width: 33.33%;
}
.col-3 {
    padding: 0 !important;
}
.right-detail {
    padding: 6px;
    border-bottom: 1.5px solid #000;
}
.right-detail:last-child {
    border-bottom: none;
}
.right-label {
    display: inline-block;
    width: 80px;
    font-weight: bold;
}
.contact-info {
    margin-top: 6px;
    border-top: 1px solid #000;
    padding-top: 6px;
}
</style>

<div class="invoice-header">
    <table class="header-table">
        <tr>
            <td class="col-1">
                <strong>Shipped To:</strong><br>
                {{ doc.customer_name }}<br>
                {% if doc.dispatch_address_name %}{{ doc.dispatch_address_name }}<br>{% endif %}
                {{ doc.shipping_address if doc.shipping_address else doc.address_display }}<br>
                {% if doc.shipping_gstin %}GSTIN: {{ doc.shipping_gstin }}{% endif %}
                {% if doc.contact_display or doc.contact_mobile or doc.contact_email %}
                    <div class="contact-info">
                    <strong>Contact:</strong> {% if doc.contact_display %}{{ doc.contact_display }}{% endif %}
                    {% if doc.contact_mobile %}<br>Tel: {{ doc.contact_mobile }}{% endif %}
                    {% if doc.contact_email %}<br>Email: {{ doc.contact_email }}{% endif %}
                    </div>
                {% endif %}
            </td>

            <td class="col-2">
                <strong>Billed To:</strong><br>
                {{ doc.customer_name }}<br>
                {{ doc.address_display if doc.address_display else '' }}<br>
                {% if doc.billing_gstin %}GSTIN: {{ doc.billing_gstin }}{% endif %}
            </td>

            <td class="col-3">
                <div class="right-detail">
                    <span class="right-label">Invoice No:</span> 
                    {% if doc.docstatus == 1 %}{{ doc.name }}{% else %}DRAFT{% endif %}
                </div>
                <div class="right-detail">
                    <span class="right-label">Date:</span> {{ doc.get_formatted("posting_date") }}
                </div>
                <div class="right-detail">
                    <span class="right-label">Place:</span> {{ doc.place_of_supply }}
                </div>

                {% if doc.po_no %}
                    <div class="right-detail">
                        <span class="right-label">PO No:</span> {{ doc.po_no }}
                    </div>
                    {% if doc.po_date %}
                    <div class="right-detail">
                        <span class="right-label">PO Date:</span> {{ doc.get_formatted("po_date") }}
                    </div>
                    {% endif %}
                {% endif %}

                {% if doc.transporter_name %}
                    <div class="right-detail">
                        <span class="right-label">Transport:</span> {{ doc.transporter_name }}
                    </div>
                {% endif %}
                {% if doc.vehicle_no %}
                    <div class="right-detail">
                        <span class="right-label">Vehicle:</span> {{ doc.vehicle_no }}
                    </div>
                {% endif %}
                {% if doc.lr_no %}
                    <div class="right-detail">
                        <span class="right-label">LR No:</span> {{ doc.lr_no }}
                    </div>
                {% endif %}
                {% if doc.ewaybill %}
                    <div class="right-detail">
                        <span class="right-label">e-Way:</span> {{ doc.ewaybill }}
                    </div>
                {% endif %}

                {% if doc.irn %}
                    {% set e_invoice_log = frappe.db.get_value("e-Invoice Log", doc.irn, ("invoice_data", "signed_qr_code"), as_dict=True) %}
                    {% if e_invoice_log %}
                        {% set invoice_data = json.loads(e_invoice_log.invoice_data) %}
                        {% set date_format = frappe.db.get_single_value("System Settings",'date_format').replace("mm","MM") %}
                        <div class="right-detail">
                            {{ web_block('e-Invoice QR', values={'e_invoice_qr_text': e_invoice_log.signed_qr_code }) }}
                        </div>
                        <div class="right-detail">
                            <span class="right-label">IRN:</span> {{ doc.irn }}
                        </div>
                        <div class="right-detail">
                            <span class="right-label">Ack No:</span> {{ invoice_data.get("AckNo") if doc.irn and invoice_data.get("AckNo") else '' }}
                        </div>
                        <div class="right-detail">
                            <span class="right-label">Ack Dt:</span> {{ frappe.utils.format_datetime(invoice_data.get("AckDt"),date_format) if doc.irn and invoice_data.get("AckDt") else '' }}
                        </div>
                    {% endif %}
                {% endif %}
            </td>
        </tr>
    </table>
</div>

The template handles various GST and business scenarios:

  • Documents in draft and submitted states
  • Different GSTIN for shipping and billing addresses
  • e-Invoice QR code and IRN details
  • e-Way Bill information
  • Transport and vehicle details
  • PO references
  • Place of Supply

The template is particularly useful for Indian businesses that need to maintain GST compliance while keeping their invoice format clean and professional. The styles are kept minimal and focused on layout and readability rather than decorative elements.

1 Like