From ed82e8ba3b79bd65c485eca6e7200bec0159ebe4 Mon Sep 17 00:00:00 2001 From: Anurag Mishra Date: Fri, 5 Apr 2019 14:33:05 +0530 Subject: [PATCH] fix: removed before from accounts_controlle.pyr and fetch the gl from frontend --- .../bank_and_cash_payment_voucher.html | 9 +++++---- .../journal_auditing_voucher.html | 11 ++++++----- .../purchase_auditing_voucher.html | 5 +++-- .../sales_auditing_voucher.html | 3 ++- erpnext/controllers/accounts_controller.py | 6 ------ 5 files changed, 16 insertions(+), 18 deletions(-) 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 06f77b0f1d..73d8f9b984 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 @@ -7,6 +7,7 @@
+ {% 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) }} @@ -33,7 +34,7 @@ Debit - {% for entries in doc.gl_entries %} + {% for entries in gl %} {% if entries.credit == 0.0 %} {{ entries.account }} @@ -48,12 +49,12 @@ {% endfor %} Total (debit) - {{ doc.gl_entries | sum(attribute='debit') }} + {{ gl | sum(attribute='debit') }} Credit - {% for entries in doc.gl_entries %} + {% for entries in gl %} {% if entries.debit == 0.0 %} {{ entries.account }} @@ -68,7 +69,7 @@ {% endfor %} Total (credit) - {{ doc.gl_entries | sum(attribute='credit') }} + {{ gl | sum(attribute='credit') }}
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 566d444ae7..1a016e97bf 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 @@ -5,6 +5,7 @@ .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) }} @@ -31,7 +32,7 @@ Debit - {% for entries in doc.gl_entries %} + {% for entries in gl %} {% if entries.credit == 0.0 %} {{ entries.account }} @@ -43,12 +44,12 @@ {% endfor %} Total (debit) - {{ doc.gl_entries | sum(attribute='debit') }} + {{ gl | sum(attribute='debit') }} Credit - {% for entries in doc.gl_entries %} + {% for entries in gl %} {% if entries.debit == 0.0 %} {{ entries.account }} @@ -60,10 +61,10 @@ {% endfor %} Total (credit) - {{ doc.gl_entries | sum(attribute='credit') }} + {{ gl | sum(attribute='credit') }} - Narration: {{ doc.gl_entries[0].remarks }} + Narration: {{ gl[0].remarks }}
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 342ce22b3a..6c53a7ade5 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,5 +1,6 @@ {%- 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) }} @@ -62,7 +63,7 @@ {% for tax in doc.taxes %} {% 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 }} @@ -85,7 +86,7 @@ Debit Amount Credit Amount - {% for entries in doc.gl_entries %} + {% for entries in gl %} {{ loop.index }} {{ entries.account }} 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 4dc4b8a4a9..1c3fb6aee9 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,5 +1,6 @@ {%- 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) }} @@ -75,7 +76,7 @@ Debit Amount Credit Amount - {% for entries in doc.gl_entries %} + {% for entries in gl %} {{ loop.index }} {{ entries.account }} diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 7bb71ec9b5..63ea2591c5 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -119,12 +119,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"):