From b62cfffdea95fde81fa0cc83d18758db3f376176 Mon Sep 17 00:00:00 2001 From: Anurag Mishra Date: Fri, 5 Apr 2019 12:35:46 +0530 Subject: [PATCH 1/4] fix: Print Auditing print format --- .../bank_and_cash_payment_voucher.html | 53 ++++++++----------- .../journal_auditing_voucher.html | 50 ++++++++--------- .../purchase_auditing_voucher.html | 12 +++-- .../sales_auditing_voucher.html | 8 +-- 4 files changed, 59 insertions(+), 64 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 2eadb2a92a..06f77b0f1d 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 @@ -30,10 +30,29 @@ Party Amount + + Debit + + {% for entries in doc.gl_entries %} + {% if entries.credit == 0.0 %} + + {{ entries.account }} + {{ entries.party_type }} + {{ entries.party }} + {{ entries.debit }} + + + Narration
{{ entries.remarks }} + + {% endif %} + {% endfor %} + + Total (debit) + {{ doc.gl_entries | sum(attribute='debit') }} + Credit - {% set total_credit = 0 -%} {% for entries in doc.gl_entries %} {% if entries.debit == 0.0 %} @@ -41,42 +60,16 @@ {{ entries.party_type }} {{ entries.party }} {{ entries.credit }} - {% set total_credit = total_credit + entries.credit -%} Narration
{{ entries.remarks }} + {% endif %} + {% endfor %} Total (credit) - {{total_credit}} + {{ doc.gl_entries | 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 4565559084..566d444ae7 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,14 +3,12 @@ .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;} - -
{%- 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) }} -
+
@@ -22,7 +20,7 @@
Voucher No: {{ doc.name }}
-
+
@@ -30,10 +28,26 @@ + + + + {% for entries in doc.gl_entries %} + {% if entries.credit == 0.0 %} + + + + + + + {% endif %} + {% endfor %} + + + + - {% set total_credit = 0 -%} {% for entries in doc.gl_entries %} {% if entries.debit == 0.0 %} @@ -41,36 +55,16 @@ - {% set total_credit = total_credit + entries.credit -%} - - - - {% endif %} {% endfor %} - + + - + - {% set total_debit = 0 -%} - {% for entries in doc.gl_entries %} - {% if entries.credit == 0.0 %} - - - - - {% set total_debit = total_debit + entries.debit -%} - - - - - - - {% endif %} - {% endfor %}
AccountParty Amount
Debit
{{ entries.account }}{{ entries.party_type }}{{ entries.party }}{{ entries.debit }}
Total (debit) {{ doc.gl_entries | sum(attribute='debit') }}
Credit
{{ entries.party_type }} {{ entries.party }} {{ entries.credit }}
Total (credit) {{total_credit}}
Total (credit) {{ doc.gl_entries | sum(attribute='credit') }}
DebitNarration: {{ doc.gl_entries[0].remarks }}
{{ entries.account }}{{ entries.party_type }}{{ entries.party }}{{ entries.debit }}
Total (debit) {{total_debit}}
\ 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 35852e1e1c..342ce22b3a 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 @@ -60,10 +60,16 @@ {% for tax in doc.taxes %} - + {% if tax.tax_amount_after_discount_amount!= 0 %} + + {% endfor %} + {% if doc.taxes_and_charges_added!= 0 %} + {% endif %} + {% if doc.taxes_and_charges_deducted!= 0 %} + {% endif %}
Tax and Charges: {{doc.taxes_and_charges}}
{{ tax.account_head }}: {{ tax.tax_amount_after_discount_amount }}
{{ tax.account_head }}: {{ tax.tax_amount_after_discount_amount }}
Taxes and Charges Added: {{ doc.taxes_and_charges_added }}
Taxes and Charges Deducted: {{ doc.taxes_and_charges_deducted }}
Total Taxes and Charges: {{ doc.total_taxes_and_charges }}
Net Payable: {{ doc.grand_total }}
@@ -76,8 +82,8 @@ Account Party Type Party - Credit Amount Debit Amount + Credit Amount {% for entries in doc.gl_entries %} @@ -85,8 +91,8 @@ {{ 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 04de83de70..4dc4b8a4a9 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 @@ -56,7 +56,9 @@ {% for tax in doc.taxes %} - + {% if tax.tax_amount_after_discount_amount!= 0 %} + + {% endif %} {% endfor %} @@ -70,8 +72,8 @@ - + {% for entries in doc.gl_entries %} @@ -79,8 +81,8 @@ - + {% endfor %} From ed82e8ba3b79bd65c485eca6e7200bec0159ebe4 Mon Sep 17 00:00:00 2001 From: Anurag Mishra Date: Fri, 5 Apr 2019 14:33:05 +0530 Subject: [PATCH 2/4] 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 @@
- {% for entries in doc.gl_entries %} + {% for entries in gl %} {% if entries.credit == 0.0 %} @@ -48,12 +49,12 @@ {% endfor %} - + - {% for entries in doc.gl_entries %} + {% for entries in gl %} {% if entries.debit == 0.0 %} @@ -68,7 +69,7 @@ {% endfor %} - +
Tax and Charges: {{doc.taxes_and_charges}}
{{ tax.account_head }}: {{ tax.tax_amount_after_discount_amount }}
{{ tax.account_head }}: {{ tax.tax_amount_after_discount_amount }}
Total Taxes and Charges: {{ doc.total_taxes_and_charges }}
Net Payable: {{ doc.grand_total }}
Account Party Type PartyCredit Amount Debit AmountCredit Amount
{{ entries.account }} {{ entries.party_type }} {{ entries.party }}{{ entries.credit }} {{ entries.debit }}{{ entries.credit }}
Debit
{{ entries.account }}
Total (debit) {{ doc.gl_entries | sum(attribute='debit') }}{{ gl | sum(attribute='debit') }}
Credit
{{ entries.account }}
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"): From ef11d378d4af19254fb6f30775c4d4ed8c5e11dc Mon Sep 17 00:00:00 2001 From: Anurag Mishra Date: Mon, 8 Apr 2019 10:53:19 +0530 Subject: [PATCH 3/4] fix: UI on generating pdf in print format --- .../bank_and_cash_payment_voucher.html | 4 ++-- .../journal_auditing_voucher.html | 6 +++--- .../purchase_auditing_voucher.html | 8 ++++---- .../sales_auditing_voucher/sales_auditing_voucher.html | 8 ++++---- 4 files changed, 13 insertions(+), 13 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 73d8f9b984..7605550c4a 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 @@ -12,12 +12,12 @@ 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) }}
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 1a016e97bf..1b92385854 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 @@ -10,12 +10,12 @@ 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) }}
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 6c53a7ade5..397a70d036 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 @@ -5,7 +5,7 @@ and doc.set("select_print_heading", _("Purchase Invoice")) -%}{%- endif -%} {{ add_header(0, 1, doc, letter_head, no_letterhead, print_settings) }}
-
+
@@ -14,7 +14,7 @@
Supplier Name: {{ doc.supplier }}
Due Date: {{ frappe.utils.formatdate(doc.due_date) }}
Mobile no: {{doc.contact_mobile}}
-
+
@@ -50,14 +50,14 @@
Voucher No: {{ doc.name }}
Date: {{ frappe.utils.formatdate(doc.creation) }}
-
+
Total Quantity: {{ doc.total_qty }}
Total: {{doc.total}}
Net Weight: {{ doc.total_net_weight }}
-
+
{% for tax in doc.taxes %} 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 1c3fb6aee9..fe08a189ea 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 @@ -5,7 +5,7 @@ and doc.set("select_print_heading", _("Sales Invoice")) -%}{%- endif -%} {{ add_header(0, 1, doc, letter_head, no_letterhead, print_settings) }}
-
+
Tax and Charges: {{doc.taxes_and_charges}}
@@ -14,7 +14,7 @@
Customer Name: {{ doc.customer }}
Due Date: {{ frappe.utils.formatdate(doc.due_date) }}
Mobile no: {{doc.contact_mobile}}
-
+
@@ -46,14 +46,14 @@
Voucher No: {{ doc.name }}
Date: {{ frappe.utils.formatdate(doc.creation) }}
-
+
Total Quantity: {{ doc.total_qty }}
Total: {{doc.total}}
Net Weight: {{ doc.total_net_weight }}
-
+
{% for tax in doc.taxes %} From 67e6da2086755f4e13cbefb7bd4e32a7f95f1d29 Mon Sep 17 00:00:00 2001 From: Anurag Mishra Date: Mon, 8 Apr 2019 11:43:24 +0530 Subject: [PATCH 4/4] fix: Removed Extra page on generating pdf in print formats --- .../bank_and_cash_payment_voucher.html | 2 +- .../journal_auditing_voucher/journal_auditing_voucher.html | 2 +- .../purchase_auditing_voucher/purchase_auditing_voucher.html | 2 +- .../sales_auditing_voucher/sales_auditing_voucher.html | 2 +- 4 files changed, 4 insertions(+), 4 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 7605550c4a..69e42c3bdb 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,7 +6,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 -%} 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 1b92385854..1351517981 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 @@ -4,7 +4,7 @@ .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 -%} 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 397a70d036..a7c3bce0b4 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,5 @@ {%- 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 -%} 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 fe08a189ea..ef4ada14a3 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,5 @@ {%- 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 -%}
Tax and Charges: {{doc.taxes_and_charges}}