dscf-banking 0.1.16 → 0.2.0
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 +102 -1
- data/db/seeds.rb +41 -115
- 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: '094b7617272cff3416e77ed910c60da7f90887cea49f72e091c25f1afd53ed69'
|
4
|
+
data.tar.gz: 1a0f6c7facbbabfd8c1bac7681a9acd6cd104dd09cb5b23115ed0859a977ae7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b9dd2e200c84a1a7cc56f4d857589b9ea732f7a9497184286e47f1aa989ee116449ce55a2d28153ab95e817e99c419ceaa19a2a143c0085e4a9b0e59b081621
|
7
|
+
data.tar.gz: 7af432c8545eac1b2537376d23cb5802bf2fb31964f89377b39e36d96fc26646f19e9ad1f4bb0c9c7a21fd62c4f8f3df3ca38f5bf34f21e76cbd578dc6b46608
|
@@ -2,6 +2,106 @@ module Dscf::Banking
|
|
2
2
|
class AccountsController < ApplicationController
|
3
3
|
include Dscf::Core::Common
|
4
4
|
|
5
|
+
def index
|
6
|
+
accounts = Dscf::Banking::Account.all
|
7
|
+
|
8
|
+
# Apply filters that require joins
|
9
|
+
if params[:user_id].present?
|
10
|
+
accounts = accounts.joins(:application).where("dscf_banking_applications.user_id = ?", params[:user_id])
|
11
|
+
end
|
12
|
+
|
13
|
+
# Apply other filters
|
14
|
+
accounts = accounts.where(status: params[:status]) if params[:status].present?
|
15
|
+
accounts = accounts.where(currency: params[:currency]) if params[:currency].present?
|
16
|
+
accounts = accounts.where(application_id: params[:application_id]) if params[:application_id].present?
|
17
|
+
accounts = accounts.where(virtual_account_product_id: params[:virtual_account_product_id]) if params[:virtual_account_product_id].present?
|
18
|
+
accounts = accounts.where(active: params[:active]) if params[:active].present?
|
19
|
+
|
20
|
+
# Apply ordering
|
21
|
+
order_column = allowed_order_columns.include?(params[:order_by]) ? params[:order_by] : "created_at"
|
22
|
+
order_direction = %w[asc desc].include?(params[:order_direction]) ? params[:order_direction] : "desc"
|
23
|
+
accounts = accounts.order("#{order_column} #{order_direction}")
|
24
|
+
|
25
|
+
render json: {
|
26
|
+
success: true,
|
27
|
+
data: accounts.map { |account| account_data(account) }
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
def show
|
32
|
+
account = Dscf::Banking::Account.find(params[:id])
|
33
|
+
render json: {
|
34
|
+
success: true,
|
35
|
+
data: account_data(account)
|
36
|
+
}
|
37
|
+
rescue ActiveRecord::RecordNotFound
|
38
|
+
render json: {
|
39
|
+
success: false,
|
40
|
+
error: "Account not found"
|
41
|
+
}, status: :not_found
|
42
|
+
end
|
43
|
+
|
44
|
+
def create
|
45
|
+
account = Dscf::Banking::Account.new(model_params)
|
46
|
+
|
47
|
+
if account.save
|
48
|
+
render json: {
|
49
|
+
success: true,
|
50
|
+
data: account_data(account)
|
51
|
+
}, status: :created
|
52
|
+
else
|
53
|
+
render json: {
|
54
|
+
success: false,
|
55
|
+
error: "Failed to create account",
|
56
|
+
errors: account.errors.full_messages
|
57
|
+
}, status: :unprocessable_entity
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def update
|
62
|
+
account = Dscf::Banking::Account.find(params[:id])
|
63
|
+
|
64
|
+
if account.update(model_params)
|
65
|
+
render json: {
|
66
|
+
success: true,
|
67
|
+
data: account_data(account)
|
68
|
+
}
|
69
|
+
else
|
70
|
+
render json: {
|
71
|
+
success: false,
|
72
|
+
error: "Failed to update account",
|
73
|
+
errors: account.errors.full_messages
|
74
|
+
}, status: :unprocessable_entity
|
75
|
+
end
|
76
|
+
rescue ActiveRecord::RecordNotFound
|
77
|
+
render json: {
|
78
|
+
success: false,
|
79
|
+
error: "Account not found"
|
80
|
+
}, status: :not_found
|
81
|
+
end
|
82
|
+
|
83
|
+
def destroy
|
84
|
+
account = Dscf::Banking::Account.find(params[:id])
|
85
|
+
|
86
|
+
if account.destroy
|
87
|
+
render json: {
|
88
|
+
success: true,
|
89
|
+
message: "Account deleted successfully"
|
90
|
+
}
|
91
|
+
else
|
92
|
+
render json: {
|
93
|
+
success: false,
|
94
|
+
error: "Failed to delete account",
|
95
|
+
errors: account.errors.full_messages
|
96
|
+
}, status: :bad_request
|
97
|
+
end
|
98
|
+
rescue ActiveRecord::RecordNotFound
|
99
|
+
render json: {
|
100
|
+
success: false,
|
101
|
+
error: "Account not found"
|
102
|
+
}, status: :not_found
|
103
|
+
end
|
104
|
+
|
5
105
|
def activate
|
6
106
|
account = Dscf::Banking::Account.find(params[:id])
|
7
107
|
|
@@ -112,6 +212,7 @@ module Dscf::Banking
|
|
112
212
|
active: account.active,
|
113
213
|
application_id: account.application_id,
|
114
214
|
virtual_account_product_id: account.virtual_account_product_id,
|
215
|
+
account_properties: account.account_properties,
|
115
216
|
created_at: account.created_at,
|
116
217
|
updated_at: account.updated_at
|
117
218
|
}
|
@@ -135,7 +236,7 @@ module Dscf::Banking
|
|
135
236
|
end
|
136
237
|
|
137
238
|
def eager_loaded_associations
|
138
|
-
[
|
239
|
+
[]
|
139
240
|
end
|
140
241
|
|
141
242
|
def allowed_order_columns
|
data/db/seeds.rb
CHANGED
@@ -1,125 +1,51 @@
|
|
1
1
|
# db/seeds.rb
|
2
|
-
|
3
|
-
#
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
#
|
9
|
-
|
10
|
-
|
11
|
-
puts "Starting DSCF Banking Engine seed data..."
|
12
|
-
|
13
|
-
|
14
|
-
# 1. Seed roles (if model exists)
|
2
|
+
# This file should contain all the record creation needed to seed the database with its default values.
|
3
|
+
# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
|
4
|
+
#
|
5
|
+
# Examples:
|
6
|
+
#
|
7
|
+
# movies = Movie.create([{ name: "Star Wars" }, { name: "Lord of the Rings" }])
|
8
|
+
# Character.create(name: "Luke", movie: movies.first)
|
9
|
+
|
10
|
+
# Seed roles based on RBAC documentation
|
15
11
|
puts "Seeding roles..."
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
role.name = 'Virtual Account Manager'
|
25
|
-
end
|
26
|
-
kyc_officer_role = Dscf::Core::Role.find_or_create_by(code: 'kyc_officer') do |role|
|
27
|
-
role.name = 'KYC Officer'
|
28
|
-
end
|
29
|
-
branch_manager_role = Dscf::Core::Role.find_or_create_by(code: 'branch_manager') do |role|
|
30
|
-
role.name = 'Branch Manager'
|
31
|
-
end
|
32
|
-
puts "✓ Roles created/found"
|
33
|
-
else
|
34
|
-
puts "Warning: Dscf::Core::Role model not found. Skipping role seeding."
|
35
|
-
end
|
36
|
-
# 2. Seed users with roles (if model exists)
|
12
|
+
user_role = Role.find_or_create_by(name: 'User')
|
13
|
+
officer_role = Role.find_or_create_by(name: 'Virtual Account Officer')
|
14
|
+
manager_role = Role.find_or_create_by(name: 'Virtual Account Manager')
|
15
|
+
kyc_officer_role = Role.find_or_create_by(name: 'KYC Officer')
|
16
|
+
branch_manager_role = Role.find_or_create_by(name: 'Branch Manager')
|
17
|
+
puts "Roles seeded successfully."
|
18
|
+
|
19
|
+
# Seed users with roles
|
37
20
|
puts "Seeding users..."
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
u.verified_at = Time.current
|
43
|
-
u.temp_password = false
|
44
|
-
end
|
45
|
-
user1.roles << user_role if defined?(user_role)
|
46
|
-
puts "Created user: #{user1.email} (user@banking.com)"
|
47
|
-
|
48
|
-
user2 = Dscf::Core::User.find_or_create_by(email: "virtual_account_officer@banking.com") do |u|
|
49
|
-
u.phone = "+251922123456"
|
50
|
-
u.password = "SecurePassword123!"
|
51
|
-
u.verified_at = Time.current
|
52
|
-
u.temp_password = false
|
53
|
-
end
|
54
|
-
user2.roles << officer_role if defined?(officer_role)
|
55
|
-
puts "Created user: #{user2.email} (virtual_account_officer@banking.com)"
|
21
|
+
# Create users and assign roles
|
22
|
+
user1 = User.create(name: "Abebe Kebede", email: "abebe@example.com", password: "SecurePassword123!")
|
23
|
+
user1.roles << user_role
|
24
|
+
puts "Created user: #{user1.name}"
|
56
25
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
u.verified_at = Time.current
|
61
|
-
u.temp_password = false
|
62
|
-
end
|
63
|
-
user3.roles << manager_role if defined?(manager_role)
|
64
|
-
puts "Created user: #{user3.email} (virtual_account_manager@banking.com)"
|
26
|
+
user2 = User.create(name: "Tigist Haile", email: "tigist@example.com", password: "SecurePassword123!")
|
27
|
+
user2.roles << officer_role
|
28
|
+
puts "Created user: #{user2.name}"
|
65
29
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
u.verified_at = Time.current
|
70
|
-
u.temp_password = false
|
71
|
-
end
|
72
|
-
user4.roles << user_role if defined?(user_role)
|
73
|
-
user4.roles << officer_role if defined?(officer_role)
|
74
|
-
puts "Created user: #{user4.email} (user_virtual_account_officer@banking.com)"
|
30
|
+
user3 = User.create(name: "Dawit Mekonnen", email: "dawit@example.com", password: "SecurePassword123!")
|
31
|
+
user3.roles << manager_role
|
32
|
+
puts "Created user: #{user3.name}"
|
75
33
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
u.temp_password = false
|
81
|
-
end
|
82
|
-
user5.roles << manager_role if defined?(manager_role)
|
83
|
-
puts "Created user: #{user5.email} (virtual_account_manager2@banking.com)"
|
34
|
+
# Additional users for testing
|
35
|
+
user4 = User.create(name: "Hirut Assefa", email: "hirut@example.com", password: "SecurePassword123!")
|
36
|
+
user4.roles << [ user_role, officer_role ] # User with multiple roles if supported
|
37
|
+
puts "Created user: #{user4.name}"
|
84
38
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
u.verified_at = Time.current
|
89
|
-
u.temp_password = false
|
90
|
-
end
|
91
|
-
user6.roles << kyc_officer_role if defined?(kyc_officer_role)
|
92
|
-
puts "Created user: #{user6.email} (kyc_officer@banking.com)"
|
39
|
+
user5 = User.create(name: "Solomon Tesfaye", email: "solomon@example.com", password: "SecurePassword123!")
|
40
|
+
user5.roles << manager_role
|
41
|
+
puts "Created user: #{user5.name}"
|
93
42
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
u.verified_at = Time.current
|
98
|
-
u.temp_password = false
|
99
|
-
end
|
100
|
-
user7.roles << branch_manager_role if defined?(branch_manager_role)
|
101
|
-
puts "Created user: #{user7.email} (branch_manager@banking.com)"
|
102
|
-
else
|
103
|
-
puts "Warning: Dscf::Core::User model not found. Skipping user seeding."
|
104
|
-
end# 3. Seed transaction types (engine model)
|
105
|
-
puts "Seeding transaction types..."
|
106
|
-
if defined?(Dscf::Banking::TransactionType)
|
107
|
-
transaction_types = [
|
108
|
-
{ name: "Deposit", code: "DEP" },
|
109
|
-
{ name: "Withdrawal", code: "WDL" },
|
110
|
-
{ name: "Transfer", code: "TRF" },
|
111
|
-
{ name: "Interest Credit", code: "INTC" },
|
112
|
-
{ name: "Fee Debit", code: "FEED" }
|
113
|
-
]
|
43
|
+
user6 = User.create(name: "Mulugeta Bekele", email: "mulugeta@example.com", password: "SecurePassword123!")
|
44
|
+
user6.roles << kyc_officer_role
|
45
|
+
puts "Created user: #{user6.name}"
|
114
46
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
end
|
119
|
-
end
|
120
|
-
puts "✓ Transaction types created/found"
|
121
|
-
else
|
122
|
-
puts "Warning: Dscf::Banking::TransactionType not found. Skipping transaction type seeding."
|
123
|
-
end
|
47
|
+
user7 = User.create(name: "Fikirte Alemayehu", email: "fikirte@example.com", password: "SecurePassword123!")
|
48
|
+
user7.roles << branch_manager_role
|
49
|
+
puts "Created user: #{user7.name}"
|
124
50
|
|
125
|
-
puts "
|
51
|
+
puts "Seeding completed successfully."
|
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.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eyosiyas Mekbib
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-10-05 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: rails
|