mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-09 03:20:21 +00:00
Find only outgoing exchanges for Enterprise scopes using with_order_cycles_outer
This commit is contained in:
@@ -47,7 +47,7 @@ class Enterprise < ActiveRecord::Base
|
||||
joins('LEFT OUTER JOIN product_distributions ON product_distributions.distributor_id = enterprises.id').
|
||||
joins('LEFT OUTER JOIN spree_products ON spree_products.id = product_distributions.product_id')
|
||||
scope :with_order_cycles_outer,
|
||||
joins('LEFT OUTER JOIN exchanges ON (exchanges.receiver_id = enterprises.id)').
|
||||
joins("LEFT OUTER JOIN exchanges ON (exchanges.receiver_id = enterprises.id AND exchanges.incoming = 'f')").
|
||||
joins('LEFT OUTER JOIN order_cycles ON (order_cycles.id = exchanges.order_cycle_id)')
|
||||
|
||||
scope :with_order_cycles_and_exchange_variants_outer,
|
||||
|
||||
@@ -106,7 +106,6 @@ describe Enterprise do
|
||||
create(:simple_order_cycle, suppliers: [s], distributors: [d], variants: [p.master], orders_open_at: 1.week.from_now, orders_close_at: 2.weeks.from_now)
|
||||
Enterprise.active_distributors.should be_empty
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "with_distributed_active_products_on_hand" do
|
||||
|
||||
Reference in New Issue
Block a user