diff --git a/app/helpers/contracts_helper.rb b/app/helpers/contracts_helper.rb
index 5f496e9..927c856 100644
--- a/app/helpers/contracts_helper.rb
+++ b/app/helpers/contracts_helper.rb
@@ -14,4 +14,32 @@ module ContractsHelper
'---'
end
end
+
+ # Simple helper to show the values of a field on an object in a standard format
+ #
+ #
+ # Label:
+ # Field value
+ #
+ def show_field(object, field, options={})
+ html_options = options[:html_options] || {}
+ label = content_tag(:span, l(("field_" + field.to_s.gsub(/\_id$/, "")).to_sym) + ": ")
+
+ formatter = options[:format]
+
+ content = if formatter
+ send(formatter, object.send(field))
+ else
+ object.send(field)
+ end
+
+ content_tag(:p,
+ label +
+ h(content),
+ html_options)
+ end
+
+ def format_hourly_rate(decimal)
+ number_to_currency(decimal) + "/hr" if decimal
+ end
end
diff --git a/app/models/contract.rb b/app/models/contract.rb
index bcb309a..1929aab 100644
--- a/app/models/contract.rb
+++ b/app/models/contract.rb
@@ -29,6 +29,15 @@ class Contract < ActiveRecord::Base
attr_accessible :po_number
attr_accessible :details
+ [:status, :contract_type, :labor_spent, :labor_budget, :overhead_spent,
+ :overhead_budget, :fixed_spent, :fixed_budget, :total_spent, :total_budget,
+ :markup_spent, :markup_budget, :profit_spent, :profit_budget,
+ :discount_spent, :discount_budget, :client_point_of_contact,
+ :estimated_hour_spent, :estimated_hour_budget
+ ].each do |mthd|
+ define_method(mthd) { "TODO" }
+ end
+
PaymentTerms = {
:net_0 => :text_payment_terms_net_0,
:net_15 => :text_payment_terms_net_15,
diff --git a/app/views/contracts/show.html.erb b/app/views/contracts/show.html.erb
index ccf4f2e..f009dc1 100644
--- a/app/views/contracts/show.html.erb
+++ b/app/views/contracts/show.html.erb
@@ -1,17 +1,49 @@
<%# TODO: Need skinning %>
<% div_for(resource) do %>
<%= content_tag(:h2, h(resource.name)) %>
- <%= content_tag(:p, h(resource.account_executive)) %>
- <%= content_tag(:p, h(resource.executed)) %>
- <%= content_tag(:p, format_date(resource.start_date)) %>
- <%= content_tag(:p, format_date(resource.end_date)) %>
- <%= content_tag(:p, h(resource.billable_rate)) %>
- <%= content_tag(:p, h(resource.discount)) %>
- <%= content_tag(:p, h(resource.discount_note)) %>
- <%= content_tag(:p, h(resource.payment_terms)) %>
- <%= content_tag(:p, h(resource.client_ap_contact_information)) %>
- <%= content_tag(:p, h(resource.po_number)) %>
- <%= content_tag(:p, h(resource.details)) %>
+
+ <%= show_field(resource, :status, :html_options => {:class => 'contract-status'}) %>
+ <%= show_field(resource, :account_executive, :html_options => {:class => 'contract-account-manager'}) %>
+ <%= show_field(resource, :contract_type, :html_options => {:class => 'contract-type'}) %>
+ <%= show_field(resource, :start_date, :format => :format_date, :html_options => {:class => 'contract-start-date'}) %>
+ <%= show_field(resource, :end_date, :format => :format_date, :html_options => {:class => 'contract-end-date'}) %>
+
+ <%= show_field(resource, :labor_spent, :html_options => {:class => 'contract-labor-spent'}) %>
+ <%= show_field(resource, :labor_budget, :html_options => {:class => 'contract-labor-budget'}) %>
+ <%= show_field(resource, :overhead_spent, :html_options => {:class => 'contract-overhead-spent'}) %>
+ <%= show_field(resource, :overhead_budget, :html_options => {:class => 'contract-overhead-budget'}) %>
+ <%= show_field(resource, :total_spent, :html_options => {:class => 'contract-total-spent'}) %>
+ <%= show_field(resource, :total_budget, :html_options => {:class => 'contract-total-budget'}) %>
+
+
+ <%= show_field(resource, :client_point_of_contact, :html_options => {:class => 'contract-client-point-of-contact'}) %>
+ <%= show_field(resource, :executed, :html_options => {:class => 'contract-executed'}) %>
+ <%= show_field(resource, :discount_note, :html_options => {:class => 'contract-discount-note'}) %>
+ <%= show_field(resource, :payment_terms, :html_options => {:class => 'contract-payment-terms'}) %>
+ <%= show_field(resource, :client_ap_contact_information, :html_options => {:class => 'contract-client-ap-contact-information'}) %>
+ <%= show_field(resource, :po_number, :html_options => {:class => 'contract-po-number'}) %>
+ <%= show_field(resource, :details, :html_options => {:class => 'contract-details'}) %>
+
+ <%= show_field(resource, :labor_spent, :html_options => {:class => 'contract-labor-spent'}) %>
+ <%= show_field(resource, :labor_budget, :html_options => {:class => 'contract-labor-budget'}) %>
+ <%= show_field(resource, :overhead_spent, :html_options => {:class => 'contract-overhead-spent'}) %>
+ <%= show_field(resource, :overhead_budget, :html_options => {:class => 'contract-overhead-budget'}) %>
+ <%= show_field(resource, :fixed_spent, :html_options => {:class => 'contract-fixed-spent'}) %>
+ <%= show_field(resource, :fixed_budget, :html_options => {:class => 'contract-fixed-budget'}) %>
+ <%= show_field(resource, :markup_spent, :html_options => {:class => 'contract-markup-spent'}) %>
+ <%= show_field(resource, :markup_budget, :html_options => {:class => 'contract-markup-budget'}) %>
+ <%= show_field(resource, :profit_spent, :html_options => {:class => 'contract-profit-spent'}) %>
+ <%= show_field(resource, :profit_budget, :html_options => {:class => 'contract-profit-budget'}) %>
+ <%= show_field(resource, :discount_spent, :html_options => {:class => 'contract-discount-spent'}) %>
+ <%= show_field(resource, :discount_budget, :html_options => {:class => 'contract-discount-budget'}) %>
+ <%= show_field(resource, :total_spent, :html_options => {:class => 'contract-total-spent'}) %>
+ <%= show_field(resource, :total_budget, :html_options => {:class => 'contract-total-budget'}) %>
+
+ <%= show_field(resource, :billable_rate, :format => :format_hourly_rate, :html_options => {:class => 'contract-billable-rate'}) %>
+ <%= show_field(resource, :estimated_hour_spent, :html_options => {:class => 'contract-estimated-hour-spent'}) %>
+ <%= show_field(resource, :estimated_hour_budget, :html_options => {:class => 'contract-estimated-hour-budget'}) %>
+
+
<% end %>
<%= link_to(l(:button_update), edit_contract_path(@project, resource)) %>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index da50bc0..98a9d08 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -32,3 +32,21 @@ en:
text_deliverable_finances: Deliverable Finances
text_short_hours: hrs
text_dollar_sign: '$'
+ field_client_point_of_contact: "Point of Contact"
+ field_discount_budget: "Discount"
+ field_discount_spent: "Discount"
+ field_estimated_hour_budget: "Est. Hours"
+ field_estimated_hour_spent: "Est. Hours"
+ field_fixed_budget: "Fixed"
+ field_fixed_spent: "Fixed"
+ field_labor_budget: "Labor"
+ field_labor_spent: "Labor"
+ field_markup_budget: "Markup"
+ field_markup_spent: "Markup"
+ field_overhead_budget: "Overhead"
+ field_overhead_spent: "Overhead"
+ field_profit_budget: "Profit"
+ field_profit_spent: "Profit"
+ field_total_budget: "Contract Total"
+ field_total_spent: "Contract Total"
+ field_contract_type: "Type"
diff --git a/test/integration/contracts_show_test.rb b/test/integration/contracts_show_test.rb
index 507d4b9..e137130 100644
--- a/test/integration/contracts_show_test.rb
+++ b/test/integration/contracts_show_test.rb
@@ -20,6 +20,55 @@ class ContractsShowTest < ActionController::IntegrationTest
end
end
+ should "show contract metadata" do
+ visit_contract_page(@contract)
+
+ assert_select "div#contract_#{@contract.id}.contract" do
+ assert_select '.contract-status'
+ assert_select '.contract-account-manager'
+ assert_select '.contract-type'
+ assert_select '.contract-start-date'
+ assert_select '.contract-end-date'
+
+ assert_select '.contract-labor-spent'
+ assert_select '.contract-labor-budget'
+ assert_select '.contract-overhead-spent'
+ assert_select '.contract-overhead-budget'
+ assert_select '.contract-total-spent'
+ assert_select '.contract-total-budget'
+
+ assert_select '#contract-terms' do
+ assert_select '.contract-client-point-of-contact'
+ assert_select '.contract-executed'
+ assert_select '.contract-discount-note'
+ assert_select '.contract-payment-terms'
+ assert_select '.contract-client-ap-contact-information'
+ assert_select '.contract-po-number'
+ assert_select '.contract-details'
+
+ assert_select '.contract-labor-spent'
+ assert_select '.contract-labor-budget'
+ assert_select '.contract-overhead-spent'
+ assert_select '.contract-overhead-budget'
+ assert_select '.contract-fixed-spent'
+ assert_select '.contract-fixed-budget'
+ assert_select '.contract-markup-spent'
+ assert_select '.contract-markup-budget'
+ assert_select '.contract-profit-spent'
+ assert_select '.contract-profit-budget'
+ assert_select '.contract-discount-spent'
+ assert_select '.contract-discount-budget'
+ assert_select '.contract-total-spent'
+ assert_select '.contract-total-budget'
+
+ assert_select '.contract-billable-rate'
+
+ assert_select '.contract-estimated-hour-spent'
+ assert_select '.contract-estimated-hour-budget'
+ end
+ end
+ end
+
should "have a link to create a new deliverable" do
visit_contracts_for_project(@project)
click_link @contract.id