Class: Dscf::Credit::LoanProfileCreationService
- Inherits:
-
Object
- Object
- Dscf::Credit::LoanProfileCreationService
- Defined in:
- app/services/dscf/credit/loan_profile_creation_service.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#loan_application ⇒ Object
readonly
Returns the value of attribute loan_application.
-
#score ⇒ Object
readonly
Returns the value of attribute score.
Instance Method Summary collapse
- #create_loan_profile ⇒ Object
-
#initialize(loan_application, score, scoring_result_data = {}) ⇒ LoanProfileCreationService
constructor
A new instance of LoanProfileCreationService.
Constructor Details
#initialize(loan_application, score, scoring_result_data = {}) ⇒ LoanProfileCreationService
Returns a new instance of LoanProfileCreationService.
5 6 7 8 9 10 |
# File 'app/services/dscf/credit/loan_profile_creation_service.rb', line 5 def initialize(loan_application, score, scoring_result_data = {}) @loan_application = loan_application @score = score @scoring_result_data = scoring_result_data @errors = [] end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
3 4 5 |
# File 'app/services/dscf/credit/loan_profile_creation_service.rb', line 3 def errors @errors end |
#loan_application ⇒ Object (readonly)
Returns the value of attribute loan_application.
3 4 5 |
# File 'app/services/dscf/credit/loan_profile_creation_service.rb', line 3 def loan_application @loan_application end |
#score ⇒ Object (readonly)
Returns the value of attribute score.
3 4 5 |
# File 'app/services/dscf/credit/loan_profile_creation_service.rb', line 3 def score @score end |
Instance Method Details
#create_loan_profile ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/services/dscf/credit/loan_profile_creation_service.rb', line 12 def create_loan_profile return error_result("Loan application is required") unless loan_application return error_result("Score is required") unless score if loan_application.loan_profile.present? return success_result(loan_application.loan_profile, "Loan profile already exists") end begin ActiveRecord::Base.transaction do loan_profile = build_loan_profile loan_profile.save! create_initial_review(loan_profile) create_scoring_result(loan_profile) calculate_facility_limits(loan_profile) success_result(loan_profile, "Loan profile created successfully") end rescue StandardError => e Rails.logger.error "Loan profile creation failed: #{e.}" Rails.logger.error e.backtrace.join("\n") error_result("Failed to create loan profile: #{e.}") end end |