Merge pull request #2019 from anandpdoshi/anand-august-1

Account Issues
This commit is contained in:
Rushabh Mehta 2014-08-05 10:36:08 +05:30
commit ca70eaa388
3 changed files with 17 additions and 8 deletions

View File

@ -7,6 +7,7 @@ erpnext.accounts.JournalVoucher = frappe.ui.form.Controller.extend({
onload: function() { onload: function() {
this.load_defaults(); this.load_defaults();
this.setup_queries(); this.setup_queries();
this.setup_balance_formatter();
}, },
onload_post_render: function() { onload_post_render: function() {
@ -66,6 +67,18 @@ erpnext.accounts.JournalVoucher = frappe.ui.form.Controller.extend({
}); });
}, },
setup_balance_formatter: function() {
var df = frappe.meta.get_docfield("Journal Voucher Detail", "balance", this.frm.doc.name);
df.formatter = function(value, df, options, doc) {
var currency = frappe.meta.get_field_currency(df, doc);
var dr_or_cr = value ? ('<label>' + (value > 0.0 ? __("Dr") : __("Cr")) + '</label>') : "";
return "<div style='text-align: right'>"
+ ((value==null || value==="") ? "" : format_currency(Math.abs(value), currency))
+ " " + dr_or_cr
+ "</div>";
}
},
against_voucher: function(doc, cdt, cdn) { against_voucher: function(doc, cdt, cdn) {
var d = frappe.get_doc(cdt, cdn); var d = frappe.get_doc(cdt, cdn);
if (d.against_voucher && !flt(d.debit)) { if (d.against_voucher && !flt(d.debit)) {
@ -108,7 +121,6 @@ erpnext.accounts.JournalVoucher = frappe.ui.form.Controller.extend({
} }
}); });
} }
}); });
cur_frm.script_manager.make(erpnext.accounts.JournalVoucher); cur_frm.script_manager.make(erpnext.accounts.JournalVoucher);

View File

@ -263,7 +263,7 @@
"print_hide": 1, "print_hide": 1,
"print_width": "120px", "print_width": "120px",
"read_only": 0, "read_only": 0,
"reqd": 0, "reqd": 1,
"width": "120px" "width": "120px"
}, },
{ {
@ -448,7 +448,7 @@
], ],
"idx": 1, "idx": 1,
"istable": 1, "istable": 1,
"modified": "2014-07-24 05:53:05.889457", "modified": "2014-08-01 06:14:28.707601",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Sales Invoice Item", "name": "Sales Invoice Item",

View File

@ -45,11 +45,8 @@ def get_balance_on(account=None, date=None):
account = frappe.form_dict.get("account") account = frappe.form_dict.get("account")
date = frappe.form_dict.get("date") date = frappe.form_dict.get("date")
acc = frappe.db.get_value('Account', account, \ acc = frappe.get_doc("Account", account)
['lft', 'rgt', 'report_type', 'group_or_ledger'], as_dict=1) acc.check_permission("read")
if not acc:
frappe.throw(_("Account {0} does not exist").format(account), frappe.DoesNotExistError)
cond = [] cond = []
if date: if date: