diff --git a/app/mailers/producer_mailer.rb b/app/mailers/producer_mailer.rb index 5d8ce57eec..b9fb52fb41 100644 --- a/app/mailers/producer_mailer.rb +++ b/app/mailers/producer_mailer.rb @@ -5,7 +5,6 @@ class ProducerMailer < Spree::BaseMailer @coordinator = order_cycle.coordinator @order_cycle = order_cycle @line_items = aggregated_line_items_from(@order_cycle, @producer) - @receival_time = @order_cycle.receival_time_for @producer @receival_instructions = @order_cycle.receival_instructions_for @producer subject = "[#{Spree::Config.site_name}] Order cycle report for #{producer.name}" diff --git a/app/models/order_cycle.rb b/app/models/order_cycle.rb index 45f90c4d8f..7734093225 100644 --- a/app/models/order_cycle.rb +++ b/app/models/order_cycle.rb @@ -200,10 +200,6 @@ class OrderCycle < ActiveRecord::Base exchanges.incoming.from_enterprises([supplier]).first end - def receival_time_for(supplier) - exchange_for_supplier(supplier).andand.receival_time - end - def receival_instructions_for(supplier) exchange_for_supplier(supplier).andand.receival_instructions end diff --git a/app/views/admin/order_cycles/_exchange_form.html.haml b/app/views/admin/order_cycles/_exchange_form.html.haml index ad9ace7001..ed3e43fd6b 100644 --- a/app/views/admin/order_cycles/_exchange_form.html.haml +++ b/app/views/admin/order_cycles/_exchange_form.html.haml @@ -9,8 +9,6 @@ selected - if type == 'supplier' %td.receival-details - = text_field_tag 'order_cycle_incoming_exchange_{{ $index }}_receival_time', '', 'id' => 'order_cycle_incoming_exchange_{{ $index }}_receival_time', 'placeholder' => 'Receive at (ie. Date / Time)', 'ng-model' => 'exchange.receival_time' - %br/ = text_field_tag 'order_cycle_incoming_exchange_{{ $index }}_receival_instructions', '', 'id' => 'order_cycle_incoming_exchange_{{ $index }}_receival_instructions', 'placeholder' => 'Receival instructions', 'ng-model' => 'exchange.receival_instructions' - if type == 'distributor' %td.collection-details diff --git a/app/views/producer_mailer/order_cycle_report.text.haml b/app/views/producer_mailer/order_cycle_report.text.haml index 1bd9099426..516c405983 100644 --- a/app/views/producer_mailer/order_cycle_report.text.haml +++ b/app/views/producer_mailer/order_cycle_report.text.haml @@ -1,6 +1,6 @@ Dear #{@producer.name}, \ -We now have all the consumer orders for next food drop. Please drop off your delivery at #{@receival_time}. +We now have all the consumer orders for next food drop. - if @receival_instructions Extra instructions: #{@receival_instructions} diff --git a/db/migrate/20151125051510_combine_exchange_receival_time_receival_instructions.rb b/db/migrate/20151125051510_combine_exchange_receival_time_receival_instructions.rb new file mode 100644 index 0000000000..434a2053ab --- /dev/null +++ b/db/migrate/20151125051510_combine_exchange_receival_time_receival_instructions.rb @@ -0,0 +1,9 @@ +class CombineExchangeReceivalTimeReceivalInstructions < ActiveRecord::Migration + def up + remove_column :exchanges, :receival_time + end + + def down + add_column :exchanges, :receival_time, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index d5494eb970..fb50bec0a1 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20151002020537) do +ActiveRecord::Schema.define(:version => 20151125051510) do create_table "account_invoices", :force => true do |t| t.integer "user_id", :null => false @@ -386,7 +386,6 @@ ActiveRecord::Schema.define(:version => 20151002020537) do t.datetime "created_at", :null => false t.datetime "updated_at", :null => false t.boolean "incoming", :default => false, :null => false - t.string "receival_time" t.string "receival_instructions" end @@ -671,9 +670,9 @@ ActiveRecord::Schema.define(:version => 20151002020537) do t.string "email" t.text "special_instructions" t.integer "distributor_id" - t.integer "order_cycle_id" t.string "currency" t.string "last_ip_address" + t.integer "order_cycle_id" t.integer "cart_id" t.integer "customer_id" end diff --git a/lib/open_food_network/order_cycle_form_applicator.rb b/lib/open_food_network/order_cycle_form_applicator.rb index 540a18da13..a2cc95b12f 100644 --- a/lib/open_food_network/order_cycle_form_applicator.rb +++ b/lib/open_food_network/order_cycle_form_applicator.rb @@ -24,12 +24,10 @@ module OpenFoodNetwork if exchange_exists?(exchange[:enterprise_id], @order_cycle.coordinator_id, true) update_exchange(exchange[:enterprise_id], @order_cycle.coordinator_id, true, {variant_ids: variant_ids, enterprise_fee_ids: enterprise_fee_ids, - receival_time: exchange[:receival_time], receival_instructions: exchange[:receival_instructions]}) else add_exchange(exchange[:enterprise_id], @order_cycle.coordinator_id, true, {variant_ids: variant_ids, enterprise_fee_ids: enterprise_fee_ids, - receival_time: exchange[:receival_time], receival_instructions: exchange[:receival_instructions],}) end end diff --git a/spec/factories.rb b/spec/factories.rb index 0db34ab78c..ef839537db 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -16,10 +16,10 @@ FactoryGirl.define do # Incoming Exchanges ex1 = create(:exchange, :order_cycle => oc, :incoming => true, :sender => supplier1, :receiver => oc.coordinator, - :receival_time => 'time 0', :receival_instructions => 'instructions 0') + :receival_instructions => 'instructions 0') ex2 = create(:exchange, :order_cycle => oc, :incoming => true, :sender => supplier2, :receiver => oc.coordinator, - :receival_time => 'time 1', :receival_instructions => 'instructions 1') + :receival_instructions => 'instructions 1') ExchangeFee.create!(exchange: ex1, enterprise_fee: create(:enterprise_fee, enterprise: ex1.sender)) ExchangeFee.create!(exchange: ex2, @@ -73,7 +73,7 @@ FactoryGirl.define do after(:create) do |oc, proxy| proxy.suppliers.each do |supplier| - ex = create(:exchange, :order_cycle => oc, :sender => supplier, :receiver => oc.coordinator, :incoming => true, :receival_time => 'time', :receival_instructions => 'instructions') + ex = create(:exchange, :order_cycle => oc, :sender => supplier, :receiver => oc.coordinator, :incoming => true, :receival_instructions => 'instructions') proxy.variants.each { |v| ex.variants << v } end diff --git a/spec/lib/open_food_network/order_cycle_form_applicator_spec.rb b/spec/lib/open_food_network/order_cycle_form_applicator_spec.rb index 91882510b4..0d6c7478fe 100644 --- a/spec/lib/open_food_network/order_cycle_form_applicator_spec.rb +++ b/spec/lib/open_food_network/order_cycle_form_applicator_spec.rb @@ -11,7 +11,7 @@ module OpenFoodNetwork coordinator_id = 123 supplier_id = 456 - incoming_exchange = {:enterprise_id => supplier_id, :incoming => true, :variants => {'1' => true, '2' => false, '3' => true}, :enterprise_fee_ids => [1, 2], :receival_time => 'receival time', :receival_instructions => 'receival instructions'} + incoming_exchange = {:enterprise_id => supplier_id, :incoming => true, :variants => {'1' => true, '2' => false, '3' => true}, :enterprise_fee_ids => [1, 2], :receival_instructions => 'receival instructions'} oc = double(:order_cycle, :coordinator_id => coordinator_id, :exchanges => [], :incoming_exchanges => [incoming_exchange], :outgoing_exchanges => []) @@ -19,7 +19,7 @@ module OpenFoodNetwork applicator.should_receive(:incoming_exchange_variant_ids).with(incoming_exchange).and_return([1, 3]) applicator.should_receive(:exchange_exists?).with(supplier_id, coordinator_id, true).and_return(false) - applicator.should_receive(:add_exchange).with(supplier_id, coordinator_id, true, {:variant_ids => [1, 3], :enterprise_fee_ids => [1, 2], :receival_time => 'receival time', :receival_instructions => 'receival instructions'}) + applicator.should_receive(:add_exchange).with(supplier_id, coordinator_id, true, {:variant_ids => [1, 3], :enterprise_fee_ids => [1, 2], :receival_instructions => 'receival instructions'}) applicator.should_receive(:destroy_untouched_exchanges) applicator.go! @@ -47,7 +47,7 @@ module OpenFoodNetwork coordinator_id = 123 supplier_id = 456 - incoming_exchange = {:enterprise_id => supplier_id, :incoming => true, :variants => {'1' => true, '2' => false, '3' => true}, :enterprise_fee_ids => [1, 2], :receival_time => 'receival time', :receival_instructions => 'receival instructions'} + incoming_exchange = {:enterprise_id => supplier_id, :incoming => true, :variants => {'1' => true, '2' => false, '3' => true}, :enterprise_fee_ids => [1, 2], :receival_instructions => 'receival instructions'} oc = double(:order_cycle, :coordinator_id => coordinator_id, @@ -59,7 +59,7 @@ module OpenFoodNetwork applicator.should_receive(:incoming_exchange_variant_ids).with(incoming_exchange).and_return([1, 3]) applicator.should_receive(:exchange_exists?).with(supplier_id, coordinator_id, true).and_return(true) - applicator.should_receive(:update_exchange).with(supplier_id, coordinator_id, true, {:variant_ids => [1, 3], :enterprise_fee_ids => [1, 2], :receival_time => 'receival time', :receival_instructions => 'receival instructions'}) + applicator.should_receive(:update_exchange).with(supplier_id, coordinator_id, true, {:variant_ids => [1, 3], :enterprise_fee_ids => [1, 2], :receival_instructions => 'receival instructions'}) applicator.should_receive(:destroy_untouched_exchanges) applicator.go! diff --git a/spec/mailers/producer_mailer_spec.rb b/spec/mailers/producer_mailer_spec.rb index 2bc1d77bef..0c7e82b89d 100644 --- a/spec/mailers/producer_mailer_spec.rb +++ b/spec/mailers/producer_mailer_spec.rb @@ -11,7 +11,7 @@ describe ProducerMailer do let(:p2) { create(:product, price: 23.45, supplier: s2) } let(:p3) { create(:product, price: 34.56, supplier: s1) } let(:order_cycle) { create(:simple_order_cycle) } - let!(:incoming_exchange) { order_cycle.exchanges.create! sender: s1, receiver: d1, incoming: true, receival_time: '10am Saturday', receival_instructions: 'Outside shed.' } + let!(:incoming_exchange) { order_cycle.exchanges.create! sender: s1, receiver: d1, incoming: true, receival_instructions: 'Outside shed.' } let!(:order) do order = create(:order, distributor: d1, order_cycle: order_cycle, state: 'complete') @@ -43,10 +43,6 @@ describe ProducerMailer do mail.reply_to.should == [s1.email] end - it "includes receival time" do - mail.body.should include '10am Saturday' - end - it "includes receival instructions" do mail.body.should include 'Outside shed.' end diff --git a/spec/models/exchange_spec.rb b/spec/models/exchange_spec.rb index 2ba0e26b24..4af94e19c2 100644 --- a/spec/models/exchange_spec.rb +++ b/spec/models/exchange_spec.rb @@ -277,7 +277,7 @@ describe Exchange do 'payment_enterprise_id' => exchange.payment_enterprise_id, 'variant_ids' => exchange.variant_ids.sort, 'enterprise_fee_ids' => exchange.enterprise_fee_ids.sort, 'pickup_time' => exchange.pickup_time, 'pickup_instructions' => exchange.pickup_instructions, - 'receival_time' => exchange.receival_time, 'receival_instructions' => exchange.receival_instructions, + 'receival_instructions' => exchange.receival_instructions, 'created_at' => exchange.created_at, 'updated_at' => exchange.updated_at} end @@ -288,7 +288,7 @@ describe Exchange do 'payment_enterprise_id' => exchange.payment_enterprise_id, 'variant_ids' => exchange.variant_ids.sort, 'enterprise_fee_ids' => exchange.enterprise_fee_ids.sort, 'pickup_time' => exchange.pickup_time, 'pickup_instructions' => exchange.pickup_instructions, - 'receival_time' => exchange.receival_time, 'receival_instructions' => exchange.receival_instructions} + 'receival_instructions' => exchange.receival_instructions} end end