twstats 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 27db2b5244ab293d6e6f955c7392b1473daeaf2832c0a5f9db342a10216a72df
4
- data.tar.gz: 1a475fe0708379be56cfd4cf9329c84cf03b4c7b21a4572a4c1a45c8c6e39608
3
+ metadata.gz: f34d4ba10054132e2b0cddb54033e418979735a7ea7c5e3d487f40eb2c5472e7
4
+ data.tar.gz: 1017e1b74d4cf8da667b634ea71285952f9f9c44a7b297cb2c8c31c21f884406
5
5
  SHA512:
6
- metadata.gz: '09a95242b4c137c7cdc474be974ab3b1f9623daeb5caaf2af63a411a0556914d30ca77a1b18f687dafd99e848e85f25b2e7486afe88a9c7399e7f1671c7c32cf'
7
- data.tar.gz: 0470c445f623518a781d4da31376c3161e1ead38f3df8b32aa7a60c3fa98507edcae85c2d5c986d7758e23b8196a4554dfe332e703db6b80d27da52b9eb439a9
6
+ metadata.gz: 21bff3055a10fd3fafb6d92647a2537afb908024e053e7bfca171532e4e7ad55e3eb7758656e8a35895411b520184d526f07b631e1ad9989d1f53855ed257182
7
+ data.tar.gz: 128b0efb50ae73c9b7b598b841ebdfeb66fb38b4ce510d2fe2a8e1b1f290cd23bfccddabb37dc4bd8fa8bee495b7fda6b0f8cd5e377b142a395aaf644170763a
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- twstats (0.2.2)
4
+ twstats (0.2.3.pre.2.pre.g8db668b)
5
5
  rainbow (~> 3.0)
6
6
  tty-prompt (~> 0.17)
7
7
 
@@ -2,6 +2,7 @@ require_relative 'twstats/extensions'
2
2
  require_relative 'twstats/version'
3
3
  require_relative 'twstats/tw_log'
4
4
  require_relative 'twstats/csv_reader'
5
+ require_relative 'twstats/timesheet_export'
5
6
  require_relative 'twstats/runner'
6
7
 
7
8
  module Twstats
@@ -19,7 +20,7 @@ module Twstats
19
20
  ]
20
21
  MENU_CHOICES = [
21
22
  {name: 'Stats', value: :stats},
22
- {name: 'Info', value: :info},
23
+ {name: 'Billing', value: :billing},
23
24
  {name: 'Quit', value: :quit}
24
25
  ]
25
26
  end
@@ -20,8 +20,8 @@ module Twstats
20
20
  case option
21
21
  when :stats
22
22
  show_stats_menu
23
- when :info
24
- show_info
23
+ when :billing
24
+ billing
25
25
  when :quit
26
26
  break
27
27
  else
@@ -30,6 +30,12 @@ module Twstats
30
30
  end
31
31
  end
32
32
 
33
+ def billing
34
+ ## Takes care of using the current CSV file to be imported into timesheets.
35
+ # Makes it easier to do it than manually going through all of them
36
+ TimeSheetExport.new(@csv, @prompt).execute
37
+ end
38
+
33
39
  def show_stats_menu
34
40
  loop do
35
41
  option = @prompt.select("Select what time logging stats you want to see", Twstats::STATS_MENU_CHOICES, cycle: true)
@@ -59,8 +65,12 @@ module Twstats
59
65
  end
60
66
  toshow.sort_by{ |k,v| v}.reverse.to_h.each do |k,v|
61
67
  if filter_billable
62
- puts " - #{k.ljust(max,' ').bright.blue} | #{"Billable:".ljust(13," ").bright} #{v[0].round(2)} (#{((v[0]/(v[0]+v[1]))*100).round(2)} %)" unless v[0].zero?
63
- puts " #{"".ljust(max,' ').bright.blue} | #{"Non-billable:".bright} #{v[1].round(2)}" unless v[1].zero?
68
+ if v[0].zero?
69
+ puts " - #{k.ljust(max,' ').bright.blue} | #{"Non-billable:".bright} #{v[1].round(2)}"# unless v[1].zero?
70
+ else
71
+ puts " - #{k.ljust(max,' ').bright.blue} | #{"Billable:".ljust(13," ").bright} #{v[0].round(2)} (#{((v[0]/(v[0]+v[1]))*100).round(2)} %)"
72
+ puts " #{"".ljust(max,' ').bright.blue} | #{"Non-billable:".bright} #{v[1].round(2)}" unless v[1].zero?
73
+ end
64
74
  else
65
75
  puts " - #{k.ljust(max,' ').bright.blue} | #{v.round(2)}" unless v.zero?
66
76
  end
@@ -0,0 +1,51 @@
1
+ require 'rainbow/refinement'
2
+ using Rainbow
3
+
4
+ module Twstats
5
+ class TimeSheetExport
6
+ def initialize(csv, prompt)
7
+ @prompt = prompt
8
+ @rows = []
9
+ # Filter by billable and not billed
10
+ csv.logs.select{|x| x.billable && !x.invoiced}.sort_by{|x| x.date}.each do |log|
11
+ @rows << {
12
+ date: log.date.strftime('%m/%d/%Y'),
13
+ who: public_name(log.who),
14
+ description: log.description,
15
+ time: log.decimal_time,
16
+ proj: log.project
17
+ }
18
+ end
19
+ @proj = csv.projects
20
+
21
+ # Ask the user how to configure the export
22
+ if csv.projects.size > 1
23
+ @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|
24
+ menu.choices csv.projects
25
+ menu.default *[*1..csv.projects.size] # Generates an array from 1 to the maximum index of the projects array
26
+ end
27
+ end
28
+ end
29
+
30
+ def execute
31
+ puts "Copy each column below into the proper column of the spreadsheet"
32
+ columns = [:date, :who, :description, :time]
33
+ columns.each do |column|
34
+ puts "***********".bright.blue
35
+ puts column.to_s.capitalize.bright.blue
36
+ puts "***********".bright.blue
37
+ @rows.each do |row|
38
+ next unless @proj.include? row[:proj]
39
+ puts "#{row[column]}"
40
+ end
41
+ end
42
+ puts "******* Total amount of time billed *******".bright.blue
43
+ puts "This amounts to #{@rows.inject(0) { |sum, x| sum += x[:time].to_f }} hours.".bright
44
+ puts "Check with the amount of hours to be billed to see they match".bright
45
+ end
46
+
47
+ def public_name(name)
48
+ name.split[0]
49
+ end
50
+ end
51
+ end
@@ -10,7 +10,7 @@ module Twstats
10
10
  attr_reader :project
11
11
  attr_reader :task
12
12
  attr_reader :billable
13
-
13
+ attr_reader :invoiced
14
14
 
15
15
  # Class use to store the information needed form a given log
16
16
  def initialize(row)
@@ -23,6 +23,7 @@ module Twstats
23
23
  @project = row["Project"]
24
24
  @task = row["Task"]
25
25
  @billable = !row["Is it Billable?"].to_i.zero?
26
+ @invoiced = !row['Invoice Number']
26
27
  @date = DateTime.parse(row['Date'])
27
28
  end
28
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twstats
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - J.P. Araque
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-22 00:00:00.000000000 Z
11
+ date: 2018-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -106,6 +106,7 @@ files:
106
106
  - lib/twstats/csv_reader.rb
107
107
  - lib/twstats/extensions.rb
108
108
  - lib/twstats/runner.rb
109
+ - lib/twstats/timesheet_export.rb
109
110
  - lib/twstats/tw_log.rb
110
111
  - lib/twstats/version.rb
111
112
  - twstats.gemspec