dscf-banking 0.2.6 → 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: 318c6e93b2062a45adb19d98709d9f0812788e0137bea60f9b56d66d2617b56a
4
- data.tar.gz: 910120a3392d73f497aa511c3f971da9326a4a7ddc45d5820430d908b0959c05
3
+ metadata.gz: c92f5cf56bdb2b4a3f6d15d1c75cfd1ac51da1e2e525ba7a568e80f289564d8a
4
+ data.tar.gz: 34962544cd525e20993f49a278655c6d291803c86a411b90eb3946f1aec62aea
5
5
  SHA512:
6
- metadata.gz: 2195accd89bcc4f487e514e8209c31131c011bb5d676729d5ea18c68955d2bfd98a179a85e018c8e54901a473ee9c16da8179feb1c3580534fea68c273bc26c6
7
- data.tar.gz: 28a117bad46972db2b9759dcfeee8c3d9bba034bada79f924058b096a6873a93d84a1fd4f39942f3857bc8a94feef3462374f2334a82a2c28a470a8b9cdc86f7
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
@@ -43,12 +44,12 @@ module Dscf::Banking
43
44
  end
44
45
 
45
46
  def review_status
46
- latest_review = reviews.where(context: 'default').order(created_at: :desc).first
47
+ latest_review = reviews.where(context: "default").order(created_at: :desc).first
47
48
  latest_review&.status || status
48
49
  end
49
50
 
50
51
  def create_account_if_approved
51
- if review_status == 'approved' && !has_account?
52
+ if review_status == "approved" && !has_account?
52
53
  AccountCreationService.call(self)
53
54
  end
54
55
  end
@@ -58,7 +59,7 @@ module Dscf::Banking
58
59
  end
59
60
 
60
61
  def self.ransackable_associations(auth_object = nil)
61
- %w[user virtual_account_product account reviews]
62
+ %w[user virtual_account_product account reviews documents]
62
63
  end
63
64
 
64
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.review_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.6"
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.6
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