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 +4 -4
- data/CHANGELOG.md +25 -0
- data/README.md +12 -0
- data/app/helpers/hr_lite/application_helper.rb +12 -28
- data/app/views/hr_lite/salary_slips/pdf.html.erb +3 -1
- data/app/views/layouts/hr_lite/application.html.erb +1 -1
- data/lib/hr_lite/amount_in_words.rb +34 -0
- data/lib/hr_lite/version.rb +1 -1
- data/lib/hr_lite.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 38321c0b3f943e26ccdfbae2109b466196174ec5e1a60c0efcbb0b751e85b9fa
|
|
4
|
+
data.tar.gz: ac91265eeaddf77c7b9972467b49682eac102fef136a58b2033d769ba3f7d150
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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.
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
-
|
|
96
|
-
"#{parts.join(' ').capitalize} rupees"
|
|
80
|
+
"#{sign}#{HrLite.config.currency_symbol}#{whole}.#{fraction.ljust(2, '0')}"
|
|
97
81
|
end
|
|
98
82
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
-
(<%=
|
|
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), "
|
|
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
|
data/lib/hr_lite/version.rb
CHANGED
data/lib/hr_lite.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.1.
|
|
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
|