Class: TaskJuggler::TimeSheetReport
- Inherits:
-
ReportBase
- Object
- ReportBase
- TaskJuggler::TimeSheetReport
- Defined in:
- lib/taskjuggler/reports/TimeSheetReport.rb
Overview
This specialization of ReportBase implements a template generator for time sheets. The time sheet is structured using the TJP file syntax.
Instance Method Summary collapse
-
#generateIntermediateFormat ⇒ Object
In the future we might want to generate other output than TJP synatx.
-
#initialize(report) ⇒ TimeSheetReport
constructor
Create a new object and set some default values.
-
#to_tjp ⇒ Object
Generate a time sheet in TJP syntax format.
Methods inherited from ReportBase
#a, #filterAccountList, #filterResourceList, #filterTaskList
Constructor Details
#initialize(report) ⇒ TimeSheetReport
Create a new object and set some default values.
53 54 55 56 57 58 |
# File 'lib/taskjuggler/reports/TimeSheetReport.rb', line 53 def initialize(report) super(report) @current = [] @future = [] end |
Instance Method Details
#generateIntermediateFormat ⇒ Object
In the future we might want to generate other output than TJP synatx. So we generate an abstract version of the time sheet first. This abstract version has a TSResourceRecord for each resource and each of these records holds a TSTaskRecord for each assigned task.
64 65 66 67 68 69 70 |
# File 'lib/taskjuggler/reports/TimeSheetReport.rb', line 64 def generateIntermediateFormat super @current = collectRecords(a('start'), a('end')) newEnd = a('end') + (a('end').to_i - a('start').to_i) newEnd = @project['end'] if newEnd > @project['end'] @future = collectRecords(a('end'), a('end') + (a('end') - a('start'))) end |
#to_tjp ⇒ Object
Generate a time sheet in TJP syntax format.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/taskjuggler/reports/TimeSheetReport.rb', line 73 def to_tjp # This String will hold the result. @file = "# The status headline should be no more than 60 characters and may\n# not be empty! The status summary is optional and should be no\n# longer than one or two sentences of plain text. The details section\n# is also optional has no length limitation. You can use simple\n# markup in this section. It is recommended that you provide at\n# least a summary or a details section.\n# See http://www.taskjuggler.org/tj3/manual/timesheet.html for details.\n#\n# --------8<--------8<--------\n" # Iterate over all the resources that we have TSResourceRecords for. @current.each do |rr| resource = rr.resource # Generate the time sheet header @file << "timesheet #{resource.fullId} " + "#{a('start')} - #{a('end')} {\n\n" @file << " # Vacation time: #{rr.vacationPercent}%\n\n" if rr.tasks.empty? # If there were no assignments, just write a comment. @file << " # There were no planned tasks assignments for " + "this period!\n\n" else rr.tasks.each do |tr| task = tr.task @file << " # Task: #{task.name}\n" @file << " task #{task.fullId} {\n" #@file << " work #{tr.workDays * # @project['dailyworkinghours']}h\n" @file << " work #{tr.workPercent}%\n" if tr.remaining @file << " remaining #{tr.remaining}d\n" else @file << " end #{tr.endDate}\n" end c = tr.workDays > 1.0 ? '' : '# ' @file << " #{c}status green \"Your headline here!\" {\n" + " # summary -8<-\n" + " # A summary text\n" + " # ->8-\n" + " # details -8<-\n" + " # Some more details\n" + " # ->8-\n" + " # flags ...\n" + " #{c}}\n" @file << " }\n\n" end end @file << " # If you had unplanned tasks, uncomment and fill out the\n # following lines:\n # newtask new.task.id \"A task title\" {\n # work X%\n # remaining Y.Yd\n # status green \"Your headline here!\" {\n # summary -8<-\n # A summary text\n # ->8-\n # details -8<-\n # Some more details\n # ->8-\n # flags ...\n # }\n # }\n\n # You can use the following section to report personal notes.\n # status green \"Your headline here!\" {\n # summary -8<-\n # A summary text\n # ->8-\n # details -8<-\n # Some more details\n # ->8-\n # }\n" future = @future[@future.index { |r| r.resource == resource }] if future && !future.tasks.empty? @file << " #\n # Your upcoming tasks for the next period\n # Please check them carefully and discuss any necessary\n # changes with your manager or project manager!\n #\n" future.tasks.each do |taskRecord| @file << " # #{taskRecord.task.name}: #{taskRecord.workPercent}%\n" end @file << "\n" else @file << "\n # You have no future assignments for this project!\n" end @file << "}\n# -------->8-------->8--------\n\n" end @file end |