From 8a22567291b2aef58b39616dd78d6e2e550cf3ed Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Tue, 2 Oct 2018 23:42:22 +0100 Subject: [PATCH] Fix enterprise fee calculation. The adjustment.source value of the fee is now allowing the inheritance of the tax category from line items --- lib/open_food_network/enterprise_fee_applicator.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/open_food_network/enterprise_fee_applicator.rb b/lib/open_food_network/enterprise_fee_applicator.rb index 04d7f248bb..b8517d851d 100644 --- a/lib/open_food_network/enterprise_fee_applicator.rb +++ b/lib/open_food_network/enterprise_fee_applicator.rb @@ -20,6 +20,12 @@ module OpenFoodNetwork def create_enterprise_fee_adjustment(label, target, calculable) adjustment = enterprise_fee.create_adjustment(label, target, calculable, true) + + # This is necessary when source is a line_item + # probably because the association order.adjustments contains "inverse_of :source" + # which overrides the value (the line item) set in calculated_adjustment.create_adjustment + adjustment.source = calculable + adjustment end def line_item_adjustment_label