hr_lite 0.1.0 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9dc0713440cde019ffbf731932a0efef58980b58baff2ccb55991aecae807714
4
- data.tar.gz: 3cbfdca3513b1d5ce604accb369f7c63e425d98ce5efe88ad2544b070900f284
3
+ metadata.gz: 38321c0b3f943e26ccdfbae2109b466196174ec5e1a60c0efcbb0b751e85b9fa
4
+ data.tar.gz: ac91265eeaddf77c7b9972467b49682eac102fef136a58b2033d769ba3f7d150
5
5
  SHA512:
6
- metadata.gz: 3e6a06f68ce96bb223860cd8ddb091986207958acccdd2ee4947c066a7885e119ae7d79e954e5ca9514eabb072b7ff3da46a95cc91463a702b553979de74e1da
7
- data.tar.gz: 72e3acb4196071320611198ac549a9c5f6301182ddd882240cb12ccfb97f0257e5d21915812b48afe760b38c41addb7be15d159400bcb8d13c8bb04c2aa5d2d5
6
+ metadata.gz: 191a72380266416ce6d4ab981f8046369261de8d4208e96334fb2236c66854d08c86ceed9e114074b35ae59e83aada5aeb8be86dfe4cce22a977e7d59971dc43
7
+ data.tar.gz: 575a1d03fc7ecf31dbda85ea7776796992cfde111725e2a94d84835ef38d96f91bb34dec4a8a1e565110ad27e27381bec08fa755eed36fa7c18329593ae21702
data/CHANGELOG.md CHANGED
@@ -7,6 +7,31 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.1.2] - 2026-07-19
11
+
12
+ ### Fixed
13
+
14
+ - Slip PDF template no longer 500s when rendered by host code
15
+ (`config.render_pdf`): amount-in-words is now a PORO
16
+ (`HrLite::AmountInWords`), not a view helper, since engine helpers are
17
+ not in scope under a host renderer. Caught live against a host app;
18
+ regression spec renders the template through a bare controller.
19
+
20
+ ## [0.1.1] - 2026-07-19
21
+
22
+ ### Added
23
+
24
+ - `bin/demo`: one-command sandbox — fresh sqlite database, engine
25
+ migrations from the gem, rich sample data (three persona tiers,
26
+ attendance history, leaves, kudos, a published payroll run, a shared
27
+ appraisal) and a click-to-sign-in persona picker.
28
+
29
+ ### Fixed
30
+
31
+ - `hrl_money` Indian digit grouping (₹3,69,000.00 — previously mis-grouped).
32
+ - Layout `<title>` uses the configured company name instead of a
33
+ hardcoded brand.
34
+
10
35
  ## [0.1.0] - 2026-07-19
11
36
 
12
37
  Initial release.
data/README.md CHANGED
@@ -21,6 +21,18 @@ promotions. Think Keka-lite, mounted inside your existing app in a few lines.
21
21
  - **Encrypted at rest**: PAN/UAN/bank numbers and every money amount use
22
22
  ActiveRecord encryption.
23
23
 
24
+ ## Try it in one command
25
+
26
+ ```bash
27
+ git clone https://github.com/kshtzkr/hr_lite && cd hr_lite
28
+ bin/demo # → http://localhost:3999
29
+ ```
30
+
31
+ A throwaway sandbox boots with three persona tiers (leadership / admin /
32
+ employee — one click to sign in as each) and pre-seeded attendance, leaves,
33
+ kudos, a published payroll run and a shared appraisal. Data resets on every
34
+ restart.
35
+
24
36
  ## Installation
25
37
 
26
38
  Everything lives in the gem — a host app adds the gem, a mount line and one
@@ -69,37 +69,21 @@ module HrLite
69
69
  return "—" if amount.nil?
70
70
 
71
71
  whole, fraction = HrLite::Money.round2(amount).to_s("F").split(".")
72
- sign = whole.delete_prefix!("-") ? "-" : ""
73
- # Indian digit grouping: 12,34,567
74
- grouped = whole.reverse.scan(/\d{1,2}(?=\d{2})|\d{1,3}/).join(",").reverse if whole.length > 3
75
- grouped ||= whole
76
- "#{sign}#{HrLite.config.currency_symbol}#{grouped}.#{fraction.ljust(2, '0')}"
77
- end
78
-
79
- ONES = %w[zero one two three four five six seven eight nine ten eleven twelve thirteen fourteen
80
- fifteen sixteen seventeen eighteen nineteen].freeze
81
- TENS = %w[zero ten twenty thirty forty fifty sixty seventy eighty ninety].freeze
82
-
83
- # Indian-system amount in words for the slip footer.
84
- def hrl_amount_in_words(amount)
85
- rupees = HrLite::Money.round_rupee(amount).to_i
86
- return "Zero rupees" if rupees.zero?
87
-
88
- parts = []
89
- [ [ 10_000_000, "crore" ], [ 100_000, "lakh" ], [ 1000, "thousand" ], [ 100, "hundred" ] ].each do |divisor, label|
90
- next unless rupees >= divisor
91
-
92
- parts << "#{hrl_two_digit_words(rupees / divisor)} #{label}"
93
- rupees %= divisor
72
+ sign = whole.start_with?("-") ? "-" : ""
73
+ whole = whole.delete_prefix("-")
74
+ # Indian digit grouping: last three digits together, then pairs
75
+ # (12,34,567 — not the western 1,234,567).
76
+ if whole.length > 3
77
+ head = whole[0..-4].reverse.scan(/\d{1,2}/).join(",").reverse
78
+ whole = "#{head},#{whole[-3..]}"
94
79
  end
95
- parts << hrl_two_digit_words(rupees) if rupees.positive?
96
- "#{parts.join(' ').capitalize} rupees"
80
+ "#{sign}#{HrLite.config.currency_symbol}#{whole}.#{fraction.ljust(2, '0')}"
97
81
  end
98
82
 
99
- def hrl_two_digit_words(number)
100
- return ONES[number] if number < 20
101
-
102
- [ TENS[number / 10], number % 10 == 0 ? nil : ONES[number % 10] ].compact.join("-")
83
+ # Indian-system amount in words for the slip footer. Delegates to the
84
+ # PORO so host-rendered templates (config.render_pdf) work too.
85
+ def hrl_amount_in_words(amount)
86
+ HrLite::AmountInWords.words(amount)
103
87
  end
104
88
  end
105
89
  end
@@ -61,8 +61,10 @@
61
61
  </div>
62
62
 
63
63
  <div class="pdf-net">
64
+ <%# PORO, not a helper — this template is rendered by HOST code via
65
+ config.render_pdf, where engine helper modules are not in scope. %>
64
66
  Net pay: <%= HrLite.config.currency_symbol %><%= @slip.net_pay.to_s("F") %>
65
- (<%= hrl_amount_in_words(@slip.net_pay) %>)
67
+ (<%= HrLite::AmountInWords.words(@slip.net_pay) %>)
66
68
  </div>
67
69
 
68
70
  <p class="pdf-foot">
@@ -1,7 +1,7 @@
1
1
  <!DOCTYPE html>
2
2
  <html lang="en">
3
3
  <head>
4
- <title><%= [ content_for(:page_title), "Earthly HR" ].compact.join(" · ") %></title>
4
+ <title><%= [ content_for(:page_title), "#{HrLite.config.company.call[:name].presence || 'HR'} — HR" ].compact.join(" · ") %></title>
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
6
6
  <%= csrf_meta_tags %>
7
7
  <%= csp_meta_tag %>
@@ -0,0 +1,34 @@
1
+ module HrLite
2
+ # Indian-system amount in words (crore/lakh/thousand). A PORO — not a view
3
+ # helper — because the slip PDF template is rendered by HOST code
4
+ # (config.render_pdf), where engine helper modules are not in scope.
5
+ module AmountInWords
6
+ ONES = %w[zero one two three four five six seven eight nine ten eleven twelve thirteen fourteen
7
+ fifteen sixteen seventeen eighteen nineteen].freeze
8
+ TENS = %w[zero ten twenty thirty forty fifty sixty seventy eighty ninety].freeze
9
+ SCALES = [ [ 10_000_000, "crore" ], [ 100_000, "lakh" ], [ 1000, "thousand" ], [ 100, "hundred" ] ].freeze
10
+
11
+ module_function
12
+
13
+ def words(amount)
14
+ rupees = Money.round_rupee(amount).to_i
15
+ return "Zero rupees" if rupees.zero?
16
+
17
+ parts = []
18
+ SCALES.each do |divisor, label|
19
+ next unless rupees >= divisor
20
+
21
+ parts << "#{two_digit(rupees / divisor)} #{label}"
22
+ rupees %= divisor
23
+ end
24
+ parts << two_digit(rupees) if rupees.positive?
25
+ "#{parts.join(' ').capitalize} rupees"
26
+ end
27
+
28
+ def two_digit(number)
29
+ return ONES[number] if number < 20
30
+
31
+ [ TENS[number / 10], number % 10 == 0 ? nil : ONES[number % 10] ].compact.join("-")
32
+ end
33
+ end
34
+ end
@@ -1,3 +1,3 @@
1
1
  module HrLite
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.2"
3
3
  end
data/lib/hr_lite.rb CHANGED
@@ -7,6 +7,7 @@ require "hr_lite/notifications"
7
7
  require "hr_lite/seeds"
8
8
  require "hr_lite/geo"
9
9
  require "hr_lite/money"
10
+ require "hr_lite/amount_in_words"
10
11
  require "hr_lite/statutory_rate_card"
11
12
 
12
13
  module HrLite
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.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - kshitiz sinha
@@ -209,6 +209,7 @@ files:
209
209
  - lib/generators/hr_lite/install/templates/AFTER_INSTALL
210
210
  - lib/generators/hr_lite/install/templates/initializer.rb
211
211
  - lib/hr_lite.rb
212
+ - lib/hr_lite/amount_in_words.rb
212
213
  - lib/hr_lite/configuration.rb
213
214
  - lib/hr_lite/current.rb
214
215
  - lib/hr_lite/engine.rb
@@ -224,7 +225,6 @@ homepage: https://github.com/kshtzkr/hr_lite
224
225
  licenses:
225
226
  - MIT
226
227
  metadata:
227
- homepage_uri: https://github.com/kshtzkr/hr_lite
228
228
  source_code_uri: https://github.com/kshtzkr/hr_lite
229
229
  changelog_uri: https://github.com/kshtzkr/hr_lite/blob/main/CHANGELOG.md
230
230
  bug_tracker_uri: https://github.com/kshtzkr/hr_lite/issues