Opening and closing balance in general ledger report

This commit is contained in:
Nabin Hait
2013-12-19 19:11:53 +05:30
parent 85800fa929
commit 2a9e4e9a32
5 changed files with 35 additions and 12 deletions

View File

@@ -36,7 +36,7 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({
"from_date": doc.posting_date,
"to_date": doc.posting_date,
};
wn.set_route("general-ledger");
wn.set_route("query-report/General Ledger");
}, "icon-table");
}

View File

@@ -55,7 +55,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
"from_date": doc.posting_date,
"to_date": doc.posting_date,
};
wn.set_route("general-ledger");
wn.set_route("query-report/General Ledger");
}, "icon-table");
var percent_paid = cint(flt(doc.grand_total - doc.outstanding_amount) / flt(doc.grand_total) * 100);

View File

@@ -3,20 +3,24 @@
from __future__ import unicode_literals
import webnotes
from webnotes.utils import flt
from webnotes.utils import flt, add_days
from webnotes import _
from accounts.utils import get_balance_on
def execute(filters=None):
validate_filters(filters)
columns = get_columns()
data = []
if filters.get("group_by"):
data = get_grouped_gle(filters)
data += get_grouped_gle(filters)
else:
data = get_gl_entries(filters)
data += get_gl_entries(filters)
if data:
data.append(get_total_row(data))
if filters.get("account"):
data = [get_opening_balance_row(filters)] + data + [get_closing_balance_row(filters)]
return columns, data
def validate_filters(filters):
@@ -27,12 +31,20 @@ def validate_filters(filters):
webnotes.throw(_("Can not filter based on Voucher No, if grouped by Voucher"))
def get_columns():
return ["Posting Date:Date:100", "Account:Link/Account:200", "Debit:Currency:100",
"Credit:Currency:100", "Voucher Type::120", "Voucher No::160",
return ["Posting Date:Date:100", "Account:Link/Account:200", "Debit:Float:100",
"Credit:Float:100", "Voucher Type::120", "Voucher No::160", "Link::20",
"Cost Center:Link/Cost Center:100", "Remarks::200"]
def get_opening_balance_row(filters):
opening_balance = get_balance_on(filters["account"], add_days(filters["from_date"], -1))
return ["", "Opening Balance", opening_balance, 0.0, "", "", ""]
def get_closing_balance_row(filters):
closing_balance = get_balance_on(filters["account"], filters["to_date"])
return ["", "Closing Balance", closing_balance, 0.0, "", "", ""]
def get_gl_entries(filters):
return webnotes.conn.sql("""select
gl_entries = webnotes.conn.sql("""select
posting_date, account, debit, credit, voucher_type, voucher_no, cost_center, remarks
from `tabGL Entry`
where company=%(company)s
@@ -40,6 +52,13 @@ def get_gl_entries(filters):
{conditions}
order by posting_date, account"""\
.format(conditions=get_conditions(filters)), filters, as_list=1)
for d in gl_entries:
icon = """<a href="%s"><i class="icon icon-share" style="cursor: pointer;"></i></a>""" \
% ("/".join(["#Form", d[4], d[5]]),)
d.insert(6, icon)
return gl_entries
def get_conditions(filters):
conditions = []