fix: skip discounts with value 0€
This commit is contained in:
@@ -72,6 +72,23 @@ class AccommodationBookingBreakdownCalculatorTest extends TestCase
|
||||
self::assertSame(12345 - 50, $breakdown['discountedTotal']);
|
||||
}
|
||||
|
||||
public function testWithDiscountsSkipsDiscountsThatAmountToNothing(): void
|
||||
{
|
||||
$booking = new AccommodationBooking();
|
||||
$booking->setAccommodationDiscount(0);
|
||||
// A discount on a bucket this booking has no price in.
|
||||
$booking->setAdditionalServicesDiscount(20);
|
||||
|
||||
$breakdown = $this->createCalculator()->withDiscounts($booking, [
|
||||
'total' => 12345,
|
||||
'basePrice' => 8000,
|
||||
'servicesPrice' => 0,
|
||||
]);
|
||||
|
||||
self::assertSame([], $breakdown['discounts']);
|
||||
self::assertSame(12345, $breakdown['discountedTotal']);
|
||||
}
|
||||
|
||||
public function testWithoutDiscountsTheDiscountedTotalIsTheTotal(): void
|
||||
{
|
||||
$breakdown = $this->createCalculator()->withDiscounts(new AccommodationBooking(), $this->breakdown());
|
||||
|
||||
Reference in New Issue
Block a user