Class: BudgetPeriodObject

Inherits:
Object
  • Object
show all
Includes:
DataFactory, Foundry, Navigation, StringFactory
Defined in:
lib/kuality-coeus/data_objects/budget/budget_periods.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Navigation

#doc_search, #fill_out, #fill_out_item, #on_document?, #on_page?, #open_document, #window_cleanup

Methods included from Utilities

#get, #make_role, #make_user, #random_percentage, #set, #snake_case

Constructor Details

#initialize(browser, opts = {}) ⇒ BudgetPeriodObject

Returns a new instance of BudgetPeriodObject.



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/kuality-coeus/data_objects/budget/budget_periods.rb', line 13

def initialize(browser, opts={})
  @browser = browser

  defaults = {
    doc_type: 'Budget Document ', # Note: the trailing space is not a typo!
    cost_sharing_distribution_list: collection('CostSharing')
  }

  set_options(defaults.merge(opts))
  requires :start_date, :budget_name
  datify
  add_cost_sharing @cost_sharing
end

Instance Attribute Details

#budget_nameObject

Returns the value of attribute budget_name.



8
9
10
# File 'lib/kuality-coeus/data_objects/budget/budget_periods.rb', line 8

def budget_name
  @budget_name
end

#cost_limitObject

Returns the value of attribute cost_limit.



8
9
10
# File 'lib/kuality-coeus/data_objects/budget/budget_periods.rb', line 8

def cost_limit
  @cost_limit
end

#cost_sharingObject

Returns the value of attribute cost_sharing.



8
9
10
# File 'lib/kuality-coeus/data_objects/budget/budget_periods.rb', line 8

def cost_sharing
  @cost_sharing
end

#cost_sharing_distribution_listObject

Returns the value of attribute cost_sharing_distribution_list.



8
9
10
# File 'lib/kuality-coeus/data_objects/budget/budget_periods.rb', line 8

def cost_sharing_distribution_list
  @cost_sharing_distribution_list
end

#datifiedObject

Returns the value of attribute datified.



8
9
10
# File 'lib/kuality-coeus/data_objects/budget/budget_periods.rb', line 8

def datified
  @datified
end

#direct_costObject

Returns the value of attribute direct_cost.



8
9
10
# File 'lib/kuality-coeus/data_objects/budget/budget_periods.rb', line 8

def direct_cost
  @direct_cost
end

#direct_cost_limitObject

Returns the value of attribute direct_cost_limit.



8
9
10
# File 'lib/kuality-coeus/data_objects/budget/budget_periods.rb', line 8

def direct_cost_limit
  @direct_cost_limit
end

#end_dateObject

Returns the value of attribute end_date.



8
9
10
# File 'lib/kuality-coeus/data_objects/budget/budget_periods.rb', line 8

def end_date
  @end_date
end

#f_and_a_costObject

Returns the value of attribute f_and_a_cost.



8
9
10
# File 'lib/kuality-coeus/data_objects/budget/budget_periods.rb', line 8

def f_and_a_cost
  @f_and_a_cost
end

#numberObject

Returns the value of attribute number.



8
9
10
# File 'lib/kuality-coeus/data_objects/budget/budget_periods.rb', line 8

def number
  @number
end

#start_dateObject

Returns the value of attribute start_date.



8
9
10
# File 'lib/kuality-coeus/data_objects/budget/budget_periods.rb', line 8

def start_date
  @start_date
end

#total_sponsor_costObject

Returns the value of attribute total_sponsor_cost.



8
9
10
# File 'lib/kuality-coeus/data_objects/budget/budget_periods.rb', line 8

def total_sponsor_cost
  @total_sponsor_cost
end

#unrecovered_f_and_aObject

Returns the value of attribute unrecovered_f_and_a.



8
9
10
# File 'lib/kuality-coeus/data_objects/budget/budget_periods.rb', line 8

def unrecovered_f_and_a
  @unrecovered_f_and_a
end

Instance Method Details

#createObject



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/kuality-coeus/data_objects/budget/budget_periods.rb', line 27

def create
  navigate
  on Parameters do |create|
    create.period_start_date.fit @start_date
    create.period_end_date.fit @end_date
    create.total_sponsor_cost.fit @total_sponsor_cost
    fill_out create, :direct_cost, :cost_sharing, :cost_limit, :direct_cost_limit
    create.fa_cost.fit @f_and_a_cost
    create.unrecovered_fa_cost.fit @unrecoverd_f_and_a
    create.add_budget_period
  end
end

#deleteObject



58
59
60
61
# File 'lib/kuality-coeus/data_objects/budget/budget_periods.rb', line 58

def delete
  navigate
  on(Parameters).delete_period @number
end

#dollar_fieldsObject



63
64
65
66
# File 'lib/kuality-coeus/data_objects/budget/budget_periods.rb', line 63

def dollar_fields
  [:total_sponsor_cost, :direct_cost, :f_and_a_cost, :unrecovered_f_and_a,
   :cost_sharing, :cost_limit, :direct_cost_limit]
end

#edit(opts = {}) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/kuality-coeus/data_objects/budget/budget_periods.rb', line 40

def edit opts={}
  navigate
  on Parameters do |edit|
    edit.start_date_period(@number).fit opts[:start_date]
    edit.end_date_period(@number).fit opts[:end_date]
    # TODO: At some point it may become critical for the data object to automatically "know" that the total sponsor cost
    # is always the sum of the direct and f&a costs.
    dollar_fields.each do |field|
      edit.send("#{field}_period", @number).fit opts[field]
    end
    edit.save
    break if edit.errors.size > 0
  end
  set_options(opts)
  datify
  add_cost_sharing opts[:cost_sharing]
end