Warning if there are mutliple active salary structures
This commit is contained in:
parent
44e9195378
commit
29ce0aab28
@ -154,21 +154,18 @@ class SalarySlip(TransactionBase):
|
|||||||
|
|
||||||
def check_sal_struct(self, joining_date, relieving_date):
|
def check_sal_struct(self, joining_date, relieving_date):
|
||||||
st_name = frappe.db.sql("""select parent from `tabSalary Structure Employee`
|
st_name = frappe.db.sql("""select parent from `tabSalary Structure Employee`
|
||||||
where employee=%s order by modified desc limit 1""",self.employee)
|
where employee=%s
|
||||||
|
and parent in (select name from `tabSalary Structure`
|
||||||
|
where is_active = 'Yes'
|
||||||
|
and (from_date <= %s or from_date <= %s)
|
||||||
|
and (to_date is null or to_date >= %s or to_date >= %s))
|
||||||
|
""",(self.employee, self.start_date, joining_date, self.end_date, relieving_date))
|
||||||
|
|
||||||
if st_name:
|
if st_name:
|
||||||
struct = frappe.db.sql("""select name from `tabSalary Structure`
|
if len(st_name) > 1:
|
||||||
where name=%s and is_active = 'Yes'
|
frappe.msgprint(_("Multiple active Salary Structures found for employee {0} for the given dates")
|
||||||
and (from_date <= %s or from_date <= %s)
|
.format(self.employee), title=_('Warning'))
|
||||||
and (to_date is null or to_date >= %s or to_date >= %s) order by from_date desc limit 1""",
|
return st_name and st_name[0][0] or ''
|
||||||
(st_name, self.start_date, joining_date, self.end_date, relieving_date))
|
|
||||||
|
|
||||||
if not struct:
|
|
||||||
self.salary_structure = None
|
|
||||||
frappe.throw(_("No active or default Salary Structure found for employee {0} for the given dates")
|
|
||||||
.format(self.employee), title=_('Salary Structure Missing'))
|
|
||||||
|
|
||||||
return struct and struct[0][0] or ''
|
|
||||||
else:
|
else:
|
||||||
self.salary_structure = None
|
self.salary_structure = None
|
||||||
frappe.throw(_("No active or default Salary Structure found for employee {0} for the given dates")
|
frappe.throw(_("No active or default Salary Structure found for employee {0} for the given dates")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user