[general ledger] group by voucher

This commit is contained in:
Nabin Hait
2013-06-24 13:54:16 +05:30
parent 55d0ec36ac
commit 8b96ba1da6
2 changed files with 13 additions and 23 deletions

View File

@@ -63,15 +63,6 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
open_btn: true, open_btn: true,
doctype: "dataContext.voucher_type" doctype: "dataContext.voucher_type"
}}, }},
{id: "against_voucher_type", name: "Against Voucher Type",
field: "against_voucher_type", width: 120},
{id: "against_voucher", name: "Against Voucher",
field: "against_voucher", width: 160,
link_formatter: {
filter_input: "against_voucher",
open_btn: true,
doctype: "dataContext.against_voucher_type"
}},
{id: "remarks", name: "Remarks", field: "remarks", width: 200, {id: "remarks", name: "Remarks", field: "remarks", width: 200,
formatter: this.text_formatter}, formatter: this.text_formatter},
@@ -224,8 +215,8 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
if(!grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no]) { if(!grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no]) {
grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no] = { grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no] = {
entries: [], row: {},
totals: me.make_summary_row("Totals", item.voucher_no) totals: {"debit": 0, "credit": 0}
} }
} }
@@ -256,8 +247,10 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
out.push(item); out.push(item);
grouped_ledgers[item.account].entries.push(item); grouped_ledgers[item.account].entries.push(item);
grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no] if(grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no].row){
.entries.push(item); grouped_ledgers[item.account].
entries_group_by_voucher[item.voucher_no].row = item;
}
} }
} }
}); });
@@ -329,14 +322,12 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
if(grouped_ledgers[account].entries.length) { if(grouped_ledgers[account].entries.length) {
$.each(Object.keys(grouped_ledgers[account].entries_group_by_voucher).sort(), $.each(Object.keys(grouped_ledgers[account].entries_group_by_voucher).sort(),
function(j, voucher) { function(j, voucher) {
if(grouped_ledgers[account].entries_group_by_voucher[voucher] voucher_dict = grouped_ledgers[account].entries_group_by_voucher[voucher];
.entries.length) { if(voucher_dict.totals.debit || voucher_dict.totals.credit) {
out = out.concat(grouped_ledgers[account] voucher_dict.row.debit = voucher_dict.totals.debit;
.entries_group_by_voucher[voucher].entries) voucher_dict.row.credit = voucher_dict.totals.credit;
.concat([ voucher_dict.row.id = "entry" + voucher
grouped_ledgers[account].entries_group_by_voucher[voucher] out = out.concat(voucher_dict.row);
.totals, {id: "_blank" + j, _no_format: true,
debit: "", credit: ""}]);
} }
}); });
} }

View File

@@ -48,8 +48,7 @@ data_map = {
}, },
"GL Entry": { "GL Entry": {
"columns": ["name", "account", "posting_date", "cost_center", "debit", "credit", "columns": ["name", "account", "posting_date", "cost_center", "debit", "credit",
"is_opening", "company", "voucher_type", "voucher_no", "remarks", "is_opening", "company", "voucher_type", "voucher_no", "remarks"],
"against_voucher_type", "against_voucher"],
"conditions": ["ifnull(is_cancelled, 'No')='No'"], "conditions": ["ifnull(is_cancelled, 'No')='No'"],
"order_by": "posting_date, account", "order_by": "posting_date, account",
"links": { "links": {