Module: EmployeesProcedures

Extended by:
ActiveSupport::Concern
Included in:
Employee
Defined in:
app/models/concerns/employees_procedures.rb

Constant Summary collapse

HEADERS =
[]

Instance Method Summary collapse

Instance Method Details

#write_procedure(erp_user_name: 'SYSTEM', validate: true) ⇒ Object

Raises:

  • (ActiveRecord::RecordInvalid)


218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
# File 'app/models/concerns/employees_procedures.rb', line 218

def write_procedure(erp_user_name: 'SYSTEM', validate: true)
  raise ActiveRecord::RecordInvalid, self if validate && !valid?

  result = ActiveRecord::Base.execute_procedure(
    :pr_insert_update_employee,
    employee_id,
    company_id,
    employee_name,
    date_of_birth&.to_datetime,
    ssn,
    start_date&.to_datetime,
    termination_date&.to_datetime,
    termination_reason,
    google_address,
    address_line1,
    address_line2,
    city,
    postal_code,
    province_id,
    business_email,
    personal_email,
    phone_no,
    mobile_phone_no,
    fax_no,
    provincial_tax_category,
    federal_tax_category,
    vacation_percentage,
    additional_federal_taxes_retained,
    additional_provincial_taxes_retained,
    health_insurance_amount,
    dental_insurance_amount,
    rrsp_amount,
    employer_rrsp_amount,
    long_term_disability_insurance_amount,
    life_insurance_amount,
    serious_illness_amount,
    cotisation_syndicale_amount,
    default_language,
    employer_health_insurance_contribution_amount,
    employer_dental_insurance_contribution_amount,
    employer_life_insurance_contribution_amount,
    accepts_direct_deposit,
    child_support_amount,
    erp_user_id,
    color,
    erp_user_name,
    active
  )[0]

  Employee.find(result['employee_id'])
end