Class: CostSharingObject

Inherits:
Object
  • Object
show all
Includes:
DataFactory, Foundry, Navigation, StringFactory
Defined in:
lib/kuality-coeus/data_objects/budget/cost_sharing.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 = {}) ⇒ CostSharingObject

Returns a new instance of CostSharingObject.



10
11
12
13
14
15
16
17
18
# File 'lib/kuality-coeus/data_objects/budget/cost_sharing.rb', line 10

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

  defaults = {
      percentage:     '0.00',
      source_account: random_alphanums
  }
  set_options(defaults.merge(opts))
end

Instance Attribute Details

#amountObject

Returns the value of attribute amount.



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

def amount
  @amount
end

#indexObject

Returns the value of attribute index.



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

def index
  @index
end

#percentageObject

Returns the value of attribute percentage.



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

def percentage
  @percentage
end

#project_periodObject

Returns the value of attribute project_period.



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

def project_period
  @project_period
end

#source_accountObject

Returns the value of attribute source_account.



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

def 
  @source_account
end

Instance Method Details

#createObject



20
21
22
23
24
25
26
27
# File 'lib/kuality-coeus/data_objects/budget/cost_sharing.rb', line 20

def create
  view
  on DistributionAndIncome do |page|
    page.add_cost_share_period.set @project_period
    # TODO: Add more here when needed
    page.add
  end
end

#edit(opts) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/kuality-coeus/data_objects/budget/cost_sharing.rb', line 35

def edit(opts)
  view
  on DistributionAndIncome do |page|
    page.expand_all
    page.cost_sharing_project_period(@index).fit opts[:project_period]
    page.cost_sharing_percentage(@index).fit opts[:percentage]
    page.(@index).fit opts[:source_account]
    page.cost_sharing_amount(@index).fit opts[:amount]
    page.save
  end
  update_options(opts)
end

#viewObject



29
30
31
32
33
# File 'lib/kuality-coeus/data_objects/budget/cost_sharing.rb', line 29

def view
  # Note: Currently assumes we're already viewing
  # the budget document!
  on(Parameters).distribution__income
end