8000 Fix negative pto calculation by apoorv1316 · Pull Request #1843 · saeloun/miru-web · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix negative pto calculation #1843

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

Merged
merged 2 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const LeaveBlock = ({ leaveType, selectedLeaveType, setSelectedLeaveType }) => {
category == "national" || category == "optional"
? label
: netDuration < 0
? `-${minToHHMM(-netDuration)} h (${label})`
? `-${minToHHMM(-netDuration)} h (-${label})`
: `${minToHHMM(netDuration)} h (${label})`;

const selectedDiv =
Expand Down
12 changes: 9 additions & 3 deletions app/services/timeoff_entries/index_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,14 @@ def calculate_leave_balance

net_duration = (total_leave_type_days * 8 * 60) + previous_year_carryforward - timeoff_entries_duration
net_hours = net_duration / 60
net_days = net_hours / 8
extra_hours = net_hours % 8
net_days = net_hours.abs / 8
extra_hours = net_hours.abs % 8

if net_hours.abs < 8
label = "#{net_hours} hours"
else
label = "#{net_days} days #{extra_hours} hours"
end

summary_object = {
id: leave_type.id,
Expand All @@ -85,7 +91,7 @@ def calculate_leave_balance
net_duration:,
net_days:,
type: "leave",
label: "#{net_days} days #{extra_hours} hours"
label:
}

leave_balance << summary_object
Expand Down
Loading
0