Merge pull request #1228 from nabinhait/hotfix

Hotfix
This commit is contained in:
Nabin Hait 2013-12-23 03:41:13 -08:00
commit 50125b35d2
11 changed files with 68 additions and 28 deletions

View File

@ -95,9 +95,10 @@ cur_frm.cscript.add_toolbar_buttons = function(doc) {
wn.route_options = {
"account": doc.name,
"from_date": sys_defaults.year_start_date,
"to_date": sys_defaults.year_end_date
"to_date": sys_defaults.year_end_date,
"company": doc.company
};
wn.set_route("general-ledger");
wn.set_route("query-report", "General Ledger");
}, "icon-table");
}
}

View File

@ -120,8 +120,9 @@ cur_frm.cscript.refresh = function(doc) {
"voucher_no": doc.name,
"from_date": doc.posting_date,
"to_date": doc.posting_date,
"company": doc.company
};
wn.set_route("general-ledger");
wn.set_route("query-report", "General Ledger");
}, "icon-table");
}
}

View File

@ -35,8 +35,9 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({
"voucher_no": doc.name,
"from_date": doc.posting_date,
"to_date": doc.posting_date,
"company": doc.company
};
wn.set_route("query-report/General Ledger");
wn.set_route("query-report", "General Ledger");
}, "icon-table");
}

View File

@ -54,8 +54,9 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
"voucher_no": doc.name,
"from_date": doc.posting_date,
"to_date": doc.posting_date,
"company": doc.company
};
wn.set_route("query-report/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

@ -175,9 +175,10 @@ erpnext.AccountsChart = Class.extend({
wn.route_options = {
"account": node.data('label'),
"from_date": sys_defaults.year_start_date,
"to_date": sys_defaults.year_end_date
"to_date": sys_defaults.year_end_date,
"company": me.company
};
wn.set_route("general-ledger");
wn.set_route("query-report", "General Ledger");
},
rename: function() {
var node = this.selected_node();

View File

@ -8,7 +8,9 @@ from webnotes import _
from accounts.utils import get_balance_on
def execute(filters=None):
validate_filters(filters)
account_details = webnotes.conn.get_value("Account", filters["account"],
["debit_or_credit", "group_or_ledger"], as_dict=True)
validate_filters(filters, account_details.group_or_ledger)
columns = get_columns()
data = []
if filters.get("group_by"):
@ -19,12 +21,13 @@ def execute(filters=None):
data.append(get_total_row(data))
if filters.get("account"):
data = [get_opening_balance_row(filters)] + data + [get_closing_balance_row(filters)]
data = [get_opening_balance_row(filters, account_details.debit_or_credit)] + data + \
[get_closing_balance_row(filters, account_details.debit_or_credit)]
return columns, data
def validate_filters(filters):
if filters.get("account") and filters.get("group_by") == "Group by Account":
def validate_filters(filters, group_or_ledger):
if group_or_ledger == "Ledger" and filters.get("group_by") == "Group by Account":
webnotes.throw(_("Can not filter based on Account, if grouped by Account"))
if filters.get("voucher_no") and filters.get("group_by") == "Group by Voucher":
@ -35,13 +38,19 @@ def get_columns():
"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):
def get_opening_balance_row(filters, debit_or_credit):
opening_balance = get_balance_on(filters["account"], add_days(filters["from_date"], -1))
return ["", "Opening Balance", opening_balance, 0.0, "", "", ""]
return get_balance_row(opening_balance, debit_or_credit, "Opening Balance")
def get_closing_balance_row(filters):
def get_closing_balance_row(filters, debit_or_credit):
closing_balance = get_balance_on(filters["account"], filters["to_date"])
return ["", "Closing Balance", closing_balance, 0.0, "", "", ""]
return get_balance_row(closing_balance, debit_or_credit, "Closing Balance")
def get_balance_row(balance, debit_or_credit, balance_label):
if debit_or_credit == "Debit":
return ["", balance_label, balance, 0.0, "", "", ""]
else:
return ["", balance_label, 0.0, balance, "", "", ""]
def get_gl_entries(filters):
gl_entries = webnotes.conn.sql("""select
@ -63,7 +72,9 @@ def get_gl_entries(filters):
def get_conditions(filters):
conditions = []
if filters.get("account"):
conditions.append("account=%(account)s")
lft, rgt = webnotes.conn.get_value("Account", filters["account"], ["lft", "rgt"])
conditions.append("""account in (select name from tabAccount
where lft>=%s and rgt<=%s and docstatus<2)""" % (lft, rgt))
if filters.get("voucher_no"):
conditions.append("voucher_no=%(voucher_no)s")

View File

@ -16,7 +16,7 @@ class BudgetError(webnotes.ValidationError): pass
def get_fiscal_year(date=None, fiscal_year=None, label="Date", verbose=1):
return get_fiscal_years(date, fiscal_year, label, verbose=1)[0]
return get_fiscal_years(date, fiscal_year, label, verbose)[0]
def get_fiscal_years(date=None, fiscal_year=None, label="Date", verbose=1):
# if year start date is 2012-04-01, year end date should be 2013-03-31 (hence subdate)

View File

@ -26,9 +26,10 @@ erpnext.AccountTreeGrid = wn.views.TreeGridReport.extend({
show: true,
parent_field: "parent_account",
formatter: function(item) {
return repl('<a href="#general-ledger/account=%(enc_value)s">%(value)s</a>', {
return repl("<a \
onclick='wn.cur_grid_report.show_general_ledger(\"%(value)s\")'>\
%(value)s</a>", {
value: item.name,
enc_value: encodeURIComponent(item.name)
});
}
},
@ -211,4 +212,14 @@ erpnext.AccountTreeGrid = wn.views.TreeGridReport.extend({
return;
}
},
show_general_ledger: function(account) {
wn.route_options = {
account: account,
company: this.company,
from_date: this.from_date,
to_date: this.to_date
};
wn.set_route("query-report", "General Ledger");
}
});

View File

@ -11,9 +11,10 @@ erpnext.stock.StockController = wn.ui.form.Controller.extend({
wn.route_options = {
voucher_no: me.frm.doc.name,
from_date: me.frm.doc.posting_date,
to_date: me.frm.doc.posting_date
to_date: me.frm.doc.posting_date,
company: me.frm.doc.company
};
wn.set_route('stock-ledger');
wn.set_route("query-report", "Stock Ledger");
}, "icon-bar-chart");
}
@ -24,11 +25,12 @@ erpnext.stock.StockController = wn.ui.form.Controller.extend({
if(this.frm.doc.docstatus===1 && cint(wn.defaults.get_default("auto_accounting_for_stock"))) {
cur_frm.appframe.add_button(wn._('Accounting Ledger'), function() {
wn.route_options = {
"voucher_no": me.frm.doc.name,
"from_date": me.frm.doc.posting_date,
"to_date": me.frm.doc.posting_date,
voucher_no: me.frm.doc.name,
from_date: me.frm.doc.posting_date,
to_date: me.frm.doc.posting_date,
company: me.frm.doc.company
};
wn.set_route("general-ledger");
wn.set_route("query-report", "General Ledger");
}, "icon-table");
}
},

View File

@ -17,10 +17,10 @@ erpnext.StockAnalytics = erpnext.StockGridReport.extend({
parent_field: "parent_item_group",
formatter: function(item) {
if(!item.is_group) {
return repl('<a href="#stock-ledger/item_code=%(enc_value)s">%(value)s</a>',
{
return repl("<a \
onclick='wn.cur_grid_report.show_stock_ledger(\"%(value)s\")'>\
%(value)s</a>", {
value: item.name,
enc_value: encodeURIComponent(item.name)
});
} else {
return item.name;
@ -183,5 +183,13 @@ erpnext.StockAnalytics = erpnext.StockGridReport.extend({
},
get_plot_points: function(item, col, idx) {
return [[dateutil.user_to_obj(col.name).getTime(), item[col.field]]]
},
show_stock_ledger: function(item_code) {
wn.route_options = {
item_code: item_code,
from_date: this.from_date,
to_date: this.to_date
};
wn.set_route("query-report", "Stock Ledger");
}
});

View File

@ -62,6 +62,9 @@ def get_item_conditions(filters):
def get_sle_conditions(filters):
conditions = []
if filters.get("item_code"):
conditions.append("""item_code in (select name from tabItem
{item_conditions})""".format(item_conditions=get_item_conditions(filters)))
if filters.get("warehouse"):
conditions.append("warehouse=%(warehouse)s")
if filters.get("voucher_no"):