Skip to content

Commit

Permalink
add overflow to statement of work
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiomagalhaes committed Dec 13, 2023
1 parent e77a7f1 commit e12adb3
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 7 deletions.
1 change: 1 addition & 0 deletions app/models/statement_of_work.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# Table name: statement_of_works
#
# id :bigint not null, primary key
# allow_revenue_overflow :boolean default(FALSE), not null
# end_date :datetime
# hour_delivery_schedule :string
# hourly_revenue :float
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def income_limit
end

def add_executed_income(income)
return income if @statement_of_work.allow_revenue_overflow?

income_to_add = 0
if (@total_executed_income + income + @executed_income_to_start_date) >= income_limit
income_to_add = [income_limit - @total_executed_income - @executed_income_to_start_date, 0].max
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

class AddAllowRevenueOverflowToStatementOfWork < ActiveRecord::Migration[7.0]
def change
add_column :statement_of_works, :allow_revenue_overflow, :boolean, default: false, null: false
end
end
3 changes: 2 additions & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 8 additions & 6 deletions spec/factories/statement_of_works.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# Table name: statement_of_works
#
# id :bigint not null, primary key
# allow_revenue_overflow :boolean default(FALSE), not null
# end_date :datetime
# hour_delivery_schedule :string
# hourly_revenue :float
Expand Down Expand Up @@ -32,31 +33,32 @@
start_date { Time.zone.today - 6.months }
end_date { Time.zone.today + 6.months }
name { FFaker::Lorem.sentence }
allow_revenue_overflow { false }

trait :with_maintenance do
model { 'maintenance' }
model { "maintenance" }
hourly_revenue { 100 }
total_hours { 120 }
total_revenue { 12_000 }
hour_delivery_schedule { 'monthly' }
hour_delivery_schedule { "monthly" }
limit_by_delivery_schedule { true }
end

trait :with_time_and_materials do
model { 'time_and_materials' }
model { "time_and_materials" }
hourly_revenue { 100 }
total_hours { 120 }
total_revenue { 12_000 }
hour_delivery_schedule { 'contract_period' }
hour_delivery_schedule { "contract_period" }
limit_by_delivery_schedule { true }
end

trait :with_fixed_bid do
model { 'time_and_materials' }
model { "time_and_materials" }
hourly_revenue { nil }
total_hours { nil }
total_revenue { 12_000 }
hour_delivery_schedule { 'contract_period' }
hour_delivery_schedule { "contract_period" }
limit_by_delivery_schedule { false }
end
end
Expand Down
1 change: 1 addition & 0 deletions spec/models/statement_of_work_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# Table name: statement_of_works
#
# id :bigint not null, primary key
# allow_revenue_overflow :boolean default(FALSE), not null
# end_date :datetime
# hour_delivery_schedule :string
# hourly_revenue :float
Expand Down

0 comments on commit e12adb3

Please sign in to comment.