dscf-banking 0.2.7 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c92f5cf56bdb2b4a3f6d15d1c75cfd1ac51da1e2e525ba7a568e80f289564d8a
4
- data.tar.gz: 34962544cd525e20993f49a278655c6d291803c86a411b90eb3946f1aec62aea
3
+ metadata.gz: bd6bfb0114ad393bd22ae2bf1db82507a7e50299aa6f7ac0c433e53ae3a24e91
4
+ data.tar.gz: 97773b5c82e95ab7d227d9473ce82658ce4df88966506d0354ee10d360749023
5
5
  SHA512:
6
- metadata.gz: 12ba4363d0f4ab6b8edf6a432539b325d68a58d7ef49b1a1d0d756ccbe7880d311eeb903e63d19920a4bc25631b1c345abcabf5bb95cd8307ffa3be2b694c43d
7
- data.tar.gz: 2b8514d69f366c986b88f393fb8e7102974c71ae3936ab618b21ad59318c2002df6b1b21db304465177351189be07486ce4552f2ac0dbdb556fb4e1010a86b2b
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
- def application_data(application)
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, :documents, 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
@@ -21,7 +21,7 @@ module Dscf::Banking
21
21
 
22
22
  before_validation :generate_application_number, if: -> { new_record? && application_number.blank? }
23
23
  before_update :set_timestamps_on_status_change
24
- after_update :create_account_if_approved
24
+ after_commit :create_account_if_approved, on: :update
25
25
 
26
26
  def approve!(approved_by = nil)
27
27
  update!(status: :approved, completed_at: Time.current)
@@ -48,12 +48,6 @@ module Dscf::Banking
48
48
  latest_review&.status || status
49
49
  end
50
50
 
51
- def create_account_if_approved
52
- if review_status == "approved" && !has_account?
53
- AccountCreationService.call(self)
54
- end
55
- end
56
-
57
51
  def self.ransackable_attributes(auth_object = nil)
58
52
  %w[id application_number status submitted_at completed_at created_at updated_at]
59
53
  end
@@ -81,5 +75,12 @@ module Dscf::Banking
81
75
  end
82
76
  end
83
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
84
85
  end
85
86
  end
@@ -1,5 +1,5 @@
1
1
  module Dscf
2
2
  module Banking
3
- VERSION = "0.2.7"
3
+ VERSION = "0.2.8"
4
4
  end
5
5
  end
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.7
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eyosiyas Mekbib