dscf-banking 0.2.5 → 0.2.7

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: ae4e30f9cb66b830a7f1dbca21d6367ca2d8f1e7ac2c2498a7fffd47d43dcb98
4
- data.tar.gz: 9d665128ce356618b58555517a363edcd950ecc7f9bc2bd84e275442d345de27
3
+ metadata.gz: c92f5cf56bdb2b4a3f6d15d1c75cfd1ac51da1e2e525ba7a568e80f289564d8a
4
+ data.tar.gz: 34962544cd525e20993f49a278655c6d291803c86a411b90eb3946f1aec62aea
5
5
  SHA512:
6
- metadata.gz: 9144d56b603e412a7107775a79f0512dea89d38c7ef524762e94f968a9528e62b93cb9eae92fcb36775c95c9b8685eb39eabae9bf52000c5f72b2297da2820f8
7
- data.tar.gz: '03409240d9099a644c393a5a07328540f4775679d4b92ef212477272d3306df2829c74aa06522cc276e24371fb6fc54f129577c447d1b851de48a0c3fb99e61a'
6
+ metadata.gz: 12ba4363d0f4ab6b8edf6a432539b325d68a58d7ef49b1a1d0d756ccbe7880d311eeb903e63d19920a4bc25631b1c345abcabf5bb95cd8307ffa3be2b694c43d
7
+ data.tar.gz: 2b8514d69f366c986b88f393fb8e7102974c71ae3936ab618b21ad59318c2002df6b1b21db304465177351189be07486ce4552f2ac0dbdb556fb4e1010a86b2b
@@ -52,7 +52,7 @@ module Dscf::Banking
52
52
  end
53
53
 
54
54
  def eager_loaded_associations
55
- [ :user, :virtual_account_product, reviews: { reviewed_by: :user_profile } ]
55
+ [ :user, :virtual_account_product, :documents, reviews: { reviewed_by: :user_profile } ]
56
56
  end
57
57
 
58
58
  def allowed_order_columns
@@ -61,10 +61,10 @@ module Dscf::Banking
61
61
 
62
62
  def default_serializer_includes
63
63
  {
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 }]
64
+ index: [ :user, :virtual_account_product, :documents, reviews: { reviewed_by: :user_profile } ],
65
+ show: [ :user, :virtual_account_product, :account, :documents, reviews: { reviewed_by: :user_profile } ],
66
+ create: [ :reviews, :documents ],
67
+ update: [ :user, :virtual_account_product, :account, :documents, reviews: { reviewed_by: :user_profile } ]
68
68
  }
69
69
  end
70
70
  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
@@ -6,7 +6,7 @@ module Dscf::Banking
6
6
  render json: {
7
7
  success: false,
8
8
  error: "Transaction not found",
9
- errors: ["Transaction with ID #{params[:id]} not found"]
9
+ errors: [ "Transaction with ID #{params[:id]} not found" ]
10
10
  }, status: :not_found
11
11
  end
12
12
 
@@ -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
@@ -42,8 +43,13 @@ module Dscf::Banking
42
43
  Account.exists?(application: self)
43
44
  end
44
45
 
46
+ def review_status
47
+ latest_review = reviews.where(context: "default").order(created_at: :desc).first
48
+ latest_review&.status || status
49
+ end
50
+
45
51
  def create_account_if_approved
46
- if saved_change_to_status? && status_approved?
52
+ if review_status == "approved" && !has_account?
47
53
  AccountCreationService.call(self)
48
54
  end
49
55
  end
@@ -53,7 +59,7 @@ module Dscf::Banking
53
59
  end
54
60
 
55
61
  def self.ransackable_associations(auth_object = nil)
56
- %w[user virtual_account_product account reviews]
62
+ %w[user virtual_account_product account reviews documents]
57
63
  end
58
64
 
59
65
  private
@@ -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
@@ -9,7 +9,7 @@ module Dscf::Banking
9
9
  end
10
10
 
11
11
  def call
12
- return nil unless @application.status_approved?
12
+ return nil unless @application.review_status == "approved"
13
13
  return nil if account_already_exists?
14
14
 
15
15
  create_account
data/config/routes.rb CHANGED
@@ -30,6 +30,7 @@ Dscf::Banking::Engine.routes.draw do
30
30
  patch :request_modification
31
31
  patch :resubmit
32
32
  end
33
+ resources :documents, only: [ :index, :show, :create, :update, :destroy ]
33
34
  end
34
35
 
35
36
  resources :transaction_types
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"
@@ -1,5 +1,5 @@
1
1
  module Dscf
2
2
  module Banking
3
- VERSION = "0.2.5"
3
+ VERSION = "0.2.7"
4
4
  end
5
5
  end
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.5
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eyosiyas Mekbib
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-10-14 00:00:00.000000000 Z
10
+ date: 2025-10-15 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rails