Implemented more of the Deliverable calculations
* Added deliverable.score * Added fixed_deliverable.score as 0 * Added deliverable.budget_ratio #1136
This commit is contained in:
@@ -7,7 +7,7 @@ class Deliverable < ActiveRecord::Base
|
|||||||
|
|
||||||
# TODO: mocked
|
# TODO: mocked
|
||||||
def score
|
def score
|
||||||
0
|
return self.progress - self.budget_ratio
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: mocked
|
# TODO: mocked
|
||||||
@@ -29,6 +29,10 @@ class Deliverable < ActiveRecord::Base
|
|||||||
return (balance / total).round
|
return (balance / total).round
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def budget_ratio
|
||||||
|
return ((self.spent / self.budget) * 100).round
|
||||||
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
# These attributes can take a Dollar amount or a %
|
# These attributes can take a Dollar amount or a %
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
class FixedDeliverable < Deliverable
|
class FixedDeliverable < Deliverable
|
||||||
unloadable
|
unloadable
|
||||||
|
|
||||||
|
# Fixed rate bids should always have a budget score of 0. This is because the budget is managed by the contractor.
|
||||||
|
def score
|
||||||
|
0
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -110,8 +110,24 @@ describe Deliverable, '.profit' do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe Deliverable, '.budget_ratio' do
|
||||||
|
it 'should be the whole number of the budget spent' do
|
||||||
|
@deliverable = Deliverable.new({ :subject => 'test' })
|
||||||
|
@deliverable.should_receive(:budget).and_return(3000.00)
|
||||||
|
@deliverable.should_receive(:spent).and_return(1000.00)
|
||||||
|
|
||||||
|
@deliverable.budget_ratio.should eql(33)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe Deliverable, '.score' do
|
describe Deliverable, '.score' do
|
||||||
it 'should'
|
it 'should be calculated by the progress and the budget usage' do
|
||||||
|
@deliverable = Deliverable.new({ :subject => 'test' })
|
||||||
|
@deliverable.should_receive(:progress).and_return(75)
|
||||||
|
@deliverable.should_receive(:budget_ratio).and_return(33)
|
||||||
|
|
||||||
|
@deliverable.score.should eql(42)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe Deliverable, '.progress' do
|
describe Deliverable, '.progress' do
|
||||||
@@ -156,10 +172,12 @@ describe Deliverable, '.progress' do
|
|||||||
@deliverable.progress.should eql(100)
|
@deliverable.progress.should eql(100)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
it 'should not change when hours are clocked'
|
it 'should not change when hours are clocked'
|
||||||
|
|
||||||
it 'should change if issues are assigned'
|
it 'should change if issues are assigned'
|
||||||
|
|
||||||
it 'should change if issues are unassigned'
|
it 'should change if issues are unassigned'
|
||||||
|
|
||||||
it 'should change when a status changes'
|
it 'should change when a status changes'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
require File.dirname(__FILE__) + '/../spec_helper'
|
||||||
|
|
||||||
|
describe FixedDeliverable, '.score' do
|
||||||
|
it 'should always be 0' do
|
||||||
|
@deliverable = FixedDeliverable.new({ :subject => 'test' })
|
||||||
|
@deliverable.score.should eql(0)
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user