mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Prepare inventory report for Spree upgrade
This change could impact the performance of the report. But therefore it takes VariantOverrides into consideration. The old code ignored the distributor for this filter. It also ignored the `on_demand` flag.
This commit is contained in:
@@ -29,16 +29,18 @@ module OpenFoodNetwork
|
||||
end
|
||||
|
||||
def filter(variants)
|
||||
filter_to_distributor filter_to_order_cycle filter_on_hand filter_to_supplier filter_not_deleted variants
|
||||
filter_on_hand filter_to_distributor filter_to_order_cycle filter_to_supplier filter_not_deleted variants
|
||||
end
|
||||
|
||||
def filter_not_deleted(variants)
|
||||
variants.not_deleted
|
||||
end
|
||||
|
||||
# Using the `in_stock?` method allows overrides by distributors.
|
||||
# It also allows the upgrade to Spree 2.0.
|
||||
def filter_on_hand(variants)
|
||||
if params[:report_type] == 'inventory'
|
||||
variants.where('spree_variants.count_on_hand > 0')
|
||||
variants.select(&:in_stock?)
|
||||
else
|
||||
variants
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user