[Minor] Apply Salary Slip validation only if it is submitted
diff --git a/erpnext/hr/doctype/leave_application/leave_application.py b/erpnext/hr/doctype/leave_application/leave_application.py
index a51e2b5..a0a718e 100755
--- a/erpnext/hr/doctype/leave_application/leave_application.py
+++ b/erpnext/hr/doctype/leave_application/leave_application.py
@@ -38,6 +38,7 @@
self.validate_block_days()
self.validate_salary_processed_days()
self.validate_leave_approver()
+ self.validate_attendance()
def on_update(self):
if (not self.previous_doc and self.leave_approver) or (self.previous_doc and \
@@ -102,7 +103,7 @@
last_processed_pay_slip = frappe.db.sql("""
select start_date, end_date from `tabSalary Slip`
- where docstatus != 2 and employee = %s
+ where docstatus = 1 and employee = %s
and ((%s between start_date and end_date) or (%s between start_date and end_date))
order by modified desc limit 1
""",(self.employee, self.to_date, self.from_date))
@@ -212,6 +213,13 @@
elif self.docstatus==1 and len(leave_approvers) and self.leave_approver != frappe.session.user:
frappe.throw(_("Only the selected Leave Approver can submit this Leave Application"),
LeaveApproverIdentityError)
+
+ def validate_attendance(self):
+ attendance = frappe.db.sql("""select name from `tabAttendance` where employee = %s and (att_date between %s and %s)
+ and docstatus = 1""",
+ (self.employee, self.from_date, self.to_date))
+ if attendance:
+ frappe.throw(_("Attendance for employee {0} is already marked for this day").format(self.employee))
def notify_employee(self, status):
employee = frappe.get_doc("Employee", self.employee)
diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.py b/erpnext/hr/doctype/salary_slip/salary_slip.py
index 3ffa4dd..9cba9b4 100644
--- a/erpnext/hr/doctype/salary_slip/salary_slip.py
+++ b/erpnext/hr/doctype/salary_slip/salary_slip.py
@@ -231,10 +231,15 @@
if working_days < 0:
frappe.throw(_("There are more holidays than working days this month."))
+ actual_lwp = self.calculate_lwp(holidays, working_days)
if not lwp:
- lwp = self.calculate_lwp(holidays, working_days)
+ lwp = actual_lwp
+ elif lwp != actual_lwp:
+ frappe.msgprint(_("Leave Without Pay does not match with approved Leave Application records"))
+
self.total_days_in_month = working_days
self.leave_without_pay = lwp
+
payment_days = flt(self.get_payment_days(joining_date, relieving_date)) - flt(lwp)
self.payment_days = payment_days > 0 and payment_days or 0
diff --git a/erpnext/hr/report/monthly_salary_register/monthly_salary_register.py b/erpnext/hr/report/monthly_salary_register/monthly_salary_register.py
index 6e1265e..1e9d03e 100644
--- a/erpnext/hr/report/monthly_salary_register/monthly_salary_register.py
+++ b/erpnext/hr/report/monthly_salary_register/monthly_salary_register.py
@@ -48,7 +48,7 @@
from `tabSalary Detail` sd, `tabSalary Component` sc
where sc.name=sd.salary_component and sd.amount != 0 and sd.parent in (%s)""" %
(', '.join(['%s']*len(salary_slips))), tuple([d.name for d in salary_slips]), as_dict=1):
- salary_components[component.type].append(component.salary_component)
+ salary_components[_(component.type)].append(component.salary_component)
columns = columns + [(e + ":Currency:120") for e in salary_components[_("Earning")]] + \
[ _("Arrear Amount") + ":Currency:120", _("Leave Encashment Amount") + ":Currency:150",