if (empty($invoice)) { throw new DocumentGenerationException('Can not generate storno document because no invoice document exists. OrderId: ' .
$operation->
getOrderId());
} $documentRefer =
json_decode((string) $invoice['config'
], true, 512, \JSON_THROW_ON_ERROR
);
$referenceInvoiceNumbers[$orderId] =
$documentRefer['documentNumber'
];
$order =
$this->
getOrder($orderId,
$invoice['orderVersionId'
],
$context,
$rendererConfig->deepLinkCode
);
$orders->
add($order);
$operation->
setReferencedDocumentId($invoice['id'
]);
if ($order->
getVersionId()) { $operation->
setOrderVersionId($order->
getVersionId());
} } catch (\Throwable
$exception) { $result->
addError($operation->
getOrderId(),
$exception);
} } // TODO: future implementation (only fetch required data and associations)
$this->eventDispatcher->
dispatch(new StornoOrdersEvent($orders,
$context,
$operations));