[#4517] Default the details row to All periods when it's out of the date range
This commit is contained in:
1 parent
74d707a1a4
commit
19ed07b617
4 files changed
+60
-10
No files matched your search
@@ -111,4 +111,12 @@ module ContractsHelper
|
||||
|
||||
options
|
||||
end
|
||||
|
||||
# Given a deliverable and period, validate the period
|
||||
# TODO: could use a better name
|
||||
def validate_period(deliverable, period)
|
||||
if deliverable.current_date && deliverable.within_period_range?(period)
|
||||
return period
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -47,6 +47,17 @@ class RetainerDeliverable < HourlyDeliverable
|
||||
date_range.include?(date)
|
||||
end
|
||||
|
||||
# period in the format of "%Y-%m" or "%B %Y"
|
||||
def within_period_range?(period)
|
||||
begin
|
||||
# both valid formats work by adding a day to the end like -01
|
||||
date = Date.parse(period.to_s + "-01")
|
||||
within_date_range?(date)
|
||||
rescue ArgumentError
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
def months
|
||||
month_acc = []
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<% period ||= nil %>
|
||||
<% validated_period = validate_period(deliverable, period) %>
|
||||
|
||||
<td colspan="11" class="deliverable_details_outer_wrapper_<%= h(deliverable.id) %>">
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<form method="get" action="<%= contract_deliverable_path(@project, contract, deliverable, :format => 'js', :as => 'deliverable_details_row') %>">
|
||||
<fieldset>
|
||||
<select name="period" id="retainer_period_change_<%= h(deliverable.id) %>" class="retainer_period_change">
|
||||
<%= retainer_period_options(deliverable, :selected => period) %>
|
||||
<%= retainer_period_options(deliverable, :selected => validated_period) %>
|
||||
</select>
|
||||
</fieldset>
|
||||
</form>
|
||||
@@ -52,28 +52,28 @@
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="l"><a href="#"><strong>Labor</strong></a></td>
|
||||
<td class="labor_budget_spent"><%= h(format_value_field_for_contracts(deliverable.labor_budget_spent(period))) %></td>
|
||||
<td class="labor_budget_total"><%= h(format_value_field_for_contracts(deliverable.labor_budget_total(period))) %></td>
|
||||
<td class="labor_budget_spent"><%= h(format_value_field_for_contracts(deliverable.labor_budget_spent(validated_period))) %></td>
|
||||
<td class="labor_budget_total"><%= h(format_value_field_for_contracts(deliverable.labor_budget_total(validated_period))) %></td>
|
||||
<td> TODO: Release 2 / TODO hrs </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="l"><a href="#"><strong>Overhead</strong></a></td>
|
||||
<td class="overhead_budget_spent"><%= h(format_value_field_for_contracts(deliverable.overhead_spent(period))) %></td>
|
||||
<td class="overhead_budget_total"><%= h(format_value_field_for_contracts(deliverable.overhead_budget_total(period))) %></td>
|
||||
<td class="overhead_budget_spent"><%= h(format_value_field_for_contracts(deliverable.overhead_spent(validated_period))) %></td>
|
||||
<td class="overhead_budget_total"><%= h(format_value_field_for_contracts(deliverable.overhead_budget_total(validated_period))) %></td>
|
||||
<td> TODO: Release 2 / TODO hrs </td>
|
||||
</tr>
|
||||
<%# TODO: Release 2, Fixed %>
|
||||
<%# TODO: Release 2, Markup %>
|
||||
<tr>
|
||||
<td class="l">Profit</td>
|
||||
<td><%= h(format_value_field_for_contracts(deliverable.profit_left(period))) %></td>
|
||||
<td><%= h(format_value_field_for_contracts(deliverable.profit_budget(period))) %></td>
|
||||
<td><%= h(format_value_field_for_contracts(deliverable.profit_left(validated_period))) %></td>
|
||||
<td><%= h(format_value_field_for_contracts(deliverable.profit_budget(validated_period))) %></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr class="total">
|
||||
<td class="l"><strong>Total:</strong></td>
|
||||
<td class="total_spent"><strong><%= h(format_value_field_for_contracts(deliverable.total_spent(period))) %></strong></td>
|
||||
<td class="total"><strong><%= h(format_value_field_for_contracts(deliverable.total(period))) %></strong></td>
|
||||
<td class="total_spent"><strong><%= h(format_value_field_for_contracts(deliverable.total_spent(validated_period))) %></strong></td>
|
||||
<td class="total"><strong><%= h(format_value_field_for_contracts(deliverable.total(validated_period))) %></strong></td>
|
||||
<td><strong>TODO: Release 2</strong></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
Reference in new issue
Block a user