jg_piawe 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -3
- data/README.md +8 -1
- data/coverage/.last_run.json +5 -0
- data/coverage/.resultset.json +835 -0
- data/coverage/.resultset.json.lock +0 -0
- data/coverage/assets/0.10.0/application.css +799 -0
- data/coverage/assets/0.10.0/application.js +1707 -0
- data/coverage/assets/0.10.0/colorbox/border.png +0 -0
- data/coverage/assets/0.10.0/colorbox/controls.png +0 -0
- data/coverage/assets/0.10.0/colorbox/loading.gif +0 -0
- data/coverage/assets/0.10.0/colorbox/loading_background.png +0 -0
- data/coverage/assets/0.10.0/favicon_green.png +0 -0
- data/coverage/assets/0.10.0/favicon_red.png +0 -0
- data/coverage/assets/0.10.0/favicon_yellow.png +0 -0
- data/coverage/assets/0.10.0/loading.gif +0 -0
- data/coverage/assets/0.10.0/magnify.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/coverage/index.html +5270 -0
- data/doc/Piawe/FileParser.html +210 -0
- data/doc/Piawe/RuleSet.html +265 -0
- data/doc/Piawe.html +302 -0
- data/doc/created.rid +5 -0
- data/doc/css/fonts.css +167 -0
- data/doc/css/rdoc.css +590 -0
- data/doc/fonts/Lato-Light.ttf +0 -0
- data/doc/fonts/Lato-LightItalic.ttf +0 -0
- data/doc/fonts/Lato-Regular.ttf +0 -0
- data/doc/fonts/Lato-RegularItalic.ttf +0 -0
- data/doc/fonts/SourceCodePro-Bold.ttf +0 -0
- data/doc/fonts/SourceCodePro-Regular.ttf +0 -0
- data/doc/images/add.png +0 -0
- data/doc/images/arrow_up.png +0 -0
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/delete.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_blue.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/transparent.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/index.html +84 -0
- data/doc/js/darkfish.js +161 -0
- data/doc/js/jquery.js +4 -0
- data/doc/js/navigation.js +142 -0
- data/doc/js/navigation.js.gz +0 -0
- data/doc/js/search.js +109 -0
- data/doc/js/search_index.js +1 -0
- data/doc/js/search_index.js.gz +0 -0
- data/doc/js/searcher.js +228 -0
- data/doc/js/searcher.js.gz +0 -0
- data/doc/table_of_contents.html +80 -0
- data/lib/piawe/rule_set.rb +4 -3
- data/lib/piawe/version.rb +1 -1
- data/lib/piawe.rb +90 -90
- metadata +77 -1
data/lib/piawe.rb
CHANGED
@@ -8,10 +8,9 @@ require 'bigdecimal'
|
|
8
8
|
# Class to encapsulate PIAWE report generation
|
9
9
|
class Piawe
|
10
10
|
|
11
|
-
|
11
|
+
include RolePlaying::Context
|
12
12
|
|
13
|
-
|
14
|
-
#
|
13
|
+
# Create a new Piawe instance to generate reports at varying dates for a particular set of people and rules
|
15
14
|
#
|
16
15
|
# ==== Parameters
|
17
16
|
#
|
@@ -23,121 +22,122 @@ class Piawe
|
|
23
22
|
#
|
24
23
|
# A people hash it a Ruby hash that has has the following format:
|
25
24
|
#
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
25
|
+
# {"people": [
|
26
|
+
# {"name": "Ebony Boycott", "hourlyRate": 75.0030, "overtimeRate": 150.0000, "normalHours": 35.0, "overtimeHours": 7.3, "injuryDate": "2016/05/01" },
|
27
|
+
# {"name": "Geoff Rainford-Brent", "hourlyRate": 30.1234, "overtimeRate": 60.3456, "normalHours": 25.0, "overtimeHours": 10.7, "injuryDate": "2016/08/04" },
|
28
|
+
# {"name": "Meg Gillespie", "hourlyRate": 50.0000, "overtimeRate": 100.0000, "normalHours": 37.5, "overtimeHours": 0.0, "injuryDate": "2015/12/31" },
|
29
|
+
# {"name": "Jason Lanning", "hourlyRate": 40.0055, "overtimeRate": 90.9876, "normalHours": 40.0, "overtimeHours": 12.4, "injuryDate": "2013/01/01" }
|
30
|
+
# ]}
|
31
|
+
#
|
32
|
+
# * name - The person's name.
|
33
|
+
#
|
34
|
+
# * hourlyRate - The person's hourly rate of pay, calculated according to PIAWE rules.
|
35
|
+
#
|
36
|
+
# * overtimeRate - The person's overtime rate of pay, calculated according to PIAWE rules.
|
37
|
+
#
|
38
|
+
# * normalHours - The person's normal weekly hours, calculated according to PIAWE rules.
|
39
|
+
#
|
40
|
+
# * overtimeHours - The person's normal weekly overtime hours, calculated according to PIAWE rules.
|
41
|
+
#
|
42
|
+
# * injuryDate - The date of the injury that caused the person to cease work.
|
43
|
+
#
|
45
44
|
# ==== Rule Hash
|
46
45
|
#
|
47
46
|
# A rule hash it a Ruby hash that has has the following format:
|
48
47
|
#
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
48
|
+
# {"rules":[
|
49
|
+
# {"applicableWeeks": "1-26", "percentagePayable": 90, "overtimeIncluded": true},
|
50
|
+
# {"applicableWeeks": "27-52", "percentagePayable": 80, "overtimeIncluded": true},
|
51
|
+
# {"applicableWeeks": "53-79", "percentagePayable": 70, "overtimeIncluded": true},
|
52
|
+
# {"applicableWeeks": "80-104", "percentagePayable": 60, "overtimeIncluded": false},
|
53
|
+
# {"applicableWeeks": "105+", "percentagePayable": 10, "overtimeIncluded": false}
|
54
|
+
# ]}
|
55
|
+
#
|
56
|
+
# * applicableWeeks - A String that indicates the range of injury weeks during which the rule applies - Week 1 starts at the day of the injury, and Week 2 starts on the 7th day after the injury, and so on. It can have two formats: either a start week and end week joined by a dash, or a start week followed by a plus sign, which indicates the rule should apply to all later weeks as well. The first rule must have a start week of 1, the last rule must use the plus sign syntax, and all intervening rules must have a start week that is one greater than the end week of the preceeding rule.
|
57
|
+
#
|
58
|
+
# * percentagePayable - A Numeric that indicates the percentage of Average Weekly Earnings that are paid when this rule applies.
|
59
|
+
#
|
60
|
+
# * overtimeIncluded - A TrueClass or FalseClass that indicates whether overtime earnings should be considered part of Average Weekly Earnings when this rule applies.
|
61
|
+
def initialize( people_array, rules_array )
|
62
|
+
@rules = Piawe::RuleSet.new rules_array
|
63
|
+
@people = people_array.map { |person_hash| Person.played_by(person_hash) }
|
64
|
+
end # initialize
|
65
|
+
|
66
|
+
|
67
|
+
# Generate a PIAWE report (Ruby Hash format) for the people and rules this Piawe instance encapsulates, as at the specified report date.
|
69
68
|
#
|
70
69
|
# ==== Parameters
|
71
70
|
#
|
72
71
|
# * +report_date+ - The date for which the report should be generated. Defaults to the current date
|
73
72
|
#
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
73
|
+
def report( report_date=Date.today )
|
74
|
+
{
|
75
|
+
report_date: report_date.strftime("%Y/%m/%d"),
|
76
|
+
report_lines: @people.map { |person| @rules.report_line(person, report_date) }
|
77
|
+
}
|
78
|
+
end # method report
|
81
79
|
|
82
80
|
|
83
|
-
|
81
|
+
# role to be applied to a person hash
|
82
|
+
# This role provides derivided fields that present a hash as a Person object
|
83
|
+
role :Person do
|
84
84
|
|
85
|
-
|
86
|
-
|
87
|
-
|
85
|
+
def weeks_since_injury(report_date) # :nodoc:
|
86
|
+
@weeks_since_injury ||= ( report_date - injury_date) / 7
|
87
|
+
end
|
88
88
|
|
89
89
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
90
|
+
def injury_date # :nodoc:
|
91
|
+
@injury_date ||= (
|
92
|
+
self.has_key?("injuryDate") || (raise ArgumentError, "person_hash does not have a key of injuryDate: #{self.inspect}")
|
93
|
+
/^\d{4}\/\d{2}\/\d{2}$/ =~ self["injuryDate"] || (raise ArgumentError, "injury date of #{self["injuryDate"]} is not in yyyy/mm/dd format: #{self.inspect}")
|
94
|
+
result = nil
|
95
|
+
begin
|
96
|
+
result = Date.parse self["injuryDate"]
|
97
|
+
rescue ArgumentError => ex
|
98
|
+
raise ArgumentError, "person_hash has an invalidly formatted injuryDate key: #{self.inspect} }"
|
99
|
+
end
|
100
|
+
result <= Date.today || (raise ArgumentError, "person_hash has an injuryDate value that is in the future: #{self.inspect}")
|
101
|
+
result
|
102
|
+
)
|
103
|
+
end
|
104
104
|
|
105
105
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
106
|
+
def name # :nodoc:
|
107
|
+
self.has_key?("name") || (raise ArgumentError, "person_hash does not have a key of name: #{self.inspect}")
|
108
|
+
self["name"] || (raise ArgumentError, "person_hash has a nil value for name key: #{self.inspect}")
|
109
|
+
self["name"]
|
110
|
+
end
|
111
111
|
|
112
112
|
|
113
|
-
|
114
|
-
|
115
|
-
|
113
|
+
def hourly_rate # :nodoc:
|
114
|
+
get_decimal "hourlyRate"
|
115
|
+
end
|
116
116
|
|
117
117
|
|
118
|
-
|
119
|
-
|
120
|
-
|
118
|
+
def overtime_rate # :nodoc:
|
119
|
+
get_decimal "overtimeRate"
|
120
|
+
end
|
121
121
|
|
122
122
|
|
123
|
-
|
124
|
-
|
125
|
-
|
123
|
+
def normal_hours # :nodoc:
|
124
|
+
get_decimal "normalHours"
|
125
|
+
end
|
126
126
|
|
127
127
|
|
128
|
-
|
129
|
-
|
130
|
-
|
128
|
+
def overtime_hours # :nodoc:
|
129
|
+
get_decimal "overtimeHours"
|
130
|
+
end
|
131
131
|
|
132
132
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
133
|
+
def get_decimal(key) # :nodoc:
|
134
|
+
self.has_key?(key) || (raise ArgumentError, "person_hash does not have a key of #{key}: #{self.inspect}")
|
135
|
+
self[key].is_a?(Numeric) || (raise ArgumentError, "person_hash has a non-numeric value for #{key} key: #{self.inspect}")
|
136
|
+
BigDecimal.new self[key], 15
|
137
|
+
end
|
138
138
|
|
139
139
|
|
140
|
-
|
140
|
+
end
|
141
141
|
|
142
142
|
|
143
143
|
end # class Piawe
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jg_piawe
|
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
|
- John Gray
|
@@ -96,6 +96,82 @@ files:
|
|
96
96
|
- Rakefile
|
97
97
|
- bin/console
|
98
98
|
- bin/setup
|
99
|
+
- coverage/.last_run.json
|
100
|
+
- coverage/.resultset.json
|
101
|
+
- coverage/.resultset.json.lock
|
102
|
+
- coverage/assets/0.10.0/application.css
|
103
|
+
- coverage/assets/0.10.0/application.js
|
104
|
+
- coverage/assets/0.10.0/colorbox/border.png
|
105
|
+
- coverage/assets/0.10.0/colorbox/controls.png
|
106
|
+
- coverage/assets/0.10.0/colorbox/loading.gif
|
107
|
+
- coverage/assets/0.10.0/colorbox/loading_background.png
|
108
|
+
- coverage/assets/0.10.0/favicon_green.png
|
109
|
+
- coverage/assets/0.10.0/favicon_red.png
|
110
|
+
- coverage/assets/0.10.0/favicon_yellow.png
|
111
|
+
- coverage/assets/0.10.0/loading.gif
|
112
|
+
- coverage/assets/0.10.0/magnify.png
|
113
|
+
- coverage/assets/0.10.0/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png
|
114
|
+
- coverage/assets/0.10.0/smoothness/images/ui-bg_flat_75_ffffff_40x100.png
|
115
|
+
- coverage/assets/0.10.0/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png
|
116
|
+
- coverage/assets/0.10.0/smoothness/images/ui-bg_glass_65_ffffff_1x400.png
|
117
|
+
- coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_dadada_1x400.png
|
118
|
+
- coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png
|
119
|
+
- coverage/assets/0.10.0/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png
|
120
|
+
- coverage/assets/0.10.0/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png
|
121
|
+
- coverage/assets/0.10.0/smoothness/images/ui-icons_222222_256x240.png
|
122
|
+
- coverage/assets/0.10.0/smoothness/images/ui-icons_2e83ff_256x240.png
|
123
|
+
- coverage/assets/0.10.0/smoothness/images/ui-icons_454545_256x240.png
|
124
|
+
- coverage/assets/0.10.0/smoothness/images/ui-icons_888888_256x240.png
|
125
|
+
- coverage/assets/0.10.0/smoothness/images/ui-icons_cd0a0a_256x240.png
|
126
|
+
- coverage/index.html
|
127
|
+
- doc/Piawe.html
|
128
|
+
- doc/Piawe/FileParser.html
|
129
|
+
- doc/Piawe/RuleSet.html
|
130
|
+
- doc/created.rid
|
131
|
+
- doc/css/fonts.css
|
132
|
+
- doc/css/rdoc.css
|
133
|
+
- doc/fonts/Lato-Light.ttf
|
134
|
+
- doc/fonts/Lato-LightItalic.ttf
|
135
|
+
- doc/fonts/Lato-Regular.ttf
|
136
|
+
- doc/fonts/Lato-RegularItalic.ttf
|
137
|
+
- doc/fonts/SourceCodePro-Bold.ttf
|
138
|
+
- doc/fonts/SourceCodePro-Regular.ttf
|
139
|
+
- doc/images/add.png
|
140
|
+
- doc/images/arrow_up.png
|
141
|
+
- doc/images/brick.png
|
142
|
+
- doc/images/brick_link.png
|
143
|
+
- doc/images/bug.png
|
144
|
+
- doc/images/bullet_black.png
|
145
|
+
- doc/images/bullet_toggle_minus.png
|
146
|
+
- doc/images/bullet_toggle_plus.png
|
147
|
+
- doc/images/date.png
|
148
|
+
- doc/images/delete.png
|
149
|
+
- doc/images/find.png
|
150
|
+
- doc/images/loadingAnimation.gif
|
151
|
+
- doc/images/macFFBgHack.png
|
152
|
+
- doc/images/package.png
|
153
|
+
- doc/images/page_green.png
|
154
|
+
- doc/images/page_white_text.png
|
155
|
+
- doc/images/page_white_width.png
|
156
|
+
- doc/images/plugin.png
|
157
|
+
- doc/images/ruby.png
|
158
|
+
- doc/images/tag_blue.png
|
159
|
+
- doc/images/tag_green.png
|
160
|
+
- doc/images/transparent.png
|
161
|
+
- doc/images/wrench.png
|
162
|
+
- doc/images/wrench_orange.png
|
163
|
+
- doc/images/zoom.png
|
164
|
+
- doc/index.html
|
165
|
+
- doc/js/darkfish.js
|
166
|
+
- doc/js/jquery.js
|
167
|
+
- doc/js/navigation.js
|
168
|
+
- doc/js/navigation.js.gz
|
169
|
+
- doc/js/search.js
|
170
|
+
- doc/js/search_index.js
|
171
|
+
- doc/js/search_index.js.gz
|
172
|
+
- doc/js/searcher.js
|
173
|
+
- doc/js/searcher.js.gz
|
174
|
+
- doc/table_of_contents.html
|
99
175
|
- exe/piawe_report
|
100
176
|
- lib/piawe.rb
|
101
177
|
- lib/piawe/file_parser.rb
|