mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Convert product distribution shipping methods to enterprise fees
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
class CreateEnterpriseFeeRecordsForProductDistributions < ActiveRecord::Migration
|
||||
def up
|
||||
ProductDistribution.all.each do |pd|
|
||||
calculator = pd.shipping_method.calculator.dup
|
||||
calculator.save!
|
||||
|
||||
ef = EnterpriseFee.new enterprise_id: pd.distributor.id, fee_type: 'packing', name: pd.shipping_method.name
|
||||
ef.calculator = calculator
|
||||
ef.save!
|
||||
|
||||
pd.enterprise_fee = ef
|
||||
pd.save!
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
ProductDistribution.update_all :enterprise_fee_id => nil
|
||||
end
|
||||
end
|
||||
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20130807230834) do
|
||||
ActiveRecord::Schema.define(:version => 20130809045637) do
|
||||
|
||||
create_table "carts", :force => true do |t|
|
||||
t.integer "user_id"
|
||||
|
||||
Reference in New Issue
Block a user