Skip to content

Commit

Permalink
Merge branch '2024.11'
Browse files Browse the repository at this point in the history
  • Loading branch information
gitlabci committed Dec 12, 2024
2 parents a19c050 + 0e763db commit 8f41515
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions tine20/Sales/Controller/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -1503,6 +1503,13 @@ protected function _inspectAfterSetRelatedDataUpdate($updatedRecord, $record, $c

public function createXRechnungsAttachment(Sales_Model_Invoice $invoice): void
{
$remove = null;
foreach ($invoice->attachments?->filter(fn ($rec) => str_ends_with($rec->name, '-xrechnung.xml')) ?? [] as $remove) {
$invoice->attachments->removeRecord($remove);
}
if (null !== $remove) {
Tinebase_FileSystem_RecordAttachments::getInstance()->setRecordAttachments($invoice);
}
try {
$customer = $this->_getCustomerFromInvoiceRelations($invoice) ?? throw new Tinebase_Exception_SystemGeneric('invoice does not have a customer');
/** @var Sales_Model_Contract $contract */
Expand Down Expand Up @@ -1569,10 +1576,6 @@ public function createXRechnungsAttachment(Sales_Model_Invoice $invoice): void
}

$attachmentName = str_replace('/', '-', $customer->getTitle() . '_' . $invoice->number . '-xrechnung.xml');
if (null !== ($remove = $invoice->attachments?->find('name', $attachmentName))) {
$invoice->attachments->removeRecord($remove);
Tinebase_FileSystem_RecordAttachments::getInstance()->setRecordAttachments($invoice);
}
Tinebase_FileSystem_RecordAttachments::getInstance()->addRecordAttachment($invoice, $attachmentName, $stream);
Tinebase_FileSystem_RecordAttachments::getInstance()->getRecordAttachments($invoice);
} catch (Exception $e) {
Expand Down

0 comments on commit 8f41515

Please sign in to comment.