Sha256: 8a7d68f55a3fe20d08c048848bdf4836e9dc4a4980ec6c0ef603e179553e4d2f
Contents?: true
Size: 1.66 KB
Versions: 1
Compression:
Stored size: 1.66 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.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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
twstats-0.2.4 | lib/twstats/timesheet_export.rb |