bscf-core 0.3.2 → 0.3.4
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/models/bscf/core/marketplace_listing.rb +1 -0
- data/app/models/bscf/core/product.rb +0 -5
- data/db/migrate/20250331113323_create_bscf_core_marketplace_listings.rb +2 -2
- data/lib/bscf/core/version.rb +1 -1
- data/lib/bscf_core.rb +7 -0
- data/spec/factories/bscf/core/products.rb +2 -22
- metadata +5 -10
- data/app/models/bscf/core/business_document.rb +0 -40
- data/app/models/bscf/core/wholesaler_product.rb +0 -36
- data/db/migrate/20250402120554_create_bscf_core_wholesaler_products.rb +0 -14
- data/db/migrate/20250403190620_create_bscf_core_business_documents.rb +0 -14
- data/spec/factories/bscf/core/business_documents.rb +0 -23
- data/spec/factories/bscf/core/wholesaler_products.rb +0 -19
- /data/app/services/{bscf/core/token_service.rb → token_service.rb} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8d2f8615fb86130f7abc8d3ee5f5d31bb5848dbb1e0702085137123dc497867
|
4
|
+
data.tar.gz: 4f139bbbc27a3657b8c0c00e39ed2045be174ff61ef4c7ac372628981e4aca47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ac6729e3c83271a58c765db29ed899be2f846f7620368d52db5de17dab0b528d2a357ab0cc6d08e6e9892bf8e31f07a7b8c18b563a3dd5ef26fc8b557d2b99e
|
7
|
+
data.tar.gz: 50fd1d3532210e10c0c2b491a64f43d16d05624a5fc6346eb79eee330764a473be133976062b7c0fda22b26fb6ae866df1e64fd8cb4ac4030cb240d78c03f164
|
@@ -2,12 +2,7 @@ module Bscf
|
|
2
2
|
module Core
|
3
3
|
class Product < ApplicationRecord
|
4
4
|
belongs_to :category
|
5
|
-
has_one_attached :thumbnail
|
6
|
-
has_many_attached :images
|
7
5
|
|
8
|
-
validates :sku, presence: true, uniqueness: true
|
9
|
-
validates :name, presence: true
|
10
|
-
validates :description, presence: true
|
11
6
|
has_many :rfq_items
|
12
7
|
has_many :request_for_quotations, through: :rfq_items
|
13
8
|
|
@@ -1,14 +1,14 @@
|
|
1
1
|
class CreateBscfCoreMarketplaceListings < ActiveRecord::Migration[8.0]
|
2
2
|
def change
|
3
3
|
create_table :bscf_core_marketplace_listings do |t|
|
4
|
-
t.references :user, null: false, foreign_key: {
|
4
|
+
t.references :user, null: false, foreign_key: {to_table: :bscf_core_users}
|
5
5
|
t.integer :listing_type, null: false
|
6
6
|
t.integer :status, null: false
|
7
7
|
t.boolean :allow_partial_match, null: false, default: false
|
8
8
|
t.datetime :preferred_delivery_date
|
9
9
|
t.datetime :expires_at
|
10
10
|
t.boolean :is_active, default: true
|
11
|
-
t.references :address, null: false, foreign_key: {
|
11
|
+
t.references :address, null: false, foreign_key: {to_table: :bscf_core_addresses}
|
12
12
|
|
13
13
|
t.timestamps
|
14
14
|
end
|
data/lib/bscf/core/version.rb
CHANGED
data/lib/bscf_core.rb
ADDED
@@ -1,28 +1,8 @@
|
|
1
1
|
FactoryBot.define do
|
2
2
|
factory :product, class: 'Bscf::Core::Product' do
|
3
|
-
category
|
4
|
-
sequence(:sku) { |n| "SKU-#{n}" }
|
5
3
|
name { Faker::Commerce.product_name }
|
6
4
|
description { Faker::Lorem.paragraph }
|
7
|
-
|
8
|
-
|
9
|
-
product.thumbnail.attach(
|
10
|
-
io: StringIO.new("test image"),
|
11
|
-
filename: 'thumbnail.jpg',
|
12
|
-
content_type: 'image/jpeg'
|
13
|
-
)
|
14
|
-
end
|
15
|
-
|
16
|
-
trait :with_images do
|
17
|
-
after(:build) do |product|
|
18
|
-
2.times do |i|
|
19
|
-
product.images.attach(
|
20
|
-
io: StringIO.new("test image #{i}"),
|
21
|
-
filename: "image_#{i}.jpg",
|
22
|
-
content_type: 'image/jpeg'
|
23
|
-
)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
5
|
+
association :category, factory: :category
|
6
|
+
base_price { Faker::Commerce.price(range: 0..1000.0) }
|
27
7
|
end
|
28
8
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bscf-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Asrat
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-04-
|
10
|
+
date: 2025-04-07 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: active_model_serializers
|
@@ -289,7 +289,6 @@ files:
|
|
289
289
|
- app/models/bscf/core/address.rb
|
290
290
|
- app/models/bscf/core/application_record.rb
|
291
291
|
- app/models/bscf/core/business.rb
|
292
|
-
- app/models/bscf/core/business_document.rb
|
293
292
|
- app/models/bscf/core/category.rb
|
294
293
|
- app/models/bscf/core/delivery_order.rb
|
295
294
|
- app/models/bscf/core/delivery_order_item.rb
|
@@ -307,8 +306,7 @@ files:
|
|
307
306
|
- app/models/bscf/core/user_role.rb
|
308
307
|
- app/models/bscf/core/virtual_account.rb
|
309
308
|
- app/models/bscf/core/virtual_account_transaction.rb
|
310
|
-
- app/
|
311
|
-
- app/services/bscf/core/token_service.rb
|
309
|
+
- app/services/token_service.rb
|
312
310
|
- config/database.yml
|
313
311
|
- config/routes.rb
|
314
312
|
- db/migrate/20250326065606_create_bscf_core_users.rb
|
@@ -330,15 +328,13 @@ files:
|
|
330
328
|
- db/migrate/20250330181143_create_bscf_core_delivery_orders.rb
|
331
329
|
- db/migrate/20250330190145_create_bscf_core_delivery_order_items.rb
|
332
330
|
- db/migrate/20250331113323_create_bscf_core_marketplace_listings.rb
|
333
|
-
- db/migrate/20250402120554_create_bscf_core_wholesaler_products.rb
|
334
|
-
- db/migrate/20250403190620_create_bscf_core_business_documents.rb
|
335
331
|
- lib/bscf/core.rb
|
336
332
|
- lib/bscf/core/engine.rb
|
337
333
|
- lib/bscf/core/version.rb
|
334
|
+
- lib/bscf_core.rb
|
338
335
|
- lib/tasks/bscf/core_tasks.rake
|
339
336
|
- lib/tasks/release.rake
|
340
337
|
- spec/factories/bscf/core/addresses.rb
|
341
|
-
- spec/factories/bscf/core/business_documents.rb
|
342
338
|
- spec/factories/bscf/core/businesses.rb
|
343
339
|
- spec/factories/bscf/core/categories.rb
|
344
340
|
- spec/factories/bscf/core/delivery_order_items.rb
|
@@ -357,7 +353,6 @@ files:
|
|
357
353
|
- spec/factories/bscf/core/users.rb
|
358
354
|
- spec/factories/bscf/core/virtual_account_transactions.rb
|
359
355
|
- spec/factories/bscf/core/virtual_accounts.rb
|
360
|
-
- spec/factories/bscf/core/wholesaler_products.rb
|
361
356
|
homepage: https://mksaddis.com/
|
362
357
|
licenses:
|
363
358
|
- MIT
|
@@ -379,7 +374,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
379
374
|
- !ruby/object:Gem::Version
|
380
375
|
version: '0'
|
381
376
|
requirements: []
|
382
|
-
rubygems_version: 3.6.
|
377
|
+
rubygems_version: 3.6.5
|
383
378
|
specification_version: 4
|
384
379
|
summary: An Engine for Supply Chain Financing
|
385
380
|
test_files: []
|
@@ -1,40 +0,0 @@
|
|
1
|
-
module Bscf
|
2
|
-
module Core
|
3
|
-
class BusinessDocument < ApplicationRecord
|
4
|
-
belongs_to :business
|
5
|
-
has_one_attached :file
|
6
|
-
|
7
|
-
before_validation :format_document_name
|
8
|
-
|
9
|
-
validates :document_number, presence: true
|
10
|
-
validates :document_name, presence: true
|
11
|
-
validates :business_id, presence: true
|
12
|
-
validates :verified_at, presence: true, if: :is_verified?
|
13
|
-
validates :file, presence: true
|
14
|
-
validate :block_executable_files
|
15
|
-
|
16
|
-
scope :verified, -> { where(is_verified: true) }
|
17
|
-
scope :unverified, -> { where(is_verified: false) }
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
def format_document_name
|
22
|
-
self.document_name = document_name.strip.titleize if document_name.present?
|
23
|
-
end
|
24
|
-
|
25
|
-
def block_executable_files
|
26
|
-
return unless file.attached?
|
27
|
-
|
28
|
-
if file.content_type.in?(%w[
|
29
|
-
application/x-msdownload
|
30
|
-
application/x-executable
|
31
|
-
application/x-msdos-program
|
32
|
-
application/x-ms-dos-executable
|
33
|
-
application/x-shellscript
|
34
|
-
])
|
35
|
-
errors.add(:file, "cannot be an executable file")
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
module Bscf::Core
|
2
|
-
class WholesalerProduct < ApplicationRecord
|
3
|
-
belongs_to :business
|
4
|
-
belongs_to :product
|
5
|
-
|
6
|
-
validates :minimum_order_quantity, presence: true, numericality: { greater_than: 0 }
|
7
|
-
validates :wholesale_price, presence: true, numericality: { greater_than: 0 }
|
8
|
-
validates :available_quantity, presence: true, numericality: { greater_than_or_equal_to: 0 }
|
9
|
-
validates :status, presence: true
|
10
|
-
|
11
|
-
validate :business_must_be_wholesaler
|
12
|
-
validate :unique_product_per_wholesaler
|
13
|
-
|
14
|
-
enum :status, {
|
15
|
-
active: 0,
|
16
|
-
inactive: 1,
|
17
|
-
out_of_stock: 2
|
18
|
-
}
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def business_must_be_wholesaler
|
23
|
-
if business && !business.wholesaler?
|
24
|
-
errors.add(:business, "must be a wholesaler")
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def unique_product_per_wholesaler
|
29
|
-
if WholesalerProduct.where(business: business, product: product)
|
30
|
-
.where.not(id: id)
|
31
|
-
.exists?
|
32
|
-
errors.add(:product, "already exists for this wholesaler")
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
class CreateBscfCoreWholesalerProducts < ActiveRecord::Migration[8.0]
|
2
|
-
def change
|
3
|
-
create_table :bscf_core_wholesaler_products do |t|
|
4
|
-
t.references :business, null: false, foreign_key: { to_table: :bscf_core_businesses }
|
5
|
-
t.references :product, null: false, foreign_key: { to_table: :bscf_core_products }
|
6
|
-
t.integer :minimum_order_quantity, null: false, default: 1
|
7
|
-
t.decimal :wholesale_price
|
8
|
-
t.integer :available_quantity, null: false, default: 0
|
9
|
-
t.integer :status, null: false, default: 0
|
10
|
-
|
11
|
-
t.timestamps
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
class CreateBscfCoreBusinessDocuments < ActiveRecord::Migration[8.0]
|
2
|
-
def change
|
3
|
-
create_table :bscf_core_business_documents do |t|
|
4
|
-
t.references :business, null: false, foreign_key: { to_table: :bscf_core_businesses }
|
5
|
-
t.string :document_number, null: false
|
6
|
-
t.string :document_name, null: false
|
7
|
-
t.string :document_description
|
8
|
-
t.datetime :verified_at
|
9
|
-
t.boolean :is_verified, null: false, default: false
|
10
|
-
|
11
|
-
t.timestamps
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
FactoryBot.define do
|
2
|
-
factory :business_document, class: 'Bscf::Core::BusinessDocument' do
|
3
|
-
association :business, factory: :business
|
4
|
-
document_number { "DOC-#{SecureRandom.hex(4).upcase}" }
|
5
|
-
document_name { "Business License" }
|
6
|
-
document_description { "Official business license document" }
|
7
|
-
is_verified { false }
|
8
|
-
|
9
|
-
after(:build) do |document|
|
10
|
-
document.file.attach(
|
11
|
-
io: StringIO.new("test content"),
|
12
|
-
filename: 'sample.pdf',
|
13
|
-
content_type: 'application/pdf'
|
14
|
-
)
|
15
|
-
end
|
16
|
-
|
17
|
-
trait :verified do
|
18
|
-
is_verified { true }
|
19
|
-
verified_at { Time.current }
|
20
|
-
association :business, factory: :business
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
FactoryBot.define do
|
2
|
-
factory :wholesaler_product, class: 'Bscf::Core::WholesalerProduct' do
|
3
|
-
association :business, :wholesaler
|
4
|
-
association :product
|
5
|
-
minimum_order_quantity { Faker::Number.between(from: 5, to: 100) }
|
6
|
-
wholesale_price { Faker::Commerce.price(range: 50..1000.0) }
|
7
|
-
available_quantity { Faker::Number.between(from: 100, to: 1000) }
|
8
|
-
status { :active }
|
9
|
-
end
|
10
|
-
|
11
|
-
trait :inactive do
|
12
|
-
status { :inactive }
|
13
|
-
end
|
14
|
-
|
15
|
-
trait :out_of_stock do
|
16
|
-
status { :out_of_stock }
|
17
|
-
available_quantity { 0 }
|
18
|
-
end
|
19
|
-
end
|
File without changes
|