[salary structure] added a validation
This commit is contained in:
parent
a305406267
commit
d16cae113a
@ -36,7 +36,7 @@ class DocType:
|
|||||||
def get_employee_details(self):
|
def get_employee_details(self):
|
||||||
ret = {}
|
ret = {}
|
||||||
det = sql("""select employee_name, branch, designation, department, grade
|
det = sql("""select employee_name, branch, designation, department, grade
|
||||||
from `tabEmployee` where name = '%s'""", self.doc.employee)
|
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]),
|
||||||
@ -50,7 +50,7 @@ class DocType:
|
|||||||
|
|
||||||
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
|
basic_info = sql("""select bank_name, bank_ac_no, esic_card_no, pf_number
|
||||||
from `tabEmployee` where name ='%s'""", employee)
|
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 '',
|
||||||
@ -74,22 +74,23 @@ class DocType:
|
|||||||
|
|
||||||
def check_existing(self):
|
def check_existing(self):
|
||||||
ret = sql("""select name from `tabSalary Structure` where is_active = 'Yes'
|
ret = sql("""select name from `tabSalary Structure` where is_active = 'Yes'
|
||||||
and employee = '%s' and name!='%s'""", (self.doc.employee,self.doc.name))
|
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'.
|
msgprint(_("""Another Salary Structure '%s' is active for employee '%s'.
|
||||||
Please make its status 'Inactive' to proceed.""") %
|
Please make its status 'Inactive' to proceed.""") %
|
||||||
(cstr(ret), self.doc.employee), raise_exception=1)
|
(cstr(ret), self.doc.employee), raise_exception=1)
|
||||||
|
|
||||||
def validate_amount(self):
|
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)
|
||||||
|
|
||||||
if flt(self.doc.net_pay) < 0:
|
if flt(self.doc.net_pay) < 0:
|
||||||
msgprint(_("Net pay can not be negative"), raise_exception=1)
|
msgprint(_("Net pay can not be negative"), raise_exception=1)
|
||||||
elif flt(self.doc.net_pay)*12 > flt(self.doc.ctc):
|
elif flt(self.doc.net_pay)*12 > 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 1/12th of Annual Cost To Company"),
|
||||||
raise_exception=1)
|
raise_exception=1)
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.check_existing()
|
self.check_existing()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user