hr_lite 0.43.0 → 0.48.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +38 -0
- data/app/assets/javascripts/hr_lite/confirm.js +2 -1
- data/app/assets/javascripts/hr_lite/geo_punch.js +16 -5
- data/app/assets/stylesheets/hr_lite/hr_lite.css +1 -1
- data/app/controllers/hr_lite/admin/attendances_controller.rb +31 -2
- data/app/controllers/hr_lite/admin/settings_controller.rb +1 -1
- data/app/controllers/hr_lite/admin/wfh_requests_controller.rb +14 -1
- data/app/models/hr_lite/attendance_penalty.rb +10 -0
- data/app/models/hr_lite/attendance_punch.rb +14 -0
- data/app/models/hr_lite/attendance_record.rb +9 -0
- data/app/models/hr_lite/leave_balance.rb +11 -0
- data/app/models/hr_lite/leave_request.rb +13 -6
- data/app/models/hr_lite/penalty_removal.rb +13 -0
- data/app/models/hr_lite/setting.rb +3 -0
- data/app/models/hr_lite/wfh_request.rb +23 -3
- data/app/services/hr_lite/attendance_puncher.rb +7 -3
- data/app/views/hr_lite/admin/attendances/index.html.erb +4 -1
- data/app/views/hr_lite/admin/attendances/show.html.erb +9 -0
- data/app/views/hr_lite/admin/leave_balances/index.html.erb +1 -1
- data/app/views/hr_lite/admin/settings/edit.html.erb +5 -0
- data/app/views/hr_lite/admin/wfh_requests/show.html.erb +17 -0
- data/app/views/hr_lite/attendance/_penalties.html.erb +18 -0
- data/app/views/hr_lite/attendance/_punch_card.html.erb +9 -4
- data/app/views/hr_lite/attendance/_trail.html.erb +3 -0
- data/app/views/hr_lite/attendance/show.html.erb +1 -0
- data/app/views/hr_lite/leave_balances/index.html.erb +1 -0
- data/app/views/hr_lite/leave_requests/_balance_chips.html.erb +1 -1
- data/app/views/hr_lite/leave_requests/new.html.erb +2 -2
- data/app/views/hr_lite/work_time/_bars.html.erb +2 -2
- data/app/views/hr_lite/work_time/_report.html.erb +2 -2
- data/config/routes.rb +2 -2
- data/db/migrate/20261015100000_create_hr_lite_attendance_punches.rb +20 -0
- data/db/migrate/20261016090000_add_penalty_leave_type_to_hr_lite_settings.rb +5 -0
- data/db/migrate/20261016091000_create_hr_lite_penalty_removals.rb +13 -0
- data/lib/hr_lite/notifications.rb +1 -0
- data/lib/hr_lite/version.rb +1 -1
- metadata +6 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3780e666e11b64f65243366d445d5f45ee6740eaee2ba3b67c3c4afd5524c630
|
|
4
|
+
data.tar.gz: e28d1822a25528f83491a9c14bb8ff79aa79c3a63735e93714e9cb96874099b3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8ca3e1262c00c6c81477dcda625defdc91bf4e80fd159cc9f6e46ec011867b920398e1cd680fbd9942407b4743d093779759718cad771dc5bd44fff564454cf2
|
|
7
|
+
data.tar.gz: '0395753ca5277c0aa9a01063ced7362531d4514f8d785e07e7dd717c50c5237a9482d38e575396d7ae9891886e2aeeceef813e4143d131990ddf4835993342d9'
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,44 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.48.2] - 2026-10-16
|
|
11
|
+
|
|
12
|
+
- Breaks count as working time. The standard day is 8h 30m including its break, but My work time (and HR's work time report) showed "Working time 8h 00m" for a full 8h 30m shift, because lunch and short breaks were left out. The KPI now reads "Working time (breaks included)" (8h 30m for that shift), and breaks show as "Of which breaks". The daily table's columns are "Working (breaks incl.)" and "Of which breaks". Only the display changed: attendance, penalties, half day and pay already used check-in to check-out.
|
|
13
|
+
|
|
14
|
+
## [0.48.1] - 2026-10-16
|
|
15
|
+
|
|
16
|
+
- A choice the punch needs can't be missed on a phone any more. Examples: "Is this your home location?" (Yes, save it / No, I am travelling) and "I am travelling — check out here". The choice sits in the red box, and the page scrolls it to the middle of the screen when the card loads. If the button is tapped without a choice, the page scrolls back to it (the browser's own "select an option" note still shows). Checked at 360 px: the box comes into view, the check-out is held until it's ticked, then it goes through.
|
|
17
|
+
|
|
18
|
+
## [0.48.0] - 2026-10-16
|
|
19
|
+
|
|
20
|
+
- When location is blocked, the punch card's message ("Location is blocked. To allow it:") and its steps now show in a red box instead of small grey text. The box clears on the next try.
|
|
21
|
+
- New iPhone steps. Location Services can be on while Safari is still blocked, so the steps now cover all three settings: turn on Location Services; on that screen set Safari Websites (or Chrome, Firefox, Edge) to While Using the App; and for Safari, set Settings → Apps → Safari → Location to Allow (or Ask). Then reload. From the Home Screen app, close and reopen it instead. Checked in the iOS 26 Simulator: tapping Check in and choosing Don't Allow shows these steps in red.
|
|
22
|
+
|
|
23
|
+
## [0.47.0] - 2026-10-16
|
|
24
|
+
|
|
25
|
+
- Penalty hours build up and limit leave. A person's attendance penalties (late, after 11:00, short day) add up with no yearly reset until HR removes them. Every 5 hours holds half a day and 10 hours a full day, the same for everyone: 100h = 10 days.
|
|
26
|
+
- In Settings, HR picks "Penalties come off" a leave type (for example Earned leave); with no type picked, penalties limit nothing. The balance itself is not cut: 12 stays 12. You can apply for at most 12 − 10 = 2 days, rounded down to half days. Past that, the request is refused: "For these dates you can apply for at most 2 days of Earned leave — 10 days held for penalties". Other leave types keep today's rule, where days past the balance are unpaid.
|
|
27
|
+
- A "Penalty hours" section on the employee's Attendance page, and on HR's page for that person, shows the hours held, the days they hold, and every HR removal (hours, who, when, reason). HR can remove any number of hours with a required reason: remove 50 of 100 and 50 stay, or remove all of it to settle to 0. The employee gets a bell and an email, and the audit log records it. Removing a single penalty works as before.
|
|
28
|
+
- HR's team attendance view shows "Penalties 100h 00m · 10 days" on each person who has any, linking to their section.
|
|
29
|
+
- "Held for penalties" and "You can apply" show on the employee's balances page, the leave chips, the apply form (with today's limit) and HR's balances grid.
|
|
30
|
+
- Migrations: `hr_lite_settings.penalty_leave_type_id` and `hr_lite_penalty_removals`.
|
|
31
|
+
|
|
32
|
+
## [0.46.0] - 2026-10-15
|
|
33
|
+
|
|
34
|
+
- Every check-in and check-out is kept. Checking in again, a repeat check-out and an HR reset used to overwrite the day's check-out, including its time and GPS. Now each punch is saved as its own row: time, GPS, accuracy, place and distance from home. Those rows are never edited or deleted, and saving a change to one raises an error. When a day has more than one in/out pair, "All punches: In 09:30 Office · Out 11:45 Office · In 12:10 Office · Out 18:05 Office" shows on the employee's Today card, their day detail and My work time, and on HR's "Where they punched". A day HR reset with Reset check-in keeps its old punches on show.
|
|
35
|
+
- The day record is still the summary: first check-in to latest check-out. Hours, short day, half day and penalties count the same as before, and the gap between two sessions still counts as worked.
|
|
36
|
+
- Migration: `hr_lite_attendance_punches`. Days punched before this release have no punch rows and show as before.
|
|
37
|
+
|
|
38
|
+
## [0.45.0] - 2026-10-15
|
|
39
|
+
|
|
40
|
+
- HR can change a WFH request after deciding it. On an approved or rejected request, the "Change this WFH" card lets HR set new dates and switch between Approved and Rejected, with a required reason. For example, a request rejected for 19–23 Oct can be approved for 20–21 Oct only. Past dates are allowed so a request can match the days actually worked from home, up to 60 days long. It can't clash with that person's other pending or approved WFH. The audit log records the old and new dates and decision ("wfh.changed"), and the employee gets the approved/rejected notice with the reason. Attendance days already punched are not rewritten.
|
|
41
|
+
|
|
42
|
+
## [0.44.0] - 2026-10-15
|
|
43
|
+
|
|
44
|
+
- HR can reset today's punch when someone taps by mistake again (after their one "Check in again" is used). On the employee's attendance page, tap today, give the reason, then pick a reset. Each one asks OK/Cancel first. **Reset check-out** puts them back in: the first check-in stands, their work mode reopens, and they check out later. **Reset check-in** clears the whole day so they check in fresh. Both are audited and the employee is notified.
|
|
45
|
+
- Removing a day's punch now also lifts that check-in's late penalties, recorded as removed by HR with the reason. Before, checking in again was charged twice.
|
|
46
|
+
- `data-turbo-confirm` can sit on a button as well as a form, so one form can hold several confirmed actions.
|
|
47
|
+
|
|
10
48
|
## [0.43.0] - 2026-10-15
|
|
11
49
|
|
|
12
50
|
- Shorter day: HR can give one employee 30, 60 or 90 minutes off the working day, for example for a long commute. It's set on their profile, with a required reason. The reason is encrypted, kept out of the audit trail, and seen only by HR. Their day becomes the Settings day minus the allowance (8h30 − 90 min = 7h). That drives their "+30 min", "Short by", checkout due time, half-day line check and slot picker. They see "Your day 7h 00m" on their attendance card. This is separate from the late buffer, which still only delays the late clock.
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
var form = event.target;
|
|
19
19
|
if (!form || form.nodeName !== "FORM") return;
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
// A button can carry its own prompt (one form, several actions).
|
|
22
|
+
var message = (event.submitter && event.submitter.getAttribute("data-turbo-confirm")) || form.getAttribute("data-turbo-confirm");
|
|
22
23
|
if (message && !window.confirm(message)) {
|
|
23
24
|
event.preventDefault();
|
|
24
25
|
event.stopPropagation();
|
|
@@ -19,13 +19,16 @@
|
|
|
19
19
|
var ua = navigator.userAgent;
|
|
20
20
|
var ios = /iPhone|iPad|iPod/.test(ua) || (/Macintosh/.test(ua) && navigator.maxTouchPoints > 1);
|
|
21
21
|
if (ios) {
|
|
22
|
+
// Location Services can be on while Safari Websites (or the browser app) is set
|
|
23
|
+
// to Never, or this site to Deny — the usual iPhone block.
|
|
22
24
|
var app = /CriOS/.test(ua) ? "Chrome" : /FxiOS/.test(ua) ? "Firefox" : /EdgiOS/.test(ua) ? "Edge" : null;
|
|
23
|
-
|
|
25
|
+
var steps = [
|
|
24
26
|
"Open Settings → Privacy & Security → Location Services and turn it on.",
|
|
25
|
-
|
|
26
|
-
: "In Settings, open Apps → Safari → Location and choose Allow (or Ask).",
|
|
27
|
-
"Come back here, reload the page and tap again."
|
|
27
|
+
"On that screen, scroll down to " + (app || "Safari Websites") + " and choose While Using the App."
|
|
28
28
|
];
|
|
29
|
+
if (!app) steps.push("Then open Settings → Apps → Safari → Location and choose Allow (or Ask).");
|
|
30
|
+
steps.push(navigator.standalone ? "Close this app fully, open it again and tap again." : "Reload this page and tap again.");
|
|
31
|
+
return steps;
|
|
29
32
|
}
|
|
30
33
|
if (/Android/.test(ua)) {
|
|
31
34
|
var samsung = /SamsungBrowser/.test(ua);
|
|
@@ -49,6 +52,7 @@
|
|
|
49
52
|
function showHelp(label, headline) {
|
|
50
53
|
if (!label) return;
|
|
51
54
|
label.textContent = headline;
|
|
55
|
+
label.classList.replace("hrl-muted", "hrl-errors") || label.classList.add("hrl-errors"); // red until the next try
|
|
52
56
|
var list = document.createElement("ol");
|
|
53
57
|
list.className = "hrl-geo-help";
|
|
54
58
|
locationSteps().forEach(function (step) {
|
|
@@ -69,6 +73,13 @@
|
|
|
69
73
|
var button = form.querySelector("[type=submit]");
|
|
70
74
|
var label = form.querySelector("[data-hrl-geo-status]");
|
|
71
75
|
var required = form.hasAttribute("data-hrl-geo-required");
|
|
76
|
+
// A choice the punch needs (home or travelling) sits mid-card on a phone and was
|
|
77
|
+
// missed: bring it into view now, and again if the button is tapped without it.
|
|
78
|
+
var choose = form.querySelector("[data-hrl-must-choose]");
|
|
79
|
+
if (choose) {
|
|
80
|
+
choose.scrollIntoView({ block: "center" });
|
|
81
|
+
form.addEventListener("invalid", function () { choose.scrollIntoView({ block: "center" }); }, true);
|
|
82
|
+
}
|
|
72
83
|
var locating = false;
|
|
73
84
|
|
|
74
85
|
function send(status) {
|
|
@@ -88,7 +99,7 @@
|
|
|
88
99
|
event.preventDefault();
|
|
89
100
|
locating = true;
|
|
90
101
|
if (button) { button.disabled = true; button.setAttribute("aria-busy", "true"); }
|
|
91
|
-
if (label) { label.hidden = false; label.textContent = "Getting location…"; }
|
|
102
|
+
if (label) { label.hidden = false; label.classList.replace("hrl-errors", "hrl-muted"); label.textContent = "Getting location…"; }
|
|
92
103
|
|
|
93
104
|
if (!navigator.geolocation) {
|
|
94
105
|
if (required) hold("This browser cannot share your location. Open this page in Chrome or Safari.");
|
|
@@ -260,7 +260,7 @@ details > form > button[type=submit], details > form > .hrl-btn { margin-top: .2
|
|
|
260
260
|
.hrl-listrow > :first-child { display: inline-flex; align-items: center; gap: var(--hrl-s-1); line-height: var(--hrl-lh-tight); }
|
|
261
261
|
/* The punch status stays in the accessibility tree (no `hidden`) so its first message is announced; empty, it takes no space. */
|
|
262
262
|
[data-hrl-geo-status]:empty { margin: 0; }
|
|
263
|
-
.hrl-geo-help { margin: var(--hrl-s-2) 0 0; padding-left: var(--hrl-s-4); color:
|
|
263
|
+
.hrl-geo-help { margin: var(--hrl-s-2) 0 0; padding-left: var(--hrl-s-4); color: inherit; }
|
|
264
264
|
.hrl-geo-help li + li { margin-top: var(--hrl-s-1); }
|
|
265
265
|
.hrl-grid { display: grid; gap: .85rem; grid-template-columns: 1fr; margin-bottom: .85rem; }
|
|
266
266
|
.hrl-grid > * { min-width: 0; }
|
|
@@ -11,6 +11,7 @@ module HrLite
|
|
|
11
11
|
@employees = @employees.select { |user| visible.include?(user.id) } if visible
|
|
12
12
|
@records = AttendanceRecord.for_date(@date).where(user_id: @employees.map(&:id)).index_by(&:user_id)
|
|
13
13
|
@flagged_count = @records.values.count(&:flagged?)
|
|
14
|
+
@penalty_minutes = AttendancePenalty.held_minutes(@employees.map(&:id))
|
|
14
15
|
# "How many people punched where": off-site punches count as one place.
|
|
15
16
|
@offices = OfficeLocation.active.to_a
|
|
16
17
|
@places = %i[check_in check_out].index_with do |side|
|
|
@@ -62,7 +63,8 @@ module HrLite
|
|
|
62
63
|
|
|
63
64
|
# Regularization: fix punches with a mandatory note, fully audited.
|
|
64
65
|
# Clearing both punch times deletes the record (that is how an
|
|
65
|
-
# erroneous punch is removed).
|
|
66
|
+
# erroneous punch is removed). Reset check-in does the same; reset
|
|
67
|
+
# check-out leaves them checked in, so they can check in or out again.
|
|
66
68
|
def update
|
|
67
69
|
@employee = find_manageable_employee
|
|
68
70
|
date = parse_date_param(params[:date])
|
|
@@ -75,7 +77,7 @@ module HrLite
|
|
|
75
77
|
end
|
|
76
78
|
|
|
77
79
|
attrs = params.require(:attendance_record).permit(:check_in_at, :check_out_at, :status, :half_day_part)
|
|
78
|
-
if attrs[:check_in_at].blank? && attrs[:check_out_at].blank?
|
|
80
|
+
if params[:reset] == "check_in" || (attrs[:check_in_at].blank? && attrs[:check_out_at].blank?)
|
|
79
81
|
# Nothing to remove used to still write a `destroy` audit row with
|
|
80
82
|
# subject_id 0 and email the employee that a punch was removed.
|
|
81
83
|
unless record.persisted?
|
|
@@ -84,6 +86,9 @@ module HrLite
|
|
|
84
86
|
end
|
|
85
87
|
|
|
86
88
|
record.destroy
|
|
89
|
+
# Its late penalties go too, so checking in again is not charged twice.
|
|
90
|
+
AttendancePenalty.active.where(attendance_record_id: record.id)
|
|
91
|
+
.find_each { |p| p.update!(removed_at: Time.current, removed_by_id: hr_current_user.id, removal_reason: note) }
|
|
87
92
|
log_regularization(record, note, removed: true)
|
|
88
93
|
return redirect_to admin_attendance_path(@employee.id, month: date.strftime("%Y-%m")),
|
|
89
94
|
notice: "Punch removed."
|
|
@@ -98,6 +103,7 @@ module HrLite
|
|
|
98
103
|
end
|
|
99
104
|
|
|
100
105
|
record.assign_attributes(attrs)
|
|
106
|
+
record.clear_check_out if params[:reset] == "check_out"
|
|
101
107
|
record.half_day_part = attrs[:half_day_part].presence if attrs.key?(:half_day_part)
|
|
102
108
|
record.status = record.half_day_part ? "half_day" : "present" if attrs.key?(:half_day_part)
|
|
103
109
|
record.status = "present" if record.status.blank?
|
|
@@ -107,6 +113,10 @@ module HrLite
|
|
|
107
113
|
|
|
108
114
|
if record.save
|
|
109
115
|
log_regularization(record, note, removed: false)
|
|
116
|
+
if params[:reset] == "check_out" && date == Date.current
|
|
117
|
+
WorkModeEvent.start!(user_id: @employee.id, mode: record.work_mode || "office", source: "hr",
|
|
118
|
+
actor: hr_current_user, attendance_record: record)
|
|
119
|
+
end
|
|
110
120
|
redirect_to admin_attendance_path(@employee.id, month: date.strftime("%Y-%m")),
|
|
111
121
|
notice: "Attendance updated."
|
|
112
122
|
else
|
|
@@ -144,6 +154,25 @@ module HrLite
|
|
|
144
154
|
redirect_to admin_attendance_path(@employee.id, month: month), notice: "Penalty removed."
|
|
145
155
|
end
|
|
146
156
|
|
|
157
|
+
# HR settles part or all of a person's penalty hours with a reason; the rest stays.
|
|
158
|
+
def remove_penalty_hours
|
|
159
|
+
@employee = find_manageable_employee
|
|
160
|
+
minutes = (params[:hours].to_f * 60).round
|
|
161
|
+
reason = params[:reason].to_s.strip
|
|
162
|
+
held = AttendancePenalty.held_minutes(@employee.id)[@employee.id].to_i
|
|
163
|
+
back = admin_attendance_path(@employee.id, anchor: "penalties")
|
|
164
|
+
return redirect_to back, alert: "A reason is required." if reason.blank?
|
|
165
|
+
return redirect_to back, alert: "Remove between 0.5h and #{helpers.hrl_days(held / 60.0)}h." unless minutes.positive? && minutes <= held
|
|
166
|
+
|
|
167
|
+
removal = PenaltyRemoval.create!(user_id: @employee.id, minutes: minutes, reason: reason, removed_by_id: hr_current_user.id)
|
|
168
|
+
hours = helpers.hrl_days(minutes / 60.0)
|
|
169
|
+
AuditLog.record!(action: "attendance.penalty_hours_removed", subject: removal, actor: hr_current_user,
|
|
170
|
+
changes: { "minutes" => minutes, "reason" => reason })
|
|
171
|
+
Notifications.publish("attendance.penalty_removed", title: "HR removed #{hours}h of your penalties", body: reason,
|
|
172
|
+
path: "/attendance#penalties", bell_to: [ @employee ], email_to: [ @employee ])
|
|
173
|
+
redirect_to back, notice: "Removed #{hours}h of penalties."
|
|
174
|
+
end
|
|
175
|
+
|
|
147
176
|
private
|
|
148
177
|
|
|
149
178
|
# Viewing somebody's month and rewriting their punches are different
|
|
@@ -8,7 +8,7 @@ module HrLite
|
|
|
8
8
|
def update
|
|
9
9
|
@setting = Setting.instance
|
|
10
10
|
if @setting.update(params.require(:setting).permit(:weekend_policy, :employee_code_prefix, :lunch_break_minutes, :short_break_minutes,
|
|
11
|
-
:day_minutes, :half_day_below_minutes, :recheck_in_from, :recheck_in_until))
|
|
11
|
+
:day_minutes, :half_day_below_minutes, :recheck_in_from, :recheck_in_until, :penalty_leave_type_id))
|
|
12
12
|
redirect_to edit_admin_setting_path, notice: "Settings saved."
|
|
13
13
|
else
|
|
14
14
|
render :edit, status: :unprocessable_entity
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module HrLite
|
|
2
2
|
module Admin
|
|
3
3
|
# WFH board (counts, who is home on a date, every schedule) and the
|
|
4
|
-
# decision screen. Viewing is attendance.view, deciding attendance.manage.
|
|
4
|
+
# decision screen. Viewing is attendance.view, deciding and changing attendance.manage.
|
|
5
5
|
class WfhRequestsController < BaseController
|
|
6
6
|
def index
|
|
7
7
|
@from = params[:from].present? ? parse_date_param(params[:from]) : Date.current
|
|
@@ -64,6 +64,19 @@ module HrLite
|
|
|
64
64
|
redirect_to admin_wfh_request_path(request), alert: "Only pending requests can be decided."
|
|
65
65
|
end
|
|
66
66
|
|
|
67
|
+
# HR changes an approved or rejected request: dates (past allowed) and/or decision, with a reason.
|
|
68
|
+
def update
|
|
69
|
+
request = decidable.where(status: %w[approved rejected]).find(params[:id])
|
|
70
|
+
note = params[:decision_note].to_s.strip
|
|
71
|
+
return redirect_to admin_wfh_request_path(request), alert: "A reason is required to change WFH." if note.blank?
|
|
72
|
+
|
|
73
|
+
request.change!(actor: hr_current_user, start_date: params[:start_date], end_date: params[:end_date],
|
|
74
|
+
status: params[:status].presence_in(%w[approved rejected]) || request.status, note: note)
|
|
75
|
+
redirect_to admin_wfh_request_path(request), notice: "WFH changed for #{hr_display_name(request.user)}."
|
|
76
|
+
rescue ActiveRecord::RecordInvalid => e
|
|
77
|
+
redirect_to admin_wfh_request_path(request), alert: "Could not change WFH: #{e.record.errors.full_messages.to_sentence}"
|
|
78
|
+
end
|
|
79
|
+
|
|
67
80
|
private
|
|
68
81
|
|
|
69
82
|
# Nobody decides their own request; out-of-scope ids are a 404.
|
|
@@ -25,6 +25,16 @@ module HrLite
|
|
|
25
25
|
((date + 1)..(date + 31)).select { |d| calendar.working_day?(d) }.first(count)
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
+
# Penalty minutes still held per person: every active penalty ever, less the
|
|
29
|
+
# hours HR removed. They build up until HR removes them; never below 0.
|
|
30
|
+
def self.held_minutes(user_ids)
|
|
31
|
+
removed = PenaltyRemoval.where(user_id: user_ids).group(:user_id).sum(:minutes)
|
|
32
|
+
active.where(user_id: user_ids).group(:user_id).sum(:minutes).to_h { |id, m| [ id, [ m - removed[id].to_i, 0 ].max ] }
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Every 5h held is half a day of leave: 7h = 0.5, 10h = 1, 100h = 10.
|
|
36
|
+
def self.days_for(minutes) = (minutes / 300) * 0.5
|
|
37
|
+
|
|
28
38
|
def label = REASONS.fetch(reason)
|
|
29
39
|
end
|
|
30
40
|
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module HrLite
|
|
2
|
+
# One check-in or check-out as it happened. Append-only: checking in again,
|
|
3
|
+
# a repeat check-out or an HR reset changes the day record, never these.
|
|
4
|
+
class AttendancePunch < ApplicationRecord
|
|
5
|
+
belongs_to :user, class_name: HrLite.config.user_class
|
|
6
|
+
|
|
7
|
+
validates :kind, inclusion: { in: %w[in out] }
|
|
8
|
+
|
|
9
|
+
def readonly? = persisted?
|
|
10
|
+
|
|
11
|
+
# "In 09:30 Office" — the day's punches read as one line.
|
|
12
|
+
def to_s = [ kind == "in" ? "In" : "Out", at.strftime("%H:%M"), AttendanceRecord::PLACES[place] ].compact.join(" ")
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -83,6 +83,15 @@ module HrLite
|
|
|
83
83
|
check_out_at.present? && rechecked_in_at.nil? && now >= s.recheck_in_from && now < s.recheck_in_until
|
|
84
84
|
end
|
|
85
85
|
|
|
86
|
+
# Every check-in and check-out of the day, oldest first, kept even after an HR reset.
|
|
87
|
+
def punches = AttendancePunch.where(user_id: user_id, date: date).order(:at, :id).to_a
|
|
88
|
+
|
|
89
|
+
# Drops the check-out so the person is in again (check in again, HR reset).
|
|
90
|
+
def clear_check_out(**attrs)
|
|
91
|
+
assign_attributes(check_out_at: nil, check_out_lat: nil, check_out_lng: nil, check_out_accuracy_m: nil,
|
|
92
|
+
check_out_place: nil, check_out_home_m: nil, check_out_work_location_id: nil, **attrs)
|
|
93
|
+
end
|
|
94
|
+
|
|
86
95
|
# Metres between where the day was checked in and checked out.
|
|
87
96
|
def punch_gap_m
|
|
88
97
|
return unless check_in_lat && check_in_lng && check_out_lat && check_out_lng
|
|
@@ -71,6 +71,17 @@ module HrLite
|
|
|
71
71
|
entitled(as_of: as_of) - used
|
|
72
72
|
end
|
|
73
73
|
|
|
74
|
+
# What can be applied for: available less days held for penalties, in half days.
|
|
75
|
+
def applicable(as_of: Date.current) = ([ available(as_of: as_of) - penalty_days, 0 ].max * 2).floor / 2.0
|
|
76
|
+
|
|
77
|
+
# Days held off the leave type HR picks in Settings. The balance itself is
|
|
78
|
+
# not cut; leave can be applied for only up to available less these.
|
|
79
|
+
def penalty_days
|
|
80
|
+
return 0 unless leave_type_id && leave_type_id == Setting.instance.penalty_leave_type_id
|
|
81
|
+
|
|
82
|
+
AttendancePenalty.days_for(AttendancePenalty.held_minutes(user_id)[user_id].to_i)
|
|
83
|
+
end
|
|
84
|
+
|
|
74
85
|
private
|
|
75
86
|
|
|
76
87
|
# Quota earned by as_of, before carry/adjustments. Monthly accrual
|
|
@@ -362,15 +362,22 @@ module HrLite
|
|
|
362
362
|
errors.add(:base, "During probation only 1 day of leave a month is allowed") if taken + days_count > 1
|
|
363
363
|
end
|
|
364
364
|
|
|
365
|
-
#
|
|
366
|
-
#
|
|
365
|
+
# Refused past the balance: comp-off (earned credit, never borrowed) and a
|
|
366
|
+
# balance with days held for penalties. Any other excess becomes loss of pay at approval.
|
|
367
367
|
def sufficient_balance
|
|
368
368
|
return unless start_date && end_date && leave_type
|
|
369
|
-
return if leave_type.unlimited? ||
|
|
369
|
+
return if leave_type.unlimited? || errors.any?
|
|
370
370
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
371
|
+
held = balance.penalty_days
|
|
372
|
+
return unless leave_type.comp_off || held.positive?
|
|
373
|
+
|
|
374
|
+
left = balance.applicable(as_of: start_date)
|
|
375
|
+
return if LeaveDayCounter.count(self) <= left
|
|
376
|
+
|
|
377
|
+
return errors.add(:base, "Not enough #{leave_type.name} balance") unless held.positive?
|
|
378
|
+
|
|
379
|
+
days = ->(n) { ActiveSupport::NumberHelper.number_to_rounded(n, precision: 1, strip_insignificant_zeros: true) }
|
|
380
|
+
errors.add(:base, "For these dates you can apply for at most #{days.(left)} days of #{leave_type.name} — #{days.(held)} #{held == 1 ? 'day' : 'days'} held for penalties")
|
|
374
381
|
end
|
|
375
382
|
end
|
|
376
383
|
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module HrLite
|
|
2
|
+
# HR took hours off a person's penalty total, with a reason; the rest stays.
|
|
3
|
+
# Append-only, so every settlement stays on the person's record.
|
|
4
|
+
class PenaltyRemoval < ApplicationRecord
|
|
5
|
+
belongs_to :user, class_name: HrLite.config.user_class
|
|
6
|
+
belongs_to :removed_by, class_name: HrLite.config.user_class
|
|
7
|
+
|
|
8
|
+
validates :minutes, numericality: { only_integer: true, greater_than: 0 }
|
|
9
|
+
validates :reason, presence: true
|
|
10
|
+
|
|
11
|
+
def readonly? = persisted?
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -5,6 +5,9 @@ module HrLite
|
|
|
5
5
|
|
|
6
6
|
WEEKEND_POLICIES = %w[sun_only sat_sun second_fourth_sat_sun].freeze
|
|
7
7
|
|
|
8
|
+
# Attendance penalties come off this leave type's balance (none: they stay as time).
|
|
9
|
+
belongs_to :penalty_leave_type, class_name: "HrLite::LeaveType", optional: true
|
|
10
|
+
|
|
8
11
|
validates :weekend_policy, inclusion: { in: WEEKEND_POLICIES }
|
|
9
12
|
validates :lunch_break_minutes, numericality: { only_integer: true, in: 5..120 }
|
|
10
13
|
validates :short_break_minutes, numericality: { only_integer: true, in: 1..60 }
|
|
@@ -12,7 +12,9 @@ module HrLite
|
|
|
12
12
|
|
|
13
13
|
validates :start_date, :end_date, :reason, presence: true
|
|
14
14
|
validates :status, inclusion: { in: STATUSES }
|
|
15
|
-
validate :dates_in_window,
|
|
15
|
+
validate :dates_in_window, on: :create
|
|
16
|
+
validate :no_overlap
|
|
17
|
+
validate :changed_dates, on: :update, if: -> { start_date_changed? || end_date_changed? }
|
|
16
18
|
|
|
17
19
|
scope :pending, -> { where(status: "pending") }
|
|
18
20
|
scope :approved, -> { where(status: "approved") }
|
|
@@ -59,6 +61,16 @@ module HrLite
|
|
|
59
61
|
"/admin/wfh_requests/#{id}", HrLite.admin_users)
|
|
60
62
|
end
|
|
61
63
|
|
|
64
|
+
# HR changes a decided request after the fact: dates, decision or both, with a reason.
|
|
65
|
+
def change!(actor:, start_date:, end_date:, status:, note:)
|
|
66
|
+
was = "#{dates_label}, #{self.status}"
|
|
67
|
+
update!(start_date: start_date, end_date: end_date, status: status, decided_by_id: actor.id,
|
|
68
|
+
decided_at: Time.current, decision_note: note)
|
|
69
|
+
AuditLog.record!(action: "wfh.changed", subject: self, actor: actor,
|
|
70
|
+
changes: { "was" => was, "now" => "#{dates_label}, #{status}", "note" => note })
|
|
71
|
+
announce("wfh.#{status}", "HR changed your WFH — #{dates_label}, #{status}", note, "/wfh_requests", [ user ])
|
|
72
|
+
end
|
|
73
|
+
|
|
62
74
|
def notify_requested
|
|
63
75
|
AuditLog.record!(action: "wfh.requested", subject: self, actor: user,
|
|
64
76
|
changes: { "dates" => dates_label, "reason" => reason })
|
|
@@ -100,10 +112,18 @@ module HrLite
|
|
|
100
112
|
end
|
|
101
113
|
|
|
102
114
|
def no_overlap
|
|
103
|
-
return unless start_date && end_date && user_id
|
|
115
|
+
return unless start_date && end_date && user_id && %w[pending approved].include?(status)
|
|
104
116
|
|
|
105
|
-
clash = self.class.live.where(user_id: user_id).overlapping(start_date, end_date).exists?
|
|
117
|
+
clash = self.class.live.where(user_id: user_id).where.not(id: id).overlapping(start_date, end_date).exists?
|
|
106
118
|
errors.add(:base, "You already have a pending or approved WFH request on some of these dates") if clash
|
|
107
119
|
end
|
|
120
|
+
|
|
121
|
+
# HR may move a request into the past to match the days actually worked.
|
|
122
|
+
def changed_dates
|
|
123
|
+
return unless start_date && end_date
|
|
124
|
+
|
|
125
|
+
errors.add(:end_date, "must be on or after the start date") if end_date < start_date
|
|
126
|
+
errors.add(:end_date, "HR can set at most #{HR_MAX_DAYS} days at a time") if days > HR_MAX_DAYS
|
|
127
|
+
end
|
|
108
128
|
end
|
|
109
129
|
end
|
|
@@ -69,8 +69,7 @@ module HrLite
|
|
|
69
69
|
return Result.new(record: record, error: "Check in again is open once a day, #{s.recheck_in_from}–#{s.recheck_in_until}.")
|
|
70
70
|
end
|
|
71
71
|
|
|
72
|
-
record.
|
|
73
|
-
check_out_place: nil, check_out_home_m: nil, check_out_work_location_id: nil, rechecked_in_at: Time.current)
|
|
72
|
+
record.clear_check_out(rechecked_in_at: Time.current)
|
|
74
73
|
else
|
|
75
74
|
return Result.new(record: record, error: already_in_message(record)) if record.check_in_at.present?
|
|
76
75
|
|
|
@@ -91,6 +90,9 @@ module HrLite
|
|
|
91
90
|
|
|
92
91
|
apply_geo_flags(record)
|
|
93
92
|
record.save!
|
|
93
|
+
AttendancePunch.create!(user_id: record.user_id, date: record.date, attendance_record_id: record.id,
|
|
94
|
+
kind: @kind == :check_in ? "in" : "out", at: reopen ? record.rechecked_in_at : record.public_send("#{@kind}_at"),
|
|
95
|
+
lat: @lat, lng: @lng, accuracy_m: @accuracy_m, place: punch_place, home_m: home_m, work_location_id: @location&.id)
|
|
94
96
|
apply_slot_rules(record) if @kind == :check_in && !reopen && HrLite.config.attendance_slots
|
|
95
97
|
track_work_mode(record) if HrLite.config.office_geofence
|
|
96
98
|
end
|
|
@@ -232,10 +234,12 @@ module HrLite
|
|
|
232
234
|
record.public_send("#{side}_lat=", @lat)
|
|
233
235
|
record.public_send("#{side}_lng=", @lng)
|
|
234
236
|
record.public_send("#{side}_accuracy_m=", @accuracy_m)
|
|
235
|
-
record.public_send("#{side}_place=",
|
|
237
|
+
record.public_send("#{side}_place=", punch_place)
|
|
236
238
|
record.public_send("#{side}_home_m=", home_m)
|
|
237
239
|
end
|
|
238
240
|
|
|
241
|
+
def punch_place = @place || ("office" if @lat && @lng && in_office?)
|
|
242
|
+
|
|
239
243
|
def already_in_message(record)
|
|
240
244
|
"Already checked in at #{record.check_in_at.in_time_zone(HrLite.config.time_zone).strftime('%H:%M')}."
|
|
241
245
|
end
|
|
@@ -41,7 +41,10 @@
|
|
|
41
41
|
<% @employees.each do |employee| %>
|
|
42
42
|
<% record = @records[employee.id] %>
|
|
43
43
|
<tr>
|
|
44
|
-
<td data-label="Employee"><%= hr_display_name(employee)
|
|
44
|
+
<td data-label="Employee"><%= hr_display_name(employee) %>
|
|
45
|
+
<% if (held = @penalty_minutes[employee.id].to_i).positive? %>
|
|
46
|
+
<br><a class="hrl-card__link hrl-small" href="<%= hr_lite.admin_attendance_path(employee.id, anchor: "penalties") %>">Penalties <%= hrl_duration(held * 60) %> · <%= hrl_days(HrLite::AttendancePenalty.days_for(held)) %> days</a>
|
|
47
|
+
<% end %></td>
|
|
45
48
|
<td data-label="In"><%= record&.check_in_at&.strftime("%H:%M") || "—" %></td>
|
|
46
49
|
<td data-label="Out"><%= record&.check_out_at&.strftime("%H:%M") || "—" %></td>
|
|
47
50
|
<td data-label="Location" class="hrl-small">
|
|
@@ -86,6 +86,15 @@
|
|
|
86
86
|
<%= f.submit "Save fix", class: "hrl-btn hrl-btn--primary" %>
|
|
87
87
|
<a class="hrl-btn" href="<%= hr_lite.admin_attendance_path(@employee.id, month: @month.strftime("%Y-%m")) %>">Cancel</a>
|
|
88
88
|
</div>
|
|
89
|
+
<%# A mistaken punch today: put them back in, or clear the day so they check in again. %>
|
|
90
|
+
<% if @edit_date == Date.current && @edit_record.check_in_at %>
|
|
91
|
+
<div class="hrl-form-actions">
|
|
92
|
+
<% if @edit_record.check_out_at %>
|
|
93
|
+
<button type="submit" name="reset" value="check_out" class="hrl-btn" data-turbo-confirm="Reset today's check-out? They are checked in again and can check out later.">Reset check‑out</button>
|
|
94
|
+
<% end %>
|
|
95
|
+
<button type="submit" name="reset" value="check_in" class="hrl-btn hrl-btn--danger" data-turbo-confirm="Reset today's check-in? The whole day is cleared and they check in again.">Reset check‑in</button>
|
|
96
|
+
</div>
|
|
97
|
+
<% end %>
|
|
89
98
|
<% end %>
|
|
90
99
|
</section>
|
|
91
100
|
<% end %>
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
<td data-label="Employee"><%= hr_display_name(employee) %><% if @no_joining_date.include?(employee.id) %><br><span class="hrl-badge hrl-badge--bad">No joining date — no leave accrues</span><% end %></td>
|
|
16
16
|
<% @types.each do |type| %>
|
|
17
17
|
<% balance = HrLite::LeaveBalance.for(employee, type, @year) %>
|
|
18
|
-
<td data-label="<%= type.code %>" class="hrl-num"><span><strong><%= hrl_days(balance.available) %></strong> left<br><span class="hrl-small hrl-muted"><%= hrl_days(balance.used) %>/<%= hrl_days(balance.entitled) %> used</span
|
|
18
|
+
<td data-label="<%= type.code %>" class="hrl-num"><span><strong><%= hrl_days(balance.available) %></strong> left<br><span class="hrl-small hrl-muted"><%= hrl_days(balance.used) %>/<%= hrl_days(balance.entitled) %> used</span><% if (held = balance.penalty_days).positive? %><br><span class="hrl-small"><%= hrl_days(held) %> held for penalties</span><% end %></span></td>
|
|
19
19
|
<% end %>
|
|
20
20
|
</tr>
|
|
21
21
|
<% end %>
|
|
@@ -39,6 +39,11 @@
|
|
|
39
39
|
<%= f.time_field :recheck_in_until %>
|
|
40
40
|
<p class="hrl-hint">After checking out, a person can check in again once a day inside these hours.</p>
|
|
41
41
|
</div>
|
|
42
|
+
<div class="hrl-field">
|
|
43
|
+
<%= f.label :penalty_leave_type_id, "Penalties come off" %>
|
|
44
|
+
<%= f.collection_select :penalty_leave_type_id, HrLite::LeaveType.active, :id, :name, { include_blank: "No leave (penalties stay as time)" }, data: { hrl_filter: "Type a leave type to filter" } %>
|
|
45
|
+
<p class="hrl-hint">Every working day of penalty time this leave year holds one day of this leave, in half days, and leave past it is refused. Removing a penalty gives the day back.</p>
|
|
46
|
+
</div>
|
|
42
47
|
<div class="hrl-field">
|
|
43
48
|
<%= f.label :employee_code_prefix, "Employee code prefix" %>
|
|
44
49
|
<%= f.text_field :employee_code_prefix %>
|
|
@@ -38,3 +38,20 @@
|
|
|
38
38
|
<% end %>
|
|
39
39
|
</section>
|
|
40
40
|
<% end %>
|
|
41
|
+
|
|
42
|
+
<% if @decidable && (@request.approved? || @request.rejected?) %>
|
|
43
|
+
<section class="hrl-card">
|
|
44
|
+
<h2 class="hrl-card__title">Change this WFH</h2>
|
|
45
|
+
<%= form_with url: hr_lite.admin_wfh_request_path(@request), method: :patch, local: true do |f| %>
|
|
46
|
+
<div class="hrl-field"><%= f.label :start_date, "From" %><%= f.date_field :start_date, value: @request.start_date, required: true %></div>
|
|
47
|
+
<div class="hrl-field"><%= f.label :end_date, "To" %><%= f.date_field :end_date, value: @request.end_date, required: true %></div>
|
|
48
|
+
<fieldset class="hrl-field">
|
|
49
|
+
<legend class="hrl-small">Decision</legend>
|
|
50
|
+
<label class="hrl-field--check"><%= f.radio_button :status, "approved", checked: @request.approved? %> Approved</label>
|
|
51
|
+
<label class="hrl-field--check"><%= f.radio_button :status, "rejected", checked: @request.rejected? %> Rejected</label>
|
|
52
|
+
</fieldset>
|
|
53
|
+
<div class="hrl-field"><%= f.label :decision_note, "Reason for the change (required)", for: "change_note" %><%= f.text_area :decision_note, id: "change_note", required: true %></div>
|
|
54
|
+
<div class="hrl-form-actions"><%= f.button "Save change", type: :submit, class: "hrl-btn hrl-btn--primary" %></div>
|
|
55
|
+
<% end %>
|
|
56
|
+
</section>
|
|
57
|
+
<% end %>
|
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
<%# The running total: penalties add up until HR removes hours; every 5h holds half a day of leave. %>
|
|
2
|
+
<% held = HrLite::AttendancePenalty.held_minutes(user.id)[user.id].to_i
|
|
3
|
+
leave_type = HrLite::Setting.instance.penalty_leave_type %>
|
|
4
|
+
<section class="hrl-card" id="penalties">
|
|
5
|
+
<h2 class="hrl-card__title">Penalty hours</h2>
|
|
6
|
+
<p><strong><%= hrl_duration(held * 60) %></strong> held · <%= hrl_days(HrLite::AttendancePenalty.days_for(held)) %> days<%= " of #{leave_type.name}" if leave_type %></p>
|
|
7
|
+
<p class="hrl-hint">Penalties add up until HR removes them. Every 5 hours holds half a day of leave, which can't be applied for.</p>
|
|
8
|
+
<% HrLite::PenaltyRemoval.where(user_id: user.id).includes(:removed_by).order(created_at: :desc).each do |removal| %>
|
|
9
|
+
<div class="hrl-feed__item hrl-small"><div class="hrl-feed__body">Removed <%= hrl_duration(removal.minutes * 60) %> on <%= removal.created_at.strftime("%-d %b %Y") %> by <%= hr_display_name(removal.removed_by) %>: <%= removal.reason %></div></div>
|
|
10
|
+
<% end %>
|
|
11
|
+
<% if local_assigns[:removable] && held.positive? %>
|
|
12
|
+
<%= form_with url: hr_lite.remove_penalty_hours_admin_attendance_path(user.id), method: :post, local: true, class: "hrl-mt" do %>
|
|
13
|
+
<div class="hrl-field"><label for="hrl-remove-hours">Hours to remove</label><input type="number" class="hrl-input" id="hrl-remove-hours" name="hours" min="0.5" step="0.5" max="<%= held / 60.0 %>" required></div>
|
|
14
|
+
<div class="hrl-field"><label for="hrl-remove-hours-reason">Reason (required)</label><input type="text" class="hrl-input" id="hrl-remove-hours-reason" name="reason" required></div>
|
|
15
|
+
<div class="hrl-form-actions"><button type="submit" class="hrl-btn">Remove hours</button></div>
|
|
16
|
+
<% end %>
|
|
17
|
+
<% end %>
|
|
18
|
+
</section>
|
|
1
19
|
<% penalties = HrLite::AttendancePenalty.where(user_id: user.id, date: month.all_month).order(:date, :id) %>
|
|
2
20
|
<section class="hrl-card">
|
|
3
21
|
<h2 class="hrl-card__title">Penalties in <%= month.strftime("%B") %></h2>
|
|
@@ -39,6 +39,10 @@
|
|
|
39
39
|
<span class="hrl-muted">Not checked in yet.</span>
|
|
40
40
|
<% end %>
|
|
41
41
|
</div>
|
|
42
|
+
<%# Checked in again: every earlier in and out stays on show. %>
|
|
43
|
+
<% if record && (punches = record.punches).size > 2 %>
|
|
44
|
+
<p class="hrl-small">All punches: <%= punches.join(" · ") %></p>
|
|
45
|
+
<% end %>
|
|
42
46
|
<% if HrLite.config.attendance_slots %>
|
|
43
47
|
<%= render "hr_lite/attendance/slot", record: record %>
|
|
44
48
|
<% end %>
|
|
@@ -77,15 +81,16 @@
|
|
|
77
81
|
</details>
|
|
78
82
|
<% end %>
|
|
79
83
|
<% if flash[:punch_offer] == "home" %>
|
|
80
|
-
|
|
81
|
-
|
|
84
|
+
<%# A choice the punch needs: red, and geo_punch.js scrolls it into view on a phone. %>
|
|
85
|
+
<div class="hrl-errors" data-hrl-must-choose><fieldset class="hrl-field">
|
|
86
|
+
<legend class="hrl-small">Is this your home location? Choose one to check in.</legend>
|
|
82
87
|
<% if HrLite::WorkLocation.live.where(user_id: hr_current_user.id).count < HrLite::WorkLocation::MAX_LIVE %>
|
|
83
88
|
<label class="hrl-field--check"><input type="radio" name="place" value="home" required> Yes, save this place as a home location</label>
|
|
84
89
|
<% else %>
|
|
85
90
|
<p class="hrl-small"><%= HrLite::WorkLocationsController::CAP_MESSAGE %></p>
|
|
86
91
|
<% end %>
|
|
87
92
|
<label class="hrl-field--check"><input type="radio" name="place" value="travel" required> No, I am travelling</label>
|
|
88
|
-
</fieldset>
|
|
93
|
+
</fieldset></div>
|
|
89
94
|
<% end %>
|
|
90
95
|
<button type="submit" class="hrl-btn hrl-btn--primary hrl-btn--big hrl-btn--block"><%= record&.check_out_at ? "Check in again" : "Check in" %></button>
|
|
91
96
|
<p class="hrl-small hrl-muted" data-hrl-geo-status role="status" aria-live="polite"></p>
|
|
@@ -96,7 +101,7 @@
|
|
|
96
101
|
<input type="hidden" name="lat"><input type="hidden" name="lng">
|
|
97
102
|
<input type="hidden" name="accuracy_m"><input type="hidden" name="geo_status">
|
|
98
103
|
<% if flash[:punch_offer] == "travel" %>
|
|
99
|
-
<div class="hrl-field"><label class="hrl-field--check"><input type="checkbox" name="place" value="travel" required> I am travelling — check out here</label></div>
|
|
104
|
+
<div class="hrl-field hrl-errors" data-hrl-must-choose><label class="hrl-field--check"><input type="checkbox" name="place" value="travel" required> Tick to confirm: I am travelling — check out here</label></div>
|
|
100
105
|
<% end %>
|
|
101
106
|
<button type="submit" class="hrl-btn hrl-btn--big hrl-btn--block">
|
|
102
107
|
Check out
|
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
<% if home_m %> · <%= number_with_delimiter(home_m) %> m from home<% end %>
|
|
9
9
|
<% if accuracy %> · ±<%= accuracy %> m<% end %></div>
|
|
10
10
|
<% end %>
|
|
11
|
+
<% if (punches = record.punches).size > 2 %>
|
|
12
|
+
<div class="hrl-punch-line">All punches: <%= punches.join(" · ") %></div>
|
|
13
|
+
<% end %>
|
|
11
14
|
<% if (route = record.route_url) %>
|
|
12
15
|
<div class="hrl-punch-line"><a class="hrl-card__link" href="<%= route %>" target="_blank" rel="noopener noreferrer">View route on Google Maps<span class="hrl-sr-only"> for <%= record.date.strftime("%-d %b") %></span></a></div>
|
|
13
16
|
<% end %>
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
<dl class="hrl-deflist">
|
|
41
41
|
<dt>In</dt><dd><%= rec&.check_in_at&.strftime("%H:%M") || "—" %></dd>
|
|
42
42
|
<dt>Out</dt><dd><%= rec&.check_out_at&.strftime("%H:%M") || "—" %></dd>
|
|
43
|
+
<% if rec && (punches = rec.punches).size > 2 %><dt>All punches</dt><dd><%= punches.join(" · ") %></dd><% end %>
|
|
43
44
|
<dt>Worked</dt><dd><%= hrl_duration(rec&.worked_duration) %></dd>
|
|
44
45
|
<% if part %><dt>Half</dt><dd><%= HrLite::DAY_PARTS.rassoc(part)&.first %></dd><% end %>
|
|
45
46
|
<% if leave %><dt>Leave</dt><dd><%= leave.leave_type.name %></dd><% end %>
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
<dt><%= balance.leave_type.comp_off ? "Credited" : "Entitled" %></dt><dd><%= hrl_days(balance.entitled) %></dd>
|
|
17
17
|
<dt>Used</dt><dd><%= hrl_days(balance.used) %></dd>
|
|
18
18
|
<dt>Available</dt><dd><strong><%= hrl_days(balance.available) %></strong></dd>
|
|
19
|
+
<% if (held = balance.penalty_days).positive? %><dt>Held for penalties</dt><dd><%= hrl_days(held) %></dd><dt>You can apply</dt><dd><%= hrl_days(balance.applicable) %></dd><% end %>
|
|
19
20
|
<% if balance.carried_forward.positive? %><dt>Carried forward</dt><dd><%= hrl_days(balance.carried_forward) %></dd><% end %>
|
|
20
21
|
<% if balance.adjustment.nonzero? %><dt>Adjustments</dt><dd><%= hrl_days(balance.adjustment) %> <span class="hrl-muted hrl-small"><%= balance.adjustment_note %></span></dd><% end %>
|
|
21
22
|
</dl>
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<% types.each do |type| %>
|
|
9
9
|
<% balance = HrLite::LeaveBalance.for(user, type, HrLite::LeaveYear.current_key) %>
|
|
10
10
|
<span class="hrl-badge hrl-badge--type" style="--hrl-type: <%= type.color %>">
|
|
11
|
-
<%= type.name %> · <%= hrl_days(balance.available) %> of <%= hrl_days(balance.entitled) %> left
|
|
11
|
+
<%= type.name %> · <%= hrl_days(balance.available) %> of <%= hrl_days(balance.entitled) %> left<% if (held = balance.penalty_days).positive? %> · <%= hrl_days(held) %> held for penalties<% end %>
|
|
12
12
|
</span>
|
|
13
13
|
<% end %>
|
|
14
14
|
</div>
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
<% left = @balances.index_by(&:leave_type_id) %>
|
|
13
13
|
<div class="hrl-chiprow" role="radiogroup" aria-labelledby="hrl-leave-type">
|
|
14
14
|
<% HrLite::LeaveType.active.each_with_index do |type, i| %>
|
|
15
|
-
<label><%= f.radio_button :leave_type_id, type.id, required: i.zero? %><span><%= type.name.sub(/ leave\z/i, "") %><%= " · #{hrl_days(left[type.id].available)} left" if left[type.id] %><%= " · Unpaid" unless type.paid %></span></label>
|
|
15
|
+
<label><%= f.radio_button :leave_type_id, type.id, required: i.zero? %><span><%= type.name.sub(/ leave\z/i, "") %><%= " · #{hrl_days(left[type.id].available)} left" if left[type.id] %><% if left[type.id] && (held = left[type.id].penalty_days).positive? %> · <%= hrl_days(held) %> held for penalties<% end %><%= " · Unpaid" unless type.paid %></span></label>
|
|
16
16
|
<% end %>
|
|
17
17
|
</div>
|
|
18
|
-
<p class="hrl-hint">Days beyond your balance are unpaid (loss of pay), cut from that month's salary
|
|
18
|
+
<p class="hrl-hint">Days beyond your balance are unpaid (loss of pay), cut from that month's salary.<% if (capped = @balances.find { |b| b.penalty_days.positive? }) %> Today you can apply for at most <%= hrl_days(capped.applicable) %> days of <%= capped.leave_type.name %>, <%= hrl_days(capped.penalty_days) %> held for penalties.<% end %></p>
|
|
19
19
|
</div>
|
|
20
20
|
<div class="hrl-field">
|
|
21
21
|
<%= f.label :start_date, "From" %>
|
|
@@ -30,11 +30,11 @@
|
|
|
30
30
|
<details class="hrl-small">
|
|
31
31
|
<summary>Show as a table</summary>
|
|
32
32
|
<table class="hrl-table">
|
|
33
|
-
<thead><tr><th><%= period.bucket.to_s.capitalize %></th><th class="hrl-num">Working</th><th class="hrl-num">
|
|
33
|
+
<thead><tr><th><%= period.bucket.to_s.capitalize %></th><th class="hrl-num">Working (breaks incl.)</th><th class="hrl-num">Of which breaks</th><th class="hrl-num">Total</th></tr></thead>
|
|
34
34
|
<tbody>
|
|
35
35
|
<% buckets.each do |key, modes| %>
|
|
36
36
|
<tr><td><%= key.strftime(period.bucket == :day ? "%a %-d %b" : fmt) %></td>
|
|
37
|
-
<td class="hrl-num"><%= hrl_duration(HrLite::WorkModeDurations::WORKING.sum { |m| modes[m] }) %></td>
|
|
37
|
+
<td class="hrl-num"><%= hrl_duration((HrLite::WorkModeDurations::WORKING + HrLite::WorkModeDurations::BREAKS).sum { |m| modes[m] }) %></td>
|
|
38
38
|
<td class="hrl-num"><%= hrl_duration(HrLite::WorkModeDurations::BREAKS.sum { |m| modes[m] }) %></td>
|
|
39
39
|
<td class="hrl-num"><%= hrl_duration(totals[key]) %></td></tr>
|
|
40
40
|
<% end %>
|
|
@@ -34,12 +34,12 @@
|
|
|
34
34
|
<% else %>
|
|
35
35
|
<% office = result.by_mode["office"]; wfh = result.by_mode["wfh"]; field = result.by_mode["travelling"] + result.by_mode["outside_meeting"] %>
|
|
36
36
|
<div class="hrl-kpis">
|
|
37
|
-
<% [ [ "Attendance (check-in to check-out)", result.attendance ], [ "Working time", result.working ], [ "
|
|
37
|
+
<% [ [ "Attendance (check-in to check-out)", result.attendance ], [ "Working time (breaks included)", result.working + result.breaks ], [ "Of which breaks", result.breaks ],
|
|
38
38
|
[ "In office", office ], [ "Work from home", wfh ], [ "Travel and client meetings", field ], [ "Out of office", result.other ] ].each do |kpi_label, secs| %>
|
|
39
39
|
<div class="hrl-kpi"><div class="hrl-kpi__value"><%= hrl_duration(secs) %></div><div class="hrl-kpi__label"><%= kpi_label %></div></div>
|
|
40
40
|
<% end %>
|
|
41
41
|
</div>
|
|
42
|
-
<p class="hrl-small hrl-muted">Working time = in office, work from home, travelling, client and other meetings, and
|
|
42
|
+
<p class="hrl-small hrl-muted">Working time = in office, work from home, travelling, client and other meetings, busy, and the breaks taken during the day — an 8h 30m shift includes its break. It is time in those modes, not a measure of output.
|
|
43
43
|
Recorded on <%= pluralize(result.days_with_data.size, "day") %>.</p>
|
|
44
44
|
|
|
45
45
|
<%= render "hr_lite/work_time/donut", result: result, label: label %>
|
data/config/routes.rb
CHANGED
|
@@ -73,7 +73,7 @@ HrLite::Engine.routes.draw do
|
|
|
73
73
|
get "overview", to: "overview#index"
|
|
74
74
|
resources :attendances, only: %i[index show update], param: :user_id do
|
|
75
75
|
collection { get :week }
|
|
76
|
-
member { post :slot; post :unlock_slot; post :remove_penalty }
|
|
76
|
+
member { post :slot; post :unlock_slot; post :remove_penalty; post :remove_penalty_hours }
|
|
77
77
|
end
|
|
78
78
|
resources :leave_requests, only: %i[index show new create edit update] do
|
|
79
79
|
member { post :approve; post :reject; post :cancel }
|
|
@@ -87,7 +87,7 @@ HrLite::Engine.routes.draw do
|
|
|
87
87
|
resources :regularization_requests, only: %i[index show] do
|
|
88
88
|
member { post :approve; post :reject }
|
|
89
89
|
end
|
|
90
|
-
resources :wfh_requests, only: %i[index show create] do
|
|
90
|
+
resources :wfh_requests, only: %i[index show create update] do
|
|
91
91
|
member { post :approve; post :reject }
|
|
92
92
|
end
|
|
93
93
|
resources :work_locations, only: :index do
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
class CreateHrLiteAttendancePunches < ActiveRecord::Migration[8.1]
|
|
2
|
+
def change
|
|
3
|
+
create_table :hr_lite_attendance_punches do |t|
|
|
4
|
+
t.bigint :user_id, null: false
|
|
5
|
+
t.date :date, null: false
|
|
6
|
+
t.bigint :attendance_record_id
|
|
7
|
+
t.string :kind, null: false
|
|
8
|
+
t.datetime :at, null: false
|
|
9
|
+
t.decimal :lat, precision: 9, scale: 6
|
|
10
|
+
t.decimal :lng, precision: 9, scale: 6
|
|
11
|
+
t.integer :accuracy_m
|
|
12
|
+
t.string :place
|
|
13
|
+
t.integer :home_m
|
|
14
|
+
t.bigint :work_location_id
|
|
15
|
+
|
|
16
|
+
t.timestamps
|
|
17
|
+
end
|
|
18
|
+
add_index :hr_lite_attendance_punches, [ :user_id, :date ]
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
class CreateHrLitePenaltyRemovals < ActiveRecord::Migration[8.1]
|
|
2
|
+
def change
|
|
3
|
+
create_table :hr_lite_penalty_removals do |t|
|
|
4
|
+
t.bigint :user_id, null: false
|
|
5
|
+
t.integer :minutes, null: false
|
|
6
|
+
t.text :reason, null: false
|
|
7
|
+
t.bigint :removed_by_id, null: false
|
|
8
|
+
|
|
9
|
+
t.timestamps
|
|
10
|
+
end
|
|
11
|
+
add_index :hr_lite_penalty_removals, :user_id
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -21,6 +21,7 @@ module HrLite
|
|
|
21
21
|
"attendance.missed_check_in" => { bell: true, email: true, leadership_email: false, leadership_bell: false },
|
|
22
22
|
"attendance.missed_check_out" => { bell: true, email: true, leadership_email: false, leadership_bell: false },
|
|
23
23
|
"attendance.short_day" => { bell: true, email: true, leadership_email: false, leadership_bell: false },
|
|
24
|
+
"attendance.penalty_removed" => { bell: true, email: true, leadership_email: false, leadership_bell: false },
|
|
24
25
|
"payroll.finalized" => { bell: false, email: false, leadership_email: true, leadership_bell: true },
|
|
25
26
|
"ca.flagged" => { bell: true, email: true, leadership_email: false, leadership_bell: false },
|
|
26
27
|
"ca.reminder" => { bell: true, email: true, leadership_email: false, leadership_bell: false },
|
data/lib/hr_lite/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hr_lite
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.48.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- kshitiz sinha
|
|
@@ -184,6 +184,7 @@ files:
|
|
|
184
184
|
- app/models/hr_lite/asset.rb
|
|
185
185
|
- app/models/hr_lite/asset_assignment.rb
|
|
186
186
|
- app/models/hr_lite/attendance_penalty.rb
|
|
187
|
+
- app/models/hr_lite/attendance_punch.rb
|
|
187
188
|
- app/models/hr_lite/attendance_record.rb
|
|
188
189
|
- app/models/hr_lite/attendance_slot.rb
|
|
189
190
|
- app/models/hr_lite/audit_log.rb
|
|
@@ -211,6 +212,7 @@ files:
|
|
|
211
212
|
- app/models/hr_lite/office_location.rb
|
|
212
213
|
- app/models/hr_lite/payroll_line_item.rb
|
|
213
214
|
- app/models/hr_lite/payroll_run.rb
|
|
215
|
+
- app/models/hr_lite/penalty_removal.rb
|
|
214
216
|
- app/models/hr_lite/performance_plan.rb
|
|
215
217
|
- app/models/hr_lite/policy.rb
|
|
216
218
|
- app/models/hr_lite/policy_acknowledgement.rb
|
|
@@ -489,6 +491,9 @@ files:
|
|
|
489
491
|
- db/migrate/20261015090000_add_working_day_to_hr_lite_settings.rb
|
|
490
492
|
- db/migrate/20261015091000_add_rechecked_in_at_to_hr_lite_attendance_records.rb
|
|
491
493
|
- db/migrate/20261015092000_add_hours_allowance_to_hr_lite_employee_profiles.rb
|
|
494
|
+
- db/migrate/20261015100000_create_hr_lite_attendance_punches.rb
|
|
495
|
+
- db/migrate/20261016090000_add_penalty_leave_type_to_hr_lite_settings.rb
|
|
496
|
+
- db/migrate/20261016091000_create_hr_lite_penalty_removals.rb
|
|
492
497
|
- lib/generators/hr_lite/install/install_generator.rb
|
|
493
498
|
- lib/generators/hr_lite/install/templates/AFTER_INSTALL
|
|
494
499
|
- lib/generators/hr_lite/install/templates/initializer.rb
|