refactor: clean and standardize print template for general ledger report

This commit is contained in:
Shllokkk
2026-03-24 13:16:15 +05:30
parent f483d9ff13
commit 3ba36212b0

View File

@@ -1,51 +1,84 @@
<!-- Modified on 25-11-2024
-->
<style type="text/css">
/* General styles for both screen display and print */
body, html {
margin-top: 10;
padding: 0;
width: 100%;
height: auto; /* Allow content to expand */
font-family: Arial, sans-serif; /* Example font */
height: auto;
font-family: "Inter", sans-serif;
color: #525252;
}
/* Ensure consistent letter spacing across all media */
.title-letter-spacing {
letter-spacing: .2rem;
color: #525252;
}
/* Styles specific to printing and PDF generation */
table {
width: 100%;
font-size: 11px;
border-collapse: collapse;
table-layout: fixed;
border: 1px solid #ededed;
}
thead tr {
background: #f8f8f8;
text-align: center;
font-weight: bold;
}
th, td {
padding: 6px 8px;
border: 1px solid #ededed;
vertical-align: top;
word-wrap: break-word;
}
.text-center { text-align: center; }
.text-right {
text-align: right;
font-variant-numeric: tabular-nums;
}
.text-left { text-align: left; }
.text-muted { color: #7c7c7c; }
.text-bold { font-weight: bold; }
.show-filters {
margin: 10px 0 14px;
padding: 8px 10px;
background: #f8f8f8;
border: 1px solid #ededed;
border-radius: 6px;
font-size: 12.5px;
color: #525252;
}
.show-filters .filter-row {
margin-bottom: 4px;
line-height: 1.5;
}
.show-filters .filter-row strong {
color: #7c7c7c;
font-weight: 500;
}
@media print {
/* Set page size and margins for printing */
@page {
size: A4; /* Use fixed A4 page size */
size: A4;
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 {
display: table-header-group;
}
/* Ensure table footers repeat on each printed page */
tfoot {
display: table-footer-group;
}
th, td {
padding: 1px;
border: 1px solid black; /* Example border for clarity */
tr {
page-break-inside: avoid;
}
/* Hide elements that should not appear in print (optional) */
.no-print {
display: none !important;
}
@@ -53,129 +86,151 @@
</style>
<br>
<div style="font-family:Arial">
<div>
<div class="title-letter-spacing" style="text-align:center; font-size:15px; text-decoration:underline;">
<b>
{%= __("STATEMENT OF ACCOUNTS") %}<br>
{% if (filters.party_name) { %}
<br>{%= filters.party_name %}
{% } else if (filters.party && filters.party.length) { %}
<br>{%= filters.party %}
{% } else if (filters.account) { %}
<br>{%= filters.account %}
{% } else { %}
<br>{%= __("All Parties ") %}
{% } %}
</b>
</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>
</b>
</div>
</div>
<div class="show-filters">
{% if subtitle %}
{{ subtitle }}
<hr>
{% endif %}
</div>
<table style="width:100%; font-size: 11px">
<thead>
<tr class="title-letter-spacing" style="text-align: center; font-weight:bold">
<td style="border: 1.5px solid black; width: 7em">{%= __("Date").toLocaleUpperCase() %}</td>
<td style="border: 1.5px solid black">{%= __("Particulars").toLocaleUpperCase() %}</td>
{% if(filters.show_remarks) { %}
<td style="border: 1.5px solid black">{%= __("Remarks").toLocaleUpperCase() %}</td>
{% } %}
<td style="border: 1.5px solid black; width: 9em">{%= __("Debit").toLocaleUpperCase() %}</td>
<td style="border: 1.5px solid black; width: 9em">{%= __("Credit").toLocaleUpperCase() %}</td>
<td style="border: 1.5px solid black; width: 10.2em">{%= __("Balance").toLocaleUpperCase() %}</td>
</tr>
</thead>
<tbody>
<div>
<!-- Title -->
<div class="text-center" style="margin-bottom: 12px;">
<!-- Title -->
<div class="title-letter-spacing" style="font-size: 17px; font-weight: 600; color: #171717;">
{%= __("STATEMENT OF ACCOUNTS") %}
</div>
<!-- Party / Account -->
<div style="margin-top: 6px; font-size: 12.5px; color: #525252;">
{% if (filters.party_name) { %}
{%= filters.party_name %}
{% } else if (filters.party && filters.party.length) { %}
{%= filters.party %}
{% } else if (filters.account) { %}
{%= filters.account %}
{% } else { %}
{%= __("All Parties") %}
{% } %}
</div>
<!-- Date Range -->
<div style="margin-top: 4px; font-size: 12.5px; color: #525252;">
{%= __("{0} to {1}", [
frappe.datetime.str_to_user(filters.from_date),
frappe.datetime.str_to_user(filters.to_date)
]) %}
</div>
</div>
<!-- Filters -->
<div class="show-filters">
{% if subtitle %}
{{ subtitle }}
{% endif %}
</div>
<!-- Table -->
<table>
<thead>
<tr class="title-letter-spacing">
<th style="width: 7em">{%= __("Date").toLocaleUpperCase() %}</th>
<th>{%= __("Particulars").toLocaleUpperCase() %}</th>
{% if(filters.show_remarks) { %}
<th>{%= __("Remarks").toLocaleUpperCase() %}</th>
{% } %}
<th style="width: 9em">{%= __("Debit").toLocaleUpperCase() %}</th>
<th style="width: 9em">{%= __("Credit").toLocaleUpperCase() %}</th>
<th style="width: 10.2em">{%= __("Balance").toLocaleUpperCase() %}</th>
</tr>
</thead>
<tbody>
{% for(var i=0, l=data.length; i<l; i++) { %}
<tr style="border-bottom: 1px solid black">
{% if(data[i].posting_date) { %}
<td style="text-align: center; border: 1px dotted black">
{%= frappe.datetime.str_to_user(data[i].posting_date) %}
</td>
<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>
{% var row = data[i]; %}
<tr>
<!-- DATE COLUMN -->
<td class="text-center">
{% if(row.posting_date) { %}
{%= frappe.datetime.str_to_user(row.posting_date) %}
{% } else if(i == 0) { %}
{%= frappe.datetime.str_to_user(filters.from_date) %}
{% } %}
<td style="text-align: right; border-right: 1px dotted black">
{% if data[i].debit != 0 %}
{%= format_currency(data[i].debit, filters.presentation_currency) %}
</td>
<!-- PARTICULARS -->
<td class="{% if(!row.posting_date) { %}text-left text-bold{% } %}">
{% if(row.posting_date) { %}
{%= row.voucher_type %} {%= row.voucher_no %}
{% if(!(filters.party || filters.account)) { %}
{%= row.party || row.account %}
{% } %}<br>
{% if(row.bill_no) { %}
{%= __("Supplier Invoice No") %}: {%= row.bill_no %}
{% } %}
</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) %}
{% } %}
</td>
<td style="text-align: left; border-right: 1px dotted black"><b>
{% } else { %}
{% if(i == l-2) { %}
{%= __("Total") %}
{% } else if(i == l-1) { %}
{%= __("Closing [Opening + Total] ") %}
{% } else { %}
{% if(i == l-1) { %}
{%= __("Closing [Opening + Total] ") %}
{% } else { %}
{%= frappe.format(data[i].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) %}
{% } %}
{%= frappe.format(row.account, {fieldtype: "Link"}) || "&nbsp;" %}
{% } %}
</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].credit, filters.presentation_currency) %}
{% } %}
{% } %}
</td>
<!-- REMARKS -->
{% if(filters.show_remarks) { %}
<td class="text-muted" style="font-size: 10px">
{% if(row.posting_date && row.remarks != "No Remarks" && row.remarks != "") { %}
{%= row.remarks %}
{% } %}
</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>
<!-- DEBIT -->
<td class="text-right">
{% if(row.posting_date) { %}
{% if(row.debit != 0) { %}
{%= format_currency(row.debit, filters.presentation_currency) %}
{% } %}
{% } else if(i != 0 && i != l-1) { %}
{%= row.account && format_currency(row.debit, filters.presentation_currency) %}
{% } %}
</td>
<!-- CREDIT -->
<td class="text-right">
{% if(row.posting_date) { %}
{% if(row.credit != 0) { %}
{%= format_currency(row.credit, filters.presentation_currency) %}
{% } %}
{% } else if(i != 0 && i != l-1) { %}
{%= row.account && format_currency(row.credit, filters.presentation_currency) %}
{% } %}
</td>
<!-- BALANCE -->
<td class="text-right {% if(i == l-1) { %}text-bold{% } %}">
{% if(i == l-1) { %}
{%= format_currency(row.balance, filters.presentation_currency) %}
{% if(row.balance < 0){ %}Cr{% } %}
{% if(row.balance > 0){ %}Dr{% } %}
{% } else if(i != l-2) { %}
{%= format_currency(row.balance, filters.presentation_currency) %}
{% } %}
</td>
</tr>
{% endfor%}
</tbody>
</table>
<p class="text-right text-muted">{%= __("Printed on {0}", [frappe.datetime.str_to_user(frappe.datetime.get_datetime_as_string())]) %}</p>
</div>
{% endfor %}
</tbody>
</table>
<p class="text-right text-muted">
{%= __("Printed on {0}", [
frappe.datetime.str_to_user(frappe.datetime.get_datetime_as_string())
]) %}
</p>
</div>