Update rake task for product distribution fees by enterprise fee

This commit is contained in:
Rohan Mitchell
2013-08-13 07:21:13 +10:00
parent b5d324ec8c
commit c011de539d
2 changed files with 13 additions and 10 deletions

View File

@@ -11,7 +11,7 @@ module SuburbSeeder
connection = ActiveRecord::Base.connection()
puts "-- Seeding australian suburbs"
puts "-- Seeding Australian suburbs"
connection.execute("
INSERT INTO suburbs (postcode,name,state_id,latitude,longitude) VALUES
(200,$$AUSTRALIAN NATIONAL UNIVERSITY$$,#{state_id_act},-35.277272,149.117136),
@@ -16894,4 +16894,4 @@ module SuburbSeeder
(6060,$$Yokine South$$,#{state_id_wa},-31.9097,115.849);
")
end
end
end

View File

@@ -72,11 +72,7 @@ namespace :openfoodweb do
FactoryGirl.create(:distributor_enterprise, :address => Spree::Address.find_by_zipcode("3040"))
end
unless Spree::ShippingMethod.all.any? { |sm| sm.calculator.is_a? OpenFoodWeb::Calculator::Itemwise }
FactoryGirl.create(:itemwise_shipping_method)
end
# -- Enterprise Users
# -- Enterprise users
unless Spree::User.count > 1
puts "[#{task_name}] Seeding enterprise users"
@@ -93,6 +89,13 @@ namespace :openfoodweb do
puts " Distributor User created: #{u.email}/#{pw} (" + u.enterprise_roles.map{ |er| er.enterprise.name}.join(", ") + ")"
end
# -- Enterprise fees
unless EnterpriseFee.count > 1
Enterprise.is_distributor.each do |distributor|
FactoryGirl.create(:enterprise_fee, enterprise: distributor)
end
end
# -- Products
unless Spree::Product.count > 0
puts "[#{task_name}] Seeding products"
@@ -104,7 +107,7 @@ namespace :openfoodweb do
ProductDistribution.create(:product => prod1,
:distributor => Enterprise.is_distributor[0],
:shipping_method => Spree::ShippingMethod.first)
:enterprise_fee => Enterprise.is_distributor[0].enterprise_fees.first)
prod2 = FactoryGirl.create(:product,
@@ -114,7 +117,7 @@ namespace :openfoodweb do
ProductDistribution.create(:product => prod2,
:distributor => Enterprise.is_distributor[1],
:shipping_method => Spree::ShippingMethod.first)
:enterprise_fee => Enterprise.is_distributor[1].enterprise_fees.first)
prod3 = FactoryGirl.create(:product,
:name => 'Beef - 5kg Trays', :price => 50.00,
@@ -123,7 +126,7 @@ namespace :openfoodweb do
ProductDistribution.create(:product => prod3,
:distributor => Enterprise.is_distributor[2],
:shipping_method => Spree::ShippingMethod.first)
:enterprise_fee => Enterprise.is_distributor[2].enterprise_fees.first)
end
end
end