feat: split nights off an accommodation booking as separate periods

addresses #869f6z36v
This commit is contained in:
fromme committed 2026-09-30 18:06:20 +02:00
1 parent 972839286c
commit 7001bc0cf2
35 files changed
+2221 -25

No files matched your search

@@ -6,6 +6,7 @@ namespace App\Tests\Service;
use App\Entity\Groups\Accommodation;
use App\Entity\Groups\AccommodationBooking;
use App\Enum\Groups\AccommodationBookingPeriodPosition;
use App\Service\AccommodationBookingBreakdownCalculator;
use App\Service\AccommodationBookingPdfGenerator;
use PHPUnit\Framework\TestCase;
@@ -27,6 +28,37 @@ class AccommodationBookingPdfGeneratorTest extends TestCase
self::assertSame(1, $this->pageCount($pdf));
}
public function testADocumentWithSplitOffPeriodsStillFitsOnASingleA4Page(): void
{
$booking = $this->booking();
$booking->splitOffPeriod(AccommodationBookingPeriodPosition::Leading, 1)->setLabel('Vorausteam')->setLines([
['label' => 'Vorausteam Übernachtung', 'amount' => 25000],
['label' => 'Vorausteam Verpflegung', 'amount' => 6000],
]);
$booking->splitOffPeriod(AccommodationBookingPeriodPosition::Trailing, 1)->setLines([
['label' => 'Abbau', 'amount' => 10000],
]);
$breakdown = [
...$this->breakdown(),
'nights' => 3,
'periods' => [
['position' => 'leading', 'label' => 'Vorausteam', 'dateFrom' => '2026-07-06', 'dateTo' => '2026-07-07', 'nights' => 1, 'lines' => [
['label' => 'Vorausteam Übernachtung', 'amount' => 25000],
['label' => 'Vorausteam Verpflegung', 'amount' => 6000],
], 'total' => 31000],
['position' => 'trailing', 'dateFrom' => '2026-07-10', 'dateTo' => '2026-07-11', 'nights' => 1, 'lines' => [
['label' => 'Abbau', 'amount' => 10000],
], 'total' => 10000],
],
'periodsTotal' => 41000,
];
$pdf = $this->createGenerator($breakdown)->render($booking);
self::assertSame(1, $this->pageCount($pdf));
}
public function testTheDownloadIsAnAttachmentNamedAfterArrivalDateAndHotel(): void
{
$response = $this->createGenerator($this->breakdown())->createDownloadResponse($this->booking());
@@ -122,6 +154,8 @@ class AccommodationBookingPdfGeneratorTest extends TestCase
'serviceDetails' => [['label' => 'Bettwäsche', 'price' => 28800]],
'servicesPrice' => 28800,
'runningCosts' => 16000,
'periods' => [],
'periodsTotal' => 0,
'total' => 844800,
'currency' => 'EUR',
'discounts' => [['label' => 'Unterkunft', 'percent' => 5, 'amount' => 16000]],