Changed profit to take into account the overhead along with the total labor cost

when profit is a %

* Fixed Models
* Fixed JS Calculator
* Cleaned up specs to access attributes directly

  #1349
This commit is contained in:
Eric Davis
2008-06-19 15:29:02 -07:00
parent 5431df3d8d
commit b776098c7d
7 changed files with 37 additions and 14 deletions
+5 -5
View File
@@ -20,7 +20,7 @@ describe Deliverable, 'associations' do
end
end
describe Deliverable, '.overhead' do
describe Deliverable, '.overhead=' do
before(:each) do
@deliverable = Deliverable.new({ :subject => 'test' })
end
@@ -28,24 +28,24 @@ describe Deliverable, '.overhead' do
describe 'with a dollar amount' do
it 'should store the dollar amount' do
@deliverable.overhead = "$1, 000.10"
@deliverable.overhead.should eql(1000.1)
@deliverable.read_attribute(:overhead).should eql(1000.1)
end
it 'should clear the .overhead_percent' do
@deliverable.overhead = "$1, 000.10"
@deliverable.overhead_percent.should eql(nil)
@deliverable.read_attribute(:overhead_percent).should eql(nil)
end
end
describe 'with a percentage' do
it 'should store the % of the amount to .overhead_percent' do
@deliverable.overhead = "100 %"
@deliverable.overhead_percent.should eql(100)
@deliverable.read_attribute(:overhead_percent).should eql(100)
end
it 'should clean the .overhead' do
@deliverable.overhead = "100 %"
@deliverable.overhead.should eql(nil)
@deliverable.read_attribute(:overhead).should eql(nil)
end
end
end
+8 -3
View File
@@ -17,8 +17,13 @@ describe FixedDeliverable, '.spent' do
end
describe FixedDeliverable, '.profit as a %' do
it 'should return the % of the fixed bid amount' do
@deliverable = FixedDeliverable.new({ :subject => 'test', :profit_percent => 50, :fixed_cost => 1000.0 })
@deliverable.profit.should eql(500.0)
it 'should return the % of the fixed bid and overhead amount' do
@deliverable = FixedDeliverable.new({ :subject => 'test', :profit_percent => 50, :fixed_cost => 1000.0, :overhead => "1000.00", :overhead_percent => nil })
@deliverable.profit.should eql(1000.0)
end
it 'should return the % of the fixed bid and overhead percentage' do
@deliverable = FixedDeliverable.new({ :subject => 'test', :profit_percent => 50, :fixed_cost => 1000.0, :overhead => nil, :overhead_percent => 100 })
@deliverable.profit.should eql(1000.0)
end
end
+8 -3
View File
@@ -28,8 +28,13 @@ describe HourlyDeliverable, '.spent' do
end
describe HourlyDeliverable, '.profit as a %' do
it 'should return the % of the hours mutipled by the cost per hour amount' do
@deliverable = HourlyDeliverable.new({ :subject => 'test', :profit_percent => 50, :cost_per_hour => 100.0, :total_hours => 10 })
@deliverable.profit.should eql(500.0)
it 'should return the % of the hours mutipled by the cost per hour amount plus the overhead' do
@deliverable = HourlyDeliverable.new({ :subject => 'test', :profit_percent => 50, :cost_per_hour => 100.0, :total_hours => 10, :overhead => '1000.00', :overhead_percent => nil })
@deliverable.profit.should eql(1000.0)
end
it 'should return the % of the hours mutipled by the cost per hour amount plus the overhead percentage' do
@deliverable = HourlyDeliverable.new({ :subject => 'test', :profit_percent => 50, :cost_per_hour => 100.0, :total_hours => 10, :overhead => nil, :overhead_percent => 100 })
@deliverable.profit.should eql(1000.0)
end
end