[fix] General ledger print format

This commit is contained in:
Nabin Hait 2015-05-27 13:01:38 +05:30
parent dcbc4d1a46
commit 5b8db3729c
2 changed files with 15 additions and 11 deletions

View File

@ -2,7 +2,7 @@
{%= frappe.boot.letter_heads[frappe.defaults.get_default("letter_head")] %} {%= frappe.boot.letter_heads[frappe.defaults.get_default("letter_head")] %}
</div> </div>
<h2 class="text-center">{%= __("Statement of Account") %}</h2> <h2 class="text-center">{%= __("Statement of Account") %}</h2>
<h4 class="text-center">{%= filters.account && (filters.account + ", ") || "" %} {%= filters.company %}</h4> <h4 class="text-center">{%= (filters.party || filters.account) && ((filters.party || filters.account) + ", ") || "" %} {%= filters.company %}</h4>
<h5 class="text-center"> <h5 class="text-center">
{%= dateutil.str_to_user(filters.from_date) %} {%= dateutil.str_to_user(filters.from_date) %}
{%= __("to") %} {%= __("to") %}
@ -26,15 +26,20 @@
<td>{%= dateutil.str_to_user(data[i][__("Posting Date")]) %}</td> <td>{%= dateutil.str_to_user(data[i][__("Posting Date")]) %}</td>
<td>{%= data[i][__("Voucher Type")] %} <td>{%= data[i][__("Voucher Type")] %}
<br>{%= data[i][__("Voucher No")] %}</td> <br>{%= data[i][__("Voucher No")] %}</td>
<td>{%= data[i][__("Account")] %} <td>
<br>{%= __("Against") %}: {%= data[i][__("Against Account")] %} {% if(!(filters.party || filters.account)) { %}
{%= data[i][__("Party")] || data[i][__("Account")] %}
<br>
{% } %}
{{ __("Against") }}: {%= data[i][__("Against Account")] %}
<br>{%= __("Remarks") %}: {%= data[i][__("Remarks")] %}</td> <br>{%= __("Remarks") %}: {%= data[i][__("Remarks")] %}</td>
<td style="text-align: right">{%= format_currency(data[i][__("Debit")]) %}</td> <td style="text-align: right">{%= format_currency(data[i][__("Debit")]) %}</td>
<td style="text-align: right">{%= format_currency(data[i][__("Credit")]) %}</td> <td style="text-align: right">{%= format_currency(data[i][__("Credit")]) %}</td>
{% } else { %} {% } else { %}
<td></td> <td></td>
<td></td> <td></td>
<td><b>{%= data[i][__("Account")] || "&nbsp;" %}</b></td> <td><b>{%= frappe.format(data[i][__("Account")], {fieldtype: "Link"}) || "&nbsp;" %}</b></td>
<td style="text-align: right"> <td style="text-align: right">
{%= data[i][__("Account")] && format_currency(data[i][__("Debit")]) %}</td> {%= data[i][__("Account")] && format_currency(data[i][__("Debit")]) %}</td>
<td style="text-align: right"> <td style="text-align: right">

View File

@ -9,7 +9,7 @@ from frappe import _
def execute(filters=None): def execute(filters=None):
account_details = {} account_details = {}
for acc in frappe.db.sql("""select name, is_group from tabAccount""", as_dict=1): for acc in frappe.db.sql("""select name, is_group from tabAccount""", as_dict=1):
account_details.setdefault(acc.name, acc) account_details.setdefault(acc.name, acc)
validate_filters(filters, account_details) validate_filters(filters, account_details)
validate_party(filters) validate_party(filters)
@ -82,8 +82,6 @@ def get_conditions(filters):
lft, rgt = frappe.db.get_value("Account", filters["account"], ["lft", "rgt"]) lft, rgt = frappe.db.get_value("Account", filters["account"], ["lft", "rgt"])
conditions.append("""account in (select name from tabAccount conditions.append("""account in (select name from tabAccount
where lft>=%s and rgt<=%s and docstatus<2)""" % (lft, rgt)) where lft>=%s and rgt<=%s and docstatus<2)""" % (lft, rgt))
else:
conditions.append("posting_date between %(from_date)s and %(to_date)s")
if filters.get("voucher_no"): if filters.get("voucher_no"):
conditions.append("voucher_no=%(voucher_no)s") conditions.append("voucher_no=%(voucher_no)s")
@ -107,7 +105,7 @@ def get_data_with_opening_closing(filters, account_details, gl_entries):
opening, total_debit, total_credit, gle_map = get_accountwise_gle(filters, gl_entries, gle_map) opening, total_debit, total_credit, gle_map = get_accountwise_gle(filters, gl_entries, gle_map)
# Opening for filtered account # Opening for filtered account
if filters.get("account"): if filters.get("account") or filters.get("party"):
data += [get_balance_row(_("Opening"), opening), {}] data += [get_balance_row(_("Opening"), opening), {}]
for acc, acc_dict in gle_map.items(): for acc, acc_dict in gle_map.items():
@ -130,7 +128,7 @@ def get_data_with_opening_closing(filters, account_details, gl_entries):
data.append({"account": "'" + _("Totals") + "'", "debit": total_debit, "credit": total_credit}) data.append({"account": "'" + _("Totals") + "'", "debit": total_debit, "credit": total_credit})
# Closing for filtered account # Closing for filtered account
if filters.get("account"): if filters.get("account") or filters.get("party"):
data.append(get_balance_row(_("Closing (Opening + Totals)"), data.append(get_balance_row(_("Closing (Opening + Totals)"),
(opening + total_debit - total_credit))) (opening + total_debit - total_credit)))
@ -153,9 +151,10 @@ def get_accountwise_gle(filters, gl_entries, gle_map):
for gle in gl_entries: for gle in gl_entries:
amount = flt(gle.debit, 3) - flt(gle.credit, 3) amount = flt(gle.debit, 3) - flt(gle.credit, 3)
if filters.get("account") and gle.posting_date < getdate(filters.from_date): if gle.posting_date < getdate(filters.from_date):
gle_map[gle.account].opening += amount gle_map[gle.account].opening += amount
opening += amount if filters.get("account") or filters.get("party"):
opening += amount
elif gle.posting_date <= getdate(filters.to_date): elif gle.posting_date <= getdate(filters.to_date):
gle_map[gle.account].entries.append(gle) gle_map[gle.account].entries.append(gle)
gle_map[gle.account].total_debit += flt(gle.debit, 3) gle_map[gle.account].total_debit += flt(gle.debit, 3)