mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-09 00:01:18 +00:00
chore: formatting
This commit is contained in:
@@ -21,14 +21,14 @@ class Attendance(Document):
|
||||
self.set_overtime_type()
|
||||
self.set_default_shift()
|
||||
|
||||
if not frappe.db.get_single_value('Payroll Settings', 'fetch_standard_working_hours_from_shift_type'):
|
||||
if not frappe.db.get_single_value("Payroll Settings", "fetch_standard_working_hours_from_shift_type"):
|
||||
self.standard_working_time = None
|
||||
|
||||
def validate_attendance_date(self):
|
||||
date_of_joining = frappe.db.get_value("Employee", self.employee, "date_of_joining")
|
||||
|
||||
# leaves can be marked for future dates
|
||||
if self.status != 'On Leave' and not self.leave_application and getdate(self.attendance_date) > getdate(nowdate()):
|
||||
if self.status != "On Leave" and not self.leave_application and getdate(self.attendance_date) > getdate(nowdate()):
|
||||
frappe.throw(_("Attendance can not be marked for future dates"))
|
||||
elif date_of_joining and getdate(self.attendance_date) < getdate(date_of_joining):
|
||||
frappe.throw(_("Attendance date can not be less than employee's joining date"))
|
||||
@@ -81,11 +81,11 @@ class Attendance(Document):
|
||||
for d in leave_record:
|
||||
self.leave_type = d.leave_type
|
||||
if d.half_day_date == getdate(self.attendance_date):
|
||||
self.status = 'Half Day'
|
||||
self.status = "Half Day"
|
||||
frappe.msgprint(_("Employee {0} on Half day on {1}")
|
||||
.format(self.employee, formatdate(self.attendance_date)))
|
||||
else:
|
||||
self.status = 'On Leave'
|
||||
self.status = "On Leave"
|
||||
frappe.msgprint(_("Employee {0} is on Leave on {1}")
|
||||
.format(self.employee, formatdate(self.attendance_date)))
|
||||
|
||||
@@ -146,7 +146,7 @@ def get_overtime_type(employee):
|
||||
emp_department = frappe.db.get_value("Employee", employee, "department")
|
||||
if emp_department:
|
||||
overtime_type_doc = frappe.get_list("Overtime Type", filters={
|
||||
"applicable_for": "Department", "department": emp_department}, fields=['name'])
|
||||
"applicable_for": "Department", "department": emp_department}, fields=["name"])
|
||||
if len(overtime_type_doc):
|
||||
overtime_type = overtime_type_doc[0].name
|
||||
emp_grade = frappe.db.get_value("Employee", employee, "grade")
|
||||
@@ -154,12 +154,12 @@ def get_overtime_type(employee):
|
||||
if emp_grade:
|
||||
overtime_type_doc = frappe.get_list("Overtime Type", filters={
|
||||
"applicable_for": "Employee Grade", "employee_grade": emp_grade},
|
||||
fields=['name'])
|
||||
fields=["name"])
|
||||
if len(overtime_type_doc):
|
||||
overtime_type = overtime_type_doc[0].name
|
||||
|
||||
overtime_type_doc = frappe.get_list("Overtime Type", filters={
|
||||
"applicable_for": "Employee", "employee": employee}, fields=['name'])
|
||||
"applicable_for": "Employee", "employee": employee}, fields=["name"])
|
||||
if len(overtime_type_doc):
|
||||
overtime_type = overtime_type_doc[0].name
|
||||
return overtime_type
|
||||
@@ -267,7 +267,7 @@ def get_unmarked_days(employee, month):
|
||||
month_start, month_end = dates_of_month[0], dates_of_month[length-1]
|
||||
|
||||
|
||||
records = frappe.get_all("Attendance", fields = ['attendance_date', 'employee'] , filters = [
|
||||
records = frappe.get_all("Attendance", fields = ["attendance_date", "employee"] , filters = [
|
||||
["attendance_date", ">=", month_start],
|
||||
["attendance_date", "<=", month_end],
|
||||
["employee", "=", employee],
|
||||
|
||||
@@ -20,8 +20,8 @@ class ShiftType(Document):
|
||||
self.set_working_hours()
|
||||
|
||||
def set_working_hours(self):
|
||||
end_time = self.end_time.split(":")
|
||||
start_time = self.start_time.split(":")
|
||||
end_time = self.end_time.split(':')
|
||||
start_time = self.start_time.split(':')
|
||||
|
||||
shift_end = timedelta(hours = int(end_time[0]), minutes = int(end_time[1]), seconds = int(end_time[2]))
|
||||
shift_start = timedelta(hours = int(start_time[0]), minutes = int(start_time[1]), seconds = int(start_time[2]))
|
||||
@@ -34,7 +34,7 @@ class ShiftType(Document):
|
||||
self.standard_working_time = convert_time_into_duration(time_difference)
|
||||
|
||||
def validate_overtime(self):
|
||||
if not frappe.db.get_single_value("Payroll Settings", "fetch_standard_working_hours_from_shift_type") and self.allow_overtime:
|
||||
if not frappe.db.get_single_value('Payroll Settings', 'fetch_standard_working_hours_from_shift_type') and self.allow_overtime:
|
||||
frappe.throw(_('Please enable "Fetch Standard Working Hours from Shift Type" in payroll Settings for Overtime.'))
|
||||
|
||||
if frappe.db.get_single_value("Payroll Settings", "overtime_based_on") != "Attendance" and self.allow_overtime:
|
||||
@@ -168,5 +168,5 @@ def get_filtered_date_list(employee, start_date, end_date, filter_attendance=Tru
|
||||
|
||||
|
||||
def convert_time_into_duration(time_difference):
|
||||
time_difference = str(time_difference).split(":")
|
||||
time_difference = str(time_difference).split(':')
|
||||
return (int(time_difference[0]) * 3600) + (int(time_difference[1]) * 60) + int(time_difference[2])
|
||||
|
||||
@@ -177,8 +177,8 @@ def get_standard_working_hours(employee, date):
|
||||
def get_frequency_and_dates(employee, date):
|
||||
salary_structure = get_salary_structure(employee)
|
||||
if salary_structure:
|
||||
payroll_frequency = frappe.db.get_value('Salary Structure', salary_structure, 'payroll_frequency')
|
||||
date_details = get_start_end_dates(payroll_frequency, date, frappe.db.get_value('Employee', employee, 'company'))
|
||||
payroll_frequency = frappe.db.get_value("Salary Structure", salary_structure, "payroll_frequency")
|
||||
date_details = get_start_end_dates(payroll_frequency, date, frappe.db.get_value('Employee', employee, "company"))
|
||||
return [date_details, payroll_frequency]
|
||||
else:
|
||||
frappe.throw(_("No Salary Structure Assignment found for Employee: {0}").format(employee))
|
||||
|
||||
@@ -24,7 +24,7 @@ class TestOvertimeSlip(unittest.TestCase):
|
||||
frappe.db.set_value("Payroll Settings", None, "fetch_standard_working_hours_from_shift_type", 0)
|
||||
frappe.db.set_value("HR Settings", None, "standard_working_hours", 7)
|
||||
|
||||
employee = make_employee("test_employee@overtime.com", company='_Test Company')
|
||||
employee = make_employee("test_employee@overtime.com", company="_Test Company")
|
||||
make_salary_structure("structure for Overtime", "Monthly", employee=employee)
|
||||
overtime_type = create_overtime_type(employee=employee)
|
||||
attendance_record = create_attendance_records_for_overtime(employee, overtime_type.name)
|
||||
@@ -46,7 +46,7 @@ class TestOvertimeSlip(unittest.TestCase):
|
||||
shift_type.last_sync_of_checkin = get_datetime(add_days(today(), 1))
|
||||
shift_type.save()
|
||||
|
||||
employee = make_employee("test_employee@overtime.com", company='_Test Company')
|
||||
employee = make_employee("test_employee@overtime.com", company="_Test Company")
|
||||
make_salary_structure("structure for Overtime", "Monthly", employee=employee)
|
||||
|
||||
frappe.db.set_value("Employee", employee, "default_shift", shift_type.name)
|
||||
@@ -63,7 +63,7 @@ class TestOvertimeSlip(unittest.TestCase):
|
||||
checkin.reload()
|
||||
|
||||
attendance_records = frappe.get_all("Attendance", filters = {
|
||||
'shift': shift_type.name, 'status': 'Present'
|
||||
"shift": shift_type.name, "status": "Present"
|
||||
}, fields = ["name", "overtime_duration", "overtime_type", "attendance_date"])
|
||||
|
||||
records = {}
|
||||
@@ -86,7 +86,7 @@ class TestOvertimeSlip(unittest.TestCase):
|
||||
frappe.db.set_value("Payroll Settings", None, "overtime_based_on", "Timesheet")
|
||||
frappe.db.set_value("HR Settings", None, "standard_working_hours", 7)
|
||||
|
||||
employee = make_employee("test_employee@overtime.com", company='_Test Company')
|
||||
employee = make_employee("test_employee@overtime.com", company="_Test Company")
|
||||
make_salary_structure("structure for Overtime", "Monthly", employee=employee)
|
||||
overtime_type = create_overtime_type(employee=employee)
|
||||
time_log, timesheet = create_timesheet_record_for_overtime(employee, overtime_type.name)
|
||||
@@ -101,12 +101,12 @@ class TestOvertimeSlip(unittest.TestCase):
|
||||
def create_attendance_records_for_overtime(employee, overtime_type):
|
||||
records = {}
|
||||
for x in range(2):
|
||||
attendance = frappe.new_doc('Attendance')
|
||||
attendance = frappe.new_doc("Attendance")
|
||||
attendance.employee = employee
|
||||
attendance.status = 'Present'
|
||||
attendance.status = "Present"
|
||||
attendance.attendance_date = add_days(today(), -(x))
|
||||
attendance.overtime_type = overtime_type
|
||||
#for convertion to duration
|
||||
#to convert to duration
|
||||
attendance.overtime_duration = 2 * 3600
|
||||
|
||||
attendance.save()
|
||||
|
||||
Reference in New Issue
Block a user