mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
small fixes for sales tax report
This commit is contained in:
committed by
Rob Harrington
parent
0429906eed
commit
d22f5678be
@@ -58,7 +58,7 @@ Spree::LineItem.class_eval do
|
||||
end
|
||||
|
||||
def tax_rates
|
||||
product.tax_category.tax_rates
|
||||
product.tax_category.andand.tax_rates || []
|
||||
end
|
||||
|
||||
def price_with_adjustments
|
||||
|
||||
@@ -65,13 +65,10 @@ module OpenFoodNetwork
|
||||
private
|
||||
|
||||
def relevant_rates
|
||||
queries = [ search.result.joins(:line_items => {:adjustments => :tax_rate}).select('spree_tax_rates.*').uniq,
|
||||
search.result.joins(:adjustments => :tax_rate).select('spree_tax_rates.*').uniq ]
|
||||
queries.map do |query|
|
||||
ActiveRecord::Base.connection.select_all(query)
|
||||
end.sum.map do |tax_rate|
|
||||
Spree::TaxRate.new(tax_rate, without_protection: true)
|
||||
end
|
||||
return @relevant_rates unless @relevant_rates.nil?
|
||||
item_rate_ids = search.result.joins(:line_items => {:adjustments => :tax_rate}).select('spree_tax_rates.id').uniq
|
||||
order_rate_ids = search.result.joins(:adjustments => :tax_rate).select('spree_tax_rates.id').uniq
|
||||
@relevant_rates = Spree::TaxRate.where(id: item_rate_ids | order_rate_ids)
|
||||
end
|
||||
|
||||
def totals_of(line_items)
|
||||
|
||||
Reference in New Issue
Block a user