mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Use indexed_fees_for for product price
This commit is contained in:
@@ -22,7 +22,12 @@ class Api::UncachedProductSerializer < ActiveModel::Serializer
|
||||
attributes :price
|
||||
|
||||
def price
|
||||
object.master.price_with_fees(options[:current_distributor], options[:current_order_cycle])
|
||||
if options[:enterprise_fee_calculator]
|
||||
object.master.price + options[:enterprise_fee_calculator].indexed_fees_for(object.master)
|
||||
else
|
||||
object.master.price_with_fees(options[:current_distributor], options[:current_order_cycle])
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -162,7 +162,10 @@ describe ShopController do
|
||||
end
|
||||
|
||||
it "returns price including fees" do
|
||||
Spree::Variant.any_instance.stub(:price_with_fees).and_return 998.00
|
||||
# Price is 19.99
|
||||
OpenFoodNetwork::EnterpriseFeeCalculator.any_instance.
|
||||
stub(:indexed_fees_for).and_return 978.01
|
||||
|
||||
xhr :get, :products
|
||||
response.body.should have_content "998.0"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user