Merge pull request #11290 from cyrillefr/Orders_in_confirmation_state_cannot_be_completed_by_hub_or_shop

Fix Orders in confirmation state cannot be completed by hub or shop
This commit is contained in:
Filipe
2023-11-16 19:50:14 +00:00
committed by GitHub
13 changed files with 49 additions and 12 deletions

View File

@@ -140,7 +140,8 @@ module Spree
#
# Otherwise redirect user to that step
def can_transition_to_payment
return if @order.payment? || @order.complete? || @order.canceled? || @order.resumed?
return if @order.confirmation? || @order.payment? ||
@order.complete? || @order.canceled? || @order.resumed?
flash[:notice] = Spree.t(:fill_in_customer_info)
redirect_to spree.edit_admin_order_customer_url(@order)
@@ -184,7 +185,8 @@ module Spree
end
def allowed_events
%w{capture void_transaction credit refund resend_authorization_email}
%w{capture void_transaction credit refund resend_authorization_email
capture_and_complete_order}
end
end
end

View File

@@ -67,7 +67,7 @@ module Spree
end
def actions
%w{capture void credit resend_authorization_email}
%w{capture_and_complete_order void credit resend_authorization_email}
end
def can_resend_authorization_email?(payment)
@@ -75,7 +75,7 @@ module Spree
end
# Indicates whether its possible to capture the payment
def can_capture?(payment)
def can_capture_and_complete_order?(payment)
return false if payment.requires_authorization?
payment.pending? || payment.checkout?

View File

@@ -47,6 +47,11 @@ module Spree
end
end
def capture_and_complete_order!
OrderWorkflow.new(order).complete!
capture!
end
def void_transaction!
return true if void?

View File

@@ -4,11 +4,11 @@ module Spree
class PaymentMethod
class Check < Spree::PaymentMethod
def actions
%w{capture void}
%w{capture_and_complete_order void}
end
# Indicates whether its possible to capture the payment
def can_capture?(payment)
def can_capture_and_complete_order?(payment)
['checkout', 'pending'].include?(payment.state)
end

View File

@@ -20,5 +20,6 @@
.icon-cancel:before,
.icon-void:before { @extend .icon-remove, :before; }
.icon-capture { @extend .icon-ok }
.icon-capture,
.icon-capture_and_complete_order { @extend .icon-ok }
.icon-credit:before { @extend .icon-ok, :before ; }

View File

@@ -84,7 +84,7 @@ table {
background-color: $color-notice;
color: $color-1;
}
.icon-edit:hover, .icon-capture:hover, .icon-ok:hover, .icon-plus:hover, .icon-road:hover {
.icon-edit:hover, .icon-capture:hover, .icon-capture_and_complete_order:hover, .icon-ok:hover, .icon-plus:hover, .icon-road:hover {
background-color: $color-success;
color: $color-1;
}

View File

@@ -34,9 +34,11 @@ button[class*="icon-"] {
@extend .icon-remove, :before;
}
.icon-capture {
.icon-capture,
.icon-capture_and_complete_order {
@extend .icon-ok;
}
.icon-credit:before {
@extend .icon-ok, :before;
}

View File

@@ -96,6 +96,7 @@ table {
}
.icon-edit:hover,
.icon-capture:hover,
.icon-capture_and_complete_order:hover,
.icon-ok:hover,
.icon-plus:hover {
background-color: $teal;