Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect Calculation of Total_Target_Seconds for Absent Employees in Report #134

Open
farzan-b opened this issue Oct 18, 2024 · 0 comments

Comments

@farzan-b
Copy link

farzan-b commented Oct 18, 2024

Description:
The script currently calculates Total_Target_Seconds for employees without a check-in as 0. This causes an issue in the report where negative hours for absent days are not added to the Diff, leading to inaccurate data for absent employees.

Steps to Reproduce:

  1. Run the report for a period where some employees are absent without any check-ins.
  2. Observe that the Total_Target_Seconds for absent days is calculated as 0.
  3. Notice that the report doesn't include negative hours in the Diff for those absent employees.

Expected Behavior:

  • The Total_Target_Seconds for absent employees should reflect the expected working hours for the absent day, and the report should show the corresponding negative hours in the Diff.

Actual Behavior:

  • The script sets Total_Target_Seconds to 0 for absent employees, causing their Diff to exclude the expected negative hours for the absent days.

Workaround:
A temporary workaround is to manually update the work_hour_report.py file to calculate Total_Target_Seconds for employees with an Absent status. However, this is not the most reliable method.

	work_data = frappe.db.sql("""
		SELECT name, log_date, employee, attendance, status, total_work_seconds, total_break_seconds,
		actual_working_hours * 60 * 60 actual_working_seconds, expected_break_hours * 60 * 60 expected_break_hours,
		target_hours, 
		CASE 
			WHEN status = 'Absent' THEN target_hours * 60 * 60 
			ELSE total_target_seconds 
		END as total_target_seconds,
		(total_work_seconds - CASE 
			WHEN status = 'Absent' THEN target_hours * 60 * 60 
			ELSE total_target_seconds 
		END) as diff_log,
		(actual_working_hours * 60 * 60 - CASE 
			WHEN status = 'Absent' THEN target_hours * 60 * 60 
			ELSE total_target_seconds 
		END) as actual_diff_log,
		TIME(first_checkin) as first_in, TIME(last_checkout) as last_out 
		FROM `tabWorkday` 
		WHERE docstatus < 2 {} {} 
		ORDER BY log_date ASC
	""".format(condition_date, condition_employee), as_dict=1)

Suggested Fix:
Add logic in utils.py to correctly calculate Total_Target_Seconds for Absent employees based on the defined working hours, ensuring the Diff reflects negative hours for absence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant