Class: Dscf::Marketplace::AggregatorListing

Inherits:
ApplicationRecord show all
Defined in:
app/models/dscf/marketplace/aggregator_listing.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.ransackable_associations(_auth_object = nil) ⇒ Object



24
25
26
# File 'app/models/dscf/marketplace/aggregator_listing.rb', line 24

def self.ransackable_associations(_auth_object = nil)
  %w[aggregator supplier_product]
end

.ransackable_attributes(_auth_object = nil) ⇒ Object



20
21
22
# File 'app/models/dscf/marketplace/aggregator_listing.rb', line 20

def self.ransackable_attributes(_auth_object = nil)
  %w[id aggregator_id supplier_product_id price quantity status created_at updated_at]
end

Instance Method Details

#available?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'app/models/dscf/marketplace/aggregator_listing.rb', line 32

def available?
  active? && quantity > 0
end

#productObject



28
29
30
# File 'app/models/dscf/marketplace/aggregator_listing.rb', line 28

def product
  supplier_product&.product
end

#total_valueObject



36
37
38
# File 'app/models/dscf/marketplace/aggregator_listing.rb', line 36

def total_value
  price * quantity
end