Class: Dscf::Credit::Loan

Inherits:
ApplicationRecord show all
Defined in:
app/models/dscf/credit/loan.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.ransackable_associations(auth_object = nil) ⇒ Object



27
28
29
# File 'app/models/dscf/credit/loan.rb', line 27

def self.ransackable_associations(auth_object = nil)
  %w[loan_profile credit_line loan_transactions daily_routine_transactions loan_accruals]
end

.ransackable_attributes(auth_object = nil) ⇒ Object



23
24
25
# File 'app/models/dscf/credit/loan.rb', line 23

def self.ransackable_attributes(auth_object = nil)
  %w[id status principal_amount remaining_amount due_date disbursed_at active created_at updated_at]
end

Instance Method Details

#total_facilitation_feeObject



34
35
36
# File 'app/models/dscf/credit/loan.rb', line 34

def total_facilitation_fee
  loan_accruals.where(accrual_type: "facilitation_fee", status: "pending").sum(:amount)
end

#total_interestObject



38
39
40
# File 'app/models/dscf/credit/loan.rb', line 38

def total_interest
  loan_accruals.where(accrual_type: "interest", status: "pending").sum(:amount)
end

#total_outstandingObject



50
51
52
# File 'app/models/dscf/credit/loan.rb', line 50

def total_outstanding
  remaining_amount + loan_accruals.where(status: "pending").sum(:amount)
end

#total_penaltyObject



42
43
44
# File 'app/models/dscf/credit/loan.rb', line 42

def total_penalty
  loan_accruals.where(accrual_type: "penalty", status: "pending").sum(:amount)
end

#total_vatObject



46
47
48
# File 'app/models/dscf/credit/loan.rb', line 46

def total_vat
  loan_accruals.where(accrual_type: "tax", status: "pending").sum(:amount)
end