class Piawe

Class to encapsulate PIAWE report generation

Constants

VERSION

Public Class Methods

new( people_array, rules_array ) click to toggle source

Create a new Piawe instance to generate reports at varying dates for a particular set of people and rules

Parameters

  • people_array - An array of people hashes

  • rules_array - An array of rule hashes

People Hash

A people hash it a Ruby hash that has has the following format:

{"people": [
  {"name": "Ebony Boycott", "hourlyRate": 75.0030, "overtimeRate": 150.0000, "normalHours": 35.0, "overtimeHours": 7.3, "injuryDate": "2016/05/01" },
  {"name": "Geoff Rainford-Brent", "hourlyRate": 30.1234, "overtimeRate": 60.3456, "normalHours": 25.0, "overtimeHours": 10.7, "injuryDate": "2016/08/04" },
  {"name": "Meg Gillespie", "hourlyRate": 50.0000, "overtimeRate": 100.0000, "normalHours": 37.5, "overtimeHours": 0.0, "injuryDate": "2015/12/31" },
  {"name": "Jason Lanning", "hourlyRate": 40.0055, "overtimeRate": 90.9876, "normalHours": 40.0, "overtimeHours": 12.4, "injuryDate": "2013/01/01" }
]}
  • name - The person's name.

  • hourlyRate - The person's hourly rate of pay, calculated according to PIAWE rules.

  • overtimeRate - The person's overtime rate of pay, calculated according to PIAWE rules.

  • normalHours - The person's normal weekly hours, calculated according to PIAWE rules.

  • overtimeHours - The person's normal weekly overtime hours, calculated according to PIAWE rules.

  • injuryDate - The date of the injury that caused the person to cease work.

Rule Hash

A rule hash it a Ruby hash that has has the following format:

{"rules":[
  {"applicableWeeks": "1-26", "percentagePayable": 90, "overtimeIncluded": true},
  {"applicableWeeks": "27-52", "percentagePayable": 80, "overtimeIncluded": true},
  {"applicableWeeks": "53-79", "percentagePayable": 70, "overtimeIncluded": true},
  {"applicableWeeks": "80-104", "percentagePayable": 60, "overtimeIncluded": false},
  {"applicableWeeks": "105+", "percentagePayable": 10, "overtimeIncluded": false}
]}
  • 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.

  • percentagePayable - A Numeric that indicates the percentage of Average Weekly Earnings that are paid when this rule applies.

  • overtimeIncluded - A TrueClass or FalseClass that indicates whether overtime earnings should be considered part of Average Weekly Earnings when this rule applies.

# File lib/piawe.rb, line 61
def initialize( people_array, rules_array )
  @rules = Piawe::RuleSet.new rules_array
  @people = people_array.map { |person_hash| Person.played_by(person_hash) }
end

Public Instance Methods

report( report_date=Date.today ) click to toggle source

Generate a PIAWE report (Ruby Hash format) for the people and rules this Piawe instance encapsulates, as at the specified report date.

Parameters

  • report_date - The date for which the report should be generated. Defaults to the current date

# File lib/piawe.rb, line 73
def report( report_date=Date.today )
  {
    report_date: report_date.strftime("%Y/%m/%d"),
    report_lines: @people.map { |person| @rules.report_line(person, report_date) }
  }
end