[accounts] [feature] added default_cash_account in company and gets set in Journal Voucher
This commit is contained in:
parent
c5570c6341
commit
df8b652402
@ -1,34 +0,0 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes.utils import flt
|
||||
from webnotes.model.code import get_obj
|
||||
from accounts.utils import get_balance_on
|
||||
|
||||
@webnotes.whitelist()
|
||||
def get_default_bank_account():
|
||||
"""
|
||||
Get default bank account for a company
|
||||
"""
|
||||
company = webnotes.form_dict.get('company')
|
||||
if not company: return
|
||||
res = webnotes.conn.sql("""\
|
||||
SELECT default_bank_account FROM `tabCompany`
|
||||
WHERE name=%s AND docstatus<2""", company)
|
||||
|
||||
if res: return res[0][0]
|
@ -137,23 +137,27 @@ cur_frm.cscript.view_ledger_entry = function(doc,cdt,cdn){
|
||||
|
||||
|
||||
cur_frm.cscript.voucher_type = function(doc, cdt, cdn) {
|
||||
if(doc.voucher_type == 'Bank Voucher' && cstr(doc.company)) {
|
||||
cur_frm.set_df_property("cheque_no", "reqd", true);
|
||||
cur_frm.set_df_property("cheque_date", "reqd", true);
|
||||
cur_frm.set_df_property("cheque_no", "reqd", doc.voucher_type=="Bank Voucher");
|
||||
cur_frm.set_df_property("cheque_date", "reqd", doc.voucher_type=="Bank Voucher");
|
||||
|
||||
var children = getchildren('Journal Voucher Detail', doc.name, 'entries');
|
||||
if(!children || children.length==0) {
|
||||
$c('accounts.get_default_bank_account', {company: doc.company }, function(r, rt) {
|
||||
if(!r.exc) {
|
||||
var jvd = wn.model.add_child(doc, 'Journal Voucher Detail', 'entries');
|
||||
jvd.account = cstr(r.message);
|
||||
refresh_field('entries');
|
||||
if(in_list(["Bank Voucher", "Cash Voucher"], doc.voucher_type)
|
||||
&& doc.company
|
||||
&& wn.model.get("Journal Voucher Detail", {"parent":doc.name}).length==0) {
|
||||
wn.call({
|
||||
type: "GET",
|
||||
method: "accounts.doctype.journal_voucher.journal_voucher.get_default_bank_cash_account",
|
||||
args: {
|
||||
"voucher_type": doc.voucher_type,
|
||||
"company": doc.company
|
||||
},
|
||||
callback: function(r) {
|
||||
if(r.message) {
|
||||
var jvdetail = wn.model.add_child(doc, "Journal Voucher Detail", "entries");
|
||||
jvdetail.account = r.message || "";
|
||||
refresh_field("entries");
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
cur_frm.set_df_property("cheque_no", "reqd", false);
|
||||
cur_frm.set_df_property("cheque_date", "reqd", false);
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -349,6 +349,10 @@ class DocType(AccountsController):
|
||||
from `tabPurchase Invoice` where docstatus = 1 and company = %s
|
||||
and outstanding_amount > 0 %s""" % ('%s', cond), self.doc.company)
|
||||
|
||||
@webnotes.whitelist()
|
||||
def get_default_bank_cash_account(company, voucher_type):
|
||||
return webnotes.conn.get_value("Company", company,
|
||||
voucher_type=="Bank Voucher" and "default_bank_account" or "default_cash_account")
|
||||
|
||||
def get_against_purchase_invoice(doctype, txt, searchfield, start, page_len, filters):
|
||||
return webnotes.conn.sql("""select name, credit_to, outstanding_amount, bill_no, bill_date
|
||||
|
@ -49,6 +49,10 @@ cur_frm.fields_dict.default_bank_account.get_query = function(doc) {
|
||||
return 'SELECT `tabAccount`.name, `tabAccount`.debit_or_credit, `tabAccount`.group_or_ledger FROM `tabAccount` WHERE `tabAccount`.company = "'+doc.name+'" AND `tabAccount`.group_or_ledger = "Ledger" AND `tabAccount`.docstatus != 2 AND `tabAccount`.account_type = "Bank or Cash" AND `tabAccount`.%(key)s LIKE "%s" ORDER BY `tabAccount`.name LIMIT 50';
|
||||
}
|
||||
|
||||
cur_frm.fields_dict.default_cash_account.get_query = function(doc) {
|
||||
return 'SELECT `tabAccount`.name, `tabAccount`.debit_or_credit, `tabAccount`.group_or_ledger FROM `tabAccount` WHERE `tabAccount`.company = "'+doc.name+'" AND `tabAccount`.group_or_ledger = "Ledger" AND `tabAccount`.docstatus != 2 AND `tabAccount`.account_type = "Bank or Cash" AND `tabAccount`.%(key)s LIKE "%s" ORDER BY `tabAccount`.name LIMIT 50';
|
||||
}
|
||||
|
||||
|
||||
cur_frm.fields_dict.receivables_group.get_query = function(doc) {
|
||||
return 'SELECT `tabAccount`.name FROM `tabAccount` WHERE `tabAccount`.company = "'+doc.name+'" AND `tabAccount`.group_or_ledger = "Group" AND `tabAccount`.docstatus != 2 AND `tabAccount`.%(key)s LIKE "%s" ORDER BY `tabAccount`.name LIMIT 50';
|
||||
|
@ -1,8 +1,8 @@
|
||||
[
|
||||
{
|
||||
"creation": "2013-02-27 09:38:05",
|
||||
"creation": "2013-03-21 17:41:00",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-03-19 12:52:00",
|
||||
"modified": "2013-03-25 15:35:34",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@ -25,19 +25,14 @@
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"cancel": 1,
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"name": "__common__",
|
||||
"parent": "Company",
|
||||
"parentfield": "permissions",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "System Manager",
|
||||
"submit": 0,
|
||||
"write": 1
|
||||
"submit": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocType",
|
||||
@ -102,6 +97,13 @@
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Account"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "default_cash_account",
|
||||
"fieldtype": "Link",
|
||||
"label": "Default Cash Account",
|
||||
"options": "Account"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:!doc.__islocal",
|
||||
"doctype": "DocField",
|
||||
@ -307,6 +309,19 @@
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocPerm"
|
||||
"cancel": 1,
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 0,
|
||||
"role": "System Manager",
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 1,
|
||||
"role": "All",
|
||||
"write": 0
|
||||
}
|
||||
]
|
Loading…
x
Reference in New Issue
Block a user