mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-13 04:00:21 +00:00
Adding producers to home and distributors to producers
This commit is contained in:
@@ -136,6 +136,14 @@ class Enterprise < ActiveRecord::Base
|
||||
", self.id, self.id)
|
||||
end
|
||||
|
||||
def distributors
|
||||
self.relatives.is_distributor
|
||||
end
|
||||
|
||||
def suppliers
|
||||
self.relatives.is_supplier
|
||||
end
|
||||
|
||||
def distributed_variants
|
||||
Spree::Variant.joins(:product).merge(Spree::Product.in_distributor(self)).select('spree_variants.*')
|
||||
end
|
||||
@@ -149,11 +157,17 @@ class Enterprise < ActiveRecord::Base
|
||||
end
|
||||
|
||||
# Return all taxons for all distributed products
|
||||
def taxons
|
||||
def distributed_taxons
|
||||
Spree::Product.in_distributor(self).map do |p|
|
||||
p.taxons
|
||||
end.flatten.uniq
|
||||
end
|
||||
# Return all taxons for all supplied products
|
||||
def supplied_taxons
|
||||
Spree::Product.in_supplier(self).map do |p|
|
||||
p.taxons
|
||||
end.flatten.uniq
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
|
||||
Reference in New Issue
Block a user