Last active
December 22, 2015 09:19
-
-
Save vzaremba/6451230 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'ostruct' | |
class LastPayReport | |
def initialize employees | |
@employees = employees | |
end | |
def get_rows | |
rows = [] | |
@employees.each do |employee| | |
employee.compensations.last_two | |
row = OpenStruct.new | |
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 | |
rows | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
and so on