Employee can be reselected but not changed in salary structure
This commit is contained in:
parent
859a995bd6
commit
45b7d17ee8
@ -14,8 +14,6 @@ cur_frm.cscript.refresh = function(doc, dt, dn){
|
||||
if((!doc.__islocal) && (doc.is_active == 'Yes')){
|
||||
cur_frm.add_custom_button(__('Make Salary Slip'), cur_frm.cscript['Make Salary Slip']);
|
||||
}
|
||||
|
||||
cur_frm.toggle_enable('employee', doc.__islocal);
|
||||
}
|
||||
|
||||
cur_frm.cscript['Make Salary Slip'] = function() {
|
||||
|
@ -54,18 +54,28 @@ class SalaryStructure(Document):
|
||||
def check_existing(self):
|
||||
ret = frappe.db.sql("""select name from `tabSalary Structure` where is_active = 'Yes'
|
||||
and employee = %s and name!=%s""", (self.employee,self.name))
|
||||
|
||||
if ret and self.is_active=='Yes':
|
||||
frappe.throw(_("Another Salary Structure {0} is active for employee {0}. Please make its status 'Inactive' to proceed.").format(cstr(ret), self.employee))
|
||||
frappe.throw(_("Another Salary Structure {0} is active for employee {1}. Please make its status 'Inactive' to proceed.").format(cstr(ret[0][0]), self.employee))
|
||||
|
||||
def validate_amount(self):
|
||||
if flt(self.net_pay) < 0:
|
||||
frappe.throw(_("Net pay cannot be negative"))
|
||||
|
||||
def validate_employee(self):
|
||||
old_employee = frappe.db.get_value("Salary Structure", self.name, "employee")
|
||||
print old_employee
|
||||
if old_employee and self.employee != old_employee:
|
||||
frappe.throw(_("Employee can not be changed"))
|
||||
|
||||
|
||||
def validate(self):
|
||||
self.check_existing()
|
||||
self.validate_amount()
|
||||
self.validate_employee()
|
||||
set_employee_name(self)
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_salary_slip(source_name, target_doc=None):
|
||||
def postprocess(source, target):
|
||||
|
Loading…
x
Reference in New Issue
Block a user