Class: InstituteRateObject

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

Constant Summary collapse

ACTIVITY_TYPES =
{
  # Description                   # Code
    'Research'                   => '1',
    'Instruction'                => '2',
    'Public Service'             => '3',
    'Clinical Trial'             => '4',
    'other'                      => '5',
    'Fellowship - Pre-Doctoral'  => '6',
    'Fellowship - Post-Doctoral' => '7',
    'Student Services'           => '8',
    'Construction'               => '9'
}
RATE_CLASS_TYPES =
{
    'E' => 'Fringe Benefits',
    'I' => 'Inflation',
    'L' => 'Lab Allocation - Other',
    'O' => 'F & A',
    'V' => 'Vacation',
    'X' => 'Other',
    'Y' => 'Lab Allocation - Salaries'
}
RATE_CLASS_CODES =
{
    'MTDC'                              => '1',
    'Lab Allocation - Salaries'         => '10',
    'Lab Allocation - M&S'              => '11',
    'Lab Allocation - Utilities'        => '12',
    'MTDC - AWARD'                      => '13',
    'TDC'                               => '2',
    'S&W'                               => '3',
    'Fund with Transaction Fee (FUNSN)' => '4',
    'Employee Benefits'                 => '5',
    'Inflation'                         => '7',
    'Vacation'                          => '8',
    'Other'                             => '9'
}
RATE_TYPES =
{
    'MTDC'=>{class: '1', type: '1'},
    'Lab Allocation - Salaries'=>{class: '10', type: '1'},
    'Lab Allocation - M&S'=>{class: '11', type: '1'},
    'Lab Allocation - Utilities'=>{class: '12', type: '1'},
    'MTDC - Award'=>{class: '13', type: '1'},
    'FUNSN'=>{class: '13', type: '10'},
    'FUNNX'=>{class: '13', type: '11'},
    'FUNSNX'=>{class: '13', type: '12'},
    'FUNSAX'=>{class: '13', type: '13'},
    'FUNNXF'=>{class: '13', type: '14'},
    'FUNMNX'=>{class: '13', type: '15'},
    'FUNMFX'=>{class: '13', type: '16'},
    'SLNSN'=>{class: '13', type: '17'},
    'SLNMN'=>{class: '13', type: '18'},
    'SLNMF'=>{class: '13', type: '19'},
    'TDC - DO NOT USE'=>{class: '13', type: '2'},
    'GENSN'=>{class: '13', type: '20'},
    'GENSNF'=>{class: '13', type: '21'},
    'RESSN'=>{class: '13', type: '22'},
    'FUNSAN'=>{class: '13', type: '23'},
    'FUNFN'=>{class: '13', type: '24'},
    'RESTDC'=>{class: '13', type: '25'},
    'FUNTDC'=>{class: '13', type: '26'},
    'RESTG'=>{class: '13', type: '27'},
    'RESTDE'=>{class: '13', type: '28'},
    'BIMN'=>{class: '13', type: '29'},
    'Other'=>{class: '13', type: '3'},
    'None'=>{class: '13', type: '4'},
    'RESMN'=>{class: '13', type: '5'},
    'RESMF'=>{class: '13', type: '6'},
    'EXCLU'=>{class: '13', type: '7'},
    'RESEB'=>{class: '13', type: '8'},
    'RESMFF'=>{class: '13', type: '9'},
    'TDC'=>{class: '2', type: '1'},
    'S&W'=>{class: '3', type: '1'},
    'Salaries'=>{class: '4', type: '1'},
    'Materials and Services'=>{class: '4', type: '2'},
    'Research Rate'=>{class: '5', type: '1'},
    'UROP Rate'=>{class: '5', type: '2'},
    'EB on LA'=>{class: '5', type: '3'},
    'another EB rate'=>{class: '5', type: '4'},
    'eb added in pb'=>{class: '5', type: '5'},
    'Award Special EB Rate'=>{class: '5', type: '6'},
    'Faculty Salaries (6/1)'=>{class: '7', type: '1'},
    'Administrative Salaries (7/1)'=>{class: '7', type: '2'},
    'Support Staff Salaries (4/1)'=>{class: '7', type: '3'},
    'Materials and Services'=>{class: '7', type: '4'},
    'Research Staff (1/1)'=>{class: '7', type: '5'},
    'Students (6/1)'=>{class: '7', type: '6'},
    'Vacation'=>{class: '8', type: '1'},
    'Vacation on LA'=>{class: '8', type: '2'},
    'Other'=>{class: '9', type: '1'}
}

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 = {}) ⇒ InstituteRateObject

Returns a new instance of InstituteRateObject.



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/kuality-coeus/data_objects/rates/institute_rate.rb', line 106

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

  defaults = {
    description: random_alphanums,
    fiscal_year: right_now[:year],
    activity_type: 'Instruction',
    on_off_campus_flag: :set,
    rate_type: 'Salaries',
    unit_number: '000001',
    rate: "#{rand(9)+1}.#{rand(100)}",
    active: :set
  }

  set_options(defaults.merge(opts))
  @start_date ||= "01/01/#{@fiscal_year}"
  @activity_type_code = ACTIVITY_TYPES[@activity_type]
  @rate_class_code = RATE_TYPES[@rate_type][:class]
  @rate_type_code = RATE_TYPES[@rate_type][:type]
end

Instance Attribute Details

#activeObject

Returns the value of attribute active.



102
103
104
# File 'lib/kuality-coeus/data_objects/rates/institute_rate.rb', line 102

def active
  @active
end

#activity_typeObject

Returns the value of attribute activity_type.



102
103
104
# File 'lib/kuality-coeus/data_objects/rates/institute_rate.rb', line 102

def activity_type
  @activity_type
end

#activity_type_codeObject

Returns the value of attribute activity_type_code.



102
103
104
# File 'lib/kuality-coeus/data_objects/rates/institute_rate.rb', line 102

def activity_type_code
  @activity_type_code
end

#descriptionObject

Returns the value of attribute description.



102
103
104
# File 'lib/kuality-coeus/data_objects/rates/institute_rate.rb', line 102

def description
  @description
end

#fiscal_yearObject

Returns the value of attribute fiscal_year.



102
103
104
# File 'lib/kuality-coeus/data_objects/rates/institute_rate.rb', line 102

def fiscal_year
  @fiscal_year
end

#on_off_campus_flagObject

Returns the value of attribute on_off_campus_flag.



102
103
104
# File 'lib/kuality-coeus/data_objects/rates/institute_rate.rb', line 102

def on_off_campus_flag
  @on_off_campus_flag
end

#rateObject

Returns the value of attribute rate.



102
103
104
# File 'lib/kuality-coeus/data_objects/rates/institute_rate.rb', line 102

def rate
  @rate
end

#rate_class_codeObject

Returns the value of attribute rate_class_code.



102
103
104
# File 'lib/kuality-coeus/data_objects/rates/institute_rate.rb', line 102

def rate_class_code
  @rate_class_code
end

#rate_typeObject

Returns the value of attribute rate_type.



102
103
104
# File 'lib/kuality-coeus/data_objects/rates/institute_rate.rb', line 102

def rate_type
  @rate_type
end

#rate_type_codeObject

Returns the value of attribute rate_type_code.



102
103
104
# File 'lib/kuality-coeus/data_objects/rates/institute_rate.rb', line 102

def rate_type_code
  @rate_type_code
end

#start_dateObject

Returns the value of attribute start_date.



102
103
104
# File 'lib/kuality-coeus/data_objects/rates/institute_rate.rb', line 102

def start_date
  @start_date
end

#unit_numberObject

Returns the value of attribute unit_number.



102
103
104
# File 'lib/kuality-coeus/data_objects/rates/institute_rate.rb', line 102

def unit_number
  @unit_number
end

Instance Method Details

#activateObject

This method…

  • Breaks the CRUD model and the design pattern, but is necessary because of how the system restricts creation of rate records

  • Assumes it doesn’t need to navigate because it’s being used in very specific places



164
165
166
167
168
169
170
171
# File 'lib/kuality-coeus/data_objects/rates/institute_rate.rb', line 164

def activate
  @active=:set
  on InstituteRatesMaintenance do |edit|
    edit.active.send(@active)
    fill_out edit, :description
    edit.blanket_approve
  end
end

#createObject



127
128
129
130
131
132
133
134
135
136
# File 'lib/kuality-coeus/data_objects/rates/institute_rate.rb', line 127

def create
  navigate
  on(InstituteRatesLookup).create_new
  on InstituteRatesMaintenance do |create|
    fill_out create, :description, :activity_type_code, :fiscal_year,
             :rate_class_code, :rate_type_code, :start_date, :unit_number,
             :rate, :on_off_campus_flag, :active
    create.blanket_approve
  end
end

#deleteObject



173
174
175
176
177
178
179
180
181
# File 'lib/kuality-coeus/data_objects/rates/institute_rate.rb', line 173

def delete
  navigate
  search
  on(InstituteRatesLookup).delete_item "#{@rate_type}"
  on InstituteRatesMaintenance do |del|
    del.description.set @description
    del.blanket_approve
  end
end

#exist?Boolean

Returns:

  • (Boolean)


138
139
140
141
142
143
144
145
146
147
# File 'lib/kuality-coeus/data_objects/rates/institute_rate.rb', line 138

def exist?
  $users.admin. if $users.current_user==nil
  navigate
  search
  if on(InstituteRatesLookup).results_table.present?
    return true
  else
    return false
  end
end

#get_current_rateObject

This method…

  • Breaks the CRUD model and the design pattern, but is necessary because of how the system restricts creation of rate records

  • Assumes it doesn’t need to navigate because it’s being used in very specific places



154
155
156
157
# File 'lib/kuality-coeus/data_objects/rates/institute_rate.rb', line 154

def get_current_rate
  on(InstituteRatesLookup).edit_item "#{@activity_type}.#{@fiscal_year}.+#{@rate_type}"
  @rate=on(InstituteRatesMaintenance).rate.value
end

#searchObject



183
184
185
186
187
188
189
190
191
# File 'lib/kuality-coeus/data_objects/rates/institute_rate.rb', line 183

def search
  on InstituteRatesLookup do |look|
    fill_out look, :activity_type_code, :fiscal_year, :rate_class_code,
             :rate_type_code, :unit_number
    look.on_off_campus campus_lookup[@on_off_campus_flag]
    look.active ''
    look.search
  end
end