Merge pull request #54915 from frappe/mergify/bp/version-16-hotfix/pr-53762

feat: General ledger print template revamp and print format introduction (backport #53762)
This commit is contained in:
Khushi Rawat
2026-05-13 16:06:27 +05:30
committed by GitHub
3 changed files with 262 additions and 141 deletions

File diff suppressed because one or more lines are too long

View File

@@ -1,51 +1,114 @@
<!-- Modified on 25-11-2024
-->
<style type="text/css"> <style type="text/css">
/* General styles for both screen display and print */
body, html { body, html {
margin-top: 10; margin-top: 10px;
padding: 0; padding: 0;
width: 100%; width: 100%;
height: auto; /* Allow content to expand */ height: auto;
font-family: Arial, sans-serif; /* Example font */ font-family: Inter, sans-serif;
font-size: 14px;
line-height: 21px;
color: #171717;
} }
/* Ensure consistent letter spacing across all media */
.title-letter-spacing { .title-letter-spacing {
letter-spacing: .2rem; font-size: 15px;
font-weight: 600;
color: #171717;
}
.report-table table {
width: 100%;
table-layout: fixed;
border-collapse: collapse;
}
.report-table thead th {
background: #f8f8f8;
text-align: center;
font-size: 14px;
font-weight: 500;
color: #7c7c7c;
border-top: 1px solid #ededed;
border-bottom: 1px solid #ededed;
padding: 6px 8px;
}
.report-table tbody td {
padding: 6px 8px;
border-top: 1px solid #ededed;
border-bottom: 1px solid #ededed;
vertical-align: top;
word-wrap: break-word;
font-size: 14px;
}
.report-table thead th:first-child {
border-left: 1px solid #ededed;
}
.report-table thead th:last-child {
border-right: 1px solid #ededed;
}
.report-table tbody tr:last-child td {
border-bottom: none;
}
.date-col {
white-space: nowrap;
}
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; font-variant-numeric: tabular-nums; }
.text-bold { font-weight: 700; }
.report-meta {
margin: 10px 0 14px;
padding: 8px 10px;
color: #171717;
font-size: 14px;
display: flex;
justify-content: space-between;
align-items: flex-start;
gap: 12px;
}
.report-meta .left,
.report-meta .right {
display: flex;
flex-direction: column;
}
.report-meta .filter-row {
margin-bottom: 4px;
line-height: 1.5;
}
.report-meta strong {
color: #7c7c7c;
font-weight: 500;
}
.report-subtitle {
margin: 10px 0 14px;
} }
/* Styles specific to printing and PDF generation */
@media print { @media print {
/* Set page size and margins for printing */
@page { @page {
size: A4; /* Use fixed A4 page size */ size: A4;
margin-top: 10mm; margin-top: 10mm;
} }
/* Force a page break before elements with the class "page-break" */
.page-break {
page-break-before: always;
margin-top: 10mm; /* Add some space after the break */
}
/* Ensure table headers repeat on each printed page */
thead { thead {
display: table-header-group; display: table-header-group;
} }
/* Ensure table footers repeat on each printed page */
tfoot { tfoot {
display: table-footer-group; display: table-footer-group;
} }
tr {
th, td { page-break-inside: avoid;
padding: 1px;
border: 1px solid black; /* Example border for clarity */
} }
/* Hide elements that should not appear in print (optional) */
.no-print { .no-print {
display: none !important; display: none !important;
} }
@@ -53,129 +116,154 @@
</style> </style>
<br> <br>
<div style="font-family:Arial">
<div> <div>
<div class="title-letter-spacing" style="text-align:center; font-size:15px; text-decoration:underline;">
<b> <div class="text-center" style="margin-bottom: 12px;">
{%= __("STATEMENT OF ACCOUNTS") %}<br> <div class="title-letter-spacing">
{% if (filters.party_name) { %} {%= __("Statement Of Accounts") %}
<br>{%= filters.party_name %} </div>
{% } else if (filters.party && filters.party.length) { %} </div>
<br>{%= filters.party %}
{% } else if (filters.account) { %} {% if (subtitle && subtitle.trim()) { %}
<br>{%= filters.account %} <div class="report-subtitle">
{% } else { %} {{ subtitle }}
<br>{%= __("All Parties ") %} </div>
{% } %} {% } else { %}
</b> <div class="report-meta">
<div class="left">
<div class="filter-row">
<strong>{%= __("Customer") %}:</strong>
{%=
(filters.party.length && filters.party.join(", ")) || filters.party_name || "All Parties"
%}
</div>
</div>
<div class="right text-right">
<div class="filter-row">
<strong>{%= __("Statement Period") %}:</strong>
{%= __("{0} to {1}", [
frappe.datetime.str_to_user(filters.from_date),
frappe.datetime.str_to_user(filters.to_date)
]) %}
</div>
</div>
</div> </div>
<div style="text-align:center; font-size:13px;"> {% } %}
<b>
{%= __("{0} to {1}", [frappe.datetime.str_to_user(filters.from_date), frappe.datetime.str_to_user(filters.to_date)]) %}<br><br> <div class="report-table">
</b> <table>
</div> <thead>
</div> <tr>
<div class="show-filters"> <th style="width: 8em; text-align: left;">{%= __("Date") %}</th>
{% if subtitle %} <th style="text-align: left;">{%= __("Voucher Details") %}</th>
{{ subtitle }}
<hr> {% if(filters.show_remarks) { %}
{% endif %} <th style="text-align: left;">{%= __("Remarks") %}</th>
</div> {% } %}
<table style="width:100%; font-size: 11px">
<thead> <th style="width: 10em; text-align: right;">{%= __("Debit") %}</th>
<tr class="title-letter-spacing" style="text-align: center; font-weight:bold"> <th style="width: 10em; text-align: right;">{%= __("Credit") %}</th>
<td style="border: 1.5px solid black; width: 7em">{%= __("Date").toLocaleUpperCase() %}</td> <th style="width: 10em; text-align: right;">{%= __("Balance") %}</th>
<td style="border: 1.5px solid black">{%= __("Particulars").toLocaleUpperCase() %}</td> </tr>
{% if(filters.show_remarks) { %} </thead>
<td style="border: 1.5px solid black">{%= __("Remarks").toLocaleUpperCase() %}</td>
{% } %} <tbody>
<td style="border: 1.5px solid black; width: 9em">{%= __("Debit").toLocaleUpperCase() %}</td> {% for(var i=0, l=data.length; i<l; i++) { %}
<td style="border: 1.5px solid black; width: 9em">{%= __("Credit").toLocaleUpperCase() %}</td> {% var row = data[i]; %}
<td style="border: 1.5px solid black; width: 10.2em">{%= __("Balance").toLocaleUpperCase() %}</td> {% var is_entry = row.posting_date; %}
</tr> {% var is_last = i == l-1; %}
</thead> {% var is_second_last = i == l-2; %}
<tbody>
{% for(var i=0, l=data.length; i<l; i++) { %} <tr>
<tr style="border-bottom: 1px solid black">
{% if(data[i].posting_date) { %} <td class="text-left date-col">
<td style="text-align: center; border: 1px dotted black"> {% if(is_entry) { %}
{%= frappe.datetime.str_to_user(data[i].posting_date) %} {%= frappe.datetime.str_to_user(row.posting_date) %}
</td> {% } else if(i == 0) { %}
<td style="border-right: 1px dotted black">
{%= data[i].voucher_type %} {%= data[i].voucher_no %}
{% if(!(filters.party || filters.account)) { %}
{%= data[i].party || data[i].account %}
{% } %}<br>
{% if(data[i].bill_no) { %}
{%= __("Supplier Invoice No") %}: {%= data[i].bill_no %}
{% } %}
</td>
{% if(filters.show_remarks) { %}
<td style="border-right: 1px dotted black; font-size: 10px">
{% if(data[i].remarks != "No Remarks" && data[i].remarks != "") { %}
{%= __("Remarks") %}: {%= data[i].remarks %}<br>
{% } %}
</td>
{% } %}
<td style="text-align: right; border-right: 1px dotted black">
{% if data[i].debit != 0 %}
{%= format_currency(data[i].debit, filters.presentation_currency) %}
{% } %}
</td>
<td style="text-align: right; border-right: 1px dotted black">
{% if data[i].credit != 0 %}
{%= format_currency(data[i].credit, filters.presentation_currency) %}
{% } %}
</td>
{% } else { %}
<td style="text-align: center; border: 1px dotted black">
{% if(i == 0) { %}
{%= frappe.datetime.str_to_user(filters.from_date) %} {%= frappe.datetime.str_to_user(filters.from_date) %}
{% } %} {% } %}
</td> </td>
<td style="text-align: left; border-right: 1px dotted black"><b>
{% if(i == l-2) { %} <td class="{% if(!is_entry) { %}text-left text-bold{% } %}">
{%= __("Total") %} {% if(is_entry) { %}
{%= row.voucher_type %} {%= row.voucher_no %}
{% if(!(filters.party || filters.account)) { %}
<div style="margin-top: 2px;">
{%= row.party || row.account %}
</div>
{% } %}
{% if(row.bill_no) { %}
<div style="margin-top: 2px;">
{%= __("Supplier Invoice No") %}: {%= row.bill_no %}
</div>
{% } %}
{% } else { %} {% } else { %}
{% if(i == l-1) { %}
{% if(is_second_last) { %}
{%= __("Total") %}
{% } else if(is_last) { %}
{%= __("Closing [Opening + Total] ") %} {%= __("Closing [Opening + Total] ") %}
{% } else { %} {% } else { %}
{%= frappe.format(data[i].account, {fieldtype: "Link"}) || "&nbsp;" %} {%= frappe.format(row.account, {fieldtype: "Link"}) || "&nbsp;" %}
{% } %}
{% } %}</b>
</td>
{% if(filters.show_remarks) { %} <td style="text-align: left; border-right: 1px dotted black"></td>{% } %}
<td style="text-align: right; border-right: 1px dotted black">
{% if(i != 0){ %}
{% if(i != l-1){ %}
{%= data[i].account && format_currency(data[i].debit, filters.presentation_currency) %}
{% } %} {% } %}
{% } %} {% } %}
</td> </td>
<td style="text-align: right; border-right: 1px dotted black">
{% if(i != 0){ %} {% if(filters.show_remarks) { %}
{% if(i != l-1){ %} <td class="text-left">
{%= data[i].account && format_currency(data[i].credit, filters.presentation_currency) %} {% if(is_entry && row.remarks && row.remarks != "No Remarks") { %}
{% } %} {%= row.remarks %}
{% } %} {% } %}
</td> </td>
{% } %}
{% if(i == l-1) { %}
<td style="text-align: right; font-weight:bold; border-right: 1px dotted black">
{%= format_currency(data[i].balance, filters.presentation_currency) %}
{% if(data[i].balance < 0){ %}Cr{% } %}
{% if(data[i].balance > 0){ %}Dr{% } %}
</td>
{% } else { %}
<td style="text-align: right; border-right: 1px dotted black">
{% if(i != l-2) { %}
{%= format_currency(data[i].balance, filters.presentation_currency) %}
{% } %}
</td>
{% } %} {% } %}
</tr>
{% endfor%} <td class="text-right">
</tbody> {% if(is_entry) { %}
</table> {% if(row.debit != 0) { %}
<p class="text-right text-muted">{%= __("Printed on {0}", [frappe.datetime.str_to_user(frappe.datetime.get_datetime_as_string())]) %}</p> {%= format_currency(row.debit, filters.presentation_currency) %}
</div> {% } %}
{% } else if(i != 0 && !is_last) { %}
{%= row.account && format_currency(row.debit, filters.presentation_currency) %}
{% } %}
</td>
<td class="text-right">
{% if(is_entry) { %}
{% if(row.credit != 0) { %}
{%= format_currency(row.credit, filters.presentation_currency) %}
{% } %}
{% } else if(i != 0 && !is_last) { %}
{%= row.account && format_currency(row.credit, filters.presentation_currency) %}
{% } %}
</td>
<td class="text-right {% if(is_last) { %}text-bold{% } %}">
{% if(is_last) { %}
{%= format_currency(row.balance, filters.presentation_currency) %}
{% if(row.balance < 0) { %} Cr{% } %}
{% if(row.balance > 0) { %} Dr{% } %}
{% } else { %}
{%= format_currency(row.balance, filters.presentation_currency) %}
{% } %}
</td>
</tr>
{% } %}
</tbody>
</table>
</div>
<p class="text-right">
{%= __("Printed on {0}", [
frappe.datetime.str_to_user(frappe.datetime.get_datetime_as_string())
]) %}
</p>
</div>