Merge branch 'master' of github.com:webnotes/erpnext
This commit is contained in:
commit
f2785c9e61
@ -18,31 +18,25 @@ from __future__ import unicode_literals
|
|||||||
import webnotes
|
import webnotes
|
||||||
|
|
||||||
from webnotes.utils import cstr, flt
|
from webnotes.utils import cstr, flt
|
||||||
from webnotes.model import db_exists
|
|
||||||
from webnotes.model.doc import addchild, make_autoname
|
from webnotes.model.doc import addchild, make_autoname
|
||||||
from webnotes.model.bean import copy_doclist
|
from webnotes import msgprint, _
|
||||||
from webnotes import msgprint
|
|
||||||
|
|
||||||
sql = webnotes.conn.sql
|
sql = webnotes.conn.sql
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class DocType:
|
class DocType:
|
||||||
#init function
|
|
||||||
def __init__(self,doc,doclist=[]):
|
def __init__(self,doc,doclist=[]):
|
||||||
self.doc = doc
|
self.doc = doc
|
||||||
self.doclist = doclist
|
self.doclist = doclist
|
||||||
|
|
||||||
#autoname function
|
|
||||||
#---------------------------------------------------------
|
|
||||||
def autoname(self):
|
def autoname(self):
|
||||||
self.doc.name = make_autoname(self.doc.employee + '/.SST' + '/.#####')
|
self.doc.name = make_autoname(self.doc.employee + '/.SST' + '/.#####')
|
||||||
|
|
||||||
#get employee details
|
|
||||||
#---------------------------------------------------------
|
|
||||||
def get_employee_details(self):
|
def get_employee_details(self):
|
||||||
ret = {}
|
ret = {}
|
||||||
det = sql("select employee_name, branch, designation, department, grade from `tabEmployee` where name = '%s'" %self.doc.employee)
|
det = sql("""select employee_name, branch, designation, department, grade
|
||||||
|
from `tabEmployee` where name = %s""", self.doc.employee)
|
||||||
if det:
|
if det:
|
||||||
ret = {
|
ret = {
|
||||||
'employee_name': cstr(det[0][0]),
|
'employee_name': cstr(det[0][0]),
|
||||||
@ -54,19 +48,15 @@ class DocType:
|
|||||||
}
|
}
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
# Set Salary structure field values
|
|
||||||
#---------------------------------------------------------
|
|
||||||
def get_ss_values(self,employee):
|
def get_ss_values(self,employee):
|
||||||
basic_info = sql("select bank_name, bank_ac_no, esic_card_no, pf_number from `tabEmployee` where name ='%s'" % employee)
|
basic_info = sql("""select bank_name, bank_ac_no, esic_card_no, pf_number
|
||||||
|
from `tabEmployee` where name =%s""", employee)
|
||||||
ret = {'bank_name': basic_info and basic_info[0][0] or '',
|
ret = {'bank_name': basic_info and basic_info[0][0] or '',
|
||||||
'bank_ac_no': basic_info and basic_info[0][1] or '',
|
'bank_ac_no': basic_info and basic_info[0][1] or '',
|
||||||
'esic_no': basic_info and basic_info[0][2] or '',
|
'esic_no': basic_info and basic_info[0][2] or '',
|
||||||
'pf_no': basic_info and basic_info[0][3] or ''}
|
'pf_no': basic_info and basic_info[0][3] or ''}
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
# Make earning and deduction table
|
|
||||||
#---------------------------------------------------------
|
|
||||||
def make_table(self, doct_name, tab_fname, tab_name):
|
def make_table(self, doct_name, tab_fname, tab_name):
|
||||||
list1 = sql("select name from `tab%s` where docstatus != 2" % doct_name)
|
list1 = sql("select name from `tab%s` where docstatus != 2" % doct_name)
|
||||||
for li in list1:
|
for li in list1:
|
||||||
@ -78,36 +68,30 @@ class DocType:
|
|||||||
child.d_type = cstr(li[0])
|
child.d_type = cstr(li[0])
|
||||||
child.d_modified_amt = 0
|
child.d_modified_amt = 0
|
||||||
|
|
||||||
# add earning & deduction types to table
|
|
||||||
#---------------------------------------------------------
|
|
||||||
def make_earn_ded_table(self):
|
def make_earn_ded_table(self):
|
||||||
#Earning List
|
|
||||||
self.make_table('Earning Type','earning_details','Salary Structure Earning')
|
self.make_table('Earning Type','earning_details','Salary Structure Earning')
|
||||||
|
self.make_table('Deduction Type','deduction_details', 'Salary Structure Deduction')
|
||||||
|
|
||||||
#Deduction List
|
|
||||||
self.make_table('Deduction Type','deduction_details',
|
|
||||||
'Salary Structure Deduction')
|
|
||||||
|
|
||||||
|
|
||||||
# Check if another active ss exists
|
|
||||||
#---------------------------------------------------------
|
|
||||||
def check_existing(self):
|
def check_existing(self):
|
||||||
ret = sql("select name from `tabSalary Structure` where is_active = 'Yes' and employee = '%s' and name!='%s'" %(self.doc.employee,self.doc.name))
|
ret = sql("""select name from `tabSalary Structure` where is_active = 'Yes'
|
||||||
|
and employee = %s and name!=%s""", (self.doc.employee,self.doc.name))
|
||||||
if ret and self.doc.is_active=='Yes':
|
if ret and self.doc.is_active=='Yes':
|
||||||
msgprint("Another Salary Structure '%s' is active for employee '%s'. Please make its status 'Inactive' to proceed."%(cstr(ret), self.doc.employee))
|
msgprint(_("""Another Salary Structure '%s' is active for employee '%s'.
|
||||||
raise Exception
|
Please make its status 'Inactive' to proceed.""") %
|
||||||
|
(cstr(ret), self.doc.employee), raise_exception=1)
|
||||||
|
|
||||||
|
def validate_amount(self):
|
||||||
|
if flt(self.doc.ctc) < 12*flt(self.doc.total_earning):
|
||||||
|
msgprint(_("Annual Cost To Company can not be less than 12 months of Total Earning"),
|
||||||
|
raise_exception=1)
|
||||||
|
|
||||||
# Validate net pay
|
|
||||||
#---------------------------------------------------------
|
|
||||||
def validate_net_pay(self):
|
|
||||||
if flt(self.doc.net_pay) < 0:
|
if flt(self.doc.net_pay) < 0:
|
||||||
msgprint("Net pay can not be negative")
|
msgprint(_("Net pay can not be negative"), raise_exception=1)
|
||||||
raise Exception
|
elif flt(self.doc.net_pay)*12 > flt(self.doc.ctc):
|
||||||
elif flt(self.doc.net_pay) > flt(self.doc.ctc):
|
msgprint(_("Net pay can not be greater than 1/12th of Annual Cost To Company"),
|
||||||
msgprint("Net pay can not be greater than CTC")
|
raise_exception=1)
|
||||||
raise Exception
|
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.check_existing()
|
self.check_existing()
|
||||||
self.validate_net_pay()
|
self.validate_amount()
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user