dscf-credit 0.1.4 → 0.1.5

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.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/concerns/dscf/core/copilot-instructions.md +683 -0
  3. data/app/controllers/concerns/dscf/core/reviewable_controller.rb +347 -0
  4. data/app/controllers/dscf/credit/categories_controller.rb +3 -3
  5. data/app/controllers/dscf/credit/credit_lines_controller.rb +21 -13
  6. data/app/controllers/dscf/credit/eligible_credit_lines_controller.rb +50 -8
  7. data/app/controllers/dscf/credit/facilitator_applications_controller.rb +35 -0
  8. data/app/controllers/dscf/credit/facilitators_controller.rb +8 -96
  9. data/app/controllers/dscf/credit/loan_applications_controller.rb +252 -0
  10. data/app/controllers/dscf/credit/loan_profiles_controller.rb +61 -68
  11. data/app/controllers/dscf/credit/payment_requests_controller.rb +3 -5
  12. data/app/controllers/dscf/credit/scoring_parameters_controller.rb +59 -13
  13. data/app/controllers/dscf/credit/system_configs_controller.rb +30 -12
  14. data/app/models/concerns/core/reviewable_model.rb +31 -0
  15. data/app/models/dscf/credit/bank.rb +3 -3
  16. data/app/models/dscf/credit/bank_branch.rb +1 -1
  17. data/app/models/dscf/credit/category.rb +1 -2
  18. data/app/models/dscf/credit/credit_line.rb +4 -10
  19. data/app/models/dscf/credit/eligible_credit_line.rb +2 -2
  20. data/app/models/dscf/credit/facilitator.rb +6 -17
  21. data/app/models/dscf/credit/facilitator_application.rb +20 -0
  22. data/app/models/dscf/credit/loan_application.rb +30 -0
  23. data/app/models/dscf/credit/loan_profile.rb +10 -30
  24. data/app/models/dscf/credit/parameter_normalizer.rb +1 -1
  25. data/app/models/dscf/credit/scoring_parameter.rb +5 -7
  26. data/app/models/dscf/credit/system_config.rb +4 -9
  27. data/app/serializers/dscf/credit/category_serializer.rb +0 -1
  28. data/app/serializers/dscf/credit/credit_line_serializer.rb +2 -2
  29. data/app/serializers/dscf/credit/facilitator_application_serializer.rb +7 -0
  30. data/app/serializers/dscf/credit/facilitator_serializer.rb +3 -6
  31. data/app/serializers/dscf/credit/loan_application_serializer.rb +12 -0
  32. data/app/serializers/dscf/credit/loan_profile_serializer.rb +3 -6
  33. data/app/serializers/dscf/credit/scoring_parameter_serializer.rb +3 -4
  34. data/app/serializers/dscf/credit/system_config_serializer.rb +2 -2
  35. data/app/services/dscf/credit/credit_scoring_engine.rb +258 -0
  36. data/app/services/dscf/credit/facility_limit_calculation_engine.rb +159 -0
  37. data/app/services/dscf/credit/loan_profile_creation_service.rb +91 -0
  38. data/app/services/dscf/credit/risk_application_service.rb +61 -11
  39. data/config/locales/en.yml +63 -48
  40. data/config/routes.rb +31 -17
  41. data/db/migrate/20250822091131_create_dscf_credit_credit_lines.rb +1 -8
  42. data/db/migrate/20250822091820_create_dscf_credit_system_configs.rb +0 -7
  43. data/db/migrate/20250822092050_create_dscf_credit_scoring_parameters.rb +2 -6
  44. data/db/migrate/20250822092225_create_dscf_credit_parameter_normalizers.rb +1 -1
  45. data/db/migrate/20250822092236_create_dscf_credit_loan_applications.rb +20 -0
  46. data/db/migrate/20250822092246_create_dscf_credit_loan_profiles.rb +7 -19
  47. data/db/migrate/20250822092426_create_dscf_credit_facilitator_applications.rb +10 -0
  48. data/db/migrate/20250822092436_create_dscf_credit_facilitators.rb +1 -16
  49. data/db/seeds.rb +316 -203
  50. data/lib/dscf/credit/version.rb +1 -1
  51. data/spec/factories/dscf/credit/banks.rb +1 -1
  52. data/spec/factories/dscf/credit/credit_lines.rb +0 -23
  53. data/spec/factories/dscf/credit/facilitator_applications.rb +37 -0
  54. data/spec/factories/dscf/credit/facilitators.rb +8 -30
  55. data/spec/factories/dscf/credit/loan_applications.rb +42 -0
  56. data/spec/factories/dscf/credit/loan_profiles.rb +20 -34
  57. data/spec/factories/dscf/credit/parameter_normalizers.rb +4 -4
  58. data/spec/factories/dscf/credit/scoring_parameters.rb +14 -11
  59. data/spec/factories/dscf/credit/system_configs.rb +21 -5
  60. metadata +20 -10
  61. data/app/controllers/concerns/dscf/credit/reviewable.rb +0 -112
  62. data/app/controllers/dscf/credit/scoring_tables_controller.rb +0 -63
  63. data/app/models/dscf/credit/scoring_table.rb +0 -24
  64. data/app/serializers/dscf/credit/scoring_table_serializer.rb +0 -9
  65. data/db/migrate/20250901172842_create_dscf_credit_scoring_tables.rb +0 -18
  66. data/spec/factories/dscf/credit/scoring_tables.rb +0 -25
@@ -85,7 +85,10 @@ en:
85
85
  update: "Loan profile updated successfully"
86
86
  approve: "Loan profile approved successfully"
87
87
  reject: "Loan profile rejected successfully"
88
- calculate_score: "Credit score calculated successfully"
88
+ request_modification: "Modification requested for loan profile successfully"
89
+ resubmit: "Loan profile resubmitted successfully"
90
+ calculate_facility_limits: "Facility limits calculated successfully"
91
+ apply_risk_factor: "Risk factor applied successfully"
89
92
  errors:
90
93
  index: "Failed to retrieve loan profiles"
91
94
  show: "Failed to retrieve loan profile details"
@@ -93,8 +96,11 @@ en:
93
96
  update: "Failed to update loan profile"
94
97
  approve: "Failed to approve loan profile"
95
98
  reject: "Failed to reject loan profile"
96
- calculate_score: "Failed to calculate credit score"
99
+ request_modification: "Failed to request modification for loan profile"
100
+ resubmit: "Failed to resubmit loan profile"
97
101
  not_found: "Loan profile not found"
102
+ calculate_facility_limits: "Failed to calculate facility limits"
103
+ apply_risk_factor: "Failed to apply risk factor"
98
104
 
99
105
  parameter_normalizer:
100
106
  success:
@@ -118,27 +124,18 @@ en:
118
124
  update: "Facilitator updated successfully"
119
125
  approve: "Facilitator approved successfully"
120
126
  reject: "Facilitator rejected successfully"
121
- set_limit: "Facilitator limit updated successfully"
122
- submit_additional_info: "Additional information submitted successfully"
123
127
  request_modification: "Modification requested for facilitator successfully"
124
128
  resubmit: "Facilitator resubmitted successfully"
125
- batch_created_all: "All facilitators created successfully"
126
- batch_created_partial: "Batch processing completed with partial success"
127
129
  errors:
130
+ index: "Failed to retrieve facilitators"
131
+ show: "Failed to retrieve facilitator details"
128
132
  create: "Failed to create facilitator"
129
133
  update: "Failed to update facilitator"
130
- show: "Failed to retrieve facilitator details"
131
134
  approve: "Failed to approve facilitator"
132
135
  reject: "Failed to reject facilitator"
133
- set_limit: "Failed to update facilitator limit"
134
- submit_additional_info: "Failed to submit additional information"
135
136
  request_modification: "Failed to request modification for facilitator"
136
137
  resubmit: "Failed to resubmit facilitator"
137
- no_business: "User must have a business associated to become a facilitator"
138
- invalid_batch_format: "Invalid batch format"
139
- empty_batch: "Empty batch provided"
140
- batch_too_large: "Batch size exceeds maximum allowed"
141
- batch_failed_all: "All facilitators failed to create"
138
+ not_found: "Facilitator not found"
142
139
 
143
140
  credit_line_spec:
144
141
  success:
@@ -189,6 +186,7 @@ en:
189
186
  create: "Failed to create eligible credit line"
190
187
  update: "Failed to update eligible credit line"
191
188
  apply_risk: "Failed to apply risk"
189
+ not_found: "Eligible credit line not found"
192
190
 
193
191
  system_config_definition:
194
192
  success:
@@ -240,24 +238,6 @@ en:
240
238
  update: "Failed to update category"
241
239
  destroy: "Failed to delete category"
242
240
 
243
- scoring_table:
244
- success:
245
- index: "Scoring tables retrieved successfully"
246
- show: "Scoring table details retrieved successfully"
247
- create: "Scoring table created successfully"
248
- update: "Scoring table updated successfully"
249
- activate: "Scoring table activated successfully"
250
- deactivate: "Scoring table deactivated successfully"
251
- destroy: "Scoring table deleted successfully"
252
- errors:
253
- index: "Failed to retrieve scoring tables"
254
- show: "Failed to retrieve scoring table details"
255
- create: "Failed to create scoring table"
256
- update: "Failed to update scoring table"
257
- activate: "Failed to activate scoring table"
258
- deactivate: "Failed to deactivate scoring table"
259
- destroy: "Failed to delete scoring table"
260
-
261
241
  payment_request:
262
242
  success:
263
243
  index: "Payment requests retrieved successfully"
@@ -276,17 +256,59 @@ en:
276
256
  eligible_credit_lines: "Failed to retrieve eligible credit lines"
277
257
  destroy: "Failed to delete payment request"
278
258
 
279
- user:
259
+ loan_application:
280
260
  success:
281
- index: "Users retrieved successfully"
282
- show: "User details retrieved successfully"
283
- create: "User created successfully"
284
- update: "User updated successfully"
261
+ index: "Loan applications retrieved successfully"
262
+ show: "Loan application details retrieved successfully"
263
+ create: "Loan application created successfully"
264
+ update: "Loan application updated successfully"
265
+ update_bank_info: "Bank information updated successfully"
266
+ update_facilitator_info: "Facilitator information updated successfully"
267
+ update_field_assessment: "Field assessment updated successfully"
268
+ calculate_credit_score: "Credit score calculated successfully"
269
+ apply_risk_factor: "Risk factor applied successfully"
270
+ approve: "Loan application approved successfully"
271
+ reject: "Loan application rejected successfully"
272
+ request_modification: "Modification requested for loan application successfully"
273
+ resubmit: "Loan application resubmitted successfully"
285
274
  errors:
286
- index: "Failed to retrieve Users"
287
- show: "Failed to retrieve User details"
288
- create: "Failed to create User"
289
- update: "Failed to update User"
275
+ index: "Failed to retrieve loan applications"
276
+ show: "Failed to retrieve loan application details"
277
+ create: "Failed to create loan application"
278
+ update: "Failed to update loan application"
279
+ update_bank_info: "Failed to update bank information"
280
+ update_facilitator_info: "Failed to update facilitator information"
281
+ update_field_assessment: "Failed to update field assessment"
282
+ calculate_credit_score: "Failed to calculate credit score"
283
+ apply_risk_factor: "Failed to apply risk factor"
284
+ invalid_risk_percentage: "Invalid risk percentage provided"
285
+ no_loan_profile: "No loan profile found for this application"
286
+ approve: "Failed to approve loan application"
287
+ reject: "Failed to reject loan application"
288
+ request_modification: "Failed to request modification for loan application"
289
+ resubmit: "Failed to resubmit loan application"
290
+ not_found: "Loan application not found"
291
+
292
+ facilitator_application:
293
+ success:
294
+ index: "Facilitator applications retrieved successfully"
295
+ show: "Facilitator application details retrieved successfully"
296
+ create: "Facilitator application created successfully"
297
+ update: "Facilitator application updated successfully"
298
+ approve: "Facilitator application approved successfully"
299
+ reject: "Facilitator application rejected successfully"
300
+ request_modification: "Modification requested for facilitator application successfully"
301
+ resubmit: "Facilitator application resubmitted successfully"
302
+ errors:
303
+ index: "Failed to retrieve facilitator applications"
304
+ show: "Failed to retrieve facilitator application details"
305
+ create: "Failed to create facilitator application"
306
+ update: "Failed to update facilitator application"
307
+ approve: "Failed to approve facilitator application"
308
+ reject: "Failed to reject facilitator application"
309
+ request_modification: "Failed to request modification for facilitator application"
310
+ resubmit: "Failed to resubmit facilitator application"
311
+ not_found: "Facilitator application not found"
290
312
 
291
313
  # Global messages
292
314
  operations:
@@ -297,13 +319,6 @@ en:
297
319
  failed: "Operation failed"
298
320
  not_found: "Resource not found"
299
321
 
300
- loan_profile:
301
- success:
302
- calculate_score: "Credit score calculated successfully"
303
- errors:
304
- calculate_score: "Failed to calculate credit score"
305
- not_found: "Loan profile not found"
306
-
307
322
  credit_limit_calculation:
308
323
  success:
309
324
  create: "Credit limits calculated successfully"
data/config/routes.rb CHANGED
@@ -1,19 +1,16 @@
1
1
  Dscf::Credit::Engine.routes.draw do
2
- # Main API endpoints
3
- resources :banks, only: [ :index, :show, :create, :update, :destroy ]
2
+ resources :banks
4
3
  resources :bank_branches
5
- resources :payments, only: [ :index, :show, :create, :update, :destroy ]
6
- resources :loans, only: [ :index, :show, :create, :update, :destroy ]
4
+ resources :payments
5
+ resources :loans
7
6
  resources :scoring_param_types
8
7
 
9
- resources :facilitators, only: [ :index, :show, :create, :update, :destroy ] do
10
- collection do
11
- post "batch_create", to: "facilitators#batch_create"
12
- post "additional_info", to: "facilitators#submit_additional_info"
13
- end
8
+ resources :facilitators do
14
9
  member do
15
- patch "approve", to: "facilitators#approve"
16
- patch "reject", to: "facilitators#reject"
10
+ patch "approve"
11
+ patch "reject"
12
+ patch "request_modification"
13
+ patch "resubmit"
17
14
  end
18
15
  end
19
16
 
@@ -22,6 +19,7 @@ Dscf::Credit::Engine.routes.draw do
22
19
  patch "approve"
23
20
  patch "reject"
24
21
  post "calculate_score"
22
+ post "calculate_facility_limits"
25
23
  end
26
24
  end
27
25
  resources :payment_requests do
@@ -63,12 +61,6 @@ Dscf::Credit::Engine.routes.draw do
63
61
  end
64
62
  end
65
63
  resources :categories
66
- resources :scoring_tables do
67
- member do
68
- patch "activate", to: "scoring_tables#activate"
69
- patch "deactivate", to: "scoring_tables#deactivate"
70
- end
71
- end
72
64
  resources :users
73
65
  resources :kyc_reviews, only: [ :index, :show ]
74
66
  resources :bank_staffs
@@ -76,4 +68,26 @@ Dscf::Credit::Engine.routes.draw do
76
68
  resources :credit_limit_calculations, only: [ :create ]
77
69
  resources :disbursements, only: [ :create ]
78
70
  resources :repayments, only: [ :create ]
71
+ resources :loan_applications do
72
+ member do
73
+ patch "approve"
74
+ patch "reject"
75
+ patch "request_modification"
76
+ patch "resubmit"
77
+ patch "update_bank_info"
78
+ patch "update_facilitator_info"
79
+ patch "update_field_assessment"
80
+ post "calculate_credit_score"
81
+ patch "apply_risk_factor"
82
+ end
83
+ end
84
+
85
+ resources :facilitator_applications do
86
+ member do
87
+ patch "approve"
88
+ patch "reject"
89
+ patch "request_modification"
90
+ patch "resubmit"
91
+ end
92
+ end
79
93
  end
@@ -6,11 +6,7 @@ class CreateDscfCreditCreditLines < ActiveRecord::Migration[8.0]
6
6
  t.string :name, null: false
7
7
  t.string :code
8
8
  t.text :description
9
- t.string :status, default: 'pending'
10
9
  t.references :created_by, polymorphic: true, null: false
11
- t.references :reviewed_by, polymorphic: true, null: true
12
- t.datetime :review_date
13
- t.jsonb :review_feedback, default: {}
14
10
  t.string :document_reference
15
11
 
16
12
  t.timestamps
@@ -18,11 +14,8 @@ class CreateDscfCreditCreditLines < ActiveRecord::Migration[8.0]
18
14
 
19
15
  add_index :dscf_credit_credit_lines, :name
20
16
  add_index :dscf_credit_credit_lines, :code
21
- add_index :dscf_credit_credit_lines, :status
22
- add_index :dscf_credit_credit_lines, [ :created_by_type, :created_by_id ]
23
- add_index :dscf_credit_credit_lines, [ :reviewed_by_type, :reviewed_by_id ]
24
- add_index :dscf_credit_credit_lines, :review_date
25
17
  add_index :dscf_credit_credit_lines, :document_reference
18
+ add_index :dscf_credit_credit_lines, [ :created_by_type, :created_by_id ]
26
19
  add_index :dscf_credit_credit_lines, [ :bank_id, :code ], unique: true
27
20
  end
28
21
  end
@@ -3,18 +3,11 @@ class CreateDscfCreditSystemConfigs < ActiveRecord::Migration[8.0]
3
3
  create_table :dscf_credit_system_configs do |t|
4
4
  t.references :config_definition, null: false, foreign_key: { to_table: :dscf_credit_system_config_definitions }, index: { unique: true }
5
5
  t.text :config_value, null: false
6
- t.string :status, default: 'pending'
7
6
  t.references :last_updated_by, polymorphic: true, null: false
8
- t.references :reviewed_by, polymorphic: true, null: false
9
- t.datetime :review_date
10
- t.jsonb :review_feedback, default: {}
11
7
 
12
8
  t.timestamps
13
9
  end
14
10
 
15
11
  add_index :dscf_credit_system_configs, [ :last_updated_by_type, :last_updated_by_id ]
16
- add_index :dscf_credit_system_configs, [ :reviewed_by_type, :reviewed_by_id ]
17
- add_index :dscf_credit_system_configs, :status
18
- add_index :dscf_credit_system_configs, :review_date
19
12
  end
20
13
  end
@@ -2,6 +2,7 @@ class CreateDscfCreditScoringParameters < ActiveRecord::Migration[8.0]
2
2
  def change
3
3
  create_table :dscf_credit_scoring_parameters do |t|
4
4
  t.references :bank, null: false, foreign_key: { to_table: :dscf_credit_banks }
5
+ t.references :category, null: false, foreign_key: { to_table: :dscf_credit_categories }
5
6
  t.string :name, null: false
6
7
  t.text :description
7
8
  t.string :data_type, null: false
@@ -11,13 +12,9 @@ class CreateDscfCreditScoringParameters < ActiveRecord::Migration[8.0]
11
12
  t.boolean :active, default: true
12
13
  t.references :previous_version, foreign_key: { to_table: :dscf_credit_scoring_parameters }, null: true
13
14
  t.references :created_by, polymorphic: true, null: false
14
- t.references :reviewed_by, polymorphic: true, null: false
15
- t.datetime :review_date
16
- t.jsonb :review_feedback, default: {}
17
15
  t.string :source
18
16
  t.references :scoring_param_type, null: false, foreign_key: { to_table: :dscf_credit_scoring_param_types }
19
17
  t.string :document_reference
20
- t.string :status, default: 'pending'
21
18
 
22
19
  t.timestamps
23
20
  end
@@ -26,10 +23,9 @@ class CreateDscfCreditScoringParameters < ActiveRecord::Migration[8.0]
26
23
  add_index :dscf_credit_scoring_parameters, :data_type
27
24
  add_index :dscf_credit_scoring_parameters, :active
28
25
  add_index :dscf_credit_scoring_parameters, [ :created_by_type, :created_by_id ]
29
- add_index :dscf_credit_scoring_parameters, [ :reviewed_by_type, :reviewed_by_id ]
30
- add_index :dscf_credit_scoring_parameters, :review_date
31
26
  add_index :dscf_credit_scoring_parameters, :source
32
27
  add_index :dscf_credit_scoring_parameters, :document_reference
33
28
  add_index :dscf_credit_scoring_parameters, [ :bank_id, :name, :active ]
29
+ add_index :dscf_credit_scoring_parameters, [ :category_id, :name ]
34
30
  end
35
31
  end
@@ -5,7 +5,7 @@ class CreateDscfCreditParameterNormalizers < ActiveRecord::Migration[8.0]
5
5
  t.string :name, null: false
6
6
  t.text :description
7
7
  t.string :raw_value, null: false
8
- t.integer :normalized_value, null: false
8
+ t.decimal :normalized_value, precision: 5, scale: 4, null: false
9
9
 
10
10
  t.timestamps
11
11
  end
@@ -0,0 +1,20 @@
1
+ class CreateDscfCreditLoanApplications < ActiveRecord::Migration[8.0]
2
+ def change
3
+ create_table :dscf_credit_loan_applications do |t|
4
+ t.references :bank, null: false, foreign_key: { to_table: :dscf_credit_banks }
5
+ t.references :user, null: false, foreign_key: { to_table: :dscf_core_users }
6
+ t.references :backer, polymorphic: true
7
+ t.references :review_branch, null: false, foreign_key: { to_table: :dscf_credit_bank_branches }
8
+ t.string :bank_statement_source
9
+ t.jsonb :user_info, default: {}
10
+ t.jsonb :facilitator_info, default: {}
11
+ t.jsonb :bank_info, default: {}
12
+ t.jsonb :field_assessment, default: {}
13
+ t.decimal :score, precision: 15, scale: 2
14
+
15
+ t.timestamps
16
+ end
17
+
18
+ add_index :dscf_credit_loan_applications, :bank_statement_source
19
+ end
20
+ end
@@ -1,28 +1,16 @@
1
1
  class CreateDscfCreditLoanProfiles < ActiveRecord::Migration[8.0]
2
2
  def change
3
3
  create_table :dscf_credit_loan_profiles do |t|
4
- t.references :bank, null: false, foreign_key: { to_table: :dscf_credit_banks }
5
- t.references :user, null: false, foreign_key: { to_table: :dscf_core_users }
6
- t.references :backer, polymorphic: true, null: true
7
- t.string :status, default: 'pending'
8
- t.decimal :total_amount, precision: 15, scale: 2, default: 0
9
- t.decimal :available_amount, precision: 15, scale: 2, default: 0
10
- t.references :reviewed_by, polymorphic: true
11
- t.datetime :review_date
12
- t.jsonb :review_feedback, default: {}
13
- t.references :review_branch, null: true, foreign_key: { to_table: :dscf_credit_bank_branches }
4
+ t.references :loan_application, null: false, foreign_key: { to_table: :dscf_credit_loan_applications }
5
+ t.string :code, null: false, limit: 8
6
+ t.decimal :score, precision: 8, scale: 2
7
+ t.decimal :total_limit, precision: 15, scale: 2, default: 0
14
8
 
15
9
  t.timestamps
16
10
  end
17
11
 
18
- add_index :dscf_credit_loan_profiles, :status
19
- add_index :dscf_credit_loan_profiles, :total_amount
20
- add_index :dscf_credit_loan_profiles, :available_amount
21
- add_index :dscf_credit_loan_profiles, [ :backer_type, :backer_id ]
22
- add_index :dscf_credit_loan_profiles, [ :reviewed_by_type, :reviewed_by_id ]
23
- add_index :dscf_credit_loan_profiles, :review_date
24
- add_index :dscf_credit_loan_profiles, [ :bank_id, :user_id, :status ]
25
- add_index :dscf_credit_loan_profiles, [ :user_id, :status ]
26
- add_index :dscf_credit_loan_profiles, [ :total_amount, :available_amount ]
12
+ add_index :dscf_credit_loan_profiles, :code, unique: true
13
+ add_index :dscf_credit_loan_profiles, :score
14
+ add_index :dscf_credit_loan_profiles, :total_limit
27
15
  end
28
16
  end
@@ -0,0 +1,10 @@
1
+ class CreateDscfCreditFacilitatorApplications < ActiveRecord::Migration[8.0]
2
+ def change
3
+ create_table :dscf_credit_facilitator_applications do |t|
4
+ t.references :user, null: false, foreign_key: { to_table: :dscf_core_users }
5
+ t.references :bank, null: false, foreign_key: { to_table: :dscf_credit_banks }
6
+ t.jsonb :facilitator_info, null: false, default: {}
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -1,25 +1,10 @@
1
1
  class CreateDscfCreditFacilitators < ActiveRecord::Migration[8.0]
2
2
  def change
3
3
  create_table :dscf_credit_facilitators do |t|
4
- t.references :user, null: false, foreign_key: { to_table: :dscf_core_users }
5
- t.references :bank, null: false, foreign_key: { to_table: :dscf_credit_banks }
6
- t.string :name, null: false
7
- t.string :type, null: false
4
+ t.references :facilitator_application, null: false, foreign_key: { to_table: :dscf_credit_facilitator_applications }
8
5
  t.decimal :total_limit, precision: 15, scale: 2
9
- t.string :kyc_status, default: 'pending'
10
- t.references :kyc_reviewed_by, polymorphic: true, null: false
11
- t.datetime :kyc_review_date
12
- t.jsonb :review_feedback, default: {}
13
6
 
14
7
  t.timestamps
15
8
  end
16
-
17
- add_index :dscf_credit_facilitators, :name
18
- add_index :dscf_credit_facilitators, :type
19
- add_index :dscf_credit_facilitators, :kyc_status
20
- add_index :dscf_credit_facilitators, [ :kyc_reviewed_by_type, :kyc_reviewed_by_id ]
21
- add_index :dscf_credit_facilitators, :kyc_review_date
22
- add_index :dscf_credit_facilitators, [ :bank_id, :user_id ], unique: true
23
- add_index :dscf_credit_facilitators, [ :user_id, :kyc_status ]
24
9
  end
25
10
  end