[fix] total amount in journal entry

This commit is contained in:
Rushabh Mehta 2015-11-25 17:51:00 +05:30
parent 131bec67bc
commit b82bdd6f1f
5 changed files with 63 additions and 15 deletions

View File

@ -339,15 +339,17 @@ class JournalEntry(AccountsController):
self.remark = ("\n").join(r) #User Remarks is not mandatory
def set_print_format_fields(self):
total_amount = 0.0
for d in self.get('accounts'):
if d.party_type and d.party:
if not self.pay_to_recd_from:
self.pay_to_recd_from = frappe.db.get_value(d.party_type, d.party,
"customer_name" if d.party_type=="Customer" else "supplier_name")
self.set_total_amount(d.debit or d.credit)
elif frappe.db.get_value("Account", d.account, "account_type") in ["Bank", "Cash"]:
self.set_total_amount(d.debit or d.credit)
total_amount += (d.debit or d.credit)
self.set_total_amount(total_amount)
def set_total_amount(self, amt):
self.total_amount = amt

View File

@ -0,0 +1,30 @@
{%- from "templates/print_formats/standard_macros.html" import add_header -%}
<div class="page-break">
{%- if not doc.get("print_heading") and not doc.get("select_print_heading")
and doc.set("select_print_heading", _("Payment Receipt Note")) -%}{%- endif -%}
{{ add_header(0, 1, doc, letter_head, no_letterhead) }}
{%- for label, value in (
(_("Received On"), frappe.utils.formatdate(doc.voucher_date)),
(_("Received From"), doc.pay_to_recd_from),
(_("Amount"), "<strong>" + doc.get_formatted("total_amount") + "</strong><br>" + (doc.total_amount_in_words or "") + "<br>"),
(_("Remarks"), doc.remark)
) -%}
<div class="row">
<div class="col-xs-3"><label class="text-right">{{ label }}</label></div>
<div class="col-xs-9">{{ value }}</div>
</div>
{%- endfor -%}
<hr>
<br>
<p class="strong">
{{ _("For") }} {{ doc.company }},<br>
<br>
<br>
<br>
{{ _("Authorized Signatory") }}
</p>
</div>

View File

@ -1,15 +1,17 @@
{
"creation": "2012-05-01 12:46:31",
"doc_type": "Journal Entry",
"docstatus": 0,
"doctype": "Print Format",
"html": "{%- from \"templates/print_formats/standard_macros.html\" import add_header -%}\n<div class=\"page-break\">\n {%- if not doc.get(\"print_heading\") and not doc.get(\"select_print_heading\") \n and doc.set(\"select_print_heading\", _(\"Payment Receipt Note\")) -%}{%- endif -%}\n {{ add_header(0, 1, doc, letter_head, no_letterhead) }}\n\n {%- for label, value in (\n (_(\"Received On\"), frappe.utils.formatdate(doc.voucher_date)),\n (_(\"Received From\"), doc.pay_to_recd_from),\n (_(\"Amount\"), \"<strong>\" + doc.get_formatted(\"total_amount\") + \"</strong><br>\" + (doc.total_amount_in_words or \"\") + \"<br>\"),\n (_(\"Remarks\"), doc.remark)\n ) -%}\n <div class=\"row\">\n <div class=\"col-xs-3\"><label class=\"text-right\">{{ label }}</label></div>\n <div class=\"col-xs-9\">{{ value }}</div>\n </div>\n\n {%- endfor -%}\n\n <hr>\n <br>\n <p class=\"strong\">\n {{ _(\"For\") }} {{ doc.company }},<br>\n <br>\n <br>\n <br>\n {{ _(\"Authorized Signatory\") }}\n </p>\n</div>\n\n",
"idx": 1,
"modified": "2015-01-16 11:03:22.893209",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Payment Receipt Voucher",
"owner": "Administrator",
"print_format_type": "Server",
"creation": "2012-05-01 12:46:31",
"custom_format": 0,
"disabled": 0,
"doc_type": "Journal Entry",
"docstatus": 0,
"doctype": "Print Format",
"html": "",
"idx": 1,
"modified": "2015-11-25 07:06:00.668141",
"modified_by": "Administrator",
"name": "Payment Receipt Voucher",
"owner": "Administrator",
"print_format_builder": 0,
"print_format_type": "Server",
"standard": "Yes"
}
}

View File

@ -235,3 +235,4 @@ execute:frappe.delete_doc_if_exists("DocType", "Stock UOM Replace Utility")
erpnext.patches.v6_8.make_webform_standard #2015-11-23
erpnext.patches.v6_8.move_drop_ship_to_po_items
erpnext.patches.v6_10.fix_ordered_received_billed
erpnext.patches.v6_10.fix_jv_total_amount

View File

@ -0,0 +1,13 @@
import frappe
# patch all for-print field (total amount) in Journal Entry in 2015
def execute():
for je in frappe.get_all("Journal Entry", filters={"creation": (">", "2015-01-01")}):
je = frappe.get_doc("Journal Entry", je.name)
original = je.total_amount
je.set_print_format_fields()
if je.total_amount != original:
je.db_set("total_amount", je.total_amount, update_modified=False)
je.db_set("total_amount_in_words", je.total_amount_in_words, update_modified=False)