[general ledger] group by voucher option
This commit is contained in:
parent
2ef637b346
commit
f78d16cca1
@ -63,11 +63,21 @@ 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},
|
||||||
|
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
|
|
||||||
filters: [
|
filters: [
|
||||||
{fieldtype:"Select", label: "Company", link:"Company", default_value: "Select Company...",
|
{fieldtype:"Select", label: "Company", link:"Company", default_value: "Select Company...",
|
||||||
filter: function(val, item, opts) {
|
filter: function(val, item, opts) {
|
||||||
@ -96,6 +106,7 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
|
|||||||
return dateutil.str_to_obj(val) >= dateutil.str_to_obj(item.posting_date);
|
return dateutil.str_to_obj(val) >= dateutil.str_to_obj(item.posting_date);
|
||||||
}},
|
}},
|
||||||
{fieldtype: "Check", label: "Group by Ledger"},
|
{fieldtype: "Check", label: "Group by Ledger"},
|
||||||
|
{fieldtype: "Check", label: "Group by Voucher"},
|
||||||
{fieldtype:"Button", label: "Refresh", icon:"icon-refresh icon-white", cssClass:"btn-info"},
|
{fieldtype:"Button", label: "Refresh", icon:"icon-refresh icon-white", cssClass:"btn-info"},
|
||||||
{fieldtype:"Button", label: "Reset Filters"}
|
{fieldtype:"Button", label: "Reset Filters"}
|
||||||
],
|
],
|
||||||
@ -116,9 +127,14 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
|
|||||||
me.filter_inputs.group_by_ledger
|
me.filter_inputs.group_by_ledger
|
||||||
.parent().toggle(!!(me.account_by_name[$(this).val()]
|
.parent().toggle(!!(me.account_by_name[$(this).val()]
|
||||||
&& me.account_by_name[$(this).val()].group_or_ledger==="Group"));
|
&& me.account_by_name[$(this).val()].group_or_ledger==="Group"));
|
||||||
|
|
||||||
|
me.filter_inputs.group_by_voucher
|
||||||
|
.parent().toggle(!!(me.account_by_name[$(this).val()]
|
||||||
|
&& me.account_by_name[$(this).val()].group_or_ledger==="Ledger"));
|
||||||
});
|
});
|
||||||
|
|
||||||
this.trigger_refresh_on_change(["group_by_ledger"]);
|
this.trigger_refresh_on_change(["group_by_ledger"]);
|
||||||
|
this.trigger_refresh_on_change(["group_by_voucher"]);
|
||||||
},
|
},
|
||||||
setup_account_filter: function(company_filter) {
|
setup_account_filter: function(company_filter) {
|
||||||
var me = this;
|
var me = this;
|
||||||
@ -139,12 +155,14 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
|
|||||||
init_filter_values: function() {
|
init_filter_values: function() {
|
||||||
this._super();
|
this._super();
|
||||||
this.filter_inputs.group_by_ledger.parent().toggle(false);
|
this.filter_inputs.group_by_ledger.parent().toggle(false);
|
||||||
|
this.filter_inputs.group_by_voucher.parent().toggle(false);
|
||||||
this.filter_inputs.company.change();
|
this.filter_inputs.company.change();
|
||||||
this.filter_inputs.account.change();
|
this.filter_inputs.account.change();
|
||||||
},
|
},
|
||||||
apply_filters_from_route: function() {
|
apply_filters_from_route: function() {
|
||||||
this._super();
|
this._super();
|
||||||
this.filter_inputs.group_by_ledger.parent().toggle(false);
|
this.filter_inputs.group_by_ledger.parent().toggle(false);
|
||||||
|
this.filter_inputs.group_by_voucher.parent().toggle(false);
|
||||||
this.filter_inputs.company.change();
|
this.filter_inputs.company.change();
|
||||||
this.filter_inputs.account.change();
|
this.filter_inputs.account.change();
|
||||||
},
|
},
|
||||||
@ -196,6 +214,7 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
|
|||||||
if(!grouped_ledgers[item.account]) {
|
if(!grouped_ledgers[item.account]) {
|
||||||
grouped_ledgers[item.account] = {
|
grouped_ledgers[item.account] = {
|
||||||
entries: [],
|
entries: [],
|
||||||
|
entries_group_by_voucher: {},
|
||||||
opening: me.make_summary_row("Opening", item.account),
|
opening: me.make_summary_row("Opening", item.account),
|
||||||
totals: me.make_summary_row("Totals", item.account),
|
totals: me.make_summary_row("Totals", item.account),
|
||||||
closing: me.make_summary_row("Closing (Opening + Totals)",
|
closing: me.make_summary_row("Closing (Opening + Totals)",
|
||||||
@ -203,6 +222,13 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no]) {
|
||||||
|
grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no] = {
|
||||||
|
entries: [],
|
||||||
|
totals: me.make_summary_row("Totals", item.voucher_no)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(date < from_date || item.is_opening=="Yes") {
|
if(date < from_date || item.is_opening=="Yes") {
|
||||||
opening.debit += item.debit;
|
opening.debit += item.debit;
|
||||||
opening.credit += item.credit;
|
opening.credit += item.credit;
|
||||||
@ -215,6 +241,11 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
|
|||||||
|
|
||||||
grouped_ledgers[item.account].totals.debit += item.debit;
|
grouped_ledgers[item.account].totals.debit += item.debit;
|
||||||
grouped_ledgers[item.account].totals.credit += item.credit;
|
grouped_ledgers[item.account].totals.credit += item.credit;
|
||||||
|
|
||||||
|
grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no]
|
||||||
|
.totals.debit += item.debit;
|
||||||
|
grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no]
|
||||||
|
.totals.credit += item.credit;
|
||||||
}
|
}
|
||||||
if(item.account) {
|
if(item.account) {
|
||||||
item.against_account = me.voucher_accounts[item.voucher_type + ":"
|
item.against_account = me.voucher_accounts[item.voucher_type + ":"
|
||||||
@ -224,6 +255,9 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
|
|||||||
if(me.apply_filters(item) && item.is_opening=="No") {
|
if(me.apply_filters(item) && item.is_opening=="No") {
|
||||||
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]
|
||||||
|
.entries.push(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -241,6 +275,11 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
|
|||||||
out = this.group_data_by_ledger(grouped_ledgers);
|
out = this.group_data_by_ledger(grouped_ledgers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(this.account_by_name[this.account].group_or_ledger==="Ledger"
|
||||||
|
&& this.group_by_voucher) {
|
||||||
|
out = this.group_data_by_voucher(grouped_ledgers);
|
||||||
|
}
|
||||||
|
|
||||||
opening = me.get_balance(me.account_by_name[me.account].debit_or_credit, opening)
|
opening = me.get_balance(me.account_by_name[me.account].debit_or_credit, opening)
|
||||||
closing = me.get_balance(me.account_by_name[me.account].debit_or_credit, closing)
|
closing = me.get_balance(me.account_by_name[me.account].debit_or_credit, closing)
|
||||||
|
|
||||||
@ -283,6 +322,28 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
|
|||||||
return [{id: "_blank_first", _no_format: true, debit: "", credit: ""}].concat(out);
|
return [{id: "_blank_first", _no_format: true, debit: "", credit: ""}].concat(out);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
group_data_by_voucher: function(grouped_ledgers) {
|
||||||
|
var me = this;
|
||||||
|
var out = []
|
||||||
|
$.each(Object.keys(grouped_ledgers).sort(), function(i, account) {
|
||||||
|
if(grouped_ledgers[account].entries.length) {
|
||||||
|
$.each(Object.keys(grouped_ledgers[account].entries_group_by_voucher).sort(),
|
||||||
|
function(j, voucher) {
|
||||||
|
if(grouped_ledgers[account].entries_group_by_voucher[voucher]
|
||||||
|
.entries.length) {
|
||||||
|
out = out.concat(grouped_ledgers[account]
|
||||||
|
.entries_group_by_voucher[voucher].entries)
|
||||||
|
.concat([
|
||||||
|
grouped_ledgers[account].entries_group_by_voucher[voucher]
|
||||||
|
.totals, {id: "_blank" + j, _no_format: true,
|
||||||
|
debit: "", credit: ""}]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return [{id: "_blank_first", _no_format: true, debit: "", credit: ""}].concat(out);
|
||||||
|
},
|
||||||
|
|
||||||
get_balance: function(debit_or_credit, balance) {
|
get_balance: function(debit_or_credit, balance) {
|
||||||
if(debit_or_credit == "Debit") {
|
if(debit_or_credit == "Debit") {
|
||||||
balance.debit -= balance.credit; balance.credit = 0;
|
balance.debit -= balance.credit; balance.credit = 0;
|
||||||
|
|||||||
@ -47,8 +47,9 @@ data_map = {
|
|||||||
"order_by": "lft"
|
"order_by": "lft"
|
||||||
},
|
},
|
||||||
"GL Entry": {
|
"GL Entry": {
|
||||||
"columns": ["name", "account", "posting_date", "cost_center", "debit", "credit", "is_opening",
|
"columns": ["name", "account", "posting_date", "cost_center", "debit", "credit",
|
||||||
"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": {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user