mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-23 06:59:20 +00:00
[merge]
This commit is contained in:
@@ -97,7 +97,7 @@ cur_frm.cscript.is_opening = function(doc, dt, dn) {
|
||||
cur_frm.cscript.get_items = function(doc, dt, dn) {
|
||||
var callback = function(r,rt) {
|
||||
unhide_field(['supplier_address', 'contact_person']);
|
||||
refresh_many(['credit_to','supplier','supplier_address','contact_person','supplier_name', 'address_display', 'contact_display','contact_mobile', 'contact_email','entries', 'purchase_receipt_main', 'purchase_order_main', 'purchase_tax_details']);
|
||||
cur_frm.refresh_fields();
|
||||
}
|
||||
$c_obj(make_doclist(dt,dn),'pull_details','',callback);
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ cur_frm.cscript.is_opening = function(doc, dt, dn) {
|
||||
cur_frm.cscript.get_items = function(doc, dt, dn) {
|
||||
var callback = function(r,rt) {
|
||||
unhide_field(['customer_address','contact_person', 'territory','customer_group']);
|
||||
cur_frm.refresh();
|
||||
cur_frm.refresh_fields();
|
||||
}
|
||||
get_server_fields('pull_details','','',doc, dt, dn,1,callback);
|
||||
}
|
||||
|
||||
@@ -170,11 +170,6 @@ wn.module_page["Accounts"] = [
|
||||
"label":wn._("Financial Analytics"),
|
||||
page: "financial-analytics"
|
||||
},
|
||||
{
|
||||
"label":wn._("Trend Analyzer"),
|
||||
route: "Report/Profile/Trend Analyzer",
|
||||
doctype: "Sales Invoice"
|
||||
},
|
||||
{
|
||||
"label":wn._("Gross Profit"),
|
||||
route: "query-report/Gross Profit",
|
||||
|
||||
@@ -68,6 +68,7 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
|
||||
|
||||
];
|
||||
},
|
||||
|
||||
filters: [
|
||||
{fieldtype:"Select", label: "Company", link:"Company", default_value: "Select Company...",
|
||||
filter: function(val, item, opts) {
|
||||
@@ -96,6 +97,7 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
|
||||
return dateutil.str_to_obj(val) >= dateutil.str_to_obj(item.posting_date);
|
||||
}},
|
||||
{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: "Reset Filters"}
|
||||
],
|
||||
@@ -116,9 +118,14 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
|
||||
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) {
|
||||
var me = this;
|
||||
@@ -139,12 +146,14 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
|
||||
init_filter_values: function() {
|
||||
this._super();
|
||||
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.account.change();
|
||||
},
|
||||
apply_filters_from_route: function() {
|
||||
this._super();
|
||||
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.account.change();
|
||||
},
|
||||
@@ -196,13 +205,21 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
|
||||
if(!grouped_ledgers[item.account]) {
|
||||
grouped_ledgers[item.account] = {
|
||||
entries: [],
|
||||
entries_group_by_voucher: {},
|
||||
opening: me.make_summary_row("Opening", item.account),
|
||||
totals: me.make_summary_row("Totals", item.account),
|
||||
closing: me.make_summary_row("Closing (Opening + Totals)",
|
||||
item.account)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
if(!grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no]) {
|
||||
grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no] = {
|
||||
row: {},
|
||||
totals: {"debit": 0, "credit": 0}
|
||||
}
|
||||
}
|
||||
|
||||
if(date < from_date || item.is_opening=="Yes") {
|
||||
opening.debit += item.debit;
|
||||
opening.credit += item.credit;
|
||||
@@ -215,6 +232,11 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
|
||||
|
||||
grouped_ledgers[item.account].totals.debit += item.debit;
|
||||
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) {
|
||||
item.against_account = me.voucher_accounts[item.voucher_type + ":"
|
||||
@@ -224,6 +246,11 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
|
||||
if(me.apply_filters(item) && item.is_opening=="No") {
|
||||
out.push(item);
|
||||
grouped_ledgers[item.account].entries.push(item);
|
||||
|
||||
if(grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no].row){
|
||||
grouped_ledgers[item.account].
|
||||
entries_group_by_voucher[item.voucher_no].row = item;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -241,6 +268,11 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
|
||||
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)
|
||||
closing = me.get_balance(me.account_by_name[me.account].debit_or_credit, closing)
|
||||
|
||||
@@ -283,6 +315,26 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
|
||||
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) {
|
||||
voucher_dict = grouped_ledgers[account].entries_group_by_voucher[voucher];
|
||||
if(voucher_dict.totals.debit || voucher_dict.totals.credit) {
|
||||
voucher_dict.row.debit = voucher_dict.totals.debit;
|
||||
voucher_dict.row.credit = voucher_dict.totals.credit;
|
||||
voucher_dict.row.id = "entry" + voucher
|
||||
out = out.concat(voucher_dict.row);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
return [{id: "_blank_first", _no_format: true, debit: "", credit: ""}].concat(out);
|
||||
},
|
||||
|
||||
get_balance: function(debit_or_credit, balance) {
|
||||
if(debit_or_credit == "Debit") {
|
||||
balance.debit -= balance.credit; balance.credit = 0;
|
||||
|
||||
@@ -21,14 +21,8 @@ from controllers.trends import get_columns,get_data
|
||||
def execute(filters=None):
|
||||
if not filters: filters ={}
|
||||
data = []
|
||||
|
||||
trans = "Purchase Invoice"
|
||||
tab = ["tabPurchase Invoice","tabPurchase Invoice Item"]
|
||||
conditions = get_columns(filters, trans)
|
||||
data = get_data(filters, conditions)
|
||||
|
||||
details = get_columns(filters, trans)
|
||||
data = get_data(filters, tab, details)
|
||||
|
||||
if not data :
|
||||
webnotes.msgprint("Data not found for selected criterias")
|
||||
|
||||
return details["columns"], data
|
||||
return conditions["columns"], data
|
||||
@@ -21,14 +21,8 @@ from controllers.trends import get_columns,get_data
|
||||
def execute(filters=None):
|
||||
if not filters: filters ={}
|
||||
data = []
|
||||
|
||||
trans = "Sales Invoice"
|
||||
tab = ["tabSales Invoice","tabSales Invoice Item"]
|
||||
conditions = get_columns(filters, trans)
|
||||
data = get_data(filters, conditions)
|
||||
|
||||
details = get_columns(filters, trans)
|
||||
data = get_data(filters, tab, details)
|
||||
|
||||
if not data :
|
||||
webnotes.msgprint("Data not found for selected criterias")
|
||||
|
||||
return details["columns"], data
|
||||
return conditions["columns"], data
|
||||
Reference in New Issue
Block a user