[fix] [report] general ledger - group by ledger and group by voucher
This commit is contained in:
parent
ed69892a0a
commit
fafb9a8843
@ -105,24 +105,12 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
|
|||||||
this.accounts_by_company = this.make_accounts_by_company();
|
this.accounts_by_company = this.make_accounts_by_company();
|
||||||
|
|
||||||
// filter accounts options by company
|
// filter accounts options by company
|
||||||
this.filter_inputs.company.change(function() {
|
this.filter_inputs.company.on("change", function() {
|
||||||
me.setup_account_filter(this);
|
me.setup_account_filter(this);
|
||||||
me.refresh()
|
me.refresh();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.filter_inputs.account.change(function() {
|
this.trigger_refresh_on_change(["group_by_ledger", "group_by_voucher"]);
|
||||||
me.make_account_by_name();
|
|
||||||
me.filter_inputs.group_by_ledger
|
|
||||||
.parent().toggle(!!(me.account_by_name[$(this).val()]
|
|
||||||
&& 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_voucher"]);
|
|
||||||
},
|
},
|
||||||
setup_account_filter: function(company_filter) {
|
setup_account_filter: function(company_filter) {
|
||||||
var me = this;
|
var me = this;
|
||||||
@ -142,17 +130,12 @@ 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.toggle_group_by_checks();
|
||||||
this.filter_inputs.group_by_voucher.parent().toggle(false);
|
this.filter_inputs.company.trigger("change");
|
||||||
this.filter_inputs.company.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.toggle_group_by_checks();
|
||||||
this.filter_inputs.group_by_voucher.parent().toggle(false);
|
|
||||||
this.filter_inputs.company.change();
|
|
||||||
this.filter_inputs.account.change();
|
|
||||||
},
|
},
|
||||||
make_accounts_by_company: function() {
|
make_accounts_by_company: function() {
|
||||||
var accounts_by_company = {};
|
var accounts_by_company = {};
|
||||||
@ -164,21 +147,27 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
|
|||||||
return accounts_by_company;
|
return accounts_by_company;
|
||||||
},
|
},
|
||||||
is_child_account: function(account, item_account) {
|
is_child_account: function(account, item_account) {
|
||||||
var opts = [account, item_account];
|
|
||||||
account = this.account_by_name[account];
|
account = this.account_by_name[account];
|
||||||
item_account = this.account_by_name[item_account];
|
item_account = this.account_by_name[item_account];
|
||||||
|
|
||||||
return ((item_account.lft >= account.lft) && (item_account.rgt <= account.rgt));
|
return ((item_account.lft >= account.lft) && (item_account.rgt <= account.rgt));
|
||||||
},
|
},
|
||||||
|
toggle_group_by_checks: function() {
|
||||||
|
this.make_account_by_name();
|
||||||
|
|
||||||
|
this.filter_inputs.group_by_ledger
|
||||||
|
.parent().toggle(!!(this.account_by_name[this.account]
|
||||||
|
&& this.account_by_name[this.account].group_or_ledger==="Group"));
|
||||||
|
|
||||||
|
this.filter_inputs.group_by_voucher
|
||||||
|
.parent().toggle(!!(this.account_by_name[this.account]
|
||||||
|
&& this.account_by_name[this.account].group_or_ledger==="Ledger"));
|
||||||
|
},
|
||||||
prepare_data: function() {
|
prepare_data: function() {
|
||||||
// add Opening, Closing, Totals rows
|
var me = this;
|
||||||
// if filtered by account and / or voucher
|
|
||||||
var data = wn.report_dump.data["GL Entry"];
|
var data = wn.report_dump.data["GL Entry"];
|
||||||
var out = [];
|
var out = [];
|
||||||
|
|
||||||
this.make_account_by_name();
|
this.toggle_group_by_checks();
|
||||||
|
|
||||||
var me = this;
|
|
||||||
|
|
||||||
var from_date = dateutil.str_to_obj(this.from_date);
|
var from_date = dateutil.str_to_obj(this.from_date);
|
||||||
var to_date = dateutil.str_to_obj(this.to_date);
|
var to_date = dateutil.str_to_obj(this.to_date);
|
||||||
@ -188,12 +177,14 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// add Opening, Closing, Totals rows
|
||||||
|
// if filtered by account and / or voucher
|
||||||
var opening = this.make_summary_row("Opening", this.account);
|
var opening = this.make_summary_row("Opening", this.account);
|
||||||
var totals = this.make_summary_row("Totals", this.account);
|
var totals = this.make_summary_row("Totals", this.account);
|
||||||
|
|
||||||
var grouped_ledgers = {};
|
var grouped_ledgers = {};
|
||||||
$.each(data, function(i, item) {
|
$.each(data, function(i, item) {
|
||||||
if((me.is_default("company") ? true : me.apply_filter(item, "company")) &&
|
if(me.apply_filter(item, "company") &&
|
||||||
(me.account ? me.is_child_account(me.account, item.account)
|
(me.account ? me.is_child_account(me.account, item.account)
|
||||||
: true) && (me.voucher_no ? item.voucher_no==me.voucher_no : true)) {
|
: true) && (me.voucher_no ? item.voucher_no==me.voucher_no : true)) {
|
||||||
var date = dateutil.str_to_obj(item.posting_date);
|
var date = dateutil.str_to_obj(item.posting_date);
|
||||||
@ -247,7 +238,7 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
|
|||||||
|
|
||||||
if(grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no].row){
|
if(grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no].row){
|
||||||
grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no]
|
grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no]
|
||||||
.row = jQuery.extend({}, item);
|
.row = $.extend({}, item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -307,10 +298,10 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
|
|||||||
.concat(grouped_ledgers[account].entries)
|
.concat(grouped_ledgers[account].entries)
|
||||||
.concat([grouped_ledgers[account].totals,
|
.concat([grouped_ledgers[account].totals,
|
||||||
grouped_ledgers[account].closing,
|
grouped_ledgers[account].closing,
|
||||||
{id: "_blank" + i, _no_format: true, debit: "", credit: ""}]);
|
{id: "_blank" + i, debit: "", credit: ""}]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return [{id: "_blank_first", _no_format: true, debit: "", credit: ""}].concat(out);
|
return [{id: "_blank_first", debit: "", credit: ""}].concat(out);
|
||||||
},
|
},
|
||||||
|
|
||||||
group_data_by_voucher: function(grouped_ledgers) {
|
group_data_by_voucher: function(grouped_ledgers) {
|
||||||
@ -331,7 +322,7 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return [{id: "_blank_first", _no_format: true, debit: "", credit: ""}].concat(out);
|
return out;
|
||||||
},
|
},
|
||||||
|
|
||||||
get_balance: function(debit_or_credit, balance) {
|
get_balance: function(debit_or_credit, balance) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user