From de074b945d294899cb92de2d0a41ee7f700e8b35 Mon Sep 17 00:00:00 2001 From: elijah Date: Sun, 7 Jun 2015 23:35:50 -0700 Subject: added money, added ability to hide hours or money, don't include issues from sub-projects. --- README.md | 3 ++- app/controllers/version_reports_controller.rb | 6 ++++- app/helpers/version_reports_helper.rb | 29 ++++++++++++++++++++++ app/views/version_reports/_issue_row.html.erb | 5 +++- app/views/version_reports/_main_issue_row.html.erb | 8 ++++-- 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) %> - <%= l_hours(issue.total_spent_hours) %> + <%= l_hours(issue.total_spent_hours) if @show_time %> + + +   <%- 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 @@

<%= display_issue(issue) %>

+ <%= hour_budget_error(issue) %> - <%= l_hours(issue.total_spent_hours) %> + <%= l_hours(issue.total_spent_hours) if @show_time %> + + + <%= hours_to_money(issue.total_spent_hours) if @show_money %> - + From <%= issue.start_date %> to <%= issue.due_date %>.
<%= textilizable issue, :description %> -- cgit v1.2.3