dscf-marketplace 0.2.8 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a001bdda08a7e52eb5e5c02224aa62c3b33d43798b1a42d061b7703415c65c79
4
- data.tar.gz: 86fc45b4129e5fe98cd1fda0dfb6c231d179c65c112b2f2e7fd4f5dc1a2ca573
3
+ metadata.gz: 22865efb806819a9ccf9e8f3dadd3c64e7debf775582f4631733588320be35de
4
+ data.tar.gz: bb48c879c14dda629bda997a5b5cdef2ed8f9ee3ba33b782266b476fd4fdccc3
5
5
  SHA512:
6
- metadata.gz: 656471a3d0b550412576a4f196f48b94820ba5f2a697b0ccf76140bd62166175e45ee3b44b5a4dd238a62cdb2060a540c3238a01711e53ead888687a470f0306
7
- data.tar.gz: c71001e3910cbef5e731ec60547883d2a24aacffd4c3a2415f641920907093968b75fea082ef686a614beaba0380091aaf365c748c80c39d04cd3386744c261b
6
+ metadata.gz: ebdbc4d233a4fa62b7e84e4798b23037e06ceece680244f71b20c518dca76c443e86d0898a941be1be99cc98a7405622e04f39e42ca6036e20093fb7d974cb2e
7
+ data.tar.gz: 31113ba05dc8eb004d58de5ca4198a9164fe4f2e74e5a03e713436050bef7fe5bb85a94554ded1eb112a995eb90b704efc9cf9203acf37a647646b527ff74421
@@ -61,7 +61,7 @@ module Dscf
61
61
 
62
62
  def default_serializer_includes
63
63
  {
64
- index: [ :user, :ordered_by, :ordered_to, :quotation, :listing ],
64
+ index: [ :user, :ordered_by, :ordered_to, :quotation, order_items: [:product] ],
65
65
  show: [ :user, :ordered_by, :ordered_to, :quotation, :listing, :delivery_order, :order_items ],
66
66
  create: [ :user, :ordered_by, :ordered_to, :quotation, :listing ],
67
67
  update: [ :user, :ordered_by, :ordered_to, :quotation, :listing ]
@@ -2,6 +2,8 @@ module Dscf::Marketplace
2
2
  class OrderItem < ApplicationRecord
3
3
  enum :status, {pending: 0, confirmed: 1, processing: 2, fulfilled: 3, cancelled: 4}
4
4
 
5
+ delegate :name, :description, :thumbnail_url, :images_urls, to: :product, allow_nil: true
6
+
5
7
  belongs_to :order, optional: true
6
8
  belongs_to :quotation_item, optional: true
7
9
  belongs_to :listing, optional: true
@@ -32,6 +34,14 @@ module Dscf::Marketplace
32
34
  product&.name
33
35
  end
34
36
 
37
+ def product_thumbnail_url
38
+ product&.thumbnail_url
39
+ end
40
+
41
+ def product_images_urls
42
+ product&.images_urls
43
+ end
44
+
35
45
  def unit_name
36
46
  unit&.name
37
47
  end
@@ -1,28 +1,24 @@
1
1
  module Dscf::Marketplace
2
2
  class SupplierProduct < ApplicationRecord
3
- # References
4
3
  belongs_to :business, class_name: "Dscf::Core::Business"
5
4
  belongs_to :product, class_name: "Dscf::Marketplace::Product"
6
5
 
7
- # Relationships
6
+ delegate :name, :description, :thumbnail_url, :images_urls, to: :product, allow_nil: true
7
+
8
8
  has_many :listings, class_name: "Dscf::Marketplace::Listing"
9
9
  has_many :order_items, class_name: "Dscf::Marketplace::OrderItem"
10
10
 
11
- # Status enum
12
11
  enum :status, {active: 0, inactive: 1, discontinued: 2}, default: :active
13
12
 
14
- # Validations
15
13
  validates :supplier_price, numericality: {greater_than: 0}, presence: true
16
14
  validates :available_quantity, numericality: {greater_than_or_equal_to: 0}
17
15
  validates :minimum_order_quantity, numericality: {greater_than: 0}, allow_nil: true
18
16
 
19
- # Scopes
20
17
  scope :active, -> { where(status: :active) }
21
18
  scope :in_stock, -> { where("available_quantity > 0") }
22
19
  scope :by_business, ->(business_id) { where(business_id: business_id) }
23
20
  scope :by_product, ->(product_id) { where(product_id: product_id) }
24
21
 
25
- # Ransack configuration for secure filtering
26
22
  def self.ransackable_attributes(_auth_object = nil)
27
23
  %w[id business_id product_id supplier_price available_quantity minimum_order_quantity status created_at updated_at]
28
24
  end
@@ -4,7 +4,7 @@ module Dscf
4
4
  attributes :id, :order_id, :quotation_item_id, :listing_id,
5
5
  :product_id, :unit_id, :quantity, :unit_price,
6
6
  :status, :created_at, :updated_at,
7
- :subtotal, :product_name, :unit_name
7
+ :subtotal, :product_name, :unit_name, :thumbnail_url, :images_urls
8
8
 
9
9
  belongs_to :order
10
10
  belongs_to :quotation_item
@@ -3,7 +3,8 @@ module Dscf
3
3
  class SupplierProductSerializer < ActiveModel::Serializer
4
4
  attributes :id, :business_id, :product_id, :supplier_price, :available_quantity,
5
5
  :minimum_order_quantity, :status, :created_at, :updated_at,
6
- :in_stock?, :price_per_unit, :display_name
6
+ :in_stock?, :price_per_unit, :display_name, :name, :description,
7
+ :thumbnail_url, :images_urls
7
8
 
8
9
  belongs_to :business
9
10
  belongs_to :product
@@ -89,7 +89,7 @@ en:
89
89
  update: "Failed to update supplier product"
90
90
  destroy: "Failed to delete supplier product"
91
91
 
92
- listing:
92
+ listings:
93
93
  success:
94
94
  index: "Listings retrieved successfully"
95
95
  show: "Listing details retrieved successfully"
@@ -1,5 +1,5 @@
1
1
  module Dscf
2
2
  module Marketplace
3
- VERSION = "0.2.8".freeze
3
+ VERSION = "0.2.91".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dscf-marketplace
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.8
4
+ version: 0.2.91
5
5
  platform: ruby
6
6
  authors:
7
7
  - Asrat