diff --git a/erpnext/accounts/print_format/bank_and_cash_payment_voucher/bank_and_cash_payment_voucher.html b/erpnext/accounts/print_format/bank_and_cash_payment_voucher/bank_and_cash_payment_voucher.html
index 2eadb2a92ac..69e42c3bdbc 100644
--- a/erpnext/accounts/print_format/bank_and_cash_payment_voucher/bank_and_cash_payment_voucher.html
+++ b/erpnext/accounts/print_format/bank_and_cash_payment_voucher/bank_and_cash_payment_voucher.html
@@ -6,17 +6,18 @@
-
+
+ {% set gl = frappe.get_list(doctype="GL Entry", fields=["account", "party_type", "party", "debit", "credit", "remarks"], filters={"voucher_type": doc.doctype, "voucher_no": doc.name}) %}
{%- if not doc.get("print_heading") and not doc.get("select_print_heading")
and doc.set("select_print_heading", _("Payment Entry")) -%}{%- endif -%}
{{ add_header(0, 1, doc, letter_head, no_letterhead, print_settings) }}
-
+
| Voucher No: | {{ doc.name }} |
-
+
| Date: | {{ frappe.utils.formatdate(doc.creation) }} |
@@ -30,53 +31,46 @@
Party |
Amount |
+
+ | Debit |
+
+ {% for entries in gl %}
+ {% if entries.credit == 0.0 %}
+
+ | {{ entries.account }} |
+ {{ entries.party_type }} |
+ {{ entries.party }} |
+ {{ entries.debit }} |
+
+
+ Narration {{ entries.remarks }} |
+
+ {% endif %}
+ {% endfor %}
+
+ | Total (debit) |
+ {{ gl | sum(attribute='debit') }} |
+
| Credit |
- {% set total_credit = 0 -%}
- {% for entries in doc.gl_entries %}
+ {% for entries in gl %}
{% if entries.debit == 0.0 %}
| {{ entries.account }} |
{{ entries.party_type }} |
{{ entries.party }} |
{{ entries.credit }} |
- {% set total_credit = total_credit + entries.credit -%}
Narration {{ entries.remarks }} |
+ {% endif %}
+ {% endfor %}
| Total (credit) |
- {{total_credit}} |
+ {{ gl | sum(attribute='credit') }} |
- {% endif %}
- {% endfor %}
-
- | |
-
-
- | Debit |
-
- {% set total_debit = 0 -%}
- {% for entries in doc.gl_entries %}
- {% if entries.credit == 0.0 %}
-
- | {{ entries.account }} |
- {{ entries.party_type }} |
- {{ entries.party }} |
- {% set total_debit = total_debit + entries.debit -%}
- {{ entries.debit }} |
-
-
- Narration {{ entries.remarks }} |
-
-
- | Total (debit) |
- {{total_debit}} |
-
- {% endif %}
- {% endfor %}
\ No newline at end of file
diff --git a/erpnext/accounts/print_format/journal_auditing_voucher/journal_auditing_voucher.html b/erpnext/accounts/print_format/journal_auditing_voucher/journal_auditing_voucher.html
index 4565559084a..13515179816 100644
--- a/erpnext/accounts/print_format/journal_auditing_voucher/journal_auditing_voucher.html
+++ b/erpnext/accounts/print_format/journal_auditing_voucher/journal_auditing_voucher.html
@@ -3,26 +3,25 @@
.table-bordered td.top-bottom {border-top: none !important;border-bottom: none !important;}
.table-bordered td.right{border-right: none !important;}
.table-bordered td.left{border-left: none !important;}
-
-
-
+
+ {% set gl = frappe.get_list(doctype="GL Entry", fields=["account", "party_type", "party", "debit", "credit", "remarks"], filters={"voucher_type": doc.doctype, "voucher_no": doc.name}) %}
{%- if not doc.get("print_heading") and not doc.get("select_print_heading")
and doc.set("select_print_heading", _("Journal Entry")) -%}{%- endif -%}
{{ add_header(0, 1, doc, letter_head, no_letterhead, print_settings) }}
-
-
+
+
- | Voucher No: | {{ doc.name }} |
+ | Voucher No: | {{ doc.name }} |
-
+
| Date: | {{ frappe.utils.formatdate(doc.creation) }} |
-
+
| Account |
@@ -30,47 +29,43 @@
Party |
Amount |
+
+ | Debit |
+
+ {% for entries in gl %}
+ {% if entries.credit == 0.0 %}
+
+ | {{ entries.account }} |
+ {{ entries.party_type }} |
+ {{ entries.party }} |
+ {{ entries.debit }} |
+
+ {% endif %}
+ {% endfor %}
+
+ | Total (debit) |
+ {{ gl | sum(attribute='debit') }} |
+
| Credit |
- {% set total_credit = 0 -%}
- {% for entries in doc.gl_entries %}
+ {% for entries in gl %}
{% if entries.debit == 0.0 %}
| {{ entries.account }} |
{{ entries.party_type }} |
{{ entries.party }} |
{{ entries.credit }} |
- {% set total_credit = total_credit + entries.credit -%}
-
-
- | Total (credit) |
- {{total_credit}} |
{% endif %}
{% endfor %}
- | |
+ Total (credit) |
+ {{ gl | sum(attribute='credit') }} |
- | Debit |
+ Narration: {{ gl[0].remarks }} |
- {% set total_debit = 0 -%}
- {% for entries in doc.gl_entries %}
- {% if entries.credit == 0.0 %}
-
- | {{ entries.account }} |
- {{ entries.party_type }} |
- {{ entries.party }} |
- {% set total_debit = total_debit + entries.debit -%}
- {{ entries.debit }} |
-
-
- | Total (debit) |
- {{total_debit}} |
-
- {% endif %}
- {% endfor %}
\ No newline at end of file
diff --git a/erpnext/accounts/print_format/purchase_auditing_voucher/purchase_auditing_voucher.html b/erpnext/accounts/print_format/purchase_auditing_voucher/purchase_auditing_voucher.html
index 35852e1e1c8..a7c3bce0b4f 100644
--- a/erpnext/accounts/print_format/purchase_auditing_voucher/purchase_auditing_voucher.html
+++ b/erpnext/accounts/print_format/purchase_auditing_voucher/purchase_auditing_voucher.html
@@ -1,10 +1,11 @@
{%- from "templates/print_formats/standard_macros.html" import add_header -%}
-
+
+ {% set gl = frappe.get_list(doctype="GL Entry", fields=["account", "party_type", "party", "debit", "credit", "remarks"], filters={"voucher_type": doc.doctype, "voucher_no": doc.name}) %}
{%- if not doc.get("print_heading") and not doc.get("select_print_heading")
and doc.set("select_print_heading", _("Purchase Invoice")) -%}{%- endif -%}
{{ add_header(0, 1, doc, letter_head, no_letterhead, print_settings) }}
-
+
| Supplier Name: | {{ doc.supplier }} |
| Due Date: | {{ frappe.utils.formatdate(doc.due_date) }} |
@@ -13,7 +14,7 @@
| Mobile no: | {{doc.contact_mobile}} |
-
+
| Voucher No: | {{ doc.name }} |
| Date: | {{ frappe.utils.formatdate(doc.creation) }} |
@@ -49,21 +50,27 @@
-
+
| Total Quantity: | {{ doc.total_qty }} |
| Total: | {{doc.total}} |
| Net Weight: | {{ doc.total_net_weight }} |
-
+
| Tax and Charges: | {{doc.taxes_and_charges}} |
{% for tax in doc.taxes %}
- | {{ tax.account_head }}: | {{ tax.tax_amount_after_discount_amount }} |
+ {% if tax.tax_amount_after_discount_amount!= 0 %}
+ | {{ tax.account_head }}: | {{ tax.tax_amount_after_discount_amount }} |
+ {% endif %}
{% endfor %}
+ {% if doc.taxes_and_charges_added!= 0 %}
| Taxes and Charges Added: | {{ doc.taxes_and_charges_added }} |
+ {% endif %}
+ {% if doc.taxes_and_charges_deducted!= 0 %}
| Taxes and Charges Deducted: | {{ doc.taxes_and_charges_deducted }} |
+ {% endif %}
| Total Taxes and Charges: | {{ doc.total_taxes_and_charges }} |
| Net Payable: | {{ doc.grand_total }} |
@@ -76,17 +83,17 @@
Account |
Party Type |
Party |
-
Credit Amount |
Debit Amount |
+
Credit Amount |
- {% for entries in doc.gl_entries %}
+ {% for entries in gl %}
| {{ loop.index }} |
{{ entries.account }} |
{{ entries.party_type }} |
{{ entries.party }} |
- {{ entries.credit }} |
{{ entries.debit }} |
+ {{ entries.credit }} |
{% endfor %}
diff --git a/erpnext/accounts/print_format/sales_auditing_voucher/sales_auditing_voucher.html b/erpnext/accounts/print_format/sales_auditing_voucher/sales_auditing_voucher.html
index 04de83de708..ef4ada14a3e 100644
--- a/erpnext/accounts/print_format/sales_auditing_voucher/sales_auditing_voucher.html
+++ b/erpnext/accounts/print_format/sales_auditing_voucher/sales_auditing_voucher.html
@@ -1,10 +1,11 @@
{%- from "templates/print_formats/standard_macros.html" import add_header -%}
-
+
+ {% set gl = frappe.get_list(doctype="GL Entry", fields=["account", "party_type", "party", "debit", "credit", "remarks"], filters={"voucher_type": doc.doctype, "voucher_no": doc.name}) %}
{%- if not doc.get("print_heading") and not doc.get("select_print_heading")
and doc.set("select_print_heading", _("Sales Invoice")) -%}{%- endif -%}
{{ add_header(0, 1, doc, letter_head, no_letterhead, print_settings) }}
-
+
| Customer Name: | {{ doc.customer }} |
| Due Date: | {{ frappe.utils.formatdate(doc.due_date) }} |
@@ -13,7 +14,7 @@
| Mobile no: | {{doc.contact_mobile}} |
-
+
| Voucher No: | {{ doc.name }} |
| Date: | {{ frappe.utils.formatdate(doc.creation) }} |
@@ -45,18 +46,20 @@
-
+
| Total Quantity: | {{ doc.total_qty }} |
| Total: | {{doc.total}} |
| Net Weight: | {{ doc.total_net_weight }} |
-
+
| Tax and Charges: | {{doc.taxes_and_charges}} |
{% for tax in doc.taxes %}
- | {{ tax.account_head }}: | {{ tax.tax_amount_after_discount_amount }} |
+ {% if tax.tax_amount_after_discount_amount!= 0 %}
+ | {{ tax.account_head }}: | {{ tax.tax_amount_after_discount_amount }} |
+ {% endif %}
{% endfor %}
| Total Taxes and Charges: | {{ doc.total_taxes_and_charges }} |
| Net Payable: | {{ doc.grand_total }} |
@@ -70,17 +73,17 @@
Account |
Party Type |
Party |
- Credit Amount |
Debit Amount |
+ Credit Amount |
- {% for entries in doc.gl_entries %}
+ {% for entries in gl %}
| {{ loop.index }} |
{{ entries.account }} |
{{ entries.party_type }} |
{{ entries.party }} |
- {{ entries.credit }} |
{{ entries.debit }} |
+ {{ entries.credit }} |
{% endfor %}
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index 86b1ab6ece8..34bbe7b9994 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -116,12 +116,6 @@ class AccountsController(TransactionBase):
self.validate_non_invoice_documents_schedule()
def before_print(self):
- if self.doctype in ['Journal Entry', 'Payment Entry', 'Sales Invoice', 'Purchase Invoice']:
- self.gl_entries = frappe.get_list("GL Entry", filters={
- "voucher_type": self.doctype,
- "voucher_no": self.name
- }, fields=["account", "party_type", "party", "debit", "credit", "remarks"])
-
if self.doctype in ['Purchase Order', 'Sales Order', 'Sales Invoice', 'Purchase Invoice',
'Supplier Quotation', 'Purchase Receipt', 'Delivery Note', 'Quotation']:
if self.get("group_same_items"):