mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-25 20:46:48 +00:00
We changed to tracking stock of on-demand items to be able to place backorders. This is mostly hidden in the app but was still visible on the inventory page. Now we are hiding that here, too.
38 lines
842 B
Ruby
38 lines
842 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Api
|
|
module Admin
|
|
class VariantSimpleSerializer < ActiveModel::Serializer
|
|
attributes :id, :name, :import_date,
|
|
:options_text, :unit_value, :unit_description, :unit_to_display,
|
|
:display_as, :display_name, :name_to_display,
|
|
:price, :on_demand, :on_hand, :producer_id
|
|
|
|
has_many :variant_overrides
|
|
|
|
def name
|
|
if object.full_name.present?
|
|
"#{object.name} - #{object.full_name}"
|
|
else
|
|
object.name
|
|
end
|
|
end
|
|
|
|
def on_hand
|
|
return if object.on_demand
|
|
return 0 if object.on_hand.nil?
|
|
|
|
object.on_hand
|
|
end
|
|
|
|
def price
|
|
object.price.nil? ? 0.to_f : object.price
|
|
end
|
|
|
|
def producer_id
|
|
object.supplier_id
|
|
end
|
|
end
|
|
end
|
|
end
|