Sha256: 689068dd1c104dae6e5664c352f9c2e6b3e14b809a168a69b4235d6a6ed5d891
Contents?: true
Size: 1.67 KB
Versions: 3
Compression:
Stored size: 1.67 KB
Contents
require 'rainbow/refinement' using Rainbow module Twstats class TimeSheetExport def initialize(csv, prompt) @prompt = prompt @rows = [] # Filter by billable and not billed csv.logs.select{|x| x.billable && !x.invoiced}.sort_by{|x| x.start_date}.each do |log| @rows << { date: log.date.strftime('%m/%d/%Y'), who: public_name(log.who), description: log.description, time: log.decimal_time, proj: log.project } end @proj = csv.projects # Ask the user how to configure the export if csv.projects.size > 1 @proj = @prompt.multi_select 'I have found more than one project in the CSV file, which ones do you want to export for timesheet?' do |menu| menu.choices csv.projects menu.default *[*1..csv.projects.size] # Generates an array from 1 to the maximum index of the projects array end end end def execute puts "Copy each column below into the proper column of the spreadsheet" columns = [:date, :who, :description, :time] columns.each do |column| puts "***********".bright.blue puts column.to_s.capitalize.bright.blue puts "***********".bright.blue @rows.each do |row| next unless @proj.include? row[:proj] puts "#{row[column]}" end end puts "******* Total amount of time billed *******".bright.blue puts "This amounts to #{@rows.inject(0) { |sum, x| sum += x[:time].to_f }} hours.".bright puts "Check with the amount of hours to be billed to see they match".bright end def public_name(name) name.split[0] end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
twstats-0.3.1 | lib/twstats/timesheet_export.rb |
twstats-0.3.0 | lib/twstats/timesheet_export.rb |
twstats-0.2.5 | lib/twstats/timesheet_export.rb |