feat(services): add availability check in rent service

A new condition was added in `rent.service.ts` to check if a vehicle is available before executing the rent operation. It also logs an error if the vehicle is not available.

Signed-off-by: Mathis <yidhra@tuta.io>
This commit is contained in:
Mathis H (Avnyr) 2024-05-03 13:18:33 +02:00
parent e8acfd7b30
commit 83d07a2812
Signed by: Mathis
GPG Key ID: DD9E0666A747D126

View File

@ -32,6 +32,10 @@ async function createRentService(data: IDbRent): Promise<boolean> {
return false;
}
const vehicleId = vehicleIfExist[0].id
if (!vehicleIfExist[0].isAvailable) {
logger.error(`Vehicle is not available`);
return false;
}
try {
const result = await MySqlService.Rent.insert(DbHandler, {
id: v4(),