dscf-banking 0.2.8 → 0.2.9
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/accounts_controller.rb +18 -0
- data/app/controllers/dscf/banking/applications_controller.rb +0 -24
- data/app/models/dscf/banking/application.rb +55 -2
- data/app/serializers/dscf/banking/document_serializer.rb +5 -1
- data/app/services/dscf/banking/account_creation_service.rb +1 -1
- data/config/initializers/review_extensions.rb +36 -0
- data/config/routes.rb +3 -0
- data/lib/dscf/banking/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df271e9f69727201aab1508e782bf5a18e7b59fba9e67dffd2224d92319f9280
|
4
|
+
data.tar.gz: '0618830ecf6bbab8f90cfffc3da24303cd08788cc8387d42070c4093b9be5b45'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ff010dc9f9a04cddbcebf7dcdd83b5ba0b592a6bac40da63422002a7db9e2f9ecede7ae7aef4cc0cafd8ce579c2d8df8c3773f1e4ea8261de8839de353c8788
|
7
|
+
data.tar.gz: 8e52eeaa335df4fbeb0af438cbb1ac1f9a9c9ee15de8629212ad9bae3ce7eb2984e2936f485f9a5edb052e45ab7bd2738c0cc3fe898dcf5ce5bcb5971ed4d393
|
@@ -195,6 +195,24 @@ module Dscf::Banking
|
|
195
195
|
}, status: :not_found
|
196
196
|
end
|
197
197
|
|
198
|
+
def me
|
199
|
+
accounts = Dscf::Banking::Account
|
200
|
+
.joins(:application)
|
201
|
+
.where("dscf_banking_applications.user_id = ?", current_user.id)
|
202
|
+
.includes(:application, :virtual_account_product)
|
203
|
+
|
204
|
+
# Apply ordering
|
205
|
+
order_column = allowed_order_columns.include?(params[:order_by]) ? params[:order_by] : "created_at"
|
206
|
+
order_direction = %w[asc desc].include?(params[:order_direction]) ? params[:order_direction] : "desc"
|
207
|
+
accounts = accounts.order("dscf_banking_accounts.#{order_column} #{order_direction}")
|
208
|
+
|
209
|
+
render json: {
|
210
|
+
success: true,
|
211
|
+
data: accounts.map { |account| account_data(account) },
|
212
|
+
message: "User accounts retrieved successfully"
|
213
|
+
}
|
214
|
+
end
|
215
|
+
|
198
216
|
private
|
199
217
|
|
200
218
|
def account_data(account)
|
@@ -22,30 +22,6 @@ 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
|
-
|
49
25
|
private
|
50
26
|
|
51
27
|
def application_data(application)
|
@@ -22,6 +22,7 @@ module Dscf::Banking
|
|
22
22
|
before_validation :generate_application_number, if: -> { new_record? && application_number.blank? }
|
23
23
|
before_update :set_timestamps_on_status_change
|
24
24
|
after_commit :create_account_if_approved, on: :update
|
25
|
+
after_find :sync_status_if_needed
|
25
26
|
|
26
27
|
def approve!(approved_by = nil)
|
27
28
|
update!(status: :approved, completed_at: Time.current)
|
@@ -45,7 +46,12 @@ module Dscf::Banking
|
|
45
46
|
|
46
47
|
def review_status
|
47
48
|
latest_review = reviews.where(context: "default").order(created_at: :desc).first
|
48
|
-
latest_review&.status || status
|
49
|
+
review_st = latest_review&.status || status
|
50
|
+
|
51
|
+
# Sync application status with review status
|
52
|
+
sync_status_with_review(review_st) if latest_review
|
53
|
+
|
54
|
+
review_st
|
49
55
|
end
|
50
56
|
|
51
57
|
def self.ransackable_attributes(auth_object = nil)
|
@@ -77,10 +83,57 @@ module Dscf::Banking
|
|
77
83
|
end
|
78
84
|
|
79
85
|
def create_account_if_approved
|
80
|
-
|
86
|
+
# First sync the status with the latest review
|
87
|
+
current_review_status = review_status # This will call sync_status_with_review
|
88
|
+
|
89
|
+
reload # Reload to get the updated status
|
90
|
+
|
91
|
+
return unless status_approved?
|
81
92
|
return if has_account?
|
82
93
|
|
83
94
|
AccountCreationService.call(self)
|
84
95
|
end
|
96
|
+
|
97
|
+
def sync_status_with_review(review_st)
|
98
|
+
return if @syncing_status
|
99
|
+
|
100
|
+
status_map = {
|
101
|
+
"submitted" => "submitted",
|
102
|
+
"under_review" => "under_review",
|
103
|
+
"approved" => "approved",
|
104
|
+
"rejected" => "rejected",
|
105
|
+
"request_modification" => "request_modification"
|
106
|
+
}
|
107
|
+
|
108
|
+
mapped_status = status_map[review_st]
|
109
|
+
if mapped_status && status != mapped_status && !new_record?
|
110
|
+
@syncing_status = true
|
111
|
+
|
112
|
+
# Prepare attributes for update
|
113
|
+
attributes_to_update = { status: mapped_status }
|
114
|
+
|
115
|
+
# If rejecting, also set rejection_reason from review feedback
|
116
|
+
if mapped_status == "rejected"
|
117
|
+
latest_review = reviews.where(context: "default", status: "rejected").order(created_at: :desc).first
|
118
|
+
if latest_review&.feedback.present?
|
119
|
+
attributes_to_update[:rejection_reason] = latest_review.feedback
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
update!(attributes_to_update)
|
124
|
+
@syncing_status = false
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
def sync_status_if_needed
|
129
|
+
return if @status_synced || new_record?
|
130
|
+
|
131
|
+
latest_review = reviews.where(context: "default").order(created_at: :desc).first
|
132
|
+
if latest_review && latest_review.status != status
|
133
|
+
sync_status_with_review(latest_review.status)
|
134
|
+
end
|
135
|
+
|
136
|
+
@status_synced = true
|
137
|
+
end
|
85
138
|
end
|
86
139
|
end
|
@@ -1,8 +1,12 @@
|
|
1
1
|
module Dscf::Banking
|
2
2
|
class DocumentSerializer < ActiveModel::Serializer
|
3
|
-
attributes :id, :document_type, :is_verified, :verified_at, :metadata, :created_at, :updated_at
|
3
|
+
attributes :id, :document_type, :is_verified, :verified_at, :metadata, :created_at, :updated_at, :file_url
|
4
4
|
|
5
5
|
# Remove polymorphic association that causes ActiveStorage issues
|
6
6
|
# belongs_to :verified_by, polymorphic: true, optional: true
|
7
|
+
|
8
|
+
def file_url
|
9
|
+
object.file_url
|
10
|
+
end
|
7
11
|
end
|
8
12
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Dscf::Banking
|
2
|
+
module ReviewExtensions
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
after_create :sync_application_status, if: -> { reviewable.is_a?(Dscf::Banking::Application) }
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def sync_application_status
|
12
|
+
return unless reviewable.is_a?(Dscf::Banking::Application)
|
13
|
+
|
14
|
+
application = reviewable
|
15
|
+
review_status = application.review_status
|
16
|
+
|
17
|
+
status_map = {
|
18
|
+
"submitted" => "submitted",
|
19
|
+
"under_review" => "under_review",
|
20
|
+
"approved" => "approved",
|
21
|
+
"rejected" => "rejected",
|
22
|
+
"request_modification" => "request_modification"
|
23
|
+
}
|
24
|
+
|
25
|
+
mapped_status = status_map[review_status]
|
26
|
+
if mapped_status && application.status != mapped_status
|
27
|
+
application.update!(status: mapped_status)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# Extend the Dscf::Core::Review model with our extensions
|
34
|
+
Rails.application.config.to_prepare do
|
35
|
+
Dscf::Core::Review.include(Dscf::Banking::ReviewExtensions) if defined?(Dscf::Core::Review)
|
36
|
+
end
|
data/config/routes.rb
CHANGED
data/lib/dscf/banking/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eyosiyas Mekbib
|
@@ -482,6 +482,7 @@ files:
|
|
482
482
|
- app/services/dscf/banking/deposit_service.rb
|
483
483
|
- app/services/dscf/banking/transfer_service.rb
|
484
484
|
- app/services/dscf/banking/withdrawal_service.rb
|
485
|
+
- config/initializers/review_extensions.rb
|
485
486
|
- config/locales/en.yml
|
486
487
|
- config/routes.rb
|
487
488
|
- db/migrate/20250830211002_create_dscf_banking_product_categories.rb
|