Toggle alternative currency fields

This commit is contained in:
Nabin Hait 2015-08-18 11:33:29 +05:30
parent 6aea1c0da5
commit 7dbd395781
2 changed files with 39 additions and 21 deletions

View File

@ -2,8 +2,44 @@
// License: GNU General Public License v3. See license.txt
frappe.provide("erpnext.accounts");
frappe.provide("erpnext.journal_entry");
frappe.require("assets/erpnext/js/utils.js");
cur_frm.add_fetch("account", "currency", "currency");
frappe.ui.form.on("Journal Entry", {
refresh: function(frm) {
erpnext.toggle_naming_series();
cur_frm.cscript.voucher_type(frm.doc);
if(frm.doc.docstatus==1) {
cur_frm.add_custom_button(__('View Ledger'), function() {
frappe.route_options = {
"voucher_no": frm.doc.name,
"from_date": frm.doc.posting_date,
"to_date": frm.doc.posting_date,
"company": frm.doc.company,
group_by_voucher: 0
};
frappe.set_route("query-report", "General Ledger");
}, "icon-table");
}
// hide /unhide fields based on currency
erpnext.journal_entry.toggle_fields_based_on_currency(frm);
}
})
erpnext.journal_entry.toggle_fields_based_on_currency = function(frm) {
var fields = ["balance_in_account_currency", "party_balance_in_account_currency",
"debit_in_account_currency", "credit_in_account_currency"];
var company_currency = erpnext.get_currency(frm.doc.company);
var grid = frm.get_field("accounts").grid;
grid.set_column_disp(fields, grid.currency!=company_currency);
}
erpnext.accounts.JournalEntry = frappe.ui.form.Controller.extend({
onload: function() {
this.load_defaults();
@ -164,24 +200,6 @@ erpnext.accounts.JournalEntry = frappe.ui.form.Controller.extend({
cur_frm.script_manager.make(erpnext.accounts.JournalEntry);
cur_frm.cscript.refresh = function(doc) {
erpnext.toggle_naming_series();
cur_frm.cscript.voucher_type(doc);
if(doc.docstatus==1) {
cur_frm.add_custom_button(__('View Ledger'), function() {
frappe.route_options = {
"voucher_no": doc.name,
"from_date": doc.posting_date,
"to_date": doc.posting_date,
"company": doc.company,
group_by_voucher: 0
};
frappe.set_route("query-report", "General Ledger");
}, "icon-table");
}
}
cur_frm.cscript.company = function(doc, cdt, cdn) {
cur_frm.refresh_fields();
erpnext.get_fiscal_year(doc.company, doc.posting_date);

View File

@ -89,7 +89,7 @@
"permlevel": 0,
"precision": "",
"print_hide": 0,
"read_only": 0,
"read_only": 1,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@ -215,7 +215,7 @@
"permlevel": 0,
"precision": "",
"print_hide": 0,
"read_only": 0,
"read_only": 1,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@ -476,7 +476,7 @@
"is_submittable": 0,
"issingle": 0,
"istable": 1,
"modified": "2015-08-17 02:11:33.991361",
"modified": "2015-08-17 19:20:19.153237",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Journal Entry Account",