Skip to content

Commit

Permalink
Merge branch 'pu/pm/SalesAttachedDocumentSeqFixs' into '2024.11'
Browse files Browse the repository at this point in the history
tweak(Sales Document) attached documents creation keeps other documents on seq

See merge request tine20/tine20!6141
  • Loading branch information
paulmhh committed Nov 1, 2024
2 parents 2a3a36d + 355b4ee commit 46e641e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tine20/Sales/Controller/Document/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,15 @@ protected function createEInvoiceAttachment(Sales_Model_Document_Invoice $record
$attachedDocument->{Sales_Model_Document_AttachedDocument::FLD_CREATED_FOR_SEQ} = $record->seq + 1;
} else {
$record->{Sales_Model_Document_Abstract::FLD_ATTACHED_DOCUMENTS}->addRecord(new Sales_Model_Document_AttachedDocument([
Sales_Model_Document_AttachedDocument::FLD_TYPE => Sales_Model_Document_AttachedDocument::TYPE_PAPERSLIP,
Sales_Model_Document_AttachedDocument::FLD_TYPE => Sales_Model_Document_AttachedDocument::TYPE_UBL,
Sales_Model_Document_AttachedDocument::FLD_NODE_ID => $attachmentId,
Sales_Model_Document_AttachedDocument::FLD_CREATED_FOR_SEQ => $record->seq + 1,
]));
}
$record->{Sales_Model_Document_Abstract::FLD_ATTACHED_DOCUMENTS}
->filter(Sales_Model_Document_AttachedDocument::FLD_CREATED_FOR_SEQ, $record->seq)
->filter(fn ($rec) => $rec->{Sales_Model_Document_AttachedDocument::FLD_TYPE} !== Sales_Model_Document_AttachedDocument::TYPE_SUPPORTING_DOCUMENT)
->{Sales_Model_Document_AttachedDocument::FLD_CREATED_FOR_SEQ} = $record->seq + 1;

$updatedRecord = $this->update($record);
$record->attachments = $updatedRecord->attachments;
Expand Down
5 changes: 5 additions & 0 deletions tine20/Sales/Frontend/Json.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class Sales_Frontend_Json extends Tinebase_Frontend_Json_Abstract
Sales_Model_DivisionEvalDimensionItem::MODEL_NAME_PART,
Sales_Model_EDocument_EAS::MODEL_NAME_PART,
Sales_Model_Einvoice_XRechnung::MODEL_NAME_PART,
Sales_Model_Document_AttachedDocument::MODEL_NAME_PART,
// 'OrderConfirmation',
// 'PurchaseInvoice',
// 'Offer',
Expand Down Expand Up @@ -949,6 +950,10 @@ public function createPaperSlip(string $model, string $documentId)
Sales_Model_Document_AttachedDocument::FLD_CREATED_FOR_SEQ => $document->seq + 1,
]));
}
$document->{Sales_Model_Document_Abstract::FLD_ATTACHED_DOCUMENTS}
->filter(Sales_Model_Document_AttachedDocument::FLD_CREATED_FOR_SEQ, $document->seq)
->filter(fn ($rec) => $rec->{Sales_Model_Document_AttachedDocument::FLD_TYPE} !== Sales_Model_Document_AttachedDocument::TYPE_SUPPORTING_DOCUMENT)
->{Sales_Model_Document_AttachedDocument::FLD_CREATED_FOR_SEQ} = $document->seq + 1;
$result = $this->_recordToJson($docCtrl->update($document));

$transaction->release();
Expand Down

0 comments on commit 46e641e

Please sign in to comment.