if ($creditItems->
count() === 0
) { throw new DocumentGenerationException( 'Can not generate credit note document because no credit line items exists. OrderId: ' .
$operation->
getOrderId() );
} $config =
clone $this->documentConfigLoader->
load(self::TYPE,
$order->
getSalesChannelId(),
$context);
$config->
merge($operation->
getConfig());
$number =
$config->
getDocumentNumber() ?:
$this->
getNumber($context,
$order,
$operation);
$referenceDocumentNumber =
$referenceInvoiceNumbers[$operation->
getOrderId()];
$config->
merge([ 'documentDate' =>
$operation->
getConfig()['documentDate'
] ?? (new \
DateTime())->
format(Defaults::STORAGE_DATE_TIME_FORMAT
),
'documentNumber' =>
$number,
'custom' =>
[ 'creditNoteNumber' =>
$number,
'invoiceNumber' =>
$referenceDocumentNumber,
],
]);