diff --git a/hr/doctype/salary_manager/salary_manager.js b/hr/doctype/salary_manager/salary_manager.js index 498d596662..032c29e509 100644 --- a/hr/doctype/salary_manager/salary_manager.js +++ b/hr/doctype/salary_manager/salary_manager.js @@ -18,10 +18,6 @@ cur_frm.cscript.create_salary_slip = function(doc, cdt, cdn) { return $c('runserverobj', args={'method':'create_sal_slip','docs':wn.model.compress(make_doclist (cdt, cdn))},callback); } - - -//Submit salary slip -//----------------------- cur_frm.cscript.submit_salary_slip = function(doc, cdt, cdn) { var check = confirm(wn._("Do you really want to Submit all Salary Slip for month : ") + doc.month+ wn._(" and fiscal year : ")+doc.fiscal_year); if(check){ @@ -33,23 +29,21 @@ cur_frm.cscript.submit_salary_slip = function(doc, cdt, cdn) { } } -// Make Bank Voucher -//----------------------- cur_frm.cscript.make_bank_voucher = function(doc,cdt,cdn){ - if(doc.month && doc.fiscal_year){ - cur_frm.cscript.make_jv(doc, cdt, cdn); - } + if(doc.company && doc.month && doc.fiscal_year){ + cur_frm.cscript.make_jv(doc, cdt, cdn); + } else { + msgprint(wn._("Company, Month and Fiscal Year is mandatory")); + } } - -// Make JV -//----------------------- cur_frm.cscript.make_jv = function(doc, dt, dn) { - var call_back = function(r,rt){ + var call_back = function(r, rt){ var jv = wn.model.make_new_doc_and_get_name('Journal Voucher'); jv = locals['Journal Voucher'][jv]; jv.voucher_type = 'Bank Voucher'; - jv.user_remark = wn._('Payment of salary for the month: ') + doc.month + wn._('and fiscal year: ') + doc.fiscal_year; + jv.user_remark = wn._('Payment of salary for the month: ') + doc.month + + wn._('and fiscal year: ') + doc.fiscal_year; jv.fiscal_year = doc.fiscal_year; jv.company = doc.company; jv.posting_date = dateutil.obj_to_str(new Date()); @@ -61,10 +55,9 @@ cur_frm.cscript.make_jv = function(doc, dt, dn) { // debit to salary account var d2 = wn.model.add_child(jv, 'Journal Voucher Detail', 'entries'); - d2.account = r.message['default_salary_account']; d2.debit = r.message['amount'] loaddoc('Journal Voucher', jv.name); } - return $c_obj(make_doclist(dt,dn),'get_acc_details','',call_back); + return $c_obj(make_doclist(dt, dn), 'get_acc_details', '', call_back); } diff --git a/hr/doctype/salary_manager/salary_manager.py b/hr/doctype/salary_manager/salary_manager.py index 9eab5f3b31..29b13aed98 100644 --- a/hr/doctype/salary_manager/salary_manager.py +++ b/hr/doctype/salary_manager/salary_manager.py @@ -3,17 +3,10 @@ from __future__ import unicode_literals import webnotes - from webnotes.utils import cint, flt -from webnotes.model import db_exists -from webnotes.model.doc import Document -from webnotes.model.bean import getlist, copy_doclist from webnotes.model.code import get_obj from webnotes import msgprint - - - class DocType: def __init__(self, doc, doclist): self.doc = doc @@ -198,14 +191,12 @@ class DocType: get default bank account,default salary acount from company """ amt = self.get_total_salary() - com = webnotes.conn.sql("select default_bank_account from `tabCompany` where name = '%s'" % self.doc.company) - - if not com[0][0] or not com[0][1]: + default_bank_account = webnotes.conn.get_value("Company", self.doc.company, + "default_bank_account") + if not default_bank_account: msgprint("You can set Default Bank Account in Company master.") - ret = { - 'def_bank_acc' : com and com[0][0] or '', - 'def_sal_acc' : com and com[0][1] or '', + return { + 'default_bank_account' : default_bank_account, 'amount' : amt - } - return ret + } \ No newline at end of file