Merge pull request #11327 from bouaik/fix-display-invoice-tab-for-completed-resumed-canceled-only

Fix display invoice tab for completed, resumed and canceled orders only
This commit is contained in:
Rachel Arnould
2023-08-09 18:37:02 +02:00
committed by GitHub
3 changed files with 7 additions and 5 deletions

View File

@@ -361,6 +361,10 @@ module Spree
complete? || resumed? || awaiting_return? || returned?
end
def can_show_invoice?
complete? || resumed? || canceled?
end
# Finalizes an in progress order after checkout is complete.
# Called after transition to complete state when payments will have been processed
def finalize!

View File

@@ -61,7 +61,7 @@
%li{ class: adjustments_classes }
= link_to_with_icon 'icon-cogs', t(:adjustments), spree.admin_order_adjustments_url(@order)
- if feature?(:invoices)
- if feature?(:invoices) && @order.can_show_invoice?
- invoices_classes = "active" if current == 'Invoices'
%li{ class: invoices_classes }
= link_to_with_icon 'icon-cogs', t(:invoices), spree.admin_order_invoices_url(@order)

View File

@@ -1123,8 +1123,7 @@ describe '
visit spree.edit_admin_order_path(order_empty)
end
it "displays the invoice tab" do
pending "issue #11240"
it "should not display the invoice tab" do
expect(page).to have_content "Cart".upcase
expect(page).not_to have_content "Invoices".upcase
end
@@ -1140,8 +1139,7 @@ describe '
visit spree.edit_admin_order_path(order4)
end
it "displays the invoice tab" do
pending "issue #11240"
it "should not display the invoice tab" do
expect(page).to have_content "Payment".upcase
expect(page).not_to have_content "Invoices".upcase
end