diff --git a/backend/app/assets/javascripts/spree/backend/views/order/details_adjustments.js b/backend/app/assets/javascripts/spree/backend/views/order/details_adjustments.js index af5534c5a64..e25468a8471 100644 --- a/backend/app/assets/javascripts/spree/backend/views/order/details_adjustments.js +++ b/backend/app/assets/javascripts/spree/backend/views/order/details_adjustments.js @@ -8,7 +8,10 @@ Spree.Views.Order.DetailsAdjustments = Backbone.View.extend({ var totals = {}; var collection = this.collection ? this.collection.chain() : _.chain([this.model]); collection - .map(function(item){ return item.get("adjustments") || [] }) + .map(function(item) { + return (item.get("adjustments") || []) + .filter(function(adjustment) { return (adjustment.eligible === true); }); + }) .flatten(true) .each(function(adjustment){ var label = adjustment.label; diff --git a/backend/spec/features/admin/orders/adjustments_spec.rb b/backend/spec/features/admin/orders/adjustments_spec.rb index aff6fed898a..51c451d957e 100644 --- a/backend/spec/features/admin/orders/adjustments_spec.rb +++ b/backend/spec/features/admin/orders/adjustments_spec.rb @@ -21,6 +21,7 @@ let(:tax_category) { create(:tax_category) } let(:variant) { create(:variant, tax_category: tax_category) } + let!(:non_eligible_adjustment) { order.adjustments.create!(order: order, label: 'Non-Eligible', amount: 10, eligible: false) } let!(:adjustment) { order.adjustments.create!(order: order, label: 'Rebate', amount: 10) } before(:each) do @@ -40,8 +41,11 @@ end end - it "only shows eligible adjustments" do - expect(page).not_to have_content("ineligible") + it "shows both eligible and non-eligible adjustments" do + expect(page).to have_content("Rebate") + expect(page).to have_content("Non-Eligible") + expect(find('tr', text: 'Rebate')[:class]).not_to eq('adjustment-ineligible') + expect(find('tr', text: 'Non-Eligible')[:class]).to eq('adjustment-ineligible') end end diff --git a/backend/spec/features/admin/orders/order_details_spec.rb b/backend/spec/features/admin/orders/order_details_spec.rb index 81959ac6ace..435aed87436 100644 --- a/backend/spec/features/admin/orders/order_details_spec.rb +++ b/backend/spec/features/admin/orders/order_details_spec.rb @@ -225,6 +225,21 @@ end end + context "with adjustments" do + let(:order) do + super().tap do |o| + o.adjustments.create!(order: order, label: 'Non-Eligible', amount: 10, eligible: false) + o.adjustments.create!(order: order, label: 'Rebate', amount: 10) + end + end + + it "shows only eligible adjustments" do + visit spree.cart_admin_order_path(order) + expect(page).to have_content("Rebate") + expect(page).not_to have_content("Non-Eligible") + end + end + context "variant doesn't track inventory" do let(:track_inventory) { false } let(:backorderable) { false }