Created
June 4, 2015 20:26
-
-
Save courte/8b492d782fea7d05c8f2 to your computer and use it in GitHub Desktop.
Timesheet#human_readable_billable_time
This file contains hidden or 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
def human_readable_billable_time | |
billable_entries_by_rate_type = entries.select(&:billable?).group_by(&:rate_type) | |
human_readable_time_string = billable_entries_by_rate_type.map do |type, entries| | |
"#{entries.map(&:amount).sum} #{type == "weekly" ? 'days' : 'hours'}" | |
end.join(" + ") | |
human_readable_time_string.empty? ? "No billable time" : human_readable_time_string | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment