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 +4 -4
- data/app/controllers/dscf/marketplace/orders_controller.rb +1 -1
- data/app/models/dscf/marketplace/order_item.rb +10 -0
- data/app/models/dscf/marketplace/supplier_product.rb +2 -6
- data/app/serializers/dscf/marketplace/order_item_serializer.rb +1 -1
- data/app/serializers/dscf/marketplace/supplier_product_serializer.rb +2 -1
- data/config/locales/en.yml +1 -1
- data/lib/dscf/marketplace/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22865efb806819a9ccf9e8f3dadd3c64e7debf775582f4631733588320be35de
|
4
|
+
data.tar.gz: bb48c879c14dda629bda997a5b5cdef2ed8f9ee3ba33b782266b476fd4fdccc3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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, :
|
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
|
-
|
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
|
data/config/locales/en.yml
CHANGED