diff --git a/app/models/spree/payment.rb b/app/models/spree/payment.rb index 6479694df9..e10920d4b8 100644 --- a/app/models/spree/payment.rb +++ b/app/models/spree/payment.rb @@ -155,6 +155,7 @@ module Spree if adjustment adjustment.originator = payment_method adjustment.label = adjustment_label + adjustment.amount = payment_method.compute_amount(self) adjustment.save elsif !processing_refund? && payment_method.present? payment_method.create_adjustment(adjustment_label, self, true) diff --git a/app/views/spree/admin/orders/_form/_adjustments.html.haml b/app/views/spree/admin/orders/_form/_adjustments.html.haml index 5f3e9f215e..771723c99e 100644 --- a/app/views/spree/admin/orders/_form/_adjustments.html.haml +++ b/app/views/spree/admin/orders/_form/_adjustments.html.haml @@ -6,7 +6,7 @@ %tr %th= Spree.t('name') %th= Spree.t('amount') - %tbody.with-border + %tbody.with-border#order_adjustments - adjustments.each do |adjustment| %tr.total %td.strong= adjustment.label + ":" diff --git a/spec/system/admin/order_spec.rb b/spec/system/admin/order_spec.rb index 5a0ff97a0b..55d91e9ef2 100644 --- a/spec/system/admin/order_spec.rb +++ b/spec/system/admin/order_spec.rb @@ -172,6 +172,25 @@ RSpec.describe ' expect(order.line_items.reload.map(&:product)).to include product end + context "When adding a product on an order with transaction fee" do + let(:order_with_fees) { create(:completed_order_with_fees, user:, distributor:, order_cycle: ) } + + it 'recalculates transaction fee' do + login_as_admin + visit spree.edit_admin_order_path(order_with_fees) + + adjustment_for_transaction_fee = order_with_fees.all_adjustments.payment_fee.eligible.first + transaction_fee = adjustment_for_transaction_fee.amount + + expect(page.find("#order_adjustments").text).to have_content(transaction_fee) + + select2_select product.name, from: 'add_variant_id', search: true + find('button.add_variant').click + expect(page).to have_css("#order_adjustments", + text: adjustment_for_transaction_fee.reload.amount) + end + end + shared_examples_for "Cancelling the order" do it "shows a modal about order cancellation" do expect(page).to have_content "This will cancel the current order."