Class: CreditApplication
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- CreditApplication
- Includes:
- Models::Auditable, Models::LiquidMethods
- Defined in:
- app/models/credit_application.rb
Overview
== Schema Information
Table name: credit_applications
Database name: primary
id :integer not null, primary key
annual_sales :string(255)
bank_account_number :string(255)
bank_account_type :string(255)
bank_address :text
bank_contact :string(255)
bank_fax :string(255)
bank_name :string(255)
bank_phone :string(255)
business_description :string(255)
business_start_date :date
business_type :string(255)
confirm_application_truth :boolean
dba_name :string(255)
employees :string(255)
floor_heating_jobs :string(255)
has_parent_company :boolean
merchandise_for_resale :boolean
notes :text
parent_company_details :text
reference_number :string(255) not null
signature_name :string(255)
signature_title :string(255)
state :string(255)
stores :string(255)
tax_number :string(255)
trade_reference_1_address :text
trade_reference_1_fax :string(255)
trade_reference_1_name :string(255)
trade_reference_1_phone :string(255)
trade_reference_2_address :text
trade_reference_2_fax :string(255)
trade_reference_2_name :string(255)
trade_reference_2_phone :string(255)
trade_reference_3_address :text
trade_reference_3_fax :string(255)
trade_reference_3_name :string(255)
trade_reference_3_phone :string(255)
created_at :datetime
updated_at :datetime
accounts_payable_contact_id :integer
creator_id :integer
customer_id :integer
owner_id :integer
primary_contact_id :integer
purchasing_agent_id :integer
updater_id :integer
Indexes
idx_owner_id (owner_id)
idx_primary_contact_id (primary_contact_id)
idx_purchasing_agent_id (purchasing_agent_id)
idx_reference_number (reference_number)
index_credit_applications_on_accounts_payable_contact_id (accounts_payable_contact_id)
index_credit_applications_on_customer_id (customer_id)
Foreign Keys
fk_rails_... (accounts_payable_contact_id => parties.id)
fk_rails_... (customer_id => parties.id)
fk_rails_... (owner_id => parties.id)
fk_rails_... (primary_contact_id => parties.id)
fk_rails_... (purchasing_agent_id => parties.id)
Constant Summary collapse
- REFERENCE_NUMBER_PATTERN =
/^CA\d+$/i
Constants included from Models::Auditable
Models::Auditable::ALWAYS_IGNORED
Instance Attribute Summary collapse
- #annual_sales ⇒ Object readonly
- #bank_account_number ⇒ Object readonly
- #bank_account_type ⇒ Object readonly
- #bank_address ⇒ Object readonly
- #bank_contact ⇒ Object readonly
- #bank_name ⇒ Object readonly
- #bank_phone ⇒ Object readonly
-
#billing_same_as_mailing ⇒ Object
Returns the value of attribute billing_same_as_mailing.
- #business_description ⇒ Object readonly
- #business_start_date ⇒ Object readonly
- #business_type ⇒ Object readonly
- #confirm_application_truth ⇒ Object readonly
- #employees ⇒ Object readonly
- #floor_heating_jobs ⇒ Object readonly
- #has_parent_company ⇒ Object readonly
- #merchandise_for_resale ⇒ Object readonly
- #parent_company_details ⇒ Object readonly
- #signature_name ⇒ Object readonly
- #signature_title ⇒ Object readonly
- #stores ⇒ Object readonly
- #tax_number ⇒ Object readonly
- #trade_reference_1_address ⇒ Object readonly
- #trade_reference_1_name ⇒ Object readonly
- #trade_reference_1_phone ⇒ Object readonly
- #trade_reference_2_address ⇒ Object readonly
- #trade_reference_2_name ⇒ Object readonly
- #trade_reference_2_phone ⇒ Object readonly
- #trade_reference_3_address ⇒ Object readonly
- #trade_reference_3_name ⇒ Object readonly
- #trade_reference_3_phone ⇒ Object readonly
Belongs to collapse
- #accounts_payable_contact ⇒ Contact
- #customer ⇒ Customer
- #owner ⇒ Contact
- #primary_contact ⇒ Contact
- #purchasing_agent ⇒ Contact
Methods included from Models::Auditable
Class Method Summary collapse
Instance 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::EventPublishable
Instance Attribute Details
#annual_sales ⇒ Object (readonly)
89 90 91 92 93 94 95 96 |
# File 'app/models/credit_application.rb', line 89 validates :annual_sales, :employees, :stores, :floor_heating_jobs, :business_start_date, :business_description, :business_type, :tax_number, :trade_reference_1_name, :trade_reference_1_address, :trade_reference_1_phone, :trade_reference_2_name, :trade_reference_2_address, :trade_reference_2_phone, :trade_reference_3_name, :trade_reference_3_address, :trade_reference_3_phone, :bank_name, :bank_contact, :bank_address, :bank_phone, :bank_account_type, :bank_account_number, :signature_name, :signature_title, presence: true |
#bank_account_number ⇒ Object (readonly)
89 90 91 92 93 94 95 96 |
# File 'app/models/credit_application.rb', line 89 validates :annual_sales, :employees, :stores, :floor_heating_jobs, :business_start_date, :business_description, :business_type, :tax_number, :trade_reference_1_name, :trade_reference_1_address, :trade_reference_1_phone, :trade_reference_2_name, :trade_reference_2_address, :trade_reference_2_phone, :trade_reference_3_name, :trade_reference_3_address, :trade_reference_3_phone, :bank_name, :bank_contact, :bank_address, :bank_phone, :bank_account_type, :bank_account_number, :signature_name, :signature_title, presence: true |
#bank_account_type ⇒ Object (readonly)
89 90 91 92 93 94 95 96 |
# File 'app/models/credit_application.rb', line 89 validates :annual_sales, :employees, :stores, :floor_heating_jobs, :business_start_date, :business_description, :business_type, :tax_number, :trade_reference_1_name, :trade_reference_1_address, :trade_reference_1_phone, :trade_reference_2_name, :trade_reference_2_address, :trade_reference_2_phone, :trade_reference_3_name, :trade_reference_3_address, :trade_reference_3_phone, :bank_name, :bank_contact, :bank_address, :bank_phone, :bank_account_type, :bank_account_number, :signature_name, :signature_title, presence: true |
#bank_address ⇒ Object (readonly)
89 90 91 92 93 94 95 96 |
# File 'app/models/credit_application.rb', line 89 validates :annual_sales, :employees, :stores, :floor_heating_jobs, :business_start_date, :business_description, :business_type, :tax_number, :trade_reference_1_name, :trade_reference_1_address, :trade_reference_1_phone, :trade_reference_2_name, :trade_reference_2_address, :trade_reference_2_phone, :trade_reference_3_name, :trade_reference_3_address, :trade_reference_3_phone, :bank_name, :bank_contact, :bank_address, :bank_phone, :bank_account_type, :bank_account_number, :signature_name, :signature_title, presence: true |
#bank_contact ⇒ Object (readonly)
89 90 91 92 93 94 95 96 |
# File 'app/models/credit_application.rb', line 89 validates :annual_sales, :employees, :stores, :floor_heating_jobs, :business_start_date, :business_description, :business_type, :tax_number, :trade_reference_1_name, :trade_reference_1_address, :trade_reference_1_phone, :trade_reference_2_name, :trade_reference_2_address, :trade_reference_2_phone, :trade_reference_3_name, :trade_reference_3_address, :trade_reference_3_phone, :bank_name, :bank_contact, :bank_address, :bank_phone, :bank_account_type, :bank_account_number, :signature_name, :signature_title, presence: true |
#bank_name ⇒ Object (readonly)
89 90 91 92 93 94 95 96 |
# File 'app/models/credit_application.rb', line 89 validates :annual_sales, :employees, :stores, :floor_heating_jobs, :business_start_date, :business_description, :business_type, :tax_number, :trade_reference_1_name, :trade_reference_1_address, :trade_reference_1_phone, :trade_reference_2_name, :trade_reference_2_address, :trade_reference_2_phone, :trade_reference_3_name, :trade_reference_3_address, :trade_reference_3_phone, :bank_name, :bank_contact, :bank_address, :bank_phone, :bank_account_type, :bank_account_number, :signature_name, :signature_title, presence: true |
#bank_phone ⇒ Object (readonly)
89 90 91 92 93 94 95 96 |
# File 'app/models/credit_application.rb', line 89 validates :annual_sales, :employees, :stores, :floor_heating_jobs, :business_start_date, :business_description, :business_type, :tax_number, :trade_reference_1_name, :trade_reference_1_address, :trade_reference_1_phone, :trade_reference_2_name, :trade_reference_2_address, :trade_reference_2_phone, :trade_reference_3_name, :trade_reference_3_address, :trade_reference_3_phone, :bank_name, :bank_contact, :bank_address, :bank_phone, :bank_account_type, :bank_account_number, :signature_name, :signature_title, presence: true |
#billing_same_as_mailing ⇒ Object
Returns the value of attribute billing_same_as_mailing.
81 82 83 |
# File 'app/models/credit_application.rb', line 81 def billing_same_as_mailing @billing_same_as_mailing end |
#business_description ⇒ Object (readonly)
89 90 91 92 93 94 95 96 |
# File 'app/models/credit_application.rb', line 89 validates :annual_sales, :employees, :stores, :floor_heating_jobs, :business_start_date, :business_description, :business_type, :tax_number, :trade_reference_1_name, :trade_reference_1_address, :trade_reference_1_phone, :trade_reference_2_name, :trade_reference_2_address, :trade_reference_2_phone, :trade_reference_3_name, :trade_reference_3_address, :trade_reference_3_phone, :bank_name, :bank_contact, :bank_address, :bank_phone, :bank_account_type, :bank_account_number, :signature_name, :signature_title, presence: true |
#business_start_date ⇒ Object (readonly)
89 90 91 92 93 94 95 96 |
# File 'app/models/credit_application.rb', line 89 validates :annual_sales, :employees, :stores, :floor_heating_jobs, :business_start_date, :business_description, :business_type, :tax_number, :trade_reference_1_name, :trade_reference_1_address, :trade_reference_1_phone, :trade_reference_2_name, :trade_reference_2_address, :trade_reference_2_phone, :trade_reference_3_name, :trade_reference_3_address, :trade_reference_3_phone, :bank_name, :bank_contact, :bank_address, :bank_phone, :bank_account_type, :bank_account_number, :signature_name, :signature_title, presence: true |
#business_type ⇒ Object (readonly)
89 90 91 92 93 94 95 96 |
# File 'app/models/credit_application.rb', line 89 validates :annual_sales, :employees, :stores, :floor_heating_jobs, :business_start_date, :business_description, :business_type, :tax_number, :trade_reference_1_name, :trade_reference_1_address, :trade_reference_1_phone, :trade_reference_2_name, :trade_reference_2_address, :trade_reference_2_phone, :trade_reference_3_name, :trade_reference_3_address, :trade_reference_3_phone, :bank_name, :bank_contact, :bank_address, :bank_phone, :bank_account_type, :bank_account_number, :signature_name, :signature_title, presence: true |
#confirm_application_truth ⇒ Object (readonly)
100 |
# File 'app/models/credit_application.rb', line 100 validates :confirm_application_truth, acceptance: { accept: true } |
#employees ⇒ Object (readonly)
89 90 91 92 93 94 95 96 |
# File 'app/models/credit_application.rb', line 89 validates :annual_sales, :employees, :stores, :floor_heating_jobs, :business_start_date, :business_description, :business_type, :tax_number, :trade_reference_1_name, :trade_reference_1_address, :trade_reference_1_phone, :trade_reference_2_name, :trade_reference_2_address, :trade_reference_2_phone, :trade_reference_3_name, :trade_reference_3_address, :trade_reference_3_phone, :bank_name, :bank_contact, :bank_address, :bank_phone, :bank_account_type, :bank_account_number, :signature_name, :signature_title, presence: true |
#floor_heating_jobs ⇒ Object (readonly)
89 90 91 92 93 94 95 96 |
# File 'app/models/credit_application.rb', line 89 validates :annual_sales, :employees, :stores, :floor_heating_jobs, :business_start_date, :business_description, :business_type, :tax_number, :trade_reference_1_name, :trade_reference_1_address, :trade_reference_1_phone, :trade_reference_2_name, :trade_reference_2_address, :trade_reference_2_phone, :trade_reference_3_name, :trade_reference_3_address, :trade_reference_3_phone, :bank_name, :bank_contact, :bank_address, :bank_phone, :bank_account_type, :bank_account_number, :signature_name, :signature_title, presence: true |
#has_parent_company ⇒ Object (readonly)
98 |
# File 'app/models/credit_application.rb', line 98 validates :merchandise_for_resale, :has_parent_company, inclusion: { in: [true, false] } |
#merchandise_for_resale ⇒ Object (readonly)
98 |
# File 'app/models/credit_application.rb', line 98 validates :merchandise_for_resale, :has_parent_company, inclusion: { in: [true, false] } |
#parent_company_details ⇒ Object (readonly)
99 |
# File 'app/models/credit_application.rb', line 99 validates :parent_company_details, presence: true, if: :has_parent_company? |
#signature_name ⇒ Object (readonly)
89 90 91 92 93 94 95 96 |
# File 'app/models/credit_application.rb', line 89 validates :annual_sales, :employees, :stores, :floor_heating_jobs, :business_start_date, :business_description, :business_type, :tax_number, :trade_reference_1_name, :trade_reference_1_address, :trade_reference_1_phone, :trade_reference_2_name, :trade_reference_2_address, :trade_reference_2_phone, :trade_reference_3_name, :trade_reference_3_address, :trade_reference_3_phone, :bank_name, :bank_contact, :bank_address, :bank_phone, :bank_account_type, :bank_account_number, :signature_name, :signature_title, presence: true |
#signature_title ⇒ Object (readonly)
89 90 91 92 93 94 95 96 |
# File 'app/models/credit_application.rb', line 89 validates :annual_sales, :employees, :stores, :floor_heating_jobs, :business_start_date, :business_description, :business_type, :tax_number, :trade_reference_1_name, :trade_reference_1_address, :trade_reference_1_phone, :trade_reference_2_name, :trade_reference_2_address, :trade_reference_2_phone, :trade_reference_3_name, :trade_reference_3_address, :trade_reference_3_phone, :bank_name, :bank_contact, :bank_address, :bank_phone, :bank_account_type, :bank_account_number, :signature_name, :signature_title, presence: true |
#stores ⇒ Object (readonly)
89 90 91 92 93 94 95 96 |
# File 'app/models/credit_application.rb', line 89 validates :annual_sales, :employees, :stores, :floor_heating_jobs, :business_start_date, :business_description, :business_type, :tax_number, :trade_reference_1_name, :trade_reference_1_address, :trade_reference_1_phone, :trade_reference_2_name, :trade_reference_2_address, :trade_reference_2_phone, :trade_reference_3_name, :trade_reference_3_address, :trade_reference_3_phone, :bank_name, :bank_contact, :bank_address, :bank_phone, :bank_account_type, :bank_account_number, :signature_name, :signature_title, presence: true |
#tax_number ⇒ Object (readonly)
89 90 91 92 93 94 95 96 |
# File 'app/models/credit_application.rb', line 89 validates :annual_sales, :employees, :stores, :floor_heating_jobs, :business_start_date, :business_description, :business_type, :tax_number, :trade_reference_1_name, :trade_reference_1_address, :trade_reference_1_phone, :trade_reference_2_name, :trade_reference_2_address, :trade_reference_2_phone, :trade_reference_3_name, :trade_reference_3_address, :trade_reference_3_phone, :bank_name, :bank_contact, :bank_address, :bank_phone, :bank_account_type, :bank_account_number, :signature_name, :signature_title, presence: true |
#trade_reference_1_address ⇒ Object (readonly)
89 90 91 92 93 94 95 96 |
# File 'app/models/credit_application.rb', line 89 validates :annual_sales, :employees, :stores, :floor_heating_jobs, :business_start_date, :business_description, :business_type, :tax_number, :trade_reference_1_name, :trade_reference_1_address, :trade_reference_1_phone, :trade_reference_2_name, :trade_reference_2_address, :trade_reference_2_phone, :trade_reference_3_name, :trade_reference_3_address, :trade_reference_3_phone, :bank_name, :bank_contact, :bank_address, :bank_phone, :bank_account_type, :bank_account_number, :signature_name, :signature_title, presence: true |
#trade_reference_1_name ⇒ Object (readonly)
89 90 91 92 93 94 95 96 |
# File 'app/models/credit_application.rb', line 89 validates :annual_sales, :employees, :stores, :floor_heating_jobs, :business_start_date, :business_description, :business_type, :tax_number, :trade_reference_1_name, :trade_reference_1_address, :trade_reference_1_phone, :trade_reference_2_name, :trade_reference_2_address, :trade_reference_2_phone, :trade_reference_3_name, :trade_reference_3_address, :trade_reference_3_phone, :bank_name, :bank_contact, :bank_address, :bank_phone, :bank_account_type, :bank_account_number, :signature_name, :signature_title, presence: true |
#trade_reference_1_phone ⇒ Object (readonly)
89 90 91 92 93 94 95 96 |
# File 'app/models/credit_application.rb', line 89 validates :annual_sales, :employees, :stores, :floor_heating_jobs, :business_start_date, :business_description, :business_type, :tax_number, :trade_reference_1_name, :trade_reference_1_address, :trade_reference_1_phone, :trade_reference_2_name, :trade_reference_2_address, :trade_reference_2_phone, :trade_reference_3_name, :trade_reference_3_address, :trade_reference_3_phone, :bank_name, :bank_contact, :bank_address, :bank_phone, :bank_account_type, :bank_account_number, :signature_name, :signature_title, presence: true |
#trade_reference_2_address ⇒ Object (readonly)
89 90 91 92 93 94 95 96 |
# File 'app/models/credit_application.rb', line 89 validates :annual_sales, :employees, :stores, :floor_heating_jobs, :business_start_date, :business_description, :business_type, :tax_number, :trade_reference_1_name, :trade_reference_1_address, :trade_reference_1_phone, :trade_reference_2_name, :trade_reference_2_address, :trade_reference_2_phone, :trade_reference_3_name, :trade_reference_3_address, :trade_reference_3_phone, :bank_name, :bank_contact, :bank_address, :bank_phone, :bank_account_type, :bank_account_number, :signature_name, :signature_title, presence: true |
#trade_reference_2_name ⇒ Object (readonly)
89 90 91 92 93 94 95 96 |
# File 'app/models/credit_application.rb', line 89 validates :annual_sales, :employees, :stores, :floor_heating_jobs, :business_start_date, :business_description, :business_type, :tax_number, :trade_reference_1_name, :trade_reference_1_address, :trade_reference_1_phone, :trade_reference_2_name, :trade_reference_2_address, :trade_reference_2_phone, :trade_reference_3_name, :trade_reference_3_address, :trade_reference_3_phone, :bank_name, :bank_contact, :bank_address, :bank_phone, :bank_account_type, :bank_account_number, :signature_name, :signature_title, presence: true |
#trade_reference_2_phone ⇒ Object (readonly)
89 90 91 92 93 94 95 96 |
# File 'app/models/credit_application.rb', line 89 validates :annual_sales, :employees, :stores, :floor_heating_jobs, :business_start_date, :business_description, :business_type, :tax_number, :trade_reference_1_name, :trade_reference_1_address, :trade_reference_1_phone, :trade_reference_2_name, :trade_reference_2_address, :trade_reference_2_phone, :trade_reference_3_name, :trade_reference_3_address, :trade_reference_3_phone, :bank_name, :bank_contact, :bank_address, :bank_phone, :bank_account_type, :bank_account_number, :signature_name, :signature_title, presence: true |
#trade_reference_3_address ⇒ Object (readonly)
89 90 91 92 93 94 95 96 |
# File 'app/models/credit_application.rb', line 89 validates :annual_sales, :employees, :stores, :floor_heating_jobs, :business_start_date, :business_description, :business_type, :tax_number, :trade_reference_1_name, :trade_reference_1_address, :trade_reference_1_phone, :trade_reference_2_name, :trade_reference_2_address, :trade_reference_2_phone, :trade_reference_3_name, :trade_reference_3_address, :trade_reference_3_phone, :bank_name, :bank_contact, :bank_address, :bank_phone, :bank_account_type, :bank_account_number, :signature_name, :signature_title, presence: true |
#trade_reference_3_name ⇒ Object (readonly)
89 90 91 92 93 94 95 96 |
# File 'app/models/credit_application.rb', line 89 validates :annual_sales, :employees, :stores, :floor_heating_jobs, :business_start_date, :business_description, :business_type, :tax_number, :trade_reference_1_name, :trade_reference_1_address, :trade_reference_1_phone, :trade_reference_2_name, :trade_reference_2_address, :trade_reference_2_phone, :trade_reference_3_name, :trade_reference_3_address, :trade_reference_3_phone, :bank_name, :bank_contact, :bank_address, :bank_phone, :bank_account_type, :bank_account_number, :signature_name, :signature_title, presence: true |
#trade_reference_3_phone ⇒ Object (readonly)
89 90 91 92 93 94 95 96 |
# File 'app/models/credit_application.rb', line 89 validates :annual_sales, :employees, :stores, :floor_heating_jobs, :business_start_date, :business_description, :business_type, :tax_number, :trade_reference_1_name, :trade_reference_1_address, :trade_reference_1_phone, :trade_reference_2_name, :trade_reference_2_address, :trade_reference_2_phone, :trade_reference_3_name, :trade_reference_3_address, :trade_reference_3_phone, :bank_name, :bank_contact, :bank_address, :bank_phone, :bank_account_type, :bank_account_number, :signature_name, :signature_title, presence: true |
Class Method Details
.states_for_select ⇒ Object
130 131 132 |
# File 'app/models/credit_application.rb', line 130 def self.states_for_select state_machines[:state].states.map { |s| [s.human_name, s.value] } end |
Instance Method Details
#accounts_payable_contact ⇒ Contact
78 |
# File 'app/models/credit_application.rb', line 78 belongs_to :accounts_payable_contact, class_name: 'Contact', optional: true |
#create_decision_activity(decision, email_template) ⇒ Object
134 135 136 137 138 139 140 141 142 143 |
# File 'app/models/credit_application.rb', line 134 def create_decision_activity(decision, email_template) activity = Activity.new(activity_type_id: ActivityTypeConstants::CRDAPP, target_datetime: Time.current, completion_datetime: Time.current, notes: "Credit Application #{decision}. Accounting Notes: #{notes}", assigned_resource_id: CurrentScope.user_id, activity_result_type_id: 2, party_id: customer_id, resource: self) activity.save! com = CommunicationBuilder.new(resource: self, template_system_code: email_template, recipient_contact_point_id: begin primary_contact.first_contact_point_by_category(ContactPoint::EMAIL).id rescue StandardError nil end).create end |
#customer ⇒ Customer
75 |
# File 'app/models/credit_application.rb', line 75 belongs_to :customer, optional: true |
#owner ⇒ Contact
77 |
# File 'app/models/credit_application.rb', line 77 belongs_to :owner, class_name: 'Contact', optional: true |
#primary_contact ⇒ Contact
76 |
# File 'app/models/credit_application.rb', line 76 belongs_to :primary_contact, class_name: 'Contact', optional: true |
#purchasing_agent ⇒ Contact
79 |
# File 'app/models/credit_application.rb', line 79 belongs_to :purchasing_agent, class_name: 'Contact', optional: true |
#to_s ⇒ Object
145 146 147 |
# File 'app/models/credit_application.rb', line 145 def to_s "Credit Application # #{reference_number}" end |