dscf-credit 0.4.48 → 0.4.49
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/application_controller.rb +1 -3
- data/app/controllers/dscf/credit/credit_limit_calculations_controller.rb +2 -0
- data/app/controllers/dscf/credit/disbursements_controller.rb +2 -0
- data/app/controllers/dscf/credit/repayments_controller.rb +2 -0
- data/app/policies/dscf/credit/application_policy.rb +75 -0
- data/app/policies/dscf/credit/bank_branch_policy.rb +6 -0
- data/app/policies/dscf/credit/bank_policy.rb +6 -0
- data/app/policies/dscf/credit/bank_staff_policy.rb +46 -0
- data/app/policies/dscf/credit/category_policy.rb +6 -0
- data/app/policies/dscf/credit/credit_line_policy.rb +6 -0
- data/app/policies/dscf/credit/credit_line_spec_policy.rb +6 -0
- data/app/policies/dscf/credit/credit_product_policy.rb +6 -0
- data/app/policies/dscf/credit/eligible_credit_line_policy.rb +40 -0
- data/app/policies/dscf/credit/facilitator_application_policy.rb +31 -0
- data/app/policies/dscf/credit/facilitator_policy.rb +6 -0
- data/app/policies/dscf/credit/information_source_policy.rb +6 -0
- data/app/policies/dscf/credit/loan_accrual_policy.rb +42 -0
- data/app/policies/dscf/credit/loan_application_datum_policy.rb +33 -0
- data/app/policies/dscf/credit/loan_application_policy.rb +43 -0
- data/app/policies/dscf/credit/loan_policy.rb +36 -0
- data/app/policies/dscf/credit/loan_profile_policy.rb +38 -0
- data/app/policies/dscf/credit/loan_transaction_policy.rb +34 -0
- data/app/policies/dscf/credit/scoring_parameter_policy.rb +6 -0
- data/app/policies/dscf/credit/scoring_table_normalizer_policy.rb +6 -0
- data/app/policies/dscf/credit/scoring_table_parameter_policy.rb +6 -0
- data/app/policies/dscf/credit/scoring_table_policy.rb +6 -0
- data/app/policies/dscf/credit/system_config_definition_policy.rb +6 -0
- data/app/policies/dscf/credit/system_config_policy.rb +6 -0
- data/db/dev_seeds.rb +582 -0
- data/db/seeds.rb +250 -4
- data/lib/dscf/credit/engine.rb +40 -0
- data/lib/dscf/credit/version.rb +1 -1
- metadata +27 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9c586be2c3e6201e240d8ff5676f1f9506f50a5a29e218b2fc597512410c113a
|
|
4
|
+
data.tar.gz: da306fa00a5696ccf4c08d2c04708ca4728862e14aac69c45d28d0f29f65b0b3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 88e936bb0fa07592fe5cd7d4bcd1a32fefa05e6f769a2241302b9b73d4f89222ec3d031cd01ac3356659c96676ec6a8e601ce2c4def71f6eec97b30272b849e5
|
|
7
|
+
data.tar.gz: a74a4d06264c133883226d28d2f6dce9c2e9826e2541944125e0cf49de602d2825da3342d3132b600cd2536948f238fad0e291dedfdd46dd4d8fdd0731c90b28
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
module Dscf::Credit
|
|
2
2
|
class CreditLimitCalculationsController < ApplicationController
|
|
3
3
|
def create
|
|
4
|
+
authorize Dscf::Credit::LoanProfile.new, :calculate_facility_limits?
|
|
5
|
+
|
|
4
6
|
loan_profile = Dscf::Credit::LoanProfile.find(params[:loan_profile_id])
|
|
5
7
|
credit_product = Dscf::Credit::CreditProduct.find(params[:credit_product_id])
|
|
6
8
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
module Dscf::Credit
|
|
2
2
|
class DisbursementsController < ApplicationController
|
|
3
3
|
def create
|
|
4
|
+
raise Pundit::NotAuthorizedError unless current_user.has_permission?("disbursements.create")
|
|
5
|
+
|
|
4
6
|
amount = disbursement_params[:amount]
|
|
5
7
|
loan_profile = Dscf::Credit::LoanProfile.find(disbursement_params[:loan_profile_id])
|
|
6
8
|
eligible_credit_line = Dscf::Credit::EligibleCreditLine.find(disbursement_params[:eligible_credit_line_id])
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
module Dscf::Credit
|
|
2
2
|
class RepaymentsController < ApplicationController
|
|
3
3
|
def create
|
|
4
|
+
raise Pundit::NotAuthorizedError unless current_user.has_permission?("repayments.create")
|
|
5
|
+
|
|
4
6
|
loan = Dscf::Credit::Loan.find(params[:loan_id])
|
|
5
7
|
payment_amount = params[:amount].to_f
|
|
6
8
|
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
module Dscf
|
|
2
|
+
module Credit
|
|
3
|
+
class ApplicationPolicy < Dscf::Core::ApplicationPolicy
|
|
4
|
+
ADMIN_ROLES = %w[ADMIN REVIEWER BANK_ADMIN BANK_STAFF].freeze
|
|
5
|
+
|
|
6
|
+
class Scope < Dscf::Core::ApplicationPolicy::Scope
|
|
7
|
+
def resolve
|
|
8
|
+
return scope.none unless user.has_permission?(index_permission_code)
|
|
9
|
+
return scope.all if user.super_admin?
|
|
10
|
+
return scope.all if admin_role?
|
|
11
|
+
|
|
12
|
+
scope.none
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
private
|
|
16
|
+
|
|
17
|
+
def admin_role?
|
|
18
|
+
(user.active_role_codes & ApplicationPolicy::ADMIN_ROLES).any?
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def show?
|
|
23
|
+
return user.has_permission?(permission_code(:show)) if admin_visible?
|
|
24
|
+
|
|
25
|
+
user.has_permission?(permission_code(:show)) && owned_record?
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def update?
|
|
29
|
+
return user.has_permission?(permission_code(:update)) if admin_visible?
|
|
30
|
+
|
|
31
|
+
user.has_permission?(permission_code(:update)) && owned_record?
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def owned_record?
|
|
35
|
+
true
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Reviewable workflow actions
|
|
39
|
+
def submit?
|
|
40
|
+
user.has_permission?(permission_code(:submit))
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def approve?
|
|
44
|
+
user.has_permission?(permission_code(:approve))
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def reject?
|
|
48
|
+
user.has_permission?(permission_code(:reject))
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def request_modification?
|
|
52
|
+
user.has_permission?(permission_code(:request_modification))
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def resubmit?
|
|
56
|
+
user.has_permission?(permission_code(:resubmit))
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# Toggle actions
|
|
60
|
+
def activate?
|
|
61
|
+
user.has_permission?(permission_code(:activate))
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def deactivate?
|
|
65
|
+
user.has_permission?(permission_code(:deactivate))
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
private
|
|
69
|
+
|
|
70
|
+
def admin_visible?
|
|
71
|
+
user.super_admin? || (ADMIN_ROLES & user.active_role_codes).any?
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
module Dscf
|
|
2
|
+
module Credit
|
|
3
|
+
class BankStaffPolicy < ApplicationPolicy
|
|
4
|
+
class Scope < ApplicationPolicy::Scope
|
|
5
|
+
def resolve
|
|
6
|
+
return scope.none unless user.has_permission?(index_permission_code)
|
|
7
|
+
return scope.all if user.super_admin?
|
|
8
|
+
|
|
9
|
+
if user.has_role?("BANK_STAFF")
|
|
10
|
+
scope.where(user_id: user.id)
|
|
11
|
+
elsif admin_role?
|
|
12
|
+
scope.all
|
|
13
|
+
else
|
|
14
|
+
scope.none
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def show?
|
|
20
|
+
return user.has_permission?(permission_code(:show)) if non_bank_staff_admin?
|
|
21
|
+
|
|
22
|
+
user.has_permission?(permission_code(:show)) && owned_record?
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def update?
|
|
26
|
+
return user.has_permission?(permission_code(:update)) if non_bank_staff_admin?
|
|
27
|
+
|
|
28
|
+
user.has_permission?(permission_code(:update)) && owned_record?
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def owned_record?
|
|
32
|
+
if user.has_role?("BANK_STAFF")
|
|
33
|
+
record.user_id == user.id
|
|
34
|
+
else
|
|
35
|
+
true
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
private
|
|
40
|
+
|
|
41
|
+
def non_bank_staff_admin?
|
|
42
|
+
user.super_admin? || ((ApplicationPolicy::ADMIN_ROLES - [ "BANK_STAFF" ]) & user.active_role_codes).any?
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
module Dscf
|
|
2
|
+
module Credit
|
|
3
|
+
class EligibleCreditLinePolicy < ApplicationPolicy
|
|
4
|
+
class Scope < ApplicationPolicy::Scope
|
|
5
|
+
def resolve
|
|
6
|
+
return scope.none unless user.has_permission?(index_permission_code)
|
|
7
|
+
return scope.all if user.super_admin?
|
|
8
|
+
return scope.all if admin_role?
|
|
9
|
+
|
|
10
|
+
if user.has_role?("USER")
|
|
11
|
+
scope.joins(loan_profile: :loan_application)
|
|
12
|
+
.where(dscf_credit_loan_applications: { user_id: user.id })
|
|
13
|
+
elsif user.has_role?("FACILITATOR")
|
|
14
|
+
scope.joins(loan_profile: :loan_application)
|
|
15
|
+
.where(
|
|
16
|
+
dscf_credit_loan_applications: { backer_type: "Dscf::Core::User", backer_id: user.id }
|
|
17
|
+
)
|
|
18
|
+
else
|
|
19
|
+
scope.none
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def owned_record?
|
|
25
|
+
if user.has_role?("USER")
|
|
26
|
+
record.loan_profile&.loan_application&.user_id == user.id
|
|
27
|
+
elsif user.has_role?("FACILITATOR")
|
|
28
|
+
la = record.loan_profile&.loan_application
|
|
29
|
+
la&.backer_type == "Dscf::Core::User" && la&.backer_id == user.id
|
|
30
|
+
else
|
|
31
|
+
true
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def apply_risk?
|
|
36
|
+
user.has_permission?(permission_code(:apply_risk))
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module Dscf
|
|
2
|
+
module Credit
|
|
3
|
+
class FacilitatorApplicationPolicy < ApplicationPolicy
|
|
4
|
+
class Scope < ApplicationPolicy::Scope
|
|
5
|
+
def resolve
|
|
6
|
+
return scope.none unless user.has_permission?(index_permission_code)
|
|
7
|
+
return scope.all if user.super_admin?
|
|
8
|
+
return scope.all if admin_role?
|
|
9
|
+
|
|
10
|
+
if user.has_role?("USER") || user.has_role?("FACILITATOR")
|
|
11
|
+
scope.where(user_id: user.id)
|
|
12
|
+
else
|
|
13
|
+
scope.none
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def bulk_create?
|
|
19
|
+
user.has_permission?("facilitator_applications.bulk_create")
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def owned_record?
|
|
23
|
+
if user.has_role?("USER") || user.has_role?("FACILITATOR")
|
|
24
|
+
record.user_id == user.id
|
|
25
|
+
else
|
|
26
|
+
true
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
module Dscf
|
|
2
|
+
module Credit
|
|
3
|
+
class LoanAccrualPolicy < ApplicationPolicy
|
|
4
|
+
class Scope < ApplicationPolicy::Scope
|
|
5
|
+
def resolve
|
|
6
|
+
return scope.none unless user.has_permission?(index_permission_code)
|
|
7
|
+
return scope.all if user.super_admin?
|
|
8
|
+
return scope.all if admin_role?
|
|
9
|
+
|
|
10
|
+
if user.has_role?("USER")
|
|
11
|
+
scope.joins(loan: { loan_profile: :loan_application })
|
|
12
|
+
.where(dscf_credit_loan_applications: { user_id: user.id })
|
|
13
|
+
elsif user.has_role?("FACILITATOR")
|
|
14
|
+
scope.joins(loan: { loan_profile: :loan_application })
|
|
15
|
+
.where(dscf_credit_loan_applications: { backer_type: "Dscf::Core::User", backer_id: user.id })
|
|
16
|
+
else
|
|
17
|
+
scope.none
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def generate?
|
|
23
|
+
user.has_permission?(permission_code(:generate))
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def statistics?
|
|
27
|
+
user.has_permission?(permission_code(:statistics))
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def owned_record?
|
|
31
|
+
if user.has_role?("USER")
|
|
32
|
+
record.loan&.loan_profile&.loan_application&.user_id == user.id
|
|
33
|
+
elsif user.has_role?("FACILITATOR")
|
|
34
|
+
la = record.loan&.loan_profile&.loan_application
|
|
35
|
+
la&.backer_type == "Dscf::Core::User" && la&.backer_id == user.id
|
|
36
|
+
else
|
|
37
|
+
true
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module Dscf
|
|
2
|
+
module Credit
|
|
3
|
+
class LoanApplicationDatumPolicy < ApplicationPolicy
|
|
4
|
+
class Scope < ApplicationPolicy::Scope
|
|
5
|
+
def resolve
|
|
6
|
+
return scope.none unless user.has_permission?(index_permission_code)
|
|
7
|
+
return scope.all if user.super_admin?
|
|
8
|
+
return scope.all if admin_role?
|
|
9
|
+
|
|
10
|
+
if user.has_role?("USER")
|
|
11
|
+
scope.joins(:loan_application)
|
|
12
|
+
.where(dscf_credit_loan_applications: { user_id: user.id })
|
|
13
|
+
elsif user.has_role?("FACILITATOR")
|
|
14
|
+
scope.joins(:loan_application)
|
|
15
|
+
.where(dscf_credit_loan_applications: { backer_type: "Dscf::Core::User", backer_id: user.id })
|
|
16
|
+
else
|
|
17
|
+
scope.none
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def owned_record?
|
|
23
|
+
if user.has_role?("USER")
|
|
24
|
+
record.loan_application&.user_id == user.id
|
|
25
|
+
elsif user.has_role?("FACILITATOR")
|
|
26
|
+
record.loan_application&.backer_type == "Dscf::Core::User" && record.loan_application&.backer_id == user.id
|
|
27
|
+
else
|
|
28
|
+
true
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
module Dscf
|
|
2
|
+
module Credit
|
|
3
|
+
class LoanApplicationPolicy < ApplicationPolicy
|
|
4
|
+
class Scope < ApplicationPolicy::Scope
|
|
5
|
+
def resolve
|
|
6
|
+
return scope.none unless user.has_permission?(index_permission_code)
|
|
7
|
+
return scope.all if user.super_admin?
|
|
8
|
+
return scope.all if admin_role?
|
|
9
|
+
|
|
10
|
+
if user.has_role?("USER")
|
|
11
|
+
scope.where(user_id: user.id)
|
|
12
|
+
elsif user.has_role?("FACILITATOR")
|
|
13
|
+
scope.where(backer_type: "Dscf::Core::User", backer_id: user.id)
|
|
14
|
+
else
|
|
15
|
+
scope.none
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def owned_record?
|
|
21
|
+
if user.has_role?("USER")
|
|
22
|
+
record.user_id == user.id
|
|
23
|
+
elsif user.has_role?("FACILITATOR")
|
|
24
|
+
record.backer_type == "Dscf::Core::User" && record.backer_id == user.id
|
|
25
|
+
else
|
|
26
|
+
true
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def submit_source_data?
|
|
31
|
+
user.has_permission?(permission_code(:submit_source_data))
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def scoring_form?
|
|
35
|
+
user.has_permission?(permission_code(:scoring_form))
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def calculate_credit_score?
|
|
39
|
+
user.has_permission?(permission_code(:calculate_credit_score))
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
module Dscf
|
|
2
|
+
module Credit
|
|
3
|
+
class LoanPolicy < ApplicationPolicy
|
|
4
|
+
class Scope < ApplicationPolicy::Scope
|
|
5
|
+
def resolve
|
|
6
|
+
return scope.none unless user.has_permission?(index_permission_code)
|
|
7
|
+
return scope.all if user.super_admin?
|
|
8
|
+
return scope.all if admin_role?
|
|
9
|
+
|
|
10
|
+
if user.has_role?("USER")
|
|
11
|
+
scope.joins(loan_profile: :loan_application)
|
|
12
|
+
.where(dscf_credit_loan_applications: { user_id: user.id })
|
|
13
|
+
elsif user.has_role?("FACILITATOR")
|
|
14
|
+
scope.joins(loan_profile: :loan_application)
|
|
15
|
+
.where(
|
|
16
|
+
dscf_credit_loan_applications: { backer_type: "Dscf::Core::User", backer_id: user.id }
|
|
17
|
+
)
|
|
18
|
+
else
|
|
19
|
+
scope.none
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def owned_record?
|
|
25
|
+
if user.has_role?("USER")
|
|
26
|
+
record.loan_profile&.loan_application&.user_id == user.id
|
|
27
|
+
elsif user.has_role?("FACILITATOR")
|
|
28
|
+
la = record.loan_profile&.loan_application
|
|
29
|
+
la&.backer_type == "Dscf::Core::User" && la&.backer_id == user.id
|
|
30
|
+
else
|
|
31
|
+
true
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
module Dscf
|
|
2
|
+
module Credit
|
|
3
|
+
class LoanProfilePolicy < ApplicationPolicy
|
|
4
|
+
class Scope < ApplicationPolicy::Scope
|
|
5
|
+
def resolve
|
|
6
|
+
return scope.none unless user.has_permission?(index_permission_code)
|
|
7
|
+
return scope.all if user.super_admin?
|
|
8
|
+
return scope.all if admin_role?
|
|
9
|
+
|
|
10
|
+
if user.has_role?("USER")
|
|
11
|
+
scope.joins(:loan_application).where(dscf_credit_loan_applications: { user_id: user.id })
|
|
12
|
+
elsif user.has_role?("FACILITATOR")
|
|
13
|
+
scope.joins(:loan_application).where(
|
|
14
|
+
dscf_credit_loan_applications: { backer_type: "Dscf::Core::User", backer_id: user.id }
|
|
15
|
+
)
|
|
16
|
+
else
|
|
17
|
+
scope.none
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def owned_record?
|
|
23
|
+
if user.has_role?("USER")
|
|
24
|
+
record.loan_application&.user_id == user.id
|
|
25
|
+
elsif user.has_role?("FACILITATOR")
|
|
26
|
+
record.loan_application&.backer_type == "Dscf::Core::User" &&
|
|
27
|
+
record.loan_application&.backer_id == user.id
|
|
28
|
+
else
|
|
29
|
+
true
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def calculate_facility_limits?
|
|
34
|
+
user.has_permission?(permission_code(:calculate_facility_limits))
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
module Dscf
|
|
2
|
+
module Credit
|
|
3
|
+
class LoanTransactionPolicy < ApplicationPolicy
|
|
4
|
+
class Scope < ApplicationPolicy::Scope
|
|
5
|
+
def resolve
|
|
6
|
+
return scope.none unless user.has_permission?(index_permission_code)
|
|
7
|
+
return scope.all if user.super_admin?
|
|
8
|
+
return scope.all if admin_role?
|
|
9
|
+
|
|
10
|
+
if user.has_role?("USER")
|
|
11
|
+
scope.joins(loan: { loan_profile: :loan_application })
|
|
12
|
+
.where(dscf_credit_loan_applications: { user_id: user.id })
|
|
13
|
+
elsif user.has_role?("FACILITATOR")
|
|
14
|
+
scope.joins(loan: { loan_profile: :loan_application })
|
|
15
|
+
.where(dscf_credit_loan_applications: { backer_type: "Dscf::Core::User", backer_id: user.id })
|
|
16
|
+
else
|
|
17
|
+
scope.none
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def owned_record?
|
|
23
|
+
if user.has_role?("USER")
|
|
24
|
+
record.loan&.loan_profile&.loan_application&.user_id == user.id
|
|
25
|
+
elsif user.has_role?("FACILITATOR")
|
|
26
|
+
la = record.loan&.loan_profile&.loan_application
|
|
27
|
+
la&.backer_type == "Dscf::Core::User" && la&.backer_id == user.id
|
|
28
|
+
else
|
|
29
|
+
true
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|