mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-23 01:03:21 +00:00
22 lines
467 B
Ruby
22 lines
467 B
Ruby
# frozen_string_literal: true
|
|
|
|
class OfferBuilder < DfcBuilder
|
|
def self.build(variant)
|
|
id = urls.enterprise_offer_url(
|
|
enterprise_id: variant.supplier_id,
|
|
id: variant.id,
|
|
)
|
|
|
|
DataFoodConsortium::Connector::Offer.new(
|
|
id,
|
|
price: variant.price.to_f,
|
|
stockLimitation: stock_limitation(variant),
|
|
)
|
|
end
|
|
|
|
def self.apply(offer, variant)
|
|
variant.on_hand = offer.stockLimitation
|
|
variant.price = offer.price
|
|
end
|
|
end
|