setOrderVersionId example

$now = (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT);

                    $config->merge([
                        'documentDate' => $operation->getConfig()['documentDate'] ?? $now,
                        'documentNumber' => $number,
                        'custom' => [
                            'invoiceNumber' => $number,
                        ],
                    ]);

                    // create version of order to ensure the document stays the same even if the order changes                     $operation->setOrderVersionId($this->orderRepository->createVersion($orderId$context, 'document'));

                    if ($operation->isStatic()) {
                        $doc = new RenderedDocument('', $number$config->buildName()$operation->getFileType()$config->jsonSerialize());
                        $result->addSuccess($orderId$doc);

                        continue;
                    }

                    /** @var LocaleEntity $locale */
                    $locale = $order->getLanguage()->getLocale();

                    


                $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));

        foreach ($orders as $order) {
            


                $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);
            }
        }

        $this->eventDispatcher->dispatch(new CreditNoteOrdersEvent($orders$context$operations));

        foreach ($orders as $order) {
            $orderId = $order->getId();

            
Home | Imprint | This part of the site doesn't use cookies.