Adding dollar signs or % to amounts
* Added number_or_percent helper to return the correct string * Deliverable.labor_budget will now return 0.0 if it's nil #1274
This commit is contained in:
@@ -63,4 +63,10 @@ module DeliverablesHelper
|
||||
)
|
||||
|
||||
end
|
||||
|
||||
def number_or_percent(number_field, percent_field)
|
||||
return number_to_currency(number_field, :precision => 0) unless number_field.blank?
|
||||
return number_to_percentage(percent_field, :precision => 0) unless percent_field.blank?
|
||||
return "$0"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -22,7 +22,7 @@ class FixedDeliverable < Deliverable
|
||||
|
||||
# Budget for the labor, excluding overhead, profit, and materials
|
||||
def labor_budget
|
||||
return read_attribute(:fixed_cost)
|
||||
return read_attribute(:fixed_cost) || 0.0
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -41,7 +41,7 @@ class HourlyDeliverable < Deliverable
|
||||
|
||||
# Budget for the labor, excluding overhead, profit, and materials
|
||||
def labor_budget
|
||||
return read_attribute(:cost_per_hour).to_f * read_attribute(:total_hours).to_f
|
||||
return (read_attribute(:cost_per_hour).to_f * read_attribute(:total_hours).to_f) || 0.0
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<%= content_tag(:td, deliverable.id) %>
|
||||
<%= content_tag(:td, h(deliverable.score.to_i), :class => 'score') if allowed_management? %>
|
||||
<%= content_tag(:td, h(deliverable.subject), :class => 'subject') %>
|
||||
<%= content_tag(:td, number_to_currency(deliverable.labor_budget, :precision => 0), :class => 'budget') %>
|
||||
<%= content_tag(:td, number_to_currency(deliverable.labor_budget || 0.0, :precision => 0), :class => 'budget') %>
|
||||
<%= content_tag(:td, number_to_currency(deliverable.spent, :precision => 0), :class => 'spent') if allowed_management? %>
|
||||
<%= content_tag(:td, format_date(deliverable.due), :class => 'due_date') %>
|
||||
<%= content_tag(:td, progress_bar(deliverable.progress, :width => '100%', :class => 'dont_ratio')) %>
|
||||
@@ -45,10 +45,10 @@
|
||||
<td colspan="3">
|
||||
<%= paragraph_with_data("Total Budget: ", number_to_currency(deliverable.budget, :precision => 0)) -%>
|
||||
<% if allowed_management? %>
|
||||
<%= paragraph_with_data("Labor: ", number_to_currency(deliverable.labor_budget, :precision => 0)) -%>
|
||||
<%= paragraph_with_data("Overhead: ", number_to_currency(deliverable.overhead, :precision => 0)) -%>
|
||||
<%= paragraph_with_data("Materials: ", number_to_currency(deliverable.materials, :precision => 0)) -%>
|
||||
<%= paragraph_with_data("Profit: ", number_to_currency(deliverable.profit, :precision => 0)) -%>
|
||||
<%= paragraph_with_data("Labor: ", number_to_currency(deliverable.labor_budget || 0.0, :precision => 0)) -%>
|
||||
<%= paragraph_with_data("Overhead: ", number_or_percent(deliverable.overhead, deliverable.overhead_percent)) -%>
|
||||
<%= paragraph_with_data("Materials: ", number_or_percent(deliverable.materials, deliverable.materials_percent)) -%>
|
||||
<%= paragraph_with_data("Profit: ", number_or_percent(deliverable.profit, deliverable.profit_percent)) -%>
|
||||
<% end %>
|
||||
</td>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user