mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
fix existing invalid enterprise fees
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class DisableInheritsTaxCategoryFromPerOrderEnterpriseFees < ActiveRecord::Migration[6.1]
|
||||
class EnterpriseFee < ApplicationRecord
|
||||
has_one :calculator, as: :calculable, class_name: "Spree::Calculator", dependent: :destroy
|
||||
end
|
||||
|
||||
class Spree
|
||||
class Calculator < ApplicationRecord
|
||||
self.table_name = 'spree_calculators'
|
||||
end
|
||||
end
|
||||
|
||||
def change
|
||||
EnterpriseFee.joins(:calculator).merge(calculators)
|
||||
.where(inherits_tax_category: true)
|
||||
.update_all(inherits_tax_category: false)
|
||||
end
|
||||
|
||||
def calculators
|
||||
Spree::Calculator.where(type: per_order_calculators)
|
||||
end
|
||||
|
||||
def per_order_calculators
|
||||
['Calculator::FlatRate',
|
||||
'Calculator::FlexiRate',
|
||||
'Calculator::PriceSack']
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user