feat: additional receipts as attachments to teamer invoices

addresses #869dv97u9
This commit is contained in:
2026-09-09 11:10:57 +02:00
parent 16d847137d
commit 52926ec6cc
29 changed files with 682 additions and 23 deletions
+39
View File
@@ -146,6 +146,45 @@ class DispositionTest extends TestCase
$this->assertFalse($disposition->isContractRejected());
}
/**
* getDocumentByType() answers with the first match and is right for the Honorarvertrag and the
* Honorarnote, of which there is one each. Belege are the first type a disposition can hold
* several of, so they need the collection-returning sibling.
*/
public function testTheReceiptsOfADispositionAreReturnedAsACollection(): void
{
$disposition = $this->createDisposition(createdAt: 'today', assignmentEndsIn: '-1 day');
$disposition
->addDocument((new Upload())->setType(Upload::TYPE_INVOICE))
->addDocument((new Upload())->setType(Upload::TYPE_RECEIPT)->setOriginalFilename('bahn.pdf'))
->addDocument((new Upload())->setType(Upload::TYPE_CONTRACT))
->addDocument((new Upload())->setType(Upload::TYPE_RECEIPT)->setOriginalFilename('taxi.jpg'))
;
$receipts = $disposition->getDocumentsByType(Upload::TYPE_RECEIPT);
$this->assertCount(2, $receipts);
$this->assertSame(
['bahn.pdf', 'taxi.jpg'],
array_values(array_map(
fn (Upload $upload): string => $upload->getOriginalFilename(),
$receipts->toArray()
))
);
// The single-result sibling keeps working for the types that only ever have one.
$this->assertSame(Upload::TYPE_INVOICE, $disposition->getDocumentByType(Upload::TYPE_INVOICE)?->getType());
}
public function testADispositionWithoutReceiptsReturnsAnEmptyCollection(): void
{
$disposition = $this->createDisposition(createdAt: 'today', assignmentEndsIn: '-1 day');
$disposition->addDocument((new Upload())->setType(Upload::TYPE_INVOICE));
$this->assertCount(0, $disposition->getDocumentsByType(Upload::TYPE_RECEIPT));
}
private function createDisposition(
string $createdAt,
string $assignmentEndsIn,