Skip to content

Instantly share code, notes, and snippets.

@vsizov
Forked from vzaremba/LastPayReport.rb
Created September 5, 2013 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vsizov/6451344 to your computer and use it in GitHub Desktop.
Save vsizov/6451344 to your computer and use it in GitHub Desktop.
class LastPayReport
def initialize employees
@employees = employees
end
def get_rows
@employees.map do |employee|
employee.compensations.last_two
row = {}
row[:full_name] = employee.full_name
row[:department] = employee.department.nil? ? "" : employee.department.name
row[:job_title] = employee.job_title.nil? ? "" : employee.job_title.name
row[:previous_pay] = employee.compensations.last_two[1].nil? ? "" : employee.compensations.last_two[1].pay_rate.to_s << "/" << employee.compensations.last_two[1].pay_type.to_s
row[:current_pay] = employee.compensations.last_two[0].nil? ? "" : employee.compensations.last_two[0].pay_rate.to_s << "/" << employee.compensations.last_two[0].pay_type.to_s
row[:change_date] = employee.compensations.last_two[1].nil? ? "" : employee.compensations.last_two[0].date
rows << row
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment