Class: Supplier
Constant Summary
collapse
- ENTITY_TYPE =
'S'.freeze
- COMPANY_CODE =
Rails.application.config.company_code
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from HasAddress
#address, #comma_separated_address, #line_separated_address, #space_separated_address
define_decrypted_attribute, define_decrypted_attributes, #errors_in_bullet_points, primary_connection, special_connection
Class Method Details
.store_translations_table_data(head_office_key:, offset:, limit:) ⇒ Object
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
# File 'app/models/supplier.rb', line 75
def self.store_translations_table_data(
head_office_key:,
offset:,
limit:
)
query = <<-SQL
SELECT
s.supplier_id AS partner_id,
s.supplier_code AS code,
s.description AS name,
s.edi_store_code AS edi_store_code,
s.address_line1 AS address_line1,
s.address_line2 AS address_line2,
s.city AS city,
s.postal_code AS postal_code,
s.active AS active
FROM
suppliers s
WHERE
s.supplier_id = ?
ORDER BY
s.supplier_id
OFFSET ? ROWS
FETCH NEXT ? ROWS ONLY;
SQL
Customer.find_by_sql([query, head_office_key, offset, limit])
end
|
Instance Method Details
#country_description ⇒ Object
38
39
40
|
# File 'app/models/supplier.rb', line 38
def country_description
country&.description
end
|
#currency ⇒ Object
42
43
44
|
# File 'app/models/supplier.rb', line 42
def currency
supplier_by_company&.currency
end
|
#currency_code ⇒ Object
46
47
48
|
# File 'app/models/supplier.rb', line 46
def currency_code
currency&.code
end
|
#currency_id ⇒ Object
50
51
52
|
# File 'app/models/supplier.rb', line 50
def currency_id
currency&.currency_id
end
|
#edi_partner ⇒ Object
18
19
20
|
# File 'app/models/supplier.rb', line 18
def edi_partner
EdiPartner.find_by(entity_type: ENTITY_TYPE, head_office_id: supplier_id)
end
|
#edi_sku_translations ⇒ Object
22
23
24
|
# File 'app/models/supplier.rb', line 22
def edi_sku_translations
EdiSkuTranslation.where(translation_type: ENTITY_TYPE, customer_supplier_id: supplier_id)
end
|
#entity_type ⇒ Object
71
72
73
|
# File 'app/models/supplier.rb', line 71
def entity_type
ENTITY_TYPE
end
|
#language_option ⇒ Object
58
59
60
61
62
63
64
65
|
# File 'app/models/supplier.rb', line 58
def language_option
case language
when 'E'
Language::ENGLISH
when 'F'
Language::FRENCH
end
end
|
#our_code_at_supplier ⇒ Object
26
27
28
|
# File 'app/models/supplier.rb', line 26
def our_code_at_supplier
supplier_by_company&.our_code_at_supplier
end
|
#payment_terms ⇒ Object
30
31
32
|
# File 'app/models/supplier.rb', line 30
def payment_terms
supplier_by_company&.payment_terms
end
|
#payment_terms_description ⇒ Object
34
35
36
|
# File 'app/models/supplier.rb', line 34
def payment_terms_description
payment_terms&.description
end
|
#province_description ⇒ Object
54
55
56
|
# File 'app/models/supplier.rb', line 54
def province_description
province&.description
end
|
#supplier_by_company ⇒ Object
67
68
69
|
# File 'app/models/supplier.rb', line 67
def supplier_by_company
supplier_by_companies&.find_by(company_code: COMPANY_CODE)
end
|