Class: IdentificationNumber

Inherits:
ApplicationRecord show all
Includes:
Models::Auditable
Defined in:
app/models/identification_number.rb

Overview

== Schema Information

Table name: identification_numbers
Database name: primary

id :integer not null, primary key
category :text
number :string(255)
created_at :datetime
updated_at :datetime
customer_id :integer

Indexes

index_identification_numbers_on_customer_id (customer_id)

Constant Summary collapse

MAIN_US =

Main us.

"EIN/Fed. Tax ID".freeze
MAIN_CA =

Main ca.

"".freeze

Constants included from Models::Auditable

Models::Auditable::ALWAYS_IGNORED

Constants included from Models::Schedulable

Models::Schedulable::SIMPLE_FORM_OPTIONS

Instance Attribute Summary collapse

Belongs to collapse

Methods included from Models::Auditable

#creator, #updater

Class Method Summary collapse

Methods included from Models::Auditable

#all_skipped_columns, #audit_reference_data, #should_not_save_version, #stamp_record

Methods inherited from ApplicationRecord

ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation

Methods included from Models::Schedulable

config

Methods included from Models::AfterCommittable

#after_commit

Methods included from Models::EventPublishable

#publish_event

Instance Attribute Details

#categoryString

Returns Category of identification number.

Returns:

  • (String)

    Category of identification number.



28
# File 'app/models/identification_number.rb', line 28

validates :category, presence: { message: "can't be blank" }

#numberString

Returns The identification number value.

Returns:

  • (String)

    The identification number value.

Validations:

  • Numericality ({ only_integer: true, if: proc { |i| i.category == "Business Number (BN)" } })
  • Length ({ in: 6..15, if: proc { |i| i.category == "Business Number (BN)" } })
  • Format ({ with: /\A[0-9]{2}-[0-9]{7}\z/, if: proc { |i| i.category == "EIN/Fed. Tax ID" } })


25
# File 'app/models/identification_number.rb', line 25

validates :number, presence: true

Class Method Details

.categoriesArray<Array(String, String)>

Returns:

  • (Array<Array(String, String)>)


45
46
47
48
49
50
51
52
# File 'app/models/identification_number.rb', line 45

def self.categories
  [["EIN/Fed. Tax ID", "EIN/Fed. Tax ID"],
   ["Business Number (BN)", "Business Number (BN)"],
   ["Home Improvement License", "Home Improvement License"],
   ["Village License", "Village License"],
   ["D-U-N-S Number", "D-U-N-S Number"],
   ["Other (please specify)", "Other"]]
end

Instance Method Details

#customerCustomer

Returns:



21
# File 'app/models/identification_number.rb', line 21

belongs_to :customer, optional: true