Show combined price for round trip bookings in the list
PHP Tests / php-tests (push) Waiting to run

Now that only the outbound leg gets a row, its Price column showed just
that leg's price, silently missing the return leg's half. It now sums both
legs (bcadd, 2dp) for a round trip, with a breakdown shown underneath;
unchanged for one-way bookings.
This commit is contained in:
Nyan Lin Paing
2026-09-03 12:00:36 +07:00
parent 90e5807a17
commit e61a847a02
2 changed files with 32 additions and 0 deletions
@@ -360,6 +360,26 @@ test('a round trip\'s return leg has no row of its own in the list, only its out
->assertCanNotSeeTableRecords([$return]);
});
test('a round trip\'s price column shows both legs combined', function () {
$outbound = Booking::factory()->create(['is_return_leg' => false, 'price' => 15000]);
$return = Booking::factory()->create([
'is_return_leg' => true,
'linked_booking_id' => $outbound->id,
'price' => 20000,
]);
$outbound->update(['linked_booking_id' => $return->id]);
Livewire::test(ListBookings::class)
->assertTableColumnStateSet('price', '35000.00', record: $outbound);
});
test('a one-way booking\'s price column shows just its own price', function () {
$booking = Booking::factory()->create(['is_return_leg' => false, 'linked_booking_id' => null, 'price' => 15000]);
Livewire::test(ListBookings::class)
->assertTableColumnStateSet('price', '15000.00', record: $booking);
});
test('the restore action is only visible for a trashed booking', function () {
$active = Booking::factory()->create();
$deleted = Booking::factory()->create();