summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2015-06-07 23:35:50 -0700
committerelijah <elijah@riseup.net>2015-06-07 23:35:50 -0700
commitde074b945d294899cb92de2d0a41ee7f700e8b35 (patch)
tree39cec3f4dcc67f17f0db0b8ba51a04da8ba0bcdf
parentfc1cffcacfa0e885c481e9d993f7c541673912c8 (diff)
added money, added ability to hide hours or money, don't include issues from sub-projects.
-rw-r--r--README.md3
-rw-r--r--app/controllers/version_reports_controller.rb6
-rw-r--r--app/helpers/version_reports_helper.rb29
-rw-r--r--app/views/version_reports/_issue_row.html.erb5
-rw-r--r--app/views/version_reports/_main_issue_row.html.erb8
5 files changed, 46 insertions, 5 deletions
diff --git a/README.md b/README.md
index 18b4509..0ac14b3 100644
--- a/README.md
+++ b/README.md
@@ -16,7 +16,8 @@ Installation:
Configuration:
-You grant the permission 'view reports' to a user in order to be able to view the report.
+* You grant the permission 'view reports' to a user in order to be able to view the report.
+* Create a custom field called 'Hour Budget'
License:
diff --git a/app/controllers/version_reports_controller.rb b/app/controllers/version_reports_controller.rb
index fb7ac6c..a2755ed 100644
--- a/app/controllers/version_reports_controller.rb
+++ b/app/controllers/version_reports_controller.rb
@@ -9,7 +9,11 @@ class VersionReportsController < ApplicationController
before_filter :authorize
def show
- @issues = @version.fixed_issues
+ @show_time = params[:time] != 'false'
+ @show_money = params[:money] != 'false'
+ # the issues fetched here are the top level 'deliverable' issues.
+ # so, we don't want to include issues from any other projects.
+ @issues = @version.fixed_issues.where(:project_id => @version.project_id)
end
private
diff --git a/app/helpers/version_reports_helper.rb b/app/helpers/version_reports_helper.rb
index 2e0ee8d..1f0f009 100644
--- a/app/helpers/version_reports_helper.rb
+++ b/app/helpers/version_reports_helper.rb
@@ -9,4 +9,33 @@ module VersionReportsHelper
link_to text, issue_path(issue)
end
+ def hours_to_money(hours)
+ "$%i" % (hours*50)
+ end
+
+ def hour_budget(issue)
+ v = issue.custom_field_values.detect {|value|
+ value.custom_field.name == 'Hour Budget'
+ }
+ if v
+ v.value.to_i
+ end
+ end
+
+ def hour_budget_error(issue)
+ return unless @show_hours
+ budget = hour_budget(issue)
+ if issue.total_spent_hours != budget
+ if issue.total_spent_hours < budget
+ content_tag :div, :class => 'flash error' do
+ "%s under budget!" % l_hours(budget - issue.total_spent_hours)
+ end
+ elsif issue.total_spent_hours > budget
+ content_tag :div, :class => 'flash warning' do
+ "%s over budget!" % l_hours(issue.total_spent_hours - budget)
+ end
+ end
+ end
+ end
+
end
diff --git a/app/views/version_reports/_issue_row.html.erb b/app/views/version_reports/_issue_row.html.erb
index 3ff7020..7d89e69 100644
--- a/app/views/version_reports/_issue_row.html.erb
+++ b/app/views/version_reports/_issue_row.html.erb
@@ -4,7 +4,10 @@
<%= display_issue(issue, :tracker) %>
</td>
<td>
- <%= l_hours(issue.total_spent_hours) %>
+ <%= l_hours(issue.total_spent_hours) if @show_time %>
+ </td>
+ <td>
+ &nbsp;
</td>
</tr>
<%- if issue.children.any? -%>
diff --git a/app/views/version_reports/_main_issue_row.html.erb b/app/views/version_reports/_main_issue_row.html.erb
index 32518e9..c83eb6d 100644
--- a/app/views/version_reports/_main_issue_row.html.erb
+++ b/app/views/version_reports/_main_issue_row.html.erb
@@ -2,13 +2,17 @@
<tr>
<td>
<h1><%= display_issue(issue) %></h1>
+ <%= hour_budget_error(issue) %>
</td>
<td>
- <%= l_hours(issue.total_spent_hours) %>
+ <%= l_hours(issue.total_spent_hours) if @show_time %>
+ </td>
+ <td>
+ <%= hours_to_money(issue.total_spent_hours) if @show_money %>
</td>
</tr>
<tr>
- <td colspan="2">
+ <td colspan="3">
From <%= issue.start_date %> to <%= issue.due_date %>.
<div class="wiki">
<%= textilizable issue, :description %>