Module: CompaniesProcedures

Extended by:
ActiveSupport::Concern
Included in:
Company
Defined in:
app/models/concerns/companies_procedures.rb

Instance Method Summary collapse

Instance Method Details

#write_procedure(ship_name: nil, validate: true) ⇒ Object

Raises:

  • (ActiveRecord::RecordInvalid)


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'app/models/concerns/companies_procedures.rb', line 16

def write_procedure(ship_name: nil, validate: true)
  raise ActiveRecord::RecordInvalid.new(self) if validate && !valid?

  result = ActiveRecord::Base.connection.execute_procedure(
    :pr_insert_update_company,
    company_id,
    # self.company_code,
    SecureRandom.uuid,
    company_name_e,
    company_name_f,
    registered_in_country_id,
    address_line1,
    address_line2,
    city,
    province_id,
    postal_code,
    logo_path,
    phone_no,
    fax_no,
    email,
    fob,
    attention,
    ship_name,
    ship_address_line1,
    ship_address_line2,
    ship_city,
    ship_province_id,
    ship_postal_code,
    ship_phone_no,
    ship_fax_no,
    ship_email,
    duns_no,
    home_currency_id || 1,
    current_period,
    decrypted_gst_no || gst_no,
    decrypted_pst_no || pst_no,
    retain_earn_gl,
    closing_entry_gl,
    discount_leeway,
    payments_frequency,
    match_toler_percent,
    match_tolerance_val,
    upc_prefix,
    upc_suffix,
    default_item_volume,
    default_item_weight,
    default_min_quantity,
    default_max_quantity,
    default_box_volume,
    test_company || 0,
    active,
    background_image,
    default_ship_to_warehouse_id,
    website_url,
    division_code,
    logo_image,
    nil,
    tenant_id,
    payroll_frequency || '02',
    default_language,
    employer_cnsst_percentage,
    employer_cnt_percentage,
    federal_identification_no,
    provincial_identification_no,
    business_start_date,
    industry_sector,
    exempt_from_fss,
    exempt_from_fss_end_date,
    neq,
    default_hours_per_week || 0,
    gvt_remittance_frequency || '01'
  )[0]

  updated_company = Company.find(result['company_id'])
  assign_attributes(updated_company.attributes)
  self
end