hr_lite 0.4.0 → 0.5.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.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +173 -1
  3. data/README.md +312 -99
  4. data/app/assets/javascripts/hr_lite/confirm.js +31 -0
  5. data/app/assets/stylesheets/hr_lite/hr_lite.css +28 -0
  6. data/app/controllers/hr_lite/admin/appraisals_controller.rb +1 -1
  7. data/app/controllers/hr_lite/admin/attendances_controller.rb +16 -1
  8. data/app/controllers/hr_lite/admin/audit_logs_controller.rb +4 -1
  9. data/app/controllers/hr_lite/admin/designation_changes_controller.rb +1 -1
  10. data/app/controllers/hr_lite/admin/employees_controller.rb +37 -13
  11. data/app/controllers/hr_lite/admin/leave_balances_controller.rb +15 -8
  12. data/app/controllers/hr_lite/admin/leave_requests_controller.rb +16 -0
  13. data/app/controllers/hr_lite/admin/payroll_runs_controller.rb +1 -1
  14. data/app/controllers/hr_lite/admin/resignations_controller.rb +17 -5
  15. data/app/controllers/hr_lite/admin/salary_slips_controller.rb +18 -3
  16. data/app/controllers/hr_lite/admin/salary_structures_controller.rb +1 -1
  17. data/app/controllers/hr_lite/admin/settings_controller.rb +1 -1
  18. data/app/controllers/hr_lite/admin/superadmin_controller.rb +21 -0
  19. data/app/controllers/hr_lite/application_controller.rb +5 -1
  20. data/app/controllers/hr_lite/org_controller.rb +6 -1
  21. data/app/controllers/hr_lite/resignations_controller.rb +6 -1
  22. data/app/helpers/hr_lite/application_helper.rb +7 -13
  23. data/app/jobs/hr_lite/application_job.rb +5 -0
  24. data/app/jobs/hr_lite/daily_digest_job.rb +1 -1
  25. data/app/jobs/hr_lite/leave_year_rollover_job.rb +1 -1
  26. data/app/jobs/hr_lite/payroll_auto_draft_job.rb +5 -2
  27. data/app/models/concerns/hr_lite/audited.rb +11 -4
  28. data/app/models/hr_lite/appraisal.rb +9 -1
  29. data/app/models/hr_lite/audit_log.rb +11 -0
  30. data/app/models/hr_lite/comp_off_request.rb +5 -15
  31. data/app/models/hr_lite/designation_change.rb +18 -1
  32. data/app/models/hr_lite/employee_profile.rb +26 -1
  33. data/app/models/hr_lite/leave_balance.rb +51 -5
  34. data/app/models/hr_lite/leave_request.rb +9 -1
  35. data/app/models/hr_lite/leave_type.rb +13 -3
  36. data/app/models/hr_lite/payroll_run.rb +39 -10
  37. data/app/models/hr_lite/regularization_request.rb +8 -0
  38. data/app/models/hr_lite/resignation.rb +27 -0
  39. data/app/models/hr_lite/salary_slip.rb +7 -3
  40. data/app/models/hr_lite/setting.rb +2 -0
  41. data/app/services/hr_lite/attendance_puncher.rb +8 -1
  42. data/app/services/hr_lite/calculators/esi.rb +7 -4
  43. data/app/services/hr_lite/calculators/professional_tax.rb +5 -1
  44. data/app/services/hr_lite/calculators/tds.rb +8 -1
  45. data/app/services/hr_lite/leave_day_counter.rb +9 -4
  46. data/app/services/hr_lite/overview_query.rb +12 -1
  47. data/app/services/hr_lite/payroll_run_processor.rb +5 -0
  48. data/app/services/hr_lite/slip_builder.rb +54 -8
  49. data/app/views/hr_lite/admin/attendances/index.html.erb +4 -1
  50. data/app/views/hr_lite/admin/comp_off_requests/show.html.erb +19 -5
  51. data/app/views/hr_lite/admin/employees/_form.html.erb +30 -3
  52. data/app/views/hr_lite/admin/employees/index.html.erb +3 -0
  53. data/app/views/hr_lite/admin/employees/show.html.erb +34 -18
  54. data/app/views/hr_lite/admin/leave_requests/show.html.erb +37 -5
  55. data/app/views/hr_lite/admin/overview/index.html.erb +21 -0
  56. data/app/views/hr_lite/admin/payroll_runs/show.html.erb +3 -1
  57. data/app/views/hr_lite/admin/regularization_requests/show.html.erb +18 -4
  58. data/app/views/hr_lite/admin/settings/edit.html.erb +7 -0
  59. data/app/views/hr_lite/attendance/_punch_card.html.erb +22 -2
  60. data/app/views/hr_lite/career/show.html.erb +7 -1
  61. data/app/views/hr_lite/salary_slips/_slip_detail.html.erb +5 -1
  62. data/app/views/hr_lite/salary_slips/pdf.html.erb +5 -5
  63. data/app/views/layouts/hr_lite/application.html.erb +47 -4
  64. data/config/routes.rb +1 -1
  65. data/db/migrate/20260720094454_add_employee_code_prefix_to_hr_lite_settings.rb +7 -0
  66. data/db/migrate/20260807184103_add_live_uniqueness_indexes_to_hr_lite.rb +28 -0
  67. data/db/migrate/20260807184426_add_fy_opening_to_hr_lite_employee_profiles.rb +14 -0
  68. data/db/migrate/20260807184939_add_out_of_window_days_to_hr_lite_salary_slips.rb +12 -0
  69. data/lib/hr_lite/amount_in_words.rb +15 -2
  70. data/lib/hr_lite/configuration.rb +8 -0
  71. data/lib/hr_lite/money.rb +18 -0
  72. data/lib/hr_lite/notifications.rb +23 -8
  73. data/lib/hr_lite/statutory_rate_card.rb +6 -1
  74. data/lib/hr_lite/version.rb +1 -1
  75. data/lib/hr_lite.rb +9 -1
  76. metadata +7 -1
@@ -28,13 +28,29 @@
28
28
  </div>
29
29
  </fieldset>
30
30
  <% end %>
31
- <div class="hrl-field"><%= f.label :employee_code %><%= f.text_field :employee_code %></div>
31
+ <% if profile.persisted? %>
32
+ <div class="hrl-field">
33
+ <%= f.label :employee_code %>
34
+ <input class="hrl-input" type="text" value="<%= profile.employee_code %>" disabled>
35
+ <p class="hrl-hint">System-assigned; the prefix lives under Settings.</p>
36
+ </div>
37
+ <% else %>
38
+ <p class="hrl-hint">The employee code is assigned automatically
39
+ (<%= HrLite::Setting.instance.employee_code_prefix %> + next number).</p>
40
+ <% end %>
32
41
  <div class="hrl-field"><%= f.label :designation %><%= f.text_field :designation %></div>
33
42
  <div class="hrl-field">
34
43
  <%= f.label :manager_id, "Reports to (their L1)" %>
44
+ <%# The current manager stays listed even after they exit. Dropping them
45
+ left the select with no matching option, so the browser preselected
46
+ the blank one and saving anything silently wiped the reporting line
47
+ of everyone whose manager had left. %>
48
+ <% candidates = HrLite.active_employees.reject { |u| u.id == profile.user_id } %>
49
+ <% if profile.manager && candidates.none? { |u| u.id == profile.manager_id } %>
50
+ <% candidates += [ profile.manager ] %>
51
+ <% end %>
35
52
  <%= f.select :manager_id,
36
- HrLite.active_employees.reject { |u| u.id == profile.user_id }
37
- .map { |u| [ HrLite.display_name(u), u.id ] },
53
+ candidates.map { |u| [ HrLite.display_name(u), u.id ] },
38
54
  include_blank: "— nobody (top of the org) —" %>
39
55
  </div>
40
56
  <div class="hrl-field"><%= f.label :department %><%= f.text_field :department %></div>
@@ -59,6 +75,17 @@
59
75
  <%= f.label :declared_annual_deductions, "Declared annual deductions (old regime only)" %>
60
76
  <%= f.number_field :declared_annual_deductions, step: 0.01, value: profile.declared_annual_deductions&.to_s("F") %>
61
77
  </div>
78
+ <%# Only what THIS install has paid is visible to the tax projection, so a
79
+ mid-year start (or a joiner from another employer) needs the earlier
80
+ months stated here or the year under-deducts. %>
81
+ <div class="hrl-field">
82
+ <%= f.label :fy_opening_gross, "Gross already paid this FY elsewhere (previous employer, or before payroll started here)" %>
83
+ <%= f.number_field :fy_opening_gross, step: 0.01, value: profile.fy_opening_gross&.to_s("F") %>
84
+ </div>
85
+ <div class="hrl-field">
86
+ <%= f.label :fy_opening_tds, "TDS already deducted this FY elsewhere" %>
87
+ <%= f.number_field :fy_opening_tds, step: 0.01, value: profile.fy_opening_tds&.to_s("F") %>
88
+ </div>
62
89
  <div class="hrl-form-actions">
63
90
  <%= f.submit "Save profile", class: "hrl-btn hrl-btn--primary" %>
64
91
  <a class="hrl-btn" href="<%= hr_lite.admin_employees_path %>">Cancel</a>
@@ -1,6 +1,9 @@
1
1
  <% content_for(:page_title) { "Employees" } %>
2
2
  <div class="hrl-page__head">
3
3
  <h1 class="hrl-page__title">Employees</h1>
4
+ <div class="hrl-page__actions">
5
+ <a class="hrl-btn hrl-btn--primary" href="<%= hr_lite.new_admin_employee_path %>">New employee</a>
6
+ </div>
4
7
  </div>
5
8
 
6
9
  <section class="hrl-card">
@@ -3,9 +3,11 @@
3
3
  <h1 class="hrl-page__title"><%= hr_display_name(@profile.user) %> <span class="hrl-muted">(<%= @profile.employee_code %>)</span></h1>
4
4
  <div class="hrl-page__actions">
5
5
  <a class="hrl-btn" href="<%= hr_lite.edit_admin_employee_path(@profile) %>">Edit</a>
6
- <a class="hrl-btn" href="<%= hr_lite.new_admin_employee_appraisal_path(@profile) %>">New appraisal</a>
7
- <a class="hrl-btn" href="<%= hr_lite.new_admin_employee_designation_change_path(@profile) %>">Role change</a>
8
- <a class="hrl-btn hrl-btn--primary" href="<%= hr_lite.new_admin_employee_salary_structure_path(@profile) %>">New structure</a>
6
+ <% if hr_superadmin? %>
7
+ <a class="hrl-btn" href="<%= hr_lite.new_admin_employee_appraisal_path(@profile) %>">New appraisal</a>
8
+ <a class="hrl-btn" href="<%= hr_lite.new_admin_employee_designation_change_path(@profile) %>">Role change</a>
9
+ <a class="hrl-btn hrl-btn--primary" href="<%= hr_lite.new_admin_employee_salary_structure_path(@profile) %>">New structure</a>
10
+ <% end %>
9
11
  </div>
10
12
  </div>
11
13
 
@@ -33,23 +35,33 @@
33
35
  </section>
34
36
  <% end %>
35
37
 
36
- <% if @profile.date_of_exit.nil? %>
37
- <section class="hrl-card">
38
- <h2 class="hrl-card__title">Offboard</h2>
38
+ <%# Stays on the page after an exit date is stamped. Accepting a resignation
39
+ stamps one, and hiding this card at that moment removed the only control
40
+ that revokes sign-in — during the notice period, when it is needed. %>
41
+ <section class="hrl-card">
42
+ <h2 class="hrl-card__title"><%= @profile.date_of_exit ? "Revoke access" : "Offboard" %></h2>
43
+ <% if @profile.date_of_exit %>
44
+ <p class="hrl-small hrl-muted">Last day is <%= @profile.date_of_exit.strftime("%d %b %Y") %> —
45
+ attendance and payroll already clip to it. Run this on or after that day to revoke
46
+ sign-in. Records are never deleted.</p>
47
+ <% else %>
39
48
  <p class="hrl-small hrl-muted">Stamps the last day (attendance and payroll clip to it) and revokes sign-in.
40
49
  Records are never deleted.</p>
41
- <%= form_with url: hr_lite.offboard_admin_employee_path(@profile), method: :post, local: true,
42
- html: { data: { turbo_confirm: "Offboard #{hr_display_name(@profile.user)}?" } } do %>
43
- <div class="hrl-field">
44
- <label for="off_date">Last working day</label>
45
- <input type="date" id="off_date" name="date_of_exit" class="hrl-input" value="<%= Date.current %>">
46
- </div>
47
- <div class="hrl-form-actions">
48
- <button class="hrl-btn hrl-btn--danger" type="submit">Offboard employee</button>
49
- </div>
50
- <% end %>
51
- </section>
52
- <% end %>
50
+ <% end %>
51
+ <%= form_with url: hr_lite.offboard_admin_employee_path(@profile), method: :post, local: true,
52
+ html: { data: { turbo_confirm: "Offboard #{hr_display_name(@profile.user)}?" } } do %>
53
+ <div class="hrl-field">
54
+ <label for="off_date">Last working day</label>
55
+ <input type="date" id="off_date" name="date_of_exit" class="hrl-input"
56
+ value="<%= @profile.date_of_exit || Date.current %>">
57
+ </div>
58
+ <div class="hrl-form-actions">
59
+ <button class="hrl-btn hrl-btn--danger" type="submit">
60
+ <%= @profile.date_of_exit ? "Revoke access now" : "Offboard employee" %>
61
+ </button>
62
+ </div>
63
+ <% end %>
64
+ </section>
53
65
 
54
66
  <div class="hrl-grid hrl-grid--2">
55
67
  <section class="hrl-card">
@@ -68,6 +80,7 @@
68
80
  </dl>
69
81
  </section>
70
82
 
83
+ <% if hr_superadmin? %>
71
84
  <section class="hrl-card">
72
85
  <h2 class="hrl-card__title">Salary structures</h2>
73
86
  <% if @structures.any? %>
@@ -90,8 +103,10 @@
90
103
  <p class="hrl-muted hrl-small">No structure yet — payroll will skip this employee.</p>
91
104
  <% end %>
92
105
  </section>
106
+ <% end %>
93
107
  </div>
94
108
 
109
+ <% if hr_superadmin? %>
95
110
  <section class="hrl-card">
96
111
  <h2 class="hrl-card__title">Appraisals</h2>
97
112
  <% appraisals = HrLite::Appraisal.where(user_id: @profile.user_id).recent_first %>
@@ -116,3 +131,4 @@
116
131
  <p class="hrl-muted hrl-small">No appraisals yet.</p>
117
132
  <% end %>
118
133
  </section>
134
+ <% end %>
@@ -10,7 +10,9 @@
10
10
  <dl class="hrl-deflist">
11
11
  <dt>Type</dt><dd><%= @request.leave_type.name %> (<%= @request.paid? ? "paid" : "unpaid" %>)</dd>
12
12
  <dt>Dates</dt><dd><%= @request.date_range_label %></dd>
13
- <dt>Working days</dt><dd><%= @request.days_count.to_f %></dd>
13
+ <%# Counted live, not from the create-time cache: a holiday added after
14
+ the request was filed changes what the balance is actually debited. %>
15
+ <dt>Working days</dt><dd><%= HrLite::LeaveDayCounter.count(@request).to_f %></dd>
14
16
  <dt>Status</dt><dd><span class="hrl-badge"><%= @request.status.humanize %></span></dd>
15
17
  <% if @request.reason.present? %><dt>Reason</dt><dd><%= @request.reason %></dd><% end %>
16
18
  <% unless @request.leave_type.unlimited? %>
@@ -21,18 +23,48 @@
21
23
  </dl>
22
24
  </section>
23
25
 
26
+ <%# An approved leave that has not started yet can still be called off — the
27
+ balance is recomputed live, so cancelling gives the days straight back. %>
28
+ <% if @request.cancellable_by?(hr_current_user) && !@request.pending? %>
29
+ <section class="hrl-card">
30
+ <h2 class="hrl-card__title">Cancel</h2>
31
+ <p class="hrl-small hrl-muted">Releases the days back to their balance. Only possible
32
+ before the leave starts.</p>
33
+ <%= form_with url: hr_lite.cancel_admin_leave_request_path(@request), method: :post, local: true,
34
+ html: { data: { turbo_confirm: "Cancel this approved leave?" } } do %>
35
+ <div class="hrl-form-actions">
36
+ <button class="hrl-btn hrl-btn--danger" type="submit">Cancel this leave</button>
37
+ </div>
38
+ <% end %>
39
+ </section>
40
+ <% end %>
41
+
24
42
  <% if @request.pending? %>
25
43
  <section class="hrl-card">
26
44
  <h2 class="hrl-card__title">Decide</h2>
45
+ <%# Approve and reject are two separate forms on purpose. Rails binds the
46
+ CSRF token to the form's OWN action, so one form retargeted with
47
+ `formaction:` can never pass verification on the second endpoint. %>
27
48
  <%= form_with url: hr_lite.approve_admin_leave_request_path(@request), method: :post, local: true do %>
28
49
  <div class="hrl-field">
29
- <label for="decision_note">Note (required to reject)</label>
30
- <textarea name="decision_note" id="decision_note" class="hrl-input"></textarea>
50
+ <label for="approve_note">Note (optional)</label>
51
+ <textarea name="decision_note" id="approve_note" class="hrl-input"></textarea>
31
52
  </div>
32
53
  <div class="hrl-form-actions">
33
54
  <button class="hrl-btn hrl-btn--primary" type="submit">Approve</button>
34
- <button class="hrl-btn hrl-btn--danger" type="submit"
35
- formaction="<%= hr_lite.reject_admin_leave_request_path(@request) %>">Reject</button>
55
+ </div>
56
+ <% end %>
57
+ </section>
58
+
59
+ <section class="hrl-card">
60
+ <h2 class="hrl-card__title">Reject</h2>
61
+ <%= form_with url: hr_lite.reject_admin_leave_request_path(@request), method: :post, local: true do %>
62
+ <div class="hrl-field">
63
+ <label for="reject_note">Reason (required)</label>
64
+ <textarea name="decision_note" id="reject_note" class="hrl-input"></textarea>
65
+ </div>
66
+ <div class="hrl-form-actions">
67
+ <button class="hrl-btn hrl-btn--danger" type="submit">Reject</button>
36
68
  </div>
37
69
  <% end %>
38
70
  </section>
@@ -25,6 +25,27 @@
25
25
  <a class="hrl-btn" href="<%= hr_lite.admin_leave_request_path(request) %>">Decide</a>
26
26
  </div>
27
27
  <% end %>
28
+ <%# Comp-off and regularization are approvals too. Listing leave alone
29
+ left both queues invisible on the board that exists to surface work. %>
30
+ <% @query.pending_comp_offs.limit(HrLite::Admin::OverviewController::SECTION_CAP).each do |request| %>
31
+ <div class="hrl-feed__item">
32
+ <div class="hrl-feed__body">
33
+ <strong><%= hr_display_name(request.user) %></strong>
34
+ — comp-off for <%= request.date_worked.strftime("%d %b") %>
35
+ (<%= request.credit_days.to_f %> d)
36
+ </div>
37
+ <a class="hrl-btn" href="<%= hr_lite.admin_comp_off_request_path(request) %>">Decide</a>
38
+ </div>
39
+ <% end %>
40
+ <% @query.pending_regularizations.limit(HrLite::Admin::OverviewController::SECTION_CAP).each do |request| %>
41
+ <div class="hrl-feed__item">
42
+ <div class="hrl-feed__body">
43
+ <strong><%= hr_display_name(request.user) %></strong>
44
+ — attendance fix for <%= request.date.strftime("%d %b") %>
45
+ </div>
46
+ <a class="hrl-btn" href="<%= hr_lite.admin_regularization_request_path(request) %>">Decide</a>
47
+ </div>
48
+ <% end %>
28
49
  <a class="hrl-small" href="<%= hr_lite.admin_leave_requests_path %>">All requests</a>
29
50
  </section>
30
51
  <% end %>
@@ -23,7 +23,9 @@
23
23
  <section class="hrl-card">
24
24
  <div class="hrl-row">
25
25
  <span class="hrl-badge"><%= @run.status.humanize %></span>
26
- <% if @run.draft? || @run.review? %>
26
+ <%# `processing` is offered too: a run stranded there by a killed process
27
+ would otherwise have no control at all and block that month forever. %>
28
+ <% if @run.draft? || @run.review? || @run.processing? %>
27
29
  <%= button_to @run.draft? ? "Compute" : "Recompute", hr_lite.compute_admin_payroll_run_path(@run),
28
30
  method: :post, class: "hrl-btn hrl-btn--primary" %>
29
31
  <% end %>
@@ -35,15 +35,29 @@
35
35
  <h2 class="hrl-card__title">Decide</h2>
36
36
  <p class="hrl-hint">Approving writes the proposed times onto the day's attendance record
37
37
  (only the provided times overwrite) with the full regularization trail.</p>
38
+ <%# Approve and reject are two separate forms on purpose. Rails binds the
39
+ CSRF token to the form's OWN action, so one form retargeted with
40
+ `formaction:` can never pass verification on the second endpoint. %>
38
41
  <%= form_with url: hr_lite.approve_admin_regularization_request_path(@request), method: :post, local: true do |f| %>
39
42
  <div class="hrl-field">
40
- <%= f.label :decision_note, "Note (required to reject, optional to approve)" %>
41
- <%= f.text_area :decision_note %>
43
+ <%= f.label :decision_note, "Note (optional)", for: "approve_note" %>
44
+ <%= f.text_area :decision_note, id: "approve_note" %>
42
45
  </div>
43
46
  <div class="hrl-form-actions">
44
47
  <%= f.button "Approve — fix attendance", type: :submit, class: "hrl-btn hrl-btn--primary" %>
45
- <%= f.button "Reject", type: :submit, class: "hrl-btn hrl-btn--danger",
46
- formaction: hr_lite.reject_admin_regularization_request_path(@request) %>
48
+ </div>
49
+ <% end %>
50
+ </section>
51
+
52
+ <section class="hrl-card">
53
+ <h2 class="hrl-card__title">Reject</h2>
54
+ <%= form_with url: hr_lite.reject_admin_regularization_request_path(@request), method: :post, local: true do |f| %>
55
+ <div class="hrl-field">
56
+ <%= f.label :decision_note, "Reason (required)", for: "reject_note" %>
57
+ <%= f.text_area :decision_note, id: "reject_note" %>
58
+ </div>
59
+ <div class="hrl-form-actions">
60
+ <%= f.button "Reject", type: :submit, class: "hrl-btn hrl-btn--danger" %>
47
61
  </div>
48
62
  <% end %>
49
63
  </section>
@@ -11,6 +11,13 @@
11
11
  <%= f.select :weekend_policy, HrLite::Setting::WEEKEND_POLICIES.map { |p| [ p.humanize, p ] } %>
12
12
  <p class="hrl-hint">Drives working-day math everywhere: leave counting, attendance, payroll.</p>
13
13
  </div>
14
+ <div class="hrl-field">
15
+ <%= f.label :employee_code_prefix, "Employee code prefix" %>
16
+ <%= f.text_field :employee_code_prefix %>
17
+ <p class="hrl-hint">Codes are assigned automatically as
18
+ <%= @setting.employee_code_prefix %>001, <%= @setting.employee_code_prefix %>002, …
19
+ — you only choose the prefix.</p>
20
+ </div>
14
21
  <div class="hrl-form-actions">
15
22
  <%= f.submit "Save", class: "hrl-btn hrl-btn--primary" %>
16
23
  </div>
@@ -1,4 +1,11 @@
1
1
  <% record = HrLite::AttendanceRecord.find_by(user_id: hr_current_user.id, date: Date.current) %>
2
+ <%# A shift that runs past midnight leaves yesterday's record open.
3
+ AttendancePuncher already closes it, but this card looked only at today,
4
+ so after midnight it offered "Check in" and the night's punch never
5
+ closed — no worked duration, no hours on the team board. %>
6
+ <% open_yesterday = record ? nil : HrLite::AttendanceRecord.for_date(Date.current - 1)
7
+ .missing_checkout
8
+ .find_by(user_id: hr_current_user.id) %>
2
9
  <section class="hrl-card">
3
10
  <h2 class="hrl-card__title">Today, <%= Date.current.strftime("%d %b") %></h2>
4
11
 
@@ -12,12 +19,25 @@
12
19
  <% if record&.flagged? %>
13
20
  <span class="hrl-badge hrl-badge--bad" title="<%= record.flag_note %>">Flagged</span>
14
21
  <% end %>
15
- <% if record.nil? %>
22
+ <% if open_yesterday %>
23
+ <span class="hrl-badge hrl-badge--warn">Yesterday still open —
24
+ in <%= open_yesterday.check_in_at.strftime("%H:%M") %></span>
25
+ <% elsif record.nil? %>
16
26
  <span class="hrl-muted">Not checked in yet.</span>
17
27
  <% end %>
18
28
  </div>
19
29
 
20
- <% if record&.check_in_at.blank? %>
30
+ <% if open_yesterday %>
31
+ <%= form_with url: hr_lite.check_out_attendance_path, method: :post, local: true,
32
+ html: { data: { "hrl-geo-punch": true } } do %>
33
+ <input type="hidden" name="lat"><input type="hidden" name="lng">
34
+ <input type="hidden" name="accuracy_m"><input type="hidden" name="geo_status">
35
+ <button type="submit" class="hrl-btn hrl-btn--big hrl-btn--block">
36
+ Check out yesterday's shift
37
+ </button>
38
+ <p class="hrl-small hrl-muted" data-hrl-geo-status hidden></p>
39
+ <% end %>
40
+ <% elsif record&.check_in_at.blank? %>
21
41
  <%= form_with url: hr_lite.check_in_attendance_path, method: :post, local: true,
22
42
  html: { data: { "hrl-geo-punch": true } } do %>
23
43
  <input type="hidden" name="lat"><input type="hidden" name="lng">
@@ -6,7 +6,13 @@
6
6
  <section class="hrl-card">
7
7
  <h2 class="hrl-card__title">Current role</h2>
8
8
  <p><strong><%= @profile&.designation.presence || "Not set yet" %></strong>
9
- <% if @profile %><span class="hrl-muted hrl-small">since <%= (@changes.first&.effective_date || @profile.date_of_joining).strftime("%b %Y") %></span><% end %>
9
+ <%# The most recent change IN FORCE, not simply the most recent row — a
10
+ promotion recorded for next quarter would otherwise date the current
11
+ role from a month that has not arrived yet. %>
12
+ <% if @profile %>
13
+ <% in_force = @changes.find { |change| change.effective_date <= Date.current } %>
14
+ <span class="hrl-muted hrl-small">since <%= (in_force&.effective_date || @profile.date_of_joining).strftime("%b %Y") %></span>
15
+ <% end %>
10
16
  </p>
11
17
  </section>
12
18
 
@@ -37,7 +37,11 @@
37
37
  <section class="hrl-card">
38
38
  <dl class="hrl-deflist">
39
39
  <dt>Net pay</dt><dd><strong><%= hrl_money(slip.net_pay) %></strong> (<%= hrl_amount_in_words(slip.net_pay) %>)</dd>
40
- <dt>Days</dt><dd><%= slip.payable_days %> payable / <%= slip.effective_lop_days %> LOP of <%= slip.days_in_month %></dd>
40
+ <%# Out-of-window days are named rather than silently dropped: without them
41
+ a mid-month joiner's row does not add up to the month. %>
42
+ <dt>Days</dt>
43
+ <dd><%= slip.payable_days %> payable / <%= slip.effective_lop_days %> LOP<% if slip.out_of_window_days.to_f.positive? %>
44
+ / <%= slip.out_of_window_days %> outside employment<% end %> of <%= slip.days_in_month %></dd>
41
45
  <% if profile %>
42
46
  <dt>Employee code</dt><dd><%= profile.employee_code %></dd>
43
47
  <% if profile.masked_uan %><dt>PF UAN</dt><dd><%= profile.masked_uan %></dd><% end %>
@@ -44,9 +44,9 @@
44
44
  <thead><tr><th>Earnings</th><th class="num">Full</th><th class="num">Earned</th></tr></thead>
45
45
  <tbody>
46
46
  <% @slip.earnings_rows.each do |row| %>
47
- <tr><td><%= row["label"] %></td><td class="num"><%= row["full_amount"] %></td><td class="num"><%= row["amount"] %></td></tr>
47
+ <tr><td><%= row["label"] %></td><td class="num"><%= HrLite::Money.format(row["full_amount"]) %></td><td class="num"><%= HrLite::Money.format(row["amount"]) %></td></tr>
48
48
  <% end %>
49
- <tr class="total"><td>Gross</td><td></td><td class="num"><%= @slip.gross_earnings.to_s("F") %></td></tr>
49
+ <tr class="total"><td>Gross</td><td></td><td class="num"><%= HrLite::Money.format(@slip.gross_earnings) %></td></tr>
50
50
  </tbody>
51
51
  </table>
52
52
  </div>
@@ -55,9 +55,9 @@
55
55
  <thead><tr><th>Deductions</th><th class="num">Amount</th></tr></thead>
56
56
  <tbody>
57
57
  <% @slip.deductions_rows.each do |row| %>
58
- <tr><td><%= row["label"] %></td><td class="num"><%= row["amount"] %></td></tr>
58
+ <tr><td><%= row["label"] %></td><td class="num"><%= HrLite::Money.format(row["amount"]) %></td></tr>
59
59
  <% end %>
60
- <tr class="total"><td>Total deductions</td><td class="num"><%= @slip.total_deductions.to_s("F") %></td></tr>
60
+ <tr class="total"><td>Total deductions</td><td class="num"><%= HrLite::Money.format(@slip.total_deductions) %></td></tr>
61
61
  </tbody>
62
62
  </table>
63
63
  </div>
@@ -66,7 +66,7 @@
66
66
  <div class="pdf-net">
67
67
  <%# PORO, not a helper — this template is rendered by HOST code via
68
68
  config.render_pdf, where engine helper modules are not in scope. %>
69
- Net pay: <%= HrLite.config.currency_symbol %><%= @slip.net_pay.to_s("F") %>
69
+ Net pay: <%= HrLite::Money.format(@slip.net_pay) %>
70
70
  (<%= HrLite::AmountInWords.words(@slip.net_pay) %>)
71
71
  </div>
72
72
 
@@ -37,10 +37,19 @@
37
37
  <% end %>
38
38
  <% end %>
39
39
 
40
- <% if hr_leadership? %>
40
+ <% if hr_leadership? || hr_superadmin? %>
41
41
  <span class="hrl-side__group">Organisation</span>
42
- <% hrl_nav_items(HrLite::ApplicationHelper::LEADERSHIP_NAV_ITEMS).each do |item| %>
43
- <%= hrl_nav_link(item) %>
42
+ <% if hr_leadership? %>
43
+ <% hrl_nav_items(HrLite::ApplicationHelper::LEADERSHIP_NAV_ITEMS).each do |item| %>
44
+ <%= hrl_nav_link(item) %>
45
+ <% end %>
46
+ <% end %>
47
+ <%# Payroll hangs off the money tier alone — a superadmin who is not
48
+ in leadership_emails still needs to reach it. %>
49
+ <% if hr_superadmin? %>
50
+ <% hrl_nav_items(HrLite::ApplicationHelper::SUPERADMIN_NAV_ITEMS).each do |item| %>
51
+ <%= hrl_nav_link(item) %>
52
+ <% end %>
44
53
  <% end %>
45
54
  <% end %>
46
55
  </nav>
@@ -73,12 +82,46 @@
73
82
  </div>
74
83
  </div>
75
84
 
85
+ <%# The left rail is display:none below 768px, so before the More sheet
86
+ existed the phone — the surface this is installed on — could reach only
87
+ the first five items. Org, Kudos, Slips, Career and every admin,
88
+ leadership and payroll screen were unreachable. <details> keeps it
89
+ dependency-free; the engine ships no Turbo or Stimulus. %>
76
90
  <nav class="hrl-tabbar" aria-label="HR sections">
77
- <% hrl_nav_items(HrLite::ApplicationHelper::NAV_ITEMS).first(5).each do |item| %>
91
+ <% primary, rest = hrl_nav_items(HrLite::ApplicationHelper::NAV_ITEMS).partition.with_index { |_, i| i < 4 } %>
92
+ <% primary.each do |item| %>
78
93
  <%= hrl_nav_link(item) %>
79
94
  <% end %>
95
+ <details class="hrl-tabbar__more">
96
+ <summary class="hrl-nav__link">More</summary>
97
+ <div class="hrl-sheet">
98
+ <% rest.each do |item| %>
99
+ <%= hrl_nav_link(item) %>
100
+ <% end %>
101
+ <% if hr_admin? || hr_leadership? %>
102
+ <span class="hrl-side__group">Manage</span>
103
+ <% hrl_nav_items(HrLite::ApplicationHelper::ADMIN_NAV_ITEMS).each do |item| %>
104
+ <%= hrl_nav_link(item) %>
105
+ <% end %>
106
+ <% end %>
107
+ <% if hr_leadership? || hr_superadmin? %>
108
+ <span class="hrl-side__group">Organisation</span>
109
+ <% if hr_leadership? %>
110
+ <% hrl_nav_items(HrLite::ApplicationHelper::LEADERSHIP_NAV_ITEMS).each do |item| %>
111
+ <%= hrl_nav_link(item) %>
112
+ <% end %>
113
+ <% end %>
114
+ <% if hr_superadmin? %>
115
+ <% hrl_nav_items(HrLite::ApplicationHelper::SUPERADMIN_NAV_ITEMS).each do |item| %>
116
+ <%= hrl_nav_link(item) %>
117
+ <% end %>
118
+ <% end %>
119
+ <% end %>
120
+ </div>
121
+ </details>
80
122
  </nav>
81
123
 
124
+ <%= javascript_include_tag "hr_lite/confirm", defer: true %>
82
125
  <%= javascript_include_tag "hr_lite/mention", defer: true %>
83
126
  <%= yield :scripts %>
84
127
  </body>
data/config/routes.rb CHANGED
@@ -35,7 +35,7 @@ HrLite::Engine.routes.draw do
35
35
  get "overview", to: "overview#index"
36
36
  resources :attendances, only: %i[index show update], param: :user_id
37
37
  resources :leave_requests, only: %i[index show] do
38
- member { post :approve; post :reject }
38
+ member { post :approve; post :reject; post :cancel }
39
39
  end
40
40
  resources :leave_balances, only: :index do
41
41
  collection { post :adjust }
@@ -0,0 +1,7 @@
1
+ class AddEmployeeCodePrefixToHrLiteSettings < ActiveRecord::Migration[8.0]
2
+ def change
3
+ # Employee codes are system-assigned: prefix + zero-padded sequence
4
+ # (EMP001, EMP002, ...). Leadership edits the prefix under Settings.
5
+ add_column :hr_lite_settings, :employee_code_prefix, :string, null: false, default: "EMP"
6
+ end
7
+ end
@@ -0,0 +1,28 @@
1
+ class AddLiveUniquenessIndexesToHrLite < ActiveRecord::Migration[8.0]
2
+ # The models already validate each of these, but a validation is a
3
+ # read-then-write: two concurrent requests both see nothing and both insert.
4
+ # Comp-off requests already had this partial index; these three did not.
5
+ #
6
+ # Every table here holds a handful of rows per employee, so the index builds
7
+ # are instant and a plain (non-concurrent) build is fine.
8
+ def change
9
+ # One open resignation per person — Resignation#single_open_resignation.
10
+ add_index :hr_lite_resignations, :user_id,
11
+ unique: true,
12
+ where: "status = 'pending'",
13
+ name: "index_hr_lite_resignations_one_pending_per_user"
14
+
15
+ # One ticket per person per day — RegularizationRequest#no_duplicate_pending.
16
+ add_index :hr_lite_regularization_requests, %i[user_id date],
17
+ unique: true,
18
+ where: "status = 'pending'",
19
+ name: "index_hr_lite_regularizations_one_pending_per_day"
20
+
21
+ # Exactly one leave type carries the comp-off flag — approvals credit into
22
+ # THE comp-off type, and two would make the target position-order roulette.
23
+ add_index :hr_lite_leave_types, :comp_off,
24
+ unique: true,
25
+ where: "comp_off",
26
+ name: "index_hr_lite_leave_types_single_comp_off"
27
+ end
28
+ end
@@ -0,0 +1,14 @@
1
+ class AddFyOpeningToHrLiteEmployeeProfiles < ActiveRecord::Migration[8.0]
2
+ # Income already paid this financial year that this install did not run:
3
+ # a previous employer, or the months before payroll was switched on. TDS
4
+ # projects the annual total from slips it can see, so without these the
5
+ # first year after a mid-year start under-projects — often far enough
6
+ # under the rebate cap to deduct nothing at all.
7
+ #
8
+ # Text, because they are encrypted at rest like every other money column
9
+ # (see HrLite::EncryptedMoney).
10
+ def change
11
+ add_column :hr_lite_employee_profiles, :fy_opening_gross, :text
12
+ add_column :hr_lite_employee_profiles, :fy_opening_tds, :text
13
+ end
14
+ end
@@ -0,0 +1,12 @@
1
+ class AddOutOfWindowDaysToHrLiteSalarySlips < ActiveRecord::Migration[8.0]
2
+ # Days outside the employment window — before joining, after the last day.
3
+ # SlipBuilder already subtracts them from payable days, but never recorded
4
+ # them, so a mid-month joiner's payslip read "15 payable, 0 LOP" of a
5
+ # 30-day month and looked as though days had gone missing.
6
+ #
7
+ # Not encrypted: a day count is not money.
8
+ def change
9
+ add_column :hr_lite_salary_slips, :out_of_window_days, :decimal, precision: 4, scale: 1,
10
+ default: "0.0", null: false
11
+ end
12
+ end
@@ -14,15 +14,28 @@ module HrLite
14
14
  rupees = Money.round_rupee(amount).to_i
15
15
  return "Zero rupees" if rupees.zero?
16
16
 
17
+ # A negative amount rendered as bare " rupees": no group was >= its
18
+ # divisor, so nothing was ever appended.
19
+ sentence = groups(rupees.abs).join(" ")
20
+ sentence = "minus #{sentence}" if rupees.negative?
21
+ "#{sentence.capitalize} rupees"
22
+ end
23
+
24
+ def groups(rupees)
17
25
  parts = []
18
26
  SCALES.each do |divisor, label|
19
27
  next unless rupees >= divisor
20
28
 
21
- parts << "#{two_digit(rupees / divisor)} #{label}"
29
+ # The crore group is unbounded — every later group is reduced below
30
+ # 100 by the preceding modulo, but this one is not, and two_digit
31
+ # only knows 0..99. Recurse for anything above a hundred crore.
32
+ count = rupees / divisor
33
+ spelled = count > 99 ? groups(count).join(" ") : two_digit(count)
34
+ parts << "#{spelled} #{label}"
22
35
  rupees %= divisor
23
36
  end
24
37
  parts << two_digit(rupees) if rupees.positive?
25
- "#{parts.join(' ').capitalize} rupees"
38
+ parts
26
39
  end
27
40
 
28
41
  def two_digit(number)
@@ -8,6 +8,7 @@ module HrLite
8
8
  :employees_scope, :mentionable_users, :notify, :render_pdf, :company,
9
9
  :time_zone, :currency_symbol, :on_designation_change,
10
10
  :leadership_emails, :leadership_check, :extra_stylesheets,
11
+ :superadmin_emails, :superadmin_check,
11
12
  :mailer_from, :public_url_base, :notification_matrix, :back_link,
12
13
  :onboard_user, :offboard_user, :invite_url_for
13
14
 
@@ -49,6 +50,13 @@ module HrLite
49
50
  emails = HrLite.config.leadership_emails.map { |e| e.to_s.downcase.strip }
50
51
  emails.include?(user.email.to_s.downcase)
51
52
  end
53
+ # Money tier: salary structures, payroll, slips, appraisals. Empty
54
+ # list means "same as leadership" (pre-0.5.0 behaviour).
55
+ @superadmin_emails = []
56
+ @superadmin_check = ->(user) do
57
+ emails = HrLite.config.superadmin_emails.map { |e| e.to_s.downcase.strip }.reject(&:empty?)
58
+ emails.empty? ? HrLite.leadership?(user) : emails.include?(user.email.to_s.downcase)
59
+ end
52
60
  @extra_stylesheets = [] # host stylesheets linked AFTER hr_lite.css (CSS-var overrides)
53
61
  @mailer_from = "hr@example.com"
54
62
  @public_url_base = nil # e.g. "https://hr.example.com" — enables email links + HrLite.public_url