Generalize per-vehicle-option booking rules to Front Seat too
Front Seat previously had a hardcoded max-per-booking check with no enable toggle; now every Vehicle Option (front_seat/back_seat/whole_vehicle) gets the same config-driven pair — an on/off toggle and a max passenger_count — surfaced via new BOOKING_*_ENABLED/BOOKING_*_MAX_PER_BOOKING env vars, editable from ManageAppSettings, and exposed on route pricing as max_per_booking.
This commit is contained in:
@@ -18,6 +18,7 @@ class RoutePricingResource extends JsonResource
|
||||
'vehicle_option' => $this->vehicle_option->value,
|
||||
'price' => (string) $this->price,
|
||||
'is_blocked' => $this->is_blocked,
|
||||
'max_per_booking' => config("booking.{$this->vehicle_option->value}_max_per_booking"),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ test('searches active routes with nested company, destinations, time slots and p
|
||||
->assertJsonPath('routes.data.0.time_slots.0.is_active', true)
|
||||
->assertJsonPath('routes.data.0.pricing.0.vehicle_option', 'front_seat')
|
||||
->assertJsonPath('routes.data.0.pricing.0.price', '12000.00')
|
||||
->assertJsonPath('routes.data.0.pricing.0.max_per_booking', config('booking.front_seat_max_per_booking'))
|
||||
->assertJsonCount(0, 'return_routes.data');
|
||||
});
|
||||
|
||||
@@ -311,8 +312,17 @@ test('lists a route\'s pricing including blocked options', function () {
|
||||
->getJson("/api/v1/routes/{$route->id}/pricing")
|
||||
->assertSuccessful()
|
||||
->assertJsonCount(2, 'data')
|
||||
->assertJsonFragment(['vehicle_option' => 'front_seat', 'price' => '12000.00', 'is_blocked' => false])
|
||||
->assertJsonFragment(['vehicle_option' => 'whole_vehicle', 'is_blocked' => true]);
|
||||
->assertJsonFragment([
|
||||
'vehicle_option' => 'front_seat',
|
||||
'price' => '12000.00',
|
||||
'is_blocked' => false,
|
||||
'max_per_booking' => config('booking.front_seat_max_per_booking'),
|
||||
])
|
||||
->assertJsonFragment([
|
||||
'vehicle_option' => 'whole_vehicle',
|
||||
'is_blocked' => true,
|
||||
'max_per_booking' => config('booking.whole_vehicle_max_per_booking'),
|
||||
]);
|
||||
});
|
||||
|
||||
test('lists a route\'s time slots with the pivot active flag', function () {
|
||||
|
||||
Reference in New Issue
Block a user