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.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +0 -0
  3. data/README.md +0 -0
  4. data/Rakefile +0 -0
  5. data/app/controllers/concerns/common.rb +0 -0
  6. data/app/controllers/concerns/pagination.rb +0 -0
  7. data/app/controllers/snf/core/application_controller.rb +6 -0
  8. data/app/jobs/snf/core/application_job.rb +6 -0
  9. data/app/mailers/snf/core/application_mailer.rb +8 -0
  10. data/app/models/snf/core/address.rb +8 -0
  11. data/app/models/snf/core/application_record.rb +7 -0
  12. data/app/models/snf/core/business.rb +13 -0
  13. data/app/models/snf/core/business_document.rb +17 -0
  14. data/app/models/snf/core/category.rb +9 -0
  15. data/app/models/snf/core/customer_group.rb +8 -0
  16. data/app/models/snf/core/group.rb +9 -0
  17. data/app/models/{snf_core → snf/core}/product.rb +4 -2
  18. data/app/models/snf/core/store.rb +12 -0
  19. data/config/routes.rb +1 -1
  20. data/db/migrate/20250226042622_create_snf_core_users.rb +0 -0
  21. data/db/migrate/20250226064444_create_snf_core_categories.rb +0 -0
  22. data/db/migrate/20250226080323_create_snf_core_businesses.rb +0 -0
  23. data/db/migrate/20250226102931_create_snf_core_business_documents.rb +0 -0
  24. data/db/migrate/20250226110217_create_snf_core_addresses.rb +0 -0
  25. data/db/migrate/20250226115215_create_snf_core_stores.rb +0 -0
  26. data/db/migrate/20250226181007_create_snf_core_products.rb +0 -0
  27. data/db/migrate/20250226190000_create_snf_core_store_inventories.rb +0 -0
  28. data/db/migrate/20250226192104_create_snf_core_groups.rb +0 -0
  29. data/db/migrate/20250226193938_create_snf_core_customer_groups.rb +0 -0
  30. data/db/migrate/20250227075048_create_snf_core_wallets.rb +0 -0
  31. data/db/migrate/20250227102833_modify_store_inventories.rb +0 -0
  32. data/lib/snf/core/engine.rb +26 -0
  33. data/lib/snf/core/version.rb +5 -0
  34. data/lib/snf/core.rb +8 -0
  35. data/lib/snf_core.rb +0 -0
  36. data/lib/tasks/snf_core_tasks.rake +0 -0
  37. metadata +18 -20
  38. data/app/controllers/snf_core/application_controller.rb +0 -4
  39. data/app/jobs/snf_core/application_job.rb +0 -4
  40. data/app/mailers/snf_core/application_mailer.rb +0 -6
  41. data/app/models/snf_core/address.rb +0 -6
  42. data/app/models/snf_core/application_record.rb +0 -5
  43. data/app/models/snf_core/business.rb +0 -11
  44. data/app/models/snf_core/business_document.rb +0 -15
  45. data/app/models/snf_core/category.rb +0 -7
  46. data/app/models/snf_core/customer_group.rb +0 -6
  47. data/app/models/snf_core/group.rb +0 -7
  48. data/app/models/snf_core/store.rb +0 -10
  49. data/app/models/snf_core/store_inventory.rb +0 -30
  50. data/app/models/snf_core/user.rb +0 -18
  51. data/app/models/snf_core/wallet.rb +0 -21
  52. data/lib/snf_core/engine.rb +0 -24
  53. data/lib/snf_core/version.rb +0 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e27e69a0690317e2f41e2d5b1df78ac8a3eb5a929466e0d482267019cf74bcc
4
- data.tar.gz: 681cda4e73f6c2099fad69738b37e0d8e6c607b1006ef6ed88cd038e2437b6b9
3
+ metadata.gz: 89b65a4972099826aebf27996343dc8a16772add722f21728fe133c3b95fb8c1
4
+ data.tar.gz: 85e86060e3d6b23bbf5112c8f50dfc93d6d73fdac92a6d69709ae1f1a23be923
5
5
  SHA512:
6
- metadata.gz: 7fecd283cdafaef743e4919e047a55703b713c05bb19026d14808411403400d0a6ae2f297fe183b9bbf27b79aba9caef5f15a70f04d800f1519c6cf4ca03b3fc
7
- data.tar.gz: 035ebba254051ea48d80c4202030d6d0ea767fe955f3acee3123061b9c61eb56faa39f276e57171dc0fe1b22e2f7bbda6bc370c984e0fe0bba546a222856c92f
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,6 @@
1
+ module Snf
2
+ module Core
3
+ class ApplicationController < ActionController::API
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Snf
2
+ module Core
3
+ class ApplicationJob < ActiveJob::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,8 @@
1
+ module Snf
2
+ module Core
3
+ class ApplicationMailer < ActionMailer::Base
4
+ default from: "from@example.com"
5
+ layout "mailer"
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Snf
2
+ module Core
3
+ class Address < ApplicationRecord
4
+ validates :address_type, :city, :sub_city, :latitude, :longitude, presence: true
5
+ validates :longitude, :latitude, numericality: true
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ module Snf
2
+ module Core
3
+ class ApplicationRecord < ActiveRecord::Base
4
+ self.abstract_class = true
5
+ end
6
+ end
7
+ end
@@ -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
@@ -0,0 +1,9 @@
1
+ module Snf
2
+ module Core
3
+ class Category < ApplicationRecord
4
+ belongs_to :parent, optional: true, class_name: "Snf::Core::Category"
5
+
6
+ validates :name, presence: true, uniqueness: true
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,8 @@
1
+ module Snf
2
+ module Core
3
+ class CustomerGroup < ApplicationRecord
4
+ belongs_to :group
5
+ belongs_to :customer, class_name: "Snf::Core::User"
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,9 @@
1
+ module Snf
2
+ module Core
3
+ class Group < ApplicationRecord
4
+ belongs_to :business
5
+
6
+ validates :name, presence: true
7
+ end
8
+ end
9
+ end
@@ -1,5 +1,6 @@
1
- module SnfCore
2
- class Product < ApplicationRecord
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
@@ -0,0 +1,12 @@
1
+ module Snf
2
+ module Core
3
+ class Store < ApplicationRecord
4
+ belongs_to :business
5
+ belongs_to :address
6
+
7
+ validates :name, :operational_status, presence: true
8
+
9
+ enum :operational_status, { in_active: 0, active: 1 }
10
+ end
11
+ end
12
+ end
data/config/routes.rb CHANGED
@@ -1,2 +1,2 @@
1
- SnfCore::Engine.routes.draw do
1
+ Snf::Core::Engine.routes.draw do
2
2
  end
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
@@ -0,0 +1,5 @@
1
+ module Snf
2
+ module Core
3
+ VERSION = "0.2.91"
4
+ end
5
+ end
data/lib/snf/core.rb ADDED
@@ -0,0 +1,8 @@
1
+ require "snf/core/version"
2
+ require "snf/core/engine"
3
+
4
+ module Snf
5
+ module Core
6
+ # Your code goes here...
7
+ end
8
+ end
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.7
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-02-28 00:00:00.000000000 Z
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/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
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.4
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,4 +0,0 @@
1
- module SnfCore
2
- class ApplicationController < ActionController::API
3
- end
4
- end
@@ -1,4 +0,0 @@
1
- module SnfCore
2
- class ApplicationJob < ActiveJob::Base
3
- end
4
- end
@@ -1,6 +0,0 @@
1
- module SnfCore
2
- class ApplicationMailer < ActionMailer::Base
3
- default from: "from@example.com"
4
- layout "mailer"
5
- end
6
- end
@@ -1,6 +0,0 @@
1
- module SnfCore
2
- class Address < ApplicationRecord
3
- validates :address_type, :city, :sub_city, :latitude, :longitude, presence: true
4
- validates :longitude, :latitude, numericality: true
5
- end
6
- end
@@ -1,5 +0,0 @@
1
- module SnfCore
2
- class ApplicationRecord < ActiveRecord::Base
3
- self.abstract_class = true
4
- end
5
- end
@@ -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,7 +0,0 @@
1
- module SnfCore
2
- class Category < ApplicationRecord
3
- belongs_to :parent, optional: true, class_name: "SnfCore::Category"
4
-
5
- validates :name, presence: true, uniqueness: true
6
- end
7
- end
@@ -1,6 +0,0 @@
1
- module SnfCore
2
- class CustomerGroup < ApplicationRecord
3
- belongs_to :group
4
- belongs_to :customer, class_name: "SnfCore::User"
5
- end
6
- end
@@ -1,7 +0,0 @@
1
- module SnfCore
2
- class Group < ApplicationRecord
3
- belongs_to :business
4
-
5
- validates :name, presence: true
6
- end
7
- end
@@ -1,10 +0,0 @@
1
- module SnfCore
2
- class Store < ApplicationRecord
3
- belongs_to :business
4
- belongs_to :address
5
-
6
- validates :name, :operational_status, presence: true
7
-
8
- enum :operational_status, { in_active: 0, active: 1 }
9
- end
10
- 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
@@ -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
@@ -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
@@ -1,3 +0,0 @@
1
- module SnfCore
2
- VERSION = "0.2.7"
3
- end