dscf-banking 0.2.6 → 0.2.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/banking/applications_controller.rb +30 -6
- data/app/controllers/dscf/banking/documents_controller.rb +53 -0
- data/app/controllers/dscf/banking/transactions_controller.rb +1 -1
- data/app/controllers/dscf/banking/virtual_account_products_controller.rb +4 -4
- data/app/models/dscf/banking/application.rb +11 -9
- data/app/serializers/dscf/banking/application_serializer.rb +1 -0
- data/app/serializers/dscf/banking/document_serializer.rb +8 -0
- data/app/services/dscf/banking/account_creation_service.rb +1 -1
- data/config/routes.rb +1 -0
- data/db/seeds.rb +1 -1
- data/lib/dscf/banking/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd6bfb0114ad393bd22ae2bf1db82507a7e50299aa6f7ac0c433e53ae3a24e91
|
4
|
+
data.tar.gz: 97773b5c82e95ab7d227d9473ce82658ce4df88966506d0354ee10d360749023
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41ff719fa8dceb6e423d57c80bc8d9b96aeb2ab619ab94eccffb24bc1cbe4ce852b160ecde131084e11902aedf95df074af6b3589ffe3335f28cfcf10abccdcc
|
7
|
+
data.tar.gz: 5db3b15472498d3509cfe556ade8bf5e64ff7261cd3e0a338f898351c8a59110fddba5d4a04f1857a106508a5154c88d8dcd3964fbcaa5b22800478ede721e49
|
@@ -22,9 +22,33 @@ module Dscf::Banking
|
|
22
22
|
resubmit: { status: "submitted", update_model: true }
|
23
23
|
}
|
24
24
|
|
25
|
+
# Override perform_review_action to sync application status with review status
|
26
|
+
def perform_review_action(action_name, action_config, context_name)
|
27
|
+
result = super
|
28
|
+
|
29
|
+
# After successful review action, update the application's status to match
|
30
|
+
if result.is_a?(Hash) && result[:success] && @obj
|
31
|
+
review_status = @obj.review_status
|
32
|
+
application_status_map = {
|
33
|
+
"submitted" => "submitted",
|
34
|
+
"under_review" => "under_review",
|
35
|
+
"approved" => "approved",
|
36
|
+
"rejected" => "rejected",
|
37
|
+
"request_modification" => "request_modification"
|
38
|
+
}
|
39
|
+
|
40
|
+
new_status = application_status_map[review_status]
|
41
|
+
if new_status && @obj.status != new_status
|
42
|
+
@obj.update_column(:status, Application.statuses[new_status])
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
result
|
47
|
+
end
|
48
|
+
|
25
49
|
private
|
26
50
|
|
27
|
-
|
51
|
+
def application_data(application)
|
28
52
|
{
|
29
53
|
id: application.id,
|
30
54
|
application_number: application.application_number,
|
@@ -52,7 +76,7 @@ module Dscf::Banking
|
|
52
76
|
end
|
53
77
|
|
54
78
|
def eager_loaded_associations
|
55
|
-
[ :user, :virtual_account_product, reviews: { reviewed_by: :user_profile } ]
|
79
|
+
[ :user, :virtual_account_product, :account, :documents, reviews: { reviewed_by: :user_profile } ]
|
56
80
|
end
|
57
81
|
|
58
82
|
def allowed_order_columns
|
@@ -61,10 +85,10 @@ module Dscf::Banking
|
|
61
85
|
|
62
86
|
def default_serializer_includes
|
63
87
|
{
|
64
|
-
index: [:user, :virtual_account_product, reviews: { reviewed_by: :user_profile }],
|
65
|
-
show: [:user, :virtual_account_product, :account, reviews: { reviewed_by: :user_profile }],
|
66
|
-
create: [:reviews],
|
67
|
-
update: [:user, :virtual_account_product, :account, reviews: { reviewed_by: :user_profile }]
|
88
|
+
index: [ :user, :virtual_account_product, :documents, reviews: { reviewed_by: :user_profile } ],
|
89
|
+
show: [ :user, :virtual_account_product, :account, :documents, reviews: { reviewed_by: :user_profile } ],
|
90
|
+
create: [ :reviews, :documents ],
|
91
|
+
update: [ :user, :virtual_account_product, :account, :documents, reviews: { reviewed_by: :user_profile } ]
|
68
92
|
}
|
69
93
|
end
|
70
94
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Dscf::Banking
|
2
|
+
class DocumentsController < ApplicationController
|
3
|
+
include Dscf::Core::Common
|
4
|
+
|
5
|
+
before_action :find_application
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
def find_application
|
10
|
+
@application = Application.find(params[:application_id])
|
11
|
+
end
|
12
|
+
|
13
|
+
def model_class
|
14
|
+
Dscf::Core::Document
|
15
|
+
end
|
16
|
+
|
17
|
+
def collection
|
18
|
+
@application.documents
|
19
|
+
end
|
20
|
+
|
21
|
+
def build_resource
|
22
|
+
@application.documents.build
|
23
|
+
end
|
24
|
+
|
25
|
+
def find_resource
|
26
|
+
@application.documents.find(params[:id])
|
27
|
+
end
|
28
|
+
|
29
|
+
def model_params
|
30
|
+
params.require(:document).permit(
|
31
|
+
:document_type,
|
32
|
+
metadata: {}
|
33
|
+
).merge(documentable: @application)
|
34
|
+
end
|
35
|
+
|
36
|
+
def eager_loaded_associations
|
37
|
+
[]
|
38
|
+
end
|
39
|
+
|
40
|
+
def allowed_order_columns
|
41
|
+
%w[id document_type is_verified verified_at created_at updated_at]
|
42
|
+
end
|
43
|
+
|
44
|
+
def default_serializer_includes
|
45
|
+
{
|
46
|
+
index: [],
|
47
|
+
show: [],
|
48
|
+
create: [],
|
49
|
+
update: []
|
50
|
+
}
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -83,10 +83,10 @@ module Dscf::Banking
|
|
83
83
|
|
84
84
|
def default_serializer_includes
|
85
85
|
{
|
86
|
-
index: [:product_category, :created_by, :approved_by, reviews: { reviewed_by: :user_profile }],
|
87
|
-
show: [:product_category, :created_by, :approved_by, reviews: { reviewed_by: :user_profile }],
|
88
|
-
create: [:reviews],
|
89
|
-
update: [:product_category, :created_by, :approved_by, reviews: { reviewed_by: :user_profile }]
|
86
|
+
index: [ :product_category, :created_by, :approved_by, reviews: { reviewed_by: :user_profile } ],
|
87
|
+
show: [ :product_category, :created_by, :approved_by, reviews: { reviewed_by: :user_profile } ],
|
88
|
+
create: [ :reviews ],
|
89
|
+
update: [ :product_category, :created_by, :approved_by, reviews: { reviewed_by: :user_profile } ]
|
90
90
|
}
|
91
91
|
end
|
92
92
|
end
|
@@ -8,6 +8,7 @@ module Dscf::Banking
|
|
8
8
|
belongs_to :assigned_branch_manager, class_name: "Dscf::Core::User", optional: true
|
9
9
|
belongs_to :virtual_account_product, class_name: "Dscf::Banking::VirtualAccountProduct"
|
10
10
|
has_one :account, class_name: "Dscf::Banking::Account"
|
11
|
+
has_many :documents, class_name: "Dscf::Core::Document", as: :documentable, dependent: :destroy
|
11
12
|
|
12
13
|
validates :application_number, presence: true, uniqueness: true, length: { maximum: 50 }
|
13
14
|
validates :applicant_type, presence: true
|
@@ -20,7 +21,7 @@ module Dscf::Banking
|
|
20
21
|
|
21
22
|
before_validation :generate_application_number, if: -> { new_record? && application_number.blank? }
|
22
23
|
before_update :set_timestamps_on_status_change
|
23
|
-
|
24
|
+
after_commit :create_account_if_approved, on: :update
|
24
25
|
|
25
26
|
def approve!(approved_by = nil)
|
26
27
|
update!(status: :approved, completed_at: Time.current)
|
@@ -43,22 +44,16 @@ module Dscf::Banking
|
|
43
44
|
end
|
44
45
|
|
45
46
|
def review_status
|
46
|
-
latest_review = reviews.where(context:
|
47
|
+
latest_review = reviews.where(context: "default").order(created_at: :desc).first
|
47
48
|
latest_review&.status || status
|
48
49
|
end
|
49
50
|
|
50
|
-
def create_account_if_approved
|
51
|
-
if review_status == 'approved' && !has_account?
|
52
|
-
AccountCreationService.call(self)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
51
|
def self.ransackable_attributes(auth_object = nil)
|
57
52
|
%w[id application_number status submitted_at completed_at created_at updated_at]
|
58
53
|
end
|
59
54
|
|
60
55
|
def self.ransackable_associations(auth_object = nil)
|
61
|
-
%w[user virtual_account_product account reviews]
|
56
|
+
%w[user virtual_account_product account reviews documents]
|
62
57
|
end
|
63
58
|
|
64
59
|
private
|
@@ -80,5 +75,12 @@ module Dscf::Banking
|
|
80
75
|
end
|
81
76
|
end
|
82
77
|
end
|
78
|
+
|
79
|
+
def create_account_if_approved
|
80
|
+
return unless review_status == "approved"
|
81
|
+
return if has_account?
|
82
|
+
|
83
|
+
AccountCreationService.call(self)
|
84
|
+
end
|
83
85
|
end
|
84
86
|
end
|
@@ -9,6 +9,7 @@ module Dscf::Banking
|
|
9
9
|
belongs_to :assigned_branch_manager, optional: true
|
10
10
|
has_one :account, serializer: AccountSerializer, if: :has_account?
|
11
11
|
has_many :reviews, serializer: Dscf::Core::ReviewSerializer
|
12
|
+
has_many :documents, serializer: DocumentSerializer
|
12
13
|
|
13
14
|
def has_account?
|
14
15
|
object.has_account?
|
@@ -0,0 +1,8 @@
|
|
1
|
+
module Dscf::Banking
|
2
|
+
class DocumentSerializer < ActiveModel::Serializer
|
3
|
+
attributes :id, :document_type, :is_verified, :verified_at, :metadata, :created_at, :updated_at
|
4
|
+
|
5
|
+
# Remove polymorphic association that causes ActiveStorage issues
|
6
|
+
# belongs_to :verified_by, polymorphic: true, optional: true
|
7
|
+
end
|
8
|
+
end
|
data/config/routes.rb
CHANGED
data/db/seeds.rb
CHANGED
@@ -63,7 +63,7 @@ end
|
|
63
63
|
puts "Created system deposit account: #{system_deposit_account.name}"
|
64
64
|
|
65
65
|
system_withdrawal_account = Dscf::Banking::Account.find_or_create_by(
|
66
|
-
name: "System Withdrawal Account",
|
66
|
+
name: "System Withdrawal Account",
|
67
67
|
system_account: true
|
68
68
|
) do |account|
|
69
69
|
account.currency = "ETB"
|
data/lib/dscf/banking/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dscf-banking
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eyosiyas Mekbib
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-10-
|
10
|
+
date: 2025-10-15 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: rails
|