diff --git a/api/app/views/spree/api/shipments/_small.json.jbuilder b/api/app/views/spree/api/shipments/_small.json.jbuilder index 591affb8d52..57cc17bafed 100644 --- a/api/app/views/spree/api/shipments/_small.json.jbuilder +++ b/api/app/views/spree/api/shipments/_small.json.jbuilder @@ -23,7 +23,7 @@ json.cache! [I18n.locale, shipment] do json.(shipping_category, :id, :name) end end - json.manifest(shipment.manifest) do |manifest_item| + json.manifest(shipment.shipping_manifest_items) do |manifest_item| json.variant_id manifest_item.variant.id json.quantity(manifest_item.quantity) json.states(manifest_item.states) diff --git a/api/app/views/spree/api/shipments/show.json.jbuilder b/api/app/views/spree/api/shipments/show.json.jbuilder index a7a328c2228..2413ca26aa3 100644 --- a/api/app/views/spree/api/shipments/show.json.jbuilder +++ b/api/app/views/spree/api/shipments/show.json.jbuilder @@ -23,7 +23,7 @@ json.cache! [I18n.locale, @shipment] do json.(shipping_category, :id, :name) end end - json.manifest(@shipment.manifest) do |manifest_item| + json.manifest(@shipment.shipping_manifest_items) do |manifest_item| json.variant do json.partial!("spree/api/variants/small", variant: manifest_item.variant) end diff --git a/backend/app/views/spree/admin/orders/confirm/_shipment_manifest.html.erb b/backend/app/views/spree/admin/orders/confirm/_shipment_manifest.html.erb index c00856d23b9..bbb5595cc70 100644 --- a/backend/app/views/spree/admin/orders/confirm/_shipment_manifest.html.erb +++ b/backend/app/views/spree/admin/orders/confirm/_shipment_manifest.html.erb @@ -1,4 +1,4 @@ -<% shipment.manifest.each do |item| %> +<% shipment.shipping_manifest_items.each do |item| %>
<%= item.variant.sku %> | <%= item.variant.product.name %> | diff --git a/core/app/views/spree/carton_mailer/shipped_email.text.erb b/core/app/views/spree/carton_mailer/shipped_email.text.erb index e7aa8441db9..34a572a7930 100644 --- a/core/app/views/spree/carton_mailer/shipped_email.text.erb +++ b/core/app/views/spree/carton_mailer/shipped_email.text.erb @@ -5,7 +5,7 @@ ============================================================ <%= t('spree.shipment_mailer.shipped_email.shipment_summary') %> ============================================================ -<% @manifest.each do |item| %> +<% @shipping_manifest_for_order.each do |item| %> <%= item.variant.sku %> <%= item.variant.product.name %> <%= item.variant.options_text %> <% end %> ============================================================ diff --git a/core/spec/models/spree/carton_spec.rb b/core/spec/models/spree/carton_spec.rb index 572183e3a1e..9ff1424961b 100644 --- a/core/spec/models/spree/carton_spec.rb +++ b/core/spec/models/spree/carton_spec.rb @@ -83,7 +83,16 @@ end describe "#manifest" do - subject { carton.manifest } + it "is deprecated" do + Spree::Deprecation.silence do + expect(Spree::Deprecation).to(receive(:warn)) + Spree::Shipment.new.manifest + end + end + end + + describe "#shipping_manifest_items" do + subject { carton.shipping_manifest_items } let(:carton) { create(:carton, inventory_units: [first_order.inventory_units, second_order.inventory_units].flatten) } let(:first_order) { create(:order_ready_to_ship, line_items_count: 1) } @@ -97,6 +106,15 @@ end describe "#manifest_for_order" do + it "is deprecated" do + Spree::Deprecation.silence do + expect(Spree::Deprecation).to(receive(:warn)) + Spree::Carton.new.manifest_for_order(create(:order)) + end + end + end + + describe "#shipping_manifest_for_order" do subject { carton.manifest_for_order(first_order) } let(:carton) { create(:carton, inventory_units: [first_order.inventory_units, second_order.inventory_units].flatten) } diff --git a/core/spec/models/spree/shipment_spec.rb b/core/spec/models/spree/shipment_spec.rb index b572575b347..bed4dbfd4bd 100644 --- a/core/spec/models/spree/shipment_spec.rb +++ b/core/spec/models/spree/shipment_spec.rb @@ -141,6 +141,26 @@ it 'should equal line items final amount with tax' do expect(shipment.item_cost).to eql(11.0) end + + context 'with more shipments for the same line_item' do + let(:order) do + create( + :order_with_line_items, + line_items_attributes: [{ price: 10, variant: variant, quantity: 2 }], + ship_address: ship_address, + ) + end + let(:other_shipment) { order.shipments.create(stock_location_id: shipment.stock_location) } + + it 'returns shipment line items amount with tax' do + expect(order.shipments.first.item_cost).to eql(22.0) + expect { + order.inventory_units.last.update(shipment_id: other_shipment.id) + }.to change { order.shipments.reload.first.item_cost }.from(22.0).to(11.0) + + expect(order.shipments.second.item_cost).to eql(11.0) + end + end end it "#discounted_cost" do @@ -187,21 +207,30 @@ expect(shipment.total).to eq(8) end - context "manifest" do + describe "#manifest_items" do let(:order) { create(:order) } let(:variant) { create(:variant) } let!(:line_item) { order.contents.add variant } let!(:shipment) { order.create_proposed_shipments.first } it "returns variant expected" do - expect(shipment.manifest.first.variant).to eq variant + expect(shipment.shipping_manifest_items.first.variant).to eq variant end context "variant was removed" do before { variant.discard } it "still returns variant expected" do - expect(shipment.manifest.first.variant).to eq variant + expect(shipment.shipping_manifest_items.first.variant).to eq variant + end + end + end + + context "manifest" do + it "is deprecated" do + Spree::Deprecation.silence do + expect(Spree::Deprecation).to(receive(:warn)) + Spree::Shipment.new.manifest end end end diff --git a/frontend/app/views/spree/checkout/_delivery.html.erb b/frontend/app/views/spree/checkout/_delivery.html.erb index 741c81658ef..68c364cd6b2 100644 --- a/frontend/app/views/spree/checkout/_delivery.html.erb +++ b/frontend/app/views/spree/checkout/_delivery.html.erb @@ -24,7 +24,7 @@<%= t('spree.price') %> |
---|---|---|
<%= render 'spree/shared/image', |