mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Use old_outstanding_balance on disabled toggle
No need to go through the `OrderBalance` in this context since we already check for the toggle.
This commit is contained in:
@@ -11,7 +11,7 @@ module Api
|
||||
if OpenFoodNetwork::FeatureToggle.enabled?(:customer_balance, object.user)
|
||||
-object.balance_value
|
||||
else
|
||||
object.outstanding_balance
|
||||
object.old_outstanding_balance
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -171,7 +171,7 @@ module OrderManagement
|
||||
if OpenFoodNetwork::FeatureToggle.enabled?(:customer_balance, @user)
|
||||
unique_orders(line_items).sum(&:new_outstanding_balance)
|
||||
else
|
||||
unique_orders(line_items).sum(&:outstanding_balance)
|
||||
unique_orders(line_items).sum(&:old_outstanding_balance)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -195,7 +195,7 @@ describe OrderManagement::Reports::BulkCoop::BulkCoopReport do
|
||||
end
|
||||
|
||||
it 'calls #outstanding_balance' do
|
||||
expect_any_instance_of(Spree::Order).to receive(:outstanding_balance)
|
||||
expect_any_instance_of(Spree::Order).to receive(:old_outstanding_balance)
|
||||
subject.send(:customer_payments_amount_owed, [line_item])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -44,12 +44,12 @@ describe Api::OrderSerializer do
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the customer_balance is not enabled' do
|
||||
context 'when the customer_balance is disabled' do
|
||||
before do
|
||||
allow(OpenFoodNetwork::FeatureToggle)
|
||||
.to receive(:enabled?).with(:customer_balance, order.user) { false }
|
||||
|
||||
allow(order).to receive(:outstanding_balance).and_return(123.0)
|
||||
allow(order).to receive(:old_outstanding_balance).and_return(123.0)
|
||||
end
|
||||
|
||||
it 'calls #outstanding_balance on the object' do
|
||||
|
||||
Reference in New Issue
Block a user