Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NTR: pipeline #915

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/Components/OrderExpiration/ExpireAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public function __construct(
OrderExpireService $orderExpireService,
SettingsService $settingsService,
LoggerInterface $logger
) {
)
{
$this->orderRepository = $orderRepository;
$this->salesChannelRepository = $salesChannelRepository;
$this->orderExpireService = $orderExpireService;
Expand Down Expand Up @@ -78,13 +79,18 @@ private function expireOrdersInSalesChannel(SalesChannelEntity $salesChannelEnti
$date = new \DateTime();
$date->modify(sprintf('-%d days', (BankTransferPayment::DUE_DATE_MAX_DAYS + 1)));


$orFilterArray = [
new EqualsFilter('transactions.stateMachineState.technicalName', OrderTransactionStates::STATE_IN_PROGRESS),
];
if (defined('\Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionStates\OrderTransactionStates::STATE_UNCONFIRMED')) {
$orFilterArray[] = new EqualsFilter('transactions.stateMachineState.technicalName', OrderTransactionStates::STATE_UNCONFIRMED);
}
$criteria = new Criteria();
$criteria->addAssociation('transactions.stateMachineState');
$criteria->addAssociation('transactions.paymentMethod');
$criteria->addFilter(new OrFilter([
new EqualsFilter('transactions.stateMachineState.technicalName', OrderTransactionStates::STATE_IN_PROGRESS),
new EqualsFilter('transactions.stateMachineState.technicalName', OrderTransactionStates::STATE_UNCONFIRMED)
]));

$criteria->addFilter(new OrFilter($orFilterArray));

$criteria->addFilter(new EqualsFilter('salesChannelId', $salesChannelEntity->getId()));
$criteria->addFilter(new RangeFilter('orderDateTime', [RangeFilter::GTE => $date->format(Defaults::STORAGE_DATE_TIME_FORMAT)]));
Expand Down
6 changes: 5 additions & 1 deletion src/Service/Order/OrderStatusUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,13 @@ public function updatePaymentStatus(OrderTransactionEntity $transaction, string
switch ($targetShopwareStatusKey) {
case MolliePaymentStatus::MOLLIE_PAYMENT_OPEN:
{
$states = [OrderTransactionStates::STATE_IN_PROGRESS];
if (defined('\Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionStates\OrderTransactionStates::STATE_UNCONFIRMED')) {
$states[] = OrderTransactionStates::STATE_UNCONFIRMED;
}
# if we are already in_progress...then don't switch to OPEN again
# otherwise SEPA bank transfer would switch back to OPEN
if (! in_array($currentShopwareStatusKey, [OrderTransactionStates::STATE_IN_PROGRESS, OrderTransactionStates::STATE_UNCONFIRMED]) || $context->hasState(self::ORDER_STATE_FORCE_OPEN)) {
if (! in_array($currentShopwareStatusKey, $states) || $context->hasState(self::ORDER_STATE_FORCE_OPEN)) {
$addLog = true;
$this->transactionTransitionService->reOpenTransaction($transaction, $context);
}
Expand Down
14 changes: 11 additions & 3 deletions src/Service/Transition/TransactionTransitionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Shopware\Core\System\StateMachine\Aggregation\StateMachineState\StateMachineStateEntity;
use Shopware\Core\System\StateMachine\Aggregation\StateMachineTransition\StateMachineTransitionActions;


class TransactionTransitionService implements TransactionTransitionServiceInterface
{
/**
Expand Down Expand Up @@ -46,19 +47,26 @@ public function __construct(
public function processTransaction(OrderTransactionEntity $transaction, Context $context): void
{
$technicalName = ($transaction->getStateMachineState() instanceof StateMachineStateEntity) ? $transaction->getStateMachineState()->getTechnicalName() : '';
$defaultState = OrderTransactionStates::STATE_IN_PROGRESS;
$action = StateMachineTransitionActions::ACTION_PROCESS;

if (defined('\Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionStates\OrderTransactionStates::STATE_UNCONFIRMED')) {
$defaultState = OrderTransactionStates::STATE_UNCONFIRMED;
$action = StateMachineTransitionActions::ACTION_PROCESS_UNCONFIRMED;
}

if ($this->isFinalOrTargetStatus($technicalName, [OrderTransactionStates::STATE_UNCONFIRMED])) {
if ($this->isFinalOrTargetStatus($technicalName, [$defaultState])) {
return;
}

$entityId = $transaction->getId();
$availableTransitions = $this->getAvailableTransitions($entityId, $context);

if (!$this->transitionIsAllowed(StateMachineTransitionActions::ACTION_PROCESS_UNCONFIRMED, $availableTransitions)) {
if (!$this->transitionIsAllowed($action, $availableTransitions)) {
$this->reOpenTransaction($transaction, $context);
}

$this->performTransition($entityId, StateMachineTransitionActions::ACTION_PROCESS_UNCONFIRMED, $context);
$this->performTransition($entityId, $action, $context);
}

public function reOpenTransaction(OrderTransactionEntity $transaction, Context $context): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ context("Order Status Mapping Tests", () => {

context(devices.getDescription(device), () => {

it('C4028: Test Status Open stays In-Progress', () => {
it('C4028: Test Status Open stays Unconfirmed/In progress', () => {

// we create a SEPA bank transfer payment
// the payment status will be IN PROGRESS then in Shopware.
Expand All @@ -66,7 +66,13 @@ context("Order Status Mapping Tests", () => {

adminLogin.login();
adminOrders.assertLatestOrderStatus('Open');
adminOrders.assertLatestPaymentStatus('In Progress');
if (shopware.isVersionLower('6.4.4.0')) {
adminOrders.assertLatestPaymentStatus('In Progress');
}else{
adminOrders.assertLatestPaymentStatus('Unconfirmed');
}


})

it('C4023: Test Status Paid', () => {
Expand Down
Loading