dscf-credit 0.2.6 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36671cda01df2f1f1b75625ccd3bb1ba23b16f97d410c498d89f0a93af02ac84
|
4
|
+
data.tar.gz: d84818826abcfb81ad715806b7383c1ed3aa64672e7e58460af664e65c46ca0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df917f92170265597d7a3dacbab1f099fdcf41fb7c8c2c5c1a37733776aa650d28dd11367064a899edd2e210316c9ebacaf11576f7196dd1014f745064711b1d
|
7
|
+
data.tar.gz: 26b4b04ca0313bff6f1fd9d8c15116f335c57dac0489f19383b1bf7849280d648338749fedc464401943a5845996ec46cfe84024eecac3adc985ecadbbbf31a3
|
@@ -1,6 +1,10 @@
|
|
1
1
|
module Dscf::Credit
|
2
2
|
class LoanProfileSerializer < ActiveModel::Serializer
|
3
|
-
attributes :id, :code, :score, :total_limit, :created_at, :updated_at
|
3
|
+
attributes :id, :code, :score, :total_limit, :created_at, :updated_at, :user_id
|
4
|
+
|
5
|
+
attribute :user_id do
|
6
|
+
object.loan_application.user_id
|
7
|
+
end
|
4
8
|
|
5
9
|
belongs_to :loan_application, serializer: Dscf::Credit::LoanApplicationSerializer
|
6
10
|
|
@@ -12,9 +12,14 @@ module Dscf::Credit
|
|
12
12
|
:total_facilitation_fee,
|
13
13
|
:total_outstanding,
|
14
14
|
:active,
|
15
|
+
:user_id,
|
15
16
|
:created_at,
|
16
17
|
:updated_at
|
17
18
|
|
19
|
+
attribute :user_id do
|
20
|
+
object.loan_profile.loan_application.user_id
|
21
|
+
end
|
22
|
+
|
18
23
|
belongs_to :loan_profile, serializer: LoanProfileSerializer
|
19
24
|
belongs_to :credit_line, serializer: CreditLineSerializer
|
20
25
|
has_many :loan_transactions, serializer: LoanTransactionSerializer
|
@@ -82,9 +82,6 @@ module Dscf::Credit
|
|
82
82
|
# Create facilitator fee accrual
|
83
83
|
create_facilitator_fee_accrual(loan, loan_terms[:facilitation_fee])
|
84
84
|
|
85
|
-
# Create VAT accrual if applicable
|
86
|
-
create_vat_accrual(loan, loan_terms[:vat_amount]) if loan_terms[:vat_amount] > 0
|
87
|
-
|
88
85
|
loan
|
89
86
|
end
|
90
87
|
|
@@ -99,18 +96,15 @@ module Dscf::Credit
|
|
99
96
|
end
|
100
97
|
|
101
98
|
facilitation_rate = credit_line_spec.facilitation_fee_rate
|
102
|
-
vat_rate = credit_line_spec.vat
|
103
99
|
loan_duration = credit_line_spec.loan_duration
|
104
100
|
|
105
101
|
facilitation_fee = principal * facilitation_rate
|
106
|
-
|
107
|
-
total_amount = principal + facilitation_fee + vat_amount
|
102
|
+
total_amount = principal + facilitation_fee
|
108
103
|
|
109
104
|
due_date = Date.current + loan_duration.days
|
110
105
|
|
111
106
|
{
|
112
107
|
facilitation_fee: facilitation_fee.round(2),
|
113
|
-
vat_amount: vat_amount.round(2),
|
114
108
|
total_amount: total_amount.round(2),
|
115
109
|
due_date: due_date
|
116
110
|
}
|
@@ -128,23 +122,10 @@ module Dscf::Credit
|
|
128
122
|
)
|
129
123
|
end
|
130
124
|
|
131
|
-
def create_vat_accrual(loan, vat_amount)
|
132
|
-
return if vat_amount <= 0
|
133
|
-
|
134
|
-
Dscf::Credit::LoanAccrual.create!(
|
135
|
-
loan: loan,
|
136
|
-
accrual_type: "tax",
|
137
|
-
amount: vat_amount,
|
138
|
-
applied_on: Date.current,
|
139
|
-
status: "pending"
|
140
|
-
)
|
141
|
-
end
|
142
|
-
|
143
125
|
def update_credit_line_limits(loan)
|
144
|
-
# Calculate total amount from accruals: principal + facilitation_fee
|
126
|
+
# Calculate total amount from accruals: principal + facilitation_fee
|
145
127
|
facilitation_fee = loan.loan_accruals.find_by(accrual_type: "facilitation_fee")&.amount || 0
|
146
|
-
|
147
|
-
total_amount = loan.principal_amount + facilitation_fee + vat
|
128
|
+
total_amount = loan.principal_amount + facilitation_fee
|
148
129
|
|
149
130
|
new_available_limit = eligible_credit_line.available_limit - total_amount
|
150
131
|
eligible_credit_line.update!(available_limit: [ new_available_limit, 0 ].max)
|
@@ -155,11 +136,9 @@ module Dscf::Credit
|
|
155
136
|
loan.reload
|
156
137
|
|
157
138
|
facilitation_fee_accrual = loan.loan_accruals.find_by(accrual_type: "facilitation_fee")
|
158
|
-
vat_accrual = loan.loan_accruals.find_by(accrual_type: "tax")
|
159
139
|
|
160
140
|
facilitation_fee = facilitation_fee_accrual&.amount&.to_f || 0.0
|
161
|
-
|
162
|
-
total_amount = loan.principal_amount.to_f + facilitation_fee + vat_amount
|
141
|
+
total_amount = loan.principal_amount.to_f + facilitation_fee
|
163
142
|
|
164
143
|
{
|
165
144
|
success: true,
|
@@ -167,7 +146,6 @@ module Dscf::Credit
|
|
167
146
|
disbursement_details: {
|
168
147
|
principal_amount: loan.principal_amount.to_f,
|
169
148
|
facilitation_fee: facilitation_fee,
|
170
|
-
vat_amount: vat_amount,
|
171
149
|
total_loan_amount: total_amount,
|
172
150
|
due_date: loan.due_date,
|
173
151
|
disbursed_at: loan.disbursed_at
|
data/lib/dscf/credit/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dscf-credit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adoniyas
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-10-
|
10
|
+
date: 2025-10-09 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: dscf-core
|