Class: Contact
Constant Summary
collapse
- REFERENCES =
{
COMPANY: 'Contact'
}
- TYPES =
{
CFO: {
TYPE: '04',
USER: true
}
}
RegexPatterns::PHONE
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from HasPhone
format_phone
Methods included from HasAddress
#address, #comma_separated_address, #line_separated_address, #space_separated_address
#write_procedure
define_decrypted_attribute, define_decrypted_attributes, #errors_in_bullet_points, primary_connection, special_connection
Class Method Details
39
40
41
42
43
44
45
46
47
|
# File 'app/models/contact.rb', line 39
def contact_categories_with_user_required_flag
types_requiring_user = Contact::TYPES.map { |_key, value| value[:TYPE] }
TypesMaster.contact_categories.map do |type|
type = type.attributes
type['user_required'] = types_requiring_user.include?(type['type'])
type
end
end
|
.create_from_user_for_company(user:, company:, category_type:) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
|
# File 'app/models/contact.rb', line 23
def create_from_user_for_company(user:, company:, category_type:)
new(
active: true,
reference: Contact::REFERENCES[:COMPANY],
reference_id: company.company_id,
company_id: company.company_id,
position: category_type,
erp_user_id: user.erp_user_id
).write_procedure(user_name: user.truncated_email)
end
|
.type_requires_user?(type) ⇒ Boolean
35
36
37
|
# File 'app/models/contact.rb', line 35
def type_requires_user?(type)
TYPES.values.find { |t| t[:TYPE] == type }&.fetch(:USER, false)
end
|
Instance Method Details
#address_line1 ⇒ Object
99
100
101
|
# File 'app/models/contact.rb', line 99
def address_line1
address1
end
|
#address_line2 ⇒ Object
103
104
105
|
# File 'app/models/contact.rb', line 103
def address_line2
address2
end
|
91
92
93
|
# File 'app/models/contact.rb', line 91
def formatted_cell_phone_no
HasPhone.format_phone(cell_phone_no)
end
|
87
88
89
|
# File 'app/models/contact.rb', line 87
def formatted_phone_no
HasPhone.format_phone(phone_no)
end
|
#language_option ⇒ Object
95
96
97
|
# File 'app/models/contact.rb', line 95
def language_option
Language.new(language).to_h
end
|
#position_description ⇒ Object
83
84
85
|
# File 'app/models/contact.rb', line 83
def position_description
TypesMaster.contact_categories.find_by(type: position)&.type_description
end
|