snf_core 0.2.7 → 0.2.91
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/MIT-LICENSE +0 -0
- data/README.md +0 -0
- data/Rakefile +0 -0
- data/app/controllers/concerns/common.rb +0 -0
- data/app/controllers/concerns/pagination.rb +0 -0
- data/app/controllers/snf/core/application_controller.rb +6 -0
- data/app/jobs/snf/core/application_job.rb +6 -0
- data/app/mailers/snf/core/application_mailer.rb +8 -0
- data/app/models/snf/core/address.rb +8 -0
- data/app/models/snf/core/application_record.rb +7 -0
- data/app/models/snf/core/business.rb +13 -0
- data/app/models/snf/core/business_document.rb +17 -0
- data/app/models/snf/core/category.rb +9 -0
- data/app/models/snf/core/customer_group.rb +8 -0
- data/app/models/snf/core/group.rb +9 -0
- data/app/models/{snf_core → snf/core}/product.rb +4 -2
- data/app/models/snf/core/store.rb +12 -0
- data/config/routes.rb +1 -1
- data/db/migrate/20250226042622_create_snf_core_users.rb +0 -0
- data/db/migrate/20250226064444_create_snf_core_categories.rb +0 -0
- data/db/migrate/20250226080323_create_snf_core_businesses.rb +0 -0
- data/db/migrate/20250226102931_create_snf_core_business_documents.rb +0 -0
- data/db/migrate/20250226110217_create_snf_core_addresses.rb +0 -0
- data/db/migrate/20250226115215_create_snf_core_stores.rb +0 -0
- data/db/migrate/20250226181007_create_snf_core_products.rb +0 -0
- data/db/migrate/20250226190000_create_snf_core_store_inventories.rb +0 -0
- data/db/migrate/20250226192104_create_snf_core_groups.rb +0 -0
- data/db/migrate/20250226193938_create_snf_core_customer_groups.rb +0 -0
- data/db/migrate/20250227075048_create_snf_core_wallets.rb +0 -0
- data/db/migrate/20250227102833_modify_store_inventories.rb +0 -0
- data/lib/snf/core/engine.rb +26 -0
- data/lib/snf/core/version.rb +5 -0
- data/lib/snf/core.rb +8 -0
- data/lib/snf_core.rb +0 -0
- data/lib/tasks/snf_core_tasks.rake +0 -0
- metadata +18 -20
- data/app/controllers/snf_core/application_controller.rb +0 -4
- data/app/jobs/snf_core/application_job.rb +0 -4
- data/app/mailers/snf_core/application_mailer.rb +0 -6
- data/app/models/snf_core/address.rb +0 -6
- data/app/models/snf_core/application_record.rb +0 -5
- data/app/models/snf_core/business.rb +0 -11
- data/app/models/snf_core/business_document.rb +0 -15
- data/app/models/snf_core/category.rb +0 -7
- data/app/models/snf_core/customer_group.rb +0 -6
- data/app/models/snf_core/group.rb +0 -7
- data/app/models/snf_core/store.rb +0 -10
- data/app/models/snf_core/store_inventory.rb +0 -30
- data/app/models/snf_core/user.rb +0 -18
- data/app/models/snf_core/wallet.rb +0 -21
- data/lib/snf_core/engine.rb +0 -24
- data/lib/snf_core/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89b65a4972099826aebf27996343dc8a16772add722f21728fe133c3b95fb8c1
|
4
|
+
data.tar.gz: 85e86060e3d6b23bbf5112c8f50dfc93d6d73fdac92a6d69709ae1f1a23be923
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff7663014478ea95efc1018461f2deb8af28fa0b0020a3b5e857a333b2bf3cfee1e19049f59f84b90ae88bf723e1f51e52a1e9be13240e20e5ad54638570cd3a
|
7
|
+
data.tar.gz: 626983de1c1b47e4097b3518c5225aa0e93e8e2948e8466e2a51dc62c23842f6d25398179e40ab38d1990d385a213b33b53eb957e496c795f38ed9549fd7fe2b
|
data/MIT-LICENSE
CHANGED
File without changes
|
data/README.md
CHANGED
File without changes
|
data/Rakefile
CHANGED
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Snf
|
2
|
+
module Core
|
3
|
+
class Business < ApplicationRecord
|
4
|
+
belongs_to :user
|
5
|
+
|
6
|
+
validates :business_name, :tin_number, :business_type, :verification_status, presence: true
|
7
|
+
validates :tin_number, uniqueness: true
|
8
|
+
|
9
|
+
enum :business_type, { retailer: 0, wholesaler: 1 }
|
10
|
+
enum :verification_status, { pending: 0, approved: 1, rejected: 2 }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Snf
|
2
|
+
module Core
|
3
|
+
class BusinessDocument < ApplicationRecord
|
4
|
+
belongs_to :business
|
5
|
+
belongs_to :verified_by, class_name: "Snf::Core::User", optional: true
|
6
|
+
|
7
|
+
enum :document_type, {
|
8
|
+
business_license: 0,
|
9
|
+
representative_id: 1
|
10
|
+
}, suffix: :doc
|
11
|
+
|
12
|
+
has_one_attached :document
|
13
|
+
|
14
|
+
validates :document_type, :uploaded_at, :document, presence: true
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
|
-
module
|
2
|
-
|
1
|
+
module Snf
|
2
|
+
module Core
|
3
|
+
class Product < ApplicationRecord
|
3
4
|
belongs_to :category
|
4
5
|
|
5
6
|
has_one_attached :thumbnail_image
|
@@ -7,5 +8,6 @@ module SnfCore
|
|
7
8
|
|
8
9
|
validates :name, presence: true
|
9
10
|
validates :sku, presence: true, uniqueness: true
|
11
|
+
end
|
10
12
|
end
|
11
13
|
end
|
data/config/routes.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
|
1
|
+
Snf::Core::Engine.routes.draw do
|
2
2
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Snf
|
2
|
+
module Core
|
3
|
+
class Engine < ::Rails::Engine
|
4
|
+
isolate_namespace Snf::Core
|
5
|
+
config.generators.api_only = true
|
6
|
+
|
7
|
+
config.generators do |g|
|
8
|
+
g.test_framework :rspec, routing_specs: false
|
9
|
+
g.fixture_replacement :factory_bot
|
10
|
+
g.factory_bot dir: "spec/factories"
|
11
|
+
end
|
12
|
+
|
13
|
+
initializer "snf_core.factories", after: "factory_bot.set_factory_paths" do
|
14
|
+
FactoryBot.definition_file_paths << File.expand_path("../../../../spec/factories", __dir__) if defined?(FactoryBot)
|
15
|
+
end
|
16
|
+
|
17
|
+
initializer :append_migrations do |app|
|
18
|
+
unless app.root.to_s.match(root.to_s + File::SEPARATOR)
|
19
|
+
app.config.paths["db/migrate"].concat(config.paths["db/migrate"].expanded)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
require "active_storage/engine"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/snf/core.rb
ADDED
data/lib/snf_core.rb
CHANGED
File without changes
|
File without changes
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snf_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.91
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Asrat
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-03-04 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: active_model_serializers
|
@@ -285,21 +285,18 @@ files:
|
|
285
285
|
- Rakefile
|
286
286
|
- app/controllers/concerns/common.rb
|
287
287
|
- app/controllers/concerns/pagination.rb
|
288
|
-
- app/controllers/
|
289
|
-
- app/jobs/
|
290
|
-
- app/mailers/
|
291
|
-
- app/models/
|
292
|
-
- app/models/
|
293
|
-
- app/models/
|
294
|
-
- app/models/
|
295
|
-
- app/models/
|
296
|
-
- app/models/
|
297
|
-
- app/models/
|
298
|
-
- app/models/
|
299
|
-
- app/models/
|
300
|
-
- app/models/snf_core/store_inventory.rb
|
301
|
-
- app/models/snf_core/user.rb
|
302
|
-
- app/models/snf_core/wallet.rb
|
288
|
+
- app/controllers/snf/core/application_controller.rb
|
289
|
+
- app/jobs/snf/core/application_job.rb
|
290
|
+
- app/mailers/snf/core/application_mailer.rb
|
291
|
+
- app/models/snf/core/address.rb
|
292
|
+
- app/models/snf/core/application_record.rb
|
293
|
+
- app/models/snf/core/business.rb
|
294
|
+
- app/models/snf/core/business_document.rb
|
295
|
+
- app/models/snf/core/category.rb
|
296
|
+
- app/models/snf/core/customer_group.rb
|
297
|
+
- app/models/snf/core/group.rb
|
298
|
+
- app/models/snf/core/product.rb
|
299
|
+
- app/models/snf/core/store.rb
|
303
300
|
- config/routes.rb
|
304
301
|
- db/migrate/20250226042622_create_snf_core_users.rb
|
305
302
|
- db/migrate/20250226064444_create_snf_core_categories.rb
|
@@ -313,9 +310,10 @@ files:
|
|
313
310
|
- db/migrate/20250226193938_create_snf_core_customer_groups.rb
|
314
311
|
- db/migrate/20250227075048_create_snf_core_wallets.rb
|
315
312
|
- db/migrate/20250227102833_modify_store_inventories.rb
|
313
|
+
- lib/snf/core.rb
|
314
|
+
- lib/snf/core/engine.rb
|
315
|
+
- lib/snf/core/version.rb
|
316
316
|
- lib/snf_core.rb
|
317
|
-
- lib/snf_core/engine.rb
|
318
|
-
- lib/snf_core/version.rb
|
319
317
|
- lib/tasks/snf_core_tasks.rake
|
320
318
|
homepage: https://mksaddis.com/
|
321
319
|
licenses:
|
@@ -338,7 +336,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
338
336
|
- !ruby/object:Gem::Version
|
339
337
|
version: '0'
|
340
338
|
requirements: []
|
341
|
-
rubygems_version: 3.6.
|
339
|
+
rubygems_version: 3.6.2
|
342
340
|
specification_version: 4
|
343
341
|
summary: An Engine for Supply Chain Financing
|
344
342
|
test_files: []
|
@@ -1,11 +0,0 @@
|
|
1
|
-
module SnfCore
|
2
|
-
class Business < ApplicationRecord
|
3
|
-
belongs_to :user
|
4
|
-
|
5
|
-
validates :business_name, :tin_number, :business_type, :verification_status, presence: true
|
6
|
-
validates :tin_number, uniqueness: true
|
7
|
-
|
8
|
-
enum :business_type, { retailer: 0, wholesaler: 1 }
|
9
|
-
enum :verification_status, { pending: 0, approved: 1, rejected: 2 }
|
10
|
-
end
|
11
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module SnfCore
|
2
|
-
class BusinessDocument < ApplicationRecord
|
3
|
-
belongs_to :business
|
4
|
-
belongs_to :verified_by, class_name: "SnfCore::User", optional: true
|
5
|
-
|
6
|
-
enum :document_type, {
|
7
|
-
business_license_doc: 0,
|
8
|
-
representative_id_doc: 1
|
9
|
-
}, _prefix: :document
|
10
|
-
|
11
|
-
has_one_attached :document
|
12
|
-
|
13
|
-
validates :document_type, :uploaded_at, :document, presence: true
|
14
|
-
end
|
15
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
module SnfCore
|
2
|
-
class StoreInventory < ApplicationRecord
|
3
|
-
belongs_to :store
|
4
|
-
belongs_to :product
|
5
|
-
|
6
|
-
enum :status, {
|
7
|
-
available: 0,
|
8
|
-
unavailable: 1
|
9
|
-
}
|
10
|
-
|
11
|
-
validates :status, presence: true
|
12
|
-
|
13
|
-
validates :base_price, presence: true, numericality: {
|
14
|
-
greater_than_or_equal_to: 0
|
15
|
-
}
|
16
|
-
|
17
|
-
validate :unique_store_product_combination
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
def unique_store_product_combination
|
22
|
-
existing = StoreInventory.where(store_id: store_id, product_id: product_id)
|
23
|
-
existing = existing.where.not(id: id) if persisted?
|
24
|
-
|
25
|
-
if existing.exists?
|
26
|
-
errors.add(:base, "Product already exists in this store's inventory")
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
data/app/models/snf_core/user.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
module SnfCore
|
2
|
-
class User < ApplicationRecord
|
3
|
-
has_one :wallet, dependent: :destroy
|
4
|
-
|
5
|
-
validates :first_name, :middle_name, :last_name, :phone_number, :role, presence: true
|
6
|
-
validates :phone_number, :email, uniqueness: true
|
7
|
-
|
8
|
-
enum :role, { admin: 0, wholesaler: 1, retailer: 2, consumer: 3 }
|
9
|
-
|
10
|
-
after_create :create_default_wallet
|
11
|
-
|
12
|
-
private
|
13
|
-
|
14
|
-
def create_default_wallet
|
15
|
-
create_wallet(balance: 0.0, is_active: true)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module SnfCore
|
2
|
-
class Wallet < ApplicationRecord
|
3
|
-
belongs_to :user
|
4
|
-
|
5
|
-
validates :wallet_number, :balance, :is_active, presence: true
|
6
|
-
validates :wallet_number, uniqueness: { case_sensitive: false }
|
7
|
-
validates :is_active, inclusion: { in: [ true, false ] }
|
8
|
-
|
9
|
-
before_validation :generate_wallet_number, on: :create
|
10
|
-
|
11
|
-
private
|
12
|
-
|
13
|
-
def generate_wallet_number
|
14
|
-
loop do
|
15
|
-
random_digits = SecureRandom.random_number(10**10).to_s.rjust(10, "0")
|
16
|
-
self.wallet_number = "BB#{random_digits}"
|
17
|
-
break unless Wallet.exists?(wallet_number: wallet_number)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
data/lib/snf_core/engine.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
module SnfCore
|
2
|
-
class Engine < ::Rails::Engine
|
3
|
-
isolate_namespace SnfCore
|
4
|
-
config.generators.api_only = true
|
5
|
-
|
6
|
-
config.generators do |g|
|
7
|
-
g.test_framework :rspec, routing_specs: false
|
8
|
-
g.fixture_replacement :factory_bot
|
9
|
-
g.factory_bot dir: "spec/factories"
|
10
|
-
end
|
11
|
-
|
12
|
-
initializer "snf_core.factories", after: "factory_bot.set_factory_paths" do
|
13
|
-
FactoryBot.definition_file_paths << File.expand_path("../../../spec/factories", __dir__) if defined?(FactoryBot)
|
14
|
-
end
|
15
|
-
|
16
|
-
initializer :append_migrations do |app|
|
17
|
-
unless app.root.to_s.match(root.to_s + File::SEPARATOR)
|
18
|
-
app.config.paths["db/migrate"].concat(config.paths["db/migrate"].expanded)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
require "active_storage/engine"
|
23
|
-
end
|
24
|
-
end
|
data/lib/snf_core/version.rb
DELETED