dscf-credit 0.1.7 → 0.1.8
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 +4 -4
- data/app/controllers/dscf/credit/loan_accruals_controller.rb +113 -0
- data/app/controllers/dscf/credit/loan_applications_controller.rb +5 -5
- data/app/controllers/dscf/credit/loan_profiles_controller.rb +2 -2
- data/app/controllers/dscf/credit/loans_controller.rb +2 -6
- data/app/controllers/dscf/credit/repayments_controller.rb +3 -3
- data/app/controllers/dscf/credit/scoring_parameters_controller.rb +1 -1
- data/app/controllers/dscf/credit/users_controller.rb +6 -0
- data/app/jobs/dscf/credit/generate_daily_accruals_job.rb +78 -0
- data/app/models/dscf/credit/loan.rb +26 -5
- data/app/models/dscf/credit/loan_accrual.rb +25 -0
- data/app/serializers/dscf/credit/loan_accrual_serializer.rb +7 -0
- data/app/serializers/dscf/credit/loan_serializer.rb +24 -2
- data/app/services/dscf/credit/credit_scoring_engine.rb +8 -8
- data/app/services/dscf/credit/disbursement_service.rb +50 -8
- data/app/services/dscf/credit/loan_accrual_generator_service.rb +272 -0
- data/app/services/dscf/credit/repayment_service.rb +216 -87
- data/config/locales/en.yml +34 -0
- data/config/routes.rb +6 -0
- data/db/migrate/20250822092654_create_dscf_credit_loans.rb +0 -4
- data/db/migrate/20251003132939_create_dscf_credit_loan_accruals.rb +19 -0
- data/db/seeds.rb +20 -5
- data/lib/dscf/credit/version.rb +1 -1
- data/spec/factories/dscf/credit/loan_accruals.rb +29 -0
- data/spec/factories/dscf/credit/loans.rb +0 -4
- metadata +9 -2
data/config/routes.rb
CHANGED
@@ -3,6 +3,12 @@ Dscf::Credit::Engine.routes.draw do
|
|
3
3
|
resources :bank_branches
|
4
4
|
resources :payments
|
5
5
|
resources :loans
|
6
|
+
resources :loan_accruals do
|
7
|
+
collection do
|
8
|
+
post :generate
|
9
|
+
get :statistics
|
10
|
+
end
|
11
|
+
end
|
6
12
|
resources :scoring_param_types
|
7
13
|
|
8
14
|
resources :facilitators do
|
@@ -5,10 +5,6 @@ class CreateDscfCreditLoans < ActiveRecord::Migration[8.0]
|
|
5
5
|
t.references :credit_line, null: false, foreign_key: { to_table: :dscf_credit_credit_lines }
|
6
6
|
t.string :status, default: 'pending'
|
7
7
|
t.decimal :principal_amount, precision: 15, scale: 2, null: false
|
8
|
-
t.decimal :accrued_interest, precision: 15, scale: 2, default: 0
|
9
|
-
t.decimal :accrued_penalty, precision: 15, scale: 2, default: 0
|
10
|
-
t.decimal :facilitation_fee, precision: 15, scale: 2, default: 0
|
11
|
-
t.decimal :total_loan_amount, precision: 15, scale: 2, null: false
|
12
8
|
t.decimal :remaining_amount, precision: 15, scale: 2, null: false
|
13
9
|
t.date :due_date, null: false
|
14
10
|
t.datetime :disbursed_at
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class CreateDscfCreditLoanAccruals < ActiveRecord::Migration[8.0]
|
2
|
+
def change
|
3
|
+
create_table :dscf_credit_loan_accruals do |t|
|
4
|
+
t.references :loan, null: false, foreign_key: { to_table: :dscf_credit_loans }
|
5
|
+
t.string :accrual_type, null: false
|
6
|
+
t.decimal :amount, precision: 15, scale: 2, null: false
|
7
|
+
t.date :applied_on, null: false
|
8
|
+
t.string :status, default: 'pending', null: false
|
9
|
+
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
|
13
|
+
add_index :dscf_credit_loan_accruals, :accrual_type
|
14
|
+
add_index :dscf_credit_loan_accruals, :applied_on
|
15
|
+
add_index :dscf_credit_loan_accruals, :status
|
16
|
+
add_index :dscf_credit_loan_accruals, [ :loan_id, :accrual_type ]
|
17
|
+
add_index :dscf_credit_loan_accruals, [ :loan_id, :status ]
|
18
|
+
end
|
19
|
+
end
|
data/db/seeds.rb
CHANGED
@@ -811,16 +811,30 @@ loan1 = Dscf::Credit::Loan.create!(
|
|
811
811
|
credit_line: credit_line1,
|
812
812
|
status: 'active',
|
813
813
|
principal_amount: 50000.00,
|
814
|
-
|
815
|
-
accrued_penalty: 0.00,
|
816
|
-
facilitation_fee: 1000.00,
|
817
|
-
total_loan_amount: 53500.00,
|
818
|
-
remaining_amount: 53500.00,
|
814
|
+
remaining_amount: 50000.00,
|
819
815
|
due_date: 3.months.from_now.to_date,
|
820
816
|
disbursed_at: 1.day.ago,
|
821
817
|
active: true
|
822
818
|
)
|
823
819
|
|
820
|
+
# 12.5. Loan Accruals (depends on loans)
|
821
|
+
puts "Seeding loan accruals..."
|
822
|
+
Dscf::Credit::LoanAccrual.create!(
|
823
|
+
loan: loan1,
|
824
|
+
accrual_type: 'interest',
|
825
|
+
amount: 250.00,
|
826
|
+
applied_on: 1.month.ago.to_date,
|
827
|
+
status: 'pending'
|
828
|
+
)
|
829
|
+
|
830
|
+
Dscf::Credit::LoanAccrual.create!(
|
831
|
+
loan: loan1,
|
832
|
+
accrual_type: 'facilitation_fee',
|
833
|
+
amount: 1000.00,
|
834
|
+
applied_on: 1.day.ago.to_date,
|
835
|
+
status: 'paid'
|
836
|
+
)
|
837
|
+
|
824
838
|
# 13. Loan Transactions (depends on loans)
|
825
839
|
puts "Seeding loan transactions..."
|
826
840
|
Dscf::Credit::LoanTransaction.create!(
|
@@ -863,6 +877,7 @@ puts "- Categories: #{Dscf::Credit::Category.count}"
|
|
863
877
|
puts "- Credit Lines: #{Dscf::Credit::CreditLine.count}"
|
864
878
|
puts "- Loan Profiles: #{Dscf::Credit::LoanProfile.count}"
|
865
879
|
puts "- Loans: #{Dscf::Credit::Loan.count}"
|
880
|
+
puts "- Loan Accruals: #{Dscf::Credit::LoanAccrual.count}"
|
866
881
|
puts "- Facilitators: #{Dscf::Credit::Facilitator.count} (will be created via API)"
|
867
882
|
puts "- System Configs: #{Dscf::Credit::SystemConfig.count}"
|
868
883
|
puts "- Scoring Parameters: #{Dscf::Credit::ScoringParameter.count}"
|
data/lib/dscf/credit/version.rb
CHANGED
@@ -0,0 +1,29 @@
|
|
1
|
+
FactoryBot.define do
|
2
|
+
factory :loan_accrual, class: "Dscf::Credit::LoanAccrual" do
|
3
|
+
association :loan, factory: :loan
|
4
|
+
accrual_type { %w[interest penalty tax facilitation_fee late_fee other].sample }
|
5
|
+
amount { Faker::Number.decimal(l_digits: 3, r_digits: 2) }
|
6
|
+
applied_on { Faker::Date.between(from: 1.month.ago, to: Date.current) }
|
7
|
+
status { %w[pending paid cancelled].sample }
|
8
|
+
|
9
|
+
trait :interest do
|
10
|
+
accrual_type { "interest" }
|
11
|
+
end
|
12
|
+
|
13
|
+
trait :penalty do
|
14
|
+
accrual_type { "penalty" }
|
15
|
+
end
|
16
|
+
|
17
|
+
trait :pending do
|
18
|
+
status { "pending" }
|
19
|
+
end
|
20
|
+
|
21
|
+
trait :paid do
|
22
|
+
status { "paid" }
|
23
|
+
end
|
24
|
+
|
25
|
+
trait :cancelled do
|
26
|
+
status { "cancelled" }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -4,10 +4,6 @@ FactoryBot.define do
|
|
4
4
|
association :credit_line, factory: :credit_line
|
5
5
|
status { %w[pending approved disbursed active overdue paid closed].sample }
|
6
6
|
principal_amount { Faker::Number.decimal(l_digits: 5, r_digits: 2) }
|
7
|
-
accrued_interest { Faker::Number.decimal(l_digits: 3, r_digits: 2) }
|
8
|
-
accrued_penalty { Faker::Number.decimal(l_digits: 3, r_digits: 2) }
|
9
|
-
facilitation_fee { Faker::Number.decimal(l_digits: 3, r_digits: 2) }
|
10
|
-
total_loan_amount { principal_amount + accrued_interest + facilitation_fee }
|
11
7
|
remaining_amount { Faker::Number.decimal(l_digits: 5, r_digits: 2) }
|
12
8
|
due_date { Faker::Date.between(from: 1.month.from_now, to: 6.months.from_now) }
|
13
9
|
disbursed_at { Faker::Time.between(from: 2.months.ago, to: Time.current) if status.in?(%w[disbursed active overdue paid closed]) }
|
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.1.
|
4
|
+
version: 0.1.8
|
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-04 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: dscf-core
|
@@ -333,6 +333,7 @@ files:
|
|
333
333
|
- app/controllers/dscf/credit/eligible_credit_lines_controller.rb
|
334
334
|
- app/controllers/dscf/credit/facilitator_applications_controller.rb
|
335
335
|
- app/controllers/dscf/credit/facilitators_controller.rb
|
336
|
+
- app/controllers/dscf/credit/loan_accruals_controller.rb
|
336
337
|
- app/controllers/dscf/credit/loan_applications_controller.rb
|
337
338
|
- app/controllers/dscf/credit/loan_profiles_controller.rb
|
338
339
|
- app/controllers/dscf/credit/loans_controller.rb
|
@@ -344,6 +345,7 @@ files:
|
|
344
345
|
- app/controllers/dscf/credit/system_configs_controller.rb
|
345
346
|
- app/controllers/dscf/credit/users_controller.rb
|
346
347
|
- app/jobs/dscf/credit/application_job.rb
|
348
|
+
- app/jobs/dscf/credit/generate_daily_accruals_job.rb
|
347
349
|
- app/mailers/dscf/credit/application_mailer.rb
|
348
350
|
- app/mailers/dscf/credit/bank_staff_welcome_mailer.rb
|
349
351
|
- app/mailers/dscf/credit/facilitator_mailer.rb
|
@@ -364,6 +366,7 @@ files:
|
|
364
366
|
- app/models/dscf/credit/facilitator_performance.rb
|
365
367
|
- app/models/dscf/credit/failed_operations_log.rb
|
366
368
|
- app/models/dscf/credit/loan.rb
|
369
|
+
- app/models/dscf/credit/loan_accrual.rb
|
367
370
|
- app/models/dscf/credit/loan_application.rb
|
368
371
|
- app/models/dscf/credit/loan_profile.rb
|
369
372
|
- app/models/dscf/credit/loan_profile_scoring_spec.rb
|
@@ -390,6 +393,7 @@ files:
|
|
390
393
|
- app/serializers/dscf/credit/facilitator_application_serializer.rb
|
391
394
|
- app/serializers/dscf/credit/facilitator_performance_serializer.rb
|
392
395
|
- app/serializers/dscf/credit/facilitator_serializer.rb
|
396
|
+
- app/serializers/dscf/credit/loan_accrual_serializer.rb
|
393
397
|
- app/serializers/dscf/credit/loan_application_serializer.rb
|
394
398
|
- app/serializers/dscf/credit/loan_profile_scoring_spec_serializer.rb
|
395
399
|
- app/serializers/dscf/credit/loan_profile_serializer.rb
|
@@ -408,6 +412,7 @@ files:
|
|
408
412
|
- app/services/dscf/credit/facilitator_approval_service.rb
|
409
413
|
- app/services/dscf/credit/facilitator_creation_service.rb
|
410
414
|
- app/services/dscf/credit/facility_limit_calculation_engine.rb
|
415
|
+
- app/services/dscf/credit/loan_accrual_generator_service.rb
|
411
416
|
- app/services/dscf/credit/loan_profile_creation_service.rb
|
412
417
|
- app/services/dscf/credit/repayment_service.rb
|
413
418
|
- app/services/dscf/credit/risk_application_service.rb
|
@@ -450,6 +455,7 @@ files:
|
|
450
455
|
- db/migrate/20250822092936_create_dscf_credit_accounting_entries.rb
|
451
456
|
- db/migrate/20250825231109_create_dscf_credit_bank_staff.rb
|
452
457
|
- db/migrate/20250917120000_create_dscf_credit_eligible_credit_lines.rb
|
458
|
+
- db/migrate/20251003132939_create_dscf_credit_loan_accruals.rb
|
453
459
|
- db/seeds.rb
|
454
460
|
- lib/dscf/credit.rb
|
455
461
|
- lib/dscf/credit/engine.rb
|
@@ -469,6 +475,7 @@ files:
|
|
469
475
|
- spec/factories/dscf/credit/facilitator_performances.rb
|
470
476
|
- spec/factories/dscf/credit/facilitators.rb
|
471
477
|
- spec/factories/dscf/credit/failed_operations_logs.rb
|
478
|
+
- spec/factories/dscf/credit/loan_accruals.rb
|
472
479
|
- spec/factories/dscf/credit/loan_applications.rb
|
473
480
|
- spec/factories/dscf/credit/loan_profile_scoring_specs.rb
|
474
481
|
- spec/factories/dscf/credit/loan_profiles.rb
|