Class: Dscf::Credit::LoanTransactionCreatorService
- Inherits:
-
Object
- Object
- Dscf::Credit::LoanTransactionCreatorService
- Defined in:
- app/services/dscf/credit/loan_transaction_creator_service.rb
Overview
Service for creating loan transaction records Handles transaction creation with automatic reference generation
Constant Summary collapse
- TRANSACTION_PREFIXES =
Transaction type prefixes for reference generation
{ "disbursement" => "DSB", "repayment" => "RPY", "interest_accrual" => "INT", "penalty" => "PEN", "fee_charge" => "FEE", "reversal" => "REV", "adjustment" => "ADJ" }.freeze
Instance Attribute Summary collapse
-
#loan ⇒ Object
readonly
Returns the value of attribute loan.
Instance Method Summary collapse
-
#create_transaction(transaction_type:, amount:, status: "completed") ⇒ Dscf::Credit::LoanTransaction
Create a loan transaction record.
-
#initialize(loan) ⇒ LoanTransactionCreatorService
constructor
A new instance of LoanTransactionCreatorService.
Constructor Details
#initialize(loan) ⇒ LoanTransactionCreatorService
Returns a new instance of LoanTransactionCreatorService.
34 35 36 |
# File 'app/services/dscf/credit/loan_transaction_creator_service.rb', line 34 def initialize(loan) @loan = loan end |
Instance Attribute Details
#loan ⇒ Object (readonly)
Returns the value of attribute loan.
21 22 23 |
# File 'app/services/dscf/credit/loan_transaction_creator_service.rb', line 21 def loan @loan end |
Instance Method Details
#create_transaction(transaction_type:, amount:, status: "completed") ⇒ Dscf::Credit::LoanTransaction
Create a loan transaction record
44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/services/dscf/credit/loan_transaction_creator_service.rb', line 44 def create_transaction(transaction_type:, amount:, status: "completed") transaction_reference = generate_transaction_reference(transaction_type) Dscf::Credit::LoanTransaction.create!( loan: loan, transaction_type: transaction_type, amount: amount, transaction_reference: transaction_reference, status: status ) end |