From fc7e33d706cd0d6ddfec410c6b3a82de0bb413d1 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Thu, 4 Jun 2015 16:43:19 +1000 Subject: [PATCH] Fall back on individual calculations when pre-prepared values are not present --- app/serializers/api/variant_serializer.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/serializers/api/variant_serializer.rb b/app/serializers/api/variant_serializer.rb index 557c87d71c..6908eaf84f 100644 --- a/app/serializers/api/variant_serializer.rb +++ b/app/serializers/api/variant_serializer.rb @@ -7,11 +7,16 @@ class Api::VariantSerializer < ActiveModel::Serializer end def fees - options[:enterprise_fee_calculator].indexed_fees_by_type_for(object) + options[:enterprise_fee_calculator].andand.indexed_fees_by_type_for(object) || + object.fees_by_type_for(options[:current_distributor], options[:current_order_cycle]) end def price_with_fees - object.price + options[:enterprise_fee_calculator].indexed_fees_for(object) + if options[:enterprise_fee_calculator] + object.price + options[:enterprise_fee_calculator].indexed_fees_for(object) + else + object.price_with_fees(options[:current_distributor], options[:current_order_cycle]) + end end def product_name