dscf-marketplace 0.2.8 → 0.2.9
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f51a5b893502ce6049f446264e9b3c7bab06887f7a8364a70d8a80c247470cc9
|
4
|
+
data.tar.gz: 05306e10728b7fcf42b05e8a80387e7d7833a8c7e54f5abd8fa4295cf1c1d5bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9438af1ce5588f183b3421199c0b9e656576d2cd89aa89d6a0e9b8e5c552dab0030df18f185e896b2ffcb53b79bf548e03bb1c348c8928b52b706840ede268cd
|
7
|
+
data.tar.gz: '0948cb5588ba6f5a5c7d1e572b992a6d96fde59d0944c7c505aa0e630c0018d35a21cd9613191e0434c24b880b0a3117f60fe782d61ee836797356a041b22749'
|
@@ -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
|
@@ -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