hr_lite 0.1.1 → 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 +10 -0
- data/app/helpers/hr_lite/application_helper.rb +3 -23
- data/app/views/hr_lite/salary_slips/pdf.html.erb +3 -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 -1
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,16 @@ 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
|
+
|
|
10
20
|
## [0.1.1] - 2026-07-19
|
|
11
21
|
|
|
12
22
|
### Added
|
|
@@ -80,30 +80,10 @@ module HrLite
|
|
|
80
80
|
"#{sign}#{HrLite.config.currency_symbol}#{whole}.#{fraction.ljust(2, '0')}"
|
|
81
81
|
end
|
|
82
82
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
TENS = %w[zero ten twenty thirty forty fifty sixty seventy eighty ninety].freeze
|
|
86
|
-
|
|
87
|
-
# Indian-system amount in words for the slip footer.
|
|
83
|
+
# Indian-system amount in words for the slip footer. Delegates to the
|
|
84
|
+
# PORO so host-rendered templates (config.render_pdf) work too.
|
|
88
85
|
def hrl_amount_in_words(amount)
|
|
89
|
-
|
|
90
|
-
return "Zero rupees" if rupees.zero?
|
|
91
|
-
|
|
92
|
-
parts = []
|
|
93
|
-
[ [ 10_000_000, "crore" ], [ 100_000, "lakh" ], [ 1000, "thousand" ], [ 100, "hundred" ] ].each do |divisor, label|
|
|
94
|
-
next unless rupees >= divisor
|
|
95
|
-
|
|
96
|
-
parts << "#{hrl_two_digit_words(rupees / divisor)} #{label}"
|
|
97
|
-
rupees %= divisor
|
|
98
|
-
end
|
|
99
|
-
parts << hrl_two_digit_words(rupees) if rupees.positive?
|
|
100
|
-
"#{parts.join(' ').capitalize} rupees"
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
def hrl_two_digit_words(number)
|
|
104
|
-
return ONES[number] if number < 20
|
|
105
|
-
|
|
106
|
-
[ TENS[number / 10], number % 10 == 0 ? nil : ONES[number % 10] ].compact.join("-")
|
|
86
|
+
HrLite::AmountInWords.words(amount)
|
|
107
87
|
end
|
|
108
88
|
end
|
|
109
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">
|
|
@@ -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
|