Class: Vendor

Inherits:
Object
  • Object
show all
Defined in:
app/models/vendor.rb

Class Method Summary collapse

Class Method Details

.find(supplier_id:, show_active_only: false, text: '') ⇒ Object



51
52
53
54
55
56
57
# File 'app/models/vendor.rb', line 51

def find(
  supplier_id:,
  show_active_only: false,
  text: ''
)
  Supplier.find(supplier_id)
end

.where(supplier_id: '', display_length: 1_000_000, search_value: '', display_start: 0, column_names: '', column_directions: '', groupping: '') ⇒ Object

returned_rows = [ “rowNumber”,

"supplier_id",
"supplier_code",
"supplier_name",
"city",
"province_description",
"postal_code",
"phone_no",
"category_description",
"industry",
"active",
"sql_search_string",
"DisplayRecords",
"TotalRecords"

]



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
# File 'app/models/vendor.rb', line 18

def where(
  supplier_id: '',
  display_length: 1_000_000,
  search_value: '',
  display_start: 0,
  column_names: '',
  column_directions: '',
  groupping: ''
)
  raw_data = ActiveRecord::Base.execute_procedure(
    'pr_get_supplier_by_page_kendo',
    supplier_id,
    display_length,
    search_value,
    display_start,
    column_names,
    column_directions,
    groupping
  )
  raw_data.map do |supplier|
    {
      id: supplier['supplier_id'],
      code: supplier['supplier_code'],
      name: supplier['supplier_name'],
      city: supplier['city'],
      province: supplier['province_description'],
      postal_code: supplier['postal_code'],
      phone_no: supplier['phone_no'],
      active: supplier['active']
    }
  end
end