fix: exclude past dates in price tables

This commit is contained in:
Björn Fromme
2026-08-06 12:19:30 +02:00
parent 577f7445ab
commit b82e017f73
3 changed files with 42 additions and 13 deletions
@@ -67,6 +67,27 @@ class PriceTimelineBuilderTest extends TestCase
$this->assertSame('2026-12-31', $result[0]->dateTo);
}
public function testInProgressPriceIsClampedToMidYearRangeStart(): void
{
$price = $this->makePrice('2026-06-01', '2026-09-30', pricePerNight: 8000);
$result = $this->builder->buildTimeline([$price], new \DateTimeImmutable('2026-08-06'), new \DateTimeImmutable('2026-12-31'), 'EUR');
$this->assertCount(1, $result);
$this->assertSame('2026-08-06', $result[0]->dateFrom);
$this->assertSame('2026-09-30', $result[0]->dateTo);
$this->assertSame(80.0, $result[0]->pricePerNight);
}
public function testPriceEndingBeforeRangeStartIsOmitted(): void
{
$price = $this->makePrice('2026-02-01', '2026-05-31', pricePerNight: 8000);
$result = $this->builder->buildTimeline([$price], new \DateTimeImmutable('2026-08-06'), new \DateTimeImmutable('2026-12-31'), 'EUR');
$this->assertSame([], $result);
}
public function testDiscountSplitsBasePeriodIntoThreeRows(): void
{
$base = $this->makePrice('2026-01-01', '2026-03-31', pricePerNight: 15000);