Class: BudgetVersionsObject

Inherits:
Object
  • Object
show all
Includes:
DataFactory, Foundry, Navigation, StringFactory
Defined in:
lib/kuality-coeus/data_objects/budget/budget_versions.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

Methods included from Utilities

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

Constructor Details

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

Returns a new instance of BudgetVersionsObject.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/kuality-coeus/data_objects/budget/budget_versions.rb', line 20

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

  defaults = {
    name:              random_alphanums_plus(40),
    cost_sharing:      '0.00',
    f_and_a:           '0.00',
    budget_periods:    BudgetPeriodsCollection.new,
    subaward_budgets:  SubawardBudgetCollection.new,
    personnel:         BudgetPersonnelCollection.new
  }

  set_options(defaults.merge(opts))
  requires :document_id, :doc_type
end

Instance Attribute Details

#budget_periodsObject

Returns the value of attribute budget_periods.



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

def budget_periods
  @budget_periods
end

#commentsObject

Returns the value of attribute comments.



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

def comments
  @comments
end

#cost_sharingObject

Returns the value of attribute cost_sharing.



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

def cost_sharing
  @cost_sharing
end

#direct_costObject

Returns the value of attribute direct_cost.



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

def direct_cost
  @direct_cost
end

#document_idObject

Returns the value of attribute document_id.



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

def document_id
  @document_id
end

#f_and_aObject

Returns the value of attribute f_and_a.



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

def f_and_a
  @f_and_a
end

#f_and_a_rate_typeObject

Returns the value of attribute f_and_a_rate_type.



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

def f_and_a_rate_type
  @f_and_a_rate_type
end

#finalObject

Returns the value of attribute final.



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

def final
  @final
end

#last_updatedObject

Returns the value of attribute last_updated.



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

def last_updated
  @last_updated
end

#last_updated_byObject

Returns the value of attribute last_updated_by.



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

def last_updated_by
  @last_updated_by
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#on_off_campusObject

Returns the value of attribute on_off_campus.



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

def on_off_campus
  @on_off_campus
end

#personnelObject

Returns the value of attribute personnel.



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

def personnel
  @personnel
end

#project_end_dateObject

Returns the value of attribute project_end_date.



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

def project_end_date
  @project_end_date
end

#project_start_dateObject

Returns the value of attribute project_start_date.



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

def project_start_date
  @project_start_date
end

#residual_fundsObject

Returns the value of attribute residual_funds.



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

def residual_funds
  @residual_funds
end

#statusObject

Returns the value of attribute status.



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

def status
  @status
end

#subaward_budgetsObject

Returns the value of attribute subaward_budgets.



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

def subaward_budgets
  @subaward_budgets
end

#submit_cost_sharingObject

Returns the value of attribute submit_cost_sharing.



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

def submit_cost_sharing
  @submit_cost_sharing
end

#totalObject

Returns the value of attribute total.



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

def total
  @total
end

#total_cost_limitObject

Returns the value of attribute total_cost_limit.



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

def total_cost_limit
  @total_cost_limit
end

#total_direct_cost_limitObject

Returns the value of attribute total_direct_cost_limit.



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

def total_direct_cost_limit
  @total_direct_cost_limit
end

#unrecovered_faObject

Returns the value of attribute unrecovered_fa.



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

def unrecovered_fa
  @unrecovered_fa
end

#unrecovered_fa_rate_typeObject

Returns the value of attribute unrecovered_fa_rate_type.



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

def unrecovered_fa_rate_type
  @unrecovered_fa_rate_type
end

#versionObject

Returns the value of attribute version.



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

def version
  @version
end

Instance Method Details

#add_period(opts = {}) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/kuality-coeus/data_objects/budget/budget_versions.rb', line 69

def add_period opts={}
  defaults={
      budget_name: @name,
      doc_type: @doc_header
  }
  opts.merge!(defaults)

  bp = create BudgetPeriodObject, opts
  return if on(Parameters).errors.size > 0 # No need to continue the method if we have an error
  @budget_periods << bp
  @budget_periods.number! # This updates the number value of all periods, as necessary
end

#add_project_personnel(opts = {}) ⇒ Object



159
160
161
162
163
164
165
# File 'lib/kuality-coeus/data_objects/budget/budget_versions.rb', line 159

def add_project_personnel(opts={})
  open_budget
  on(Parameters).personnel
  person = make BudgetPersonnelObject, opts
  person.create
  @personnel << person
end

#add_subaward_budget(opts = {}) ⇒ Object



151
152
153
154
155
156
157
# File 'lib/kuality-coeus/data_objects/budget/budget_versions.rb', line 151

def add_subaward_budget(opts={})
  open_budget
  on(Parameters).budget_actions
  sab = make SubawardBudgetObject, opts
  sab.create
  @subaward_budgets << sab
end

#copy_all_periods(new_name) ⇒ Object



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/kuality-coeus/data_objects/budget/budget_versions.rb', line 121

def copy_all_periods(new_name)
  navigate
  new_version_number='x'
  on(BudgetVersions).copy @name
  on(Confirmation).copy_all_periods
  on BudgetVersions do |copy|
    copy.name_of_copy.set new_name
    copy.save
    new_version_number=copy.version(new_name)
  end
  new_bv = self.clone
  new_bv.name=new_name
  new_bv.version=new_version_number
  new_bv
end

#copy_one_period(new_name, version) ⇒ Object



137
138
139
# File 'lib/kuality-coeus/data_objects/budget/budget_versions.rb', line 137

def copy_one_period(new_name, version)
  # pending resolution of a bug
end

#createObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/kuality-coeus/data_objects/budget/budget_versions.rb', line 36

def create
  navigate
  on BudgetVersions do |add|
    @doc_header=add.doc_title
    add.name.set @name
    add.add
    add.final(@name).fit @final
    add.budget_status(@name).pick! @status
    add.save
    break if parameters.compact==nil # No reason to continue if there aren't other things to do
    # Otherwise, go to parameters page and fill out the rest of the stuff...
    add.open(@name)
  end
  #TODO: This needs to be dealt with more intelligently.
  # It's clear that we need to learn more about how to set up
  # sponsors better, so that we can predict when this dialog
  # will show up and when it won't...
  confirmation
  on Parameters do |parameters|
    @project_start_date=parameters.project_start_date
    @project_end_date=parameters.project_end_date
    parameters.total_direct_cost_limit.fit @total_direct_cost_limit
    fill_out parameters, :comments, :modular_budget,
             :residual_funds, :total_cost_limit, :unrecovered_fa_rate_type,
             :f_and_a_rate_type, :submit_cost_sharing
    parameters.on_off_campus.fit @on_off_campus
    parameters.alert.ok if parameters.alert.exists?
    parameters.save
  end
  confirmation
  get_budget_periods
end

#default_periodsObject



141
142
143
144
145
146
147
148
149
# File 'lib/kuality-coeus/data_objects/budget/budget_versions.rb', line 141

def default_periods
  open_budget
  on Parameters do |page|
    page.parameters unless page.parameters_button.parent.class_name=='tabright tabcurrent'
    page.default_periods
  end
  @budget_periods.clear
  get_budget_periods
end

#delete_period(number) ⇒ Object



87
88
89
90
91
# File 'lib/kuality-coeus/data_objects/budget/budget_versions.rb', line 87

def delete_period number
  @budget_periods.period(number).delete
  @budget_periods.delete(@budget_periods.period(number))
  @budget_periods.number!
end

#edit(opts = {}) ⇒ Object

Please note, this method is for VERY basic editing… Use it for editing the Budget Version while on the Proposal, but not the Periods



95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/kuality-coeus/data_objects/budget/budget_versions.rb', line 95

def edit opts={}
  navigate
  on(BudgetVersions).open @name
  confirmation
  on Parameters do |edit|
    edit.final.fit opts[:final]
    edit.budget_status.fit opts[:budget_status]
    edit.total_direct_cost_limit.fit opts[:total_direct_cost_limit]
    # TODO: More to add here...
    edit.save
  end
  set_options(opts)
end

#edit_period(number, opts = {}) ⇒ Object



82
83
84
85
# File 'lib/kuality-coeus/data_objects/budget/budget_versions.rb', line 82

def edit_period number, opts={}
  @budget_periods.period(number).edit opts
  @budget_periods.number!
end

#open_budgetObject



109
110
111
112
113
114
115
116
117
118
119
# File 'lib/kuality-coeus/data_objects/budget/budget_versions.rb', line 109

def open_budget
  navigate
  on BudgetVersions do |page|
    page.open @name
  end
  #TODO: This needs to be dealt with more intelligently.
  # It's clear that we need to learn more about how to set up
  # sponsors better, so that we can predict when this dialog
  # will show up and when it won't...
  confirmation
end