2 Commits
Author SHA1 Message Date
Daniel-Garmig a495be6bb2 API - Added mapping for API request objects.
CI / Docker Lint (push) Successful in 28s
2024-10-01 20:43:25 +02:00
Daniel-Garmig 986f422824 Fixed duplicated fields on /api/booking/details and removed unnecesary ignore attributes. 2024-09-28 00:03:05 +02:00
12 changed files with 143 additions and 178 deletions
+36 -51
View File
@@ -20,13 +20,14 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Routing\Attribute\Route;
use OpenApi\Attributes as OA; use OpenApi\Attributes as OA;
use Symfony\Component\HttpKernel\Attribute\MapRequestPayload;
class BookingController extends AbstractController class BookingController extends AbstractController
{ {
/** /**
* Get booking details * Get booking details
*/ */
#[Route('/api/booking/details', name: 'app_booking_details', methods: ["POST"])] #[Route('/api/booking/details', name: 'app_booking_details', methods: ["POST"], format: "json")]
#[OA\Tag(name: "Booking")] #[OA\Tag(name: "Booking")]
#[OA\Response( #[OA\Response(
response: 200, response: 200,
@@ -42,23 +43,22 @@ class BookingController extends AbstractController
ref: new Model(type: BookingDetailsRequest::class), ref: new Model(type: BookingDetailsRequest::class),
) )
)] )]
public function getBookingDetails(Request $request, BookingRepository $repoBooking): JsonResponse public function getBookingDetails(
{ BookingRepository $repoBooking,
$payload = $request->toArray(); #[MapRequestPayload()] BookingDetailsRequest $detailsRequest
if (\is_null($payload)) { ): JsonResponse {
if (\is_null($detailsRequest)) {
throw new \Exception('Invalid Payload', 400); throw new \Exception('Invalid Payload', 400);
} }
$refNumber = $payload["refNumber"]; $bookingList = $repoBooking->findBy(["refNumber" => $detailsRequest->refNumber]);
$customerEmail = $payload["email"];
$bookingList = $repoBooking->findBy(["refNumber" => $refNumber]);
if (\is_null($bookingList) || \count($bookingList) == 0) { if (\is_null($bookingList) || \count($bookingList) == 0) {
throw new HttpException(404, 'Invalid Booking'); throw new HttpException(404, 'Invalid Booking');
} }
$customerBooking = $bookingList[0]; $customerBooking = $bookingList[0];
if ($customerBooking->getBookingCustomer()->getEmail() != $customerEmail) { if ($customerBooking->getBookingCustomer()->getEmail() != $detailsRequest->email) {
throw new HttpException(404, 'Invalid Booking'); throw new HttpException(404, 'Invalid Booking');
} }
@@ -68,7 +68,7 @@ class BookingController extends AbstractController
/** /**
* Create a new Booking. * Create a new Booking.
*/ */
#[Route('/api/booking/create', name: 'app_booking_create', methods: ["POST"])] #[Route('/api/booking/create', name: 'app_booking_create', methods: ["POST"], format: "json")]
#[OA\Tag(name: "Booking")] #[OA\Tag(name: "Booking")]
#[OA\Response( #[OA\Response(
response: 200, response: 200,
@@ -84,25 +84,21 @@ class BookingController extends AbstractController
ref: new Model(type: BookingCreateRequest::class), ref: new Model(type: BookingCreateRequest::class),
) )
)] )]
public function newBooking(Request $request, BookingRepository $repoBooking, EntityManagerInterface $entityManager, public function newBooking(
RoomCategoryRepository $repoCat, RoomAvailabilityRepository $repoAvailability, Request $request,
PricesService $priceSrv): JsonResponse EntityManagerInterface $entityManager,
{ RoomCategoryRepository $repoCat,
$payload = $request->toArray(); RoomAvailabilityRepository $repoAvailability,
if (\is_null($payload)) { PricesService $priceSrv,
#[MapRequestPayload()] BookingCreateRequest $createRequest
): JsonResponse {
if (\is_null($createRequest)) {
throw new HttpException('Invalid Payload', 400); throw new HttpException('Invalid Payload', 400);
} }
$booking = new Booking(); $booking = new Booking();
try { try {
$reqArrivalDate = $payload["arrivalDate"]; if ($createRequest->arrivalDate >= $createRequest->departureDate) {
$reqDepartureDate = $payload["departureDate"];
$arrivalDate = new \DateTime($reqArrivalDate);
$departureDate = new \DateTime($reqDepartureDate);
if ($arrivalDate >= $departureDate) {
throw new HttpException(400, "Arrival cant be before departure"); throw new HttpException(400, "Arrival cant be before departure");
} }
@@ -112,9 +108,11 @@ class BookingController extends AbstractController
// Create booking from request data. // Create booking from request data.
$booking->setBookingTime($currentTime); $booking->setBookingTime($currentTime);
$booking->setArrivalDate($arrivalDate); $booking->setArrivalDate($createRequest->arrivalDate);
$booking->setDepartureDate($departureDate); $booking->setDepartureDate($createRequest->departureDate);
$booking->setBookingCustomer($createRequest->customerDetails);
//TODOME: Improve refNumber generation.
$highest_id = $entityManager->createQueryBuilder() $highest_id = $entityManager->createQueryBuilder()
->select('MAX(e.id)') ->select('MAX(e.id)')
->from('App\Entity\Booking', 'e') ->from('App\Entity\Booking', 'e')
@@ -125,39 +123,27 @@ class BookingController extends AbstractController
$entityManager->persist($booking); $entityManager->persist($booking);
// Create booking customer. if (\count($createRequest->rooms) == 0) {
$reqCustomer = $payload["customerDetails"];
$bookingCustomer = new BookingCustomer();
$bookingCustomer->setName($reqCustomer["name"]);
$bookingCustomer->setSurname($reqCustomer["surname"]);
$bookingCustomer->setEmail($reqCustomer["email"]);
$bookingCustomer->setPhoneNumber($reqCustomer["phoneNumber"]);
$bookingCustomer->setBooking($booking);
$entityManager->persist($bookingCustomer);
$reqRoomList = $payload["rooms"];
if (\count($reqRoomList) == 0) {
throw new HttpException(400, "Se debe indicar al menos una habitación"); throw new HttpException(400, "Se debe indicar al menos una habitación");
} }
// Create each room. // Create each room.
foreach ($reqRoomList as $roomItem) { foreach ($createRequest->rooms as $roomItem) {
$room = new BookingRoom(); $room = new BookingRoom();
$room->setBooking($booking); $room->setBooking($booking);
//Get Room category. //Get Room category.
$roomCategory = $repoCat->find($roomItem["roomCategory"]); $roomCategory = $repoCat->find($roomItem->roomCategory);
if ($roomCategory == null) { if ($roomCategory == null) {
throw new HttpException(400, "La RoomCategory no es válida."); throw new HttpException(400, "La RoomCategory no es válida.");
} }
//Check room availability. //Check room availability.
$amountAvailable = $repoAvailability->getAvailabilityForCategoryInPeriod($roomCategory, $arrivalDate, $departureDate); $amountAvailable = $repoAvailability->getAvailabilityForCategoryInPeriod($roomCategory, $createRequest->arrivalDate, $createRequest->departureDate);
$selectedAmount = $roomItem['amount']; $selectedAmount = $roomItem->amount;
$selectedGuestAmount = $roomItem["guestNumber"]; $selectedGuestAmount = $roomItem->guestNumber;
if($amountAvailable == null || $selectedAmount > $amountAvailable) { if ($amountAvailable == null || $selectedAmount > $amountAvailable) {
throw new HttpException(400, "No se pueden reservar más habitaciones de las disponibles."); throw new HttpException(400, "No se pueden reservar más habitaciones de las disponibles.");
} }
@@ -166,17 +152,17 @@ class BookingController extends AbstractController
$room->setAmount($selectedAmount); $room->setAmount($selectedAmount);
//Get Price for period. //Get Price for period.
$priceList = $priceSrv->getFinalPricesForSearch($roomCategory, $arrivalDate, $departureDate); $priceList = $priceSrv->getFinalPricesForSearch($roomCategory, $createRequest->arrivalDate, $createRequest->departureDate);
$priceFound = false; $priceFound = false;
foreach ($priceList as $key => $value) { foreach ($priceList as $key => $value) {
if($key == $selectedGuestAmount) { if ($key == $selectedGuestAmount) {
$room->setRoomPrice($value); $room->setRoomPrice($value);
$priceFound = true; $priceFound = true;
break; break;
} }
} }
if(!$priceFound) { if (!$priceFound) {
throw new HttpException( throw new HttpException(
500, 500,
"No se puedo obtener el precio para la categoría: " . $roomCategory->getId() . " , guests: " . $selectedGuestAmount "No se puedo obtener el precio para la categoría: " . $roomCategory->getId() . " , guests: " . $selectedGuestAmount
@@ -186,12 +172,11 @@ class BookingController extends AbstractController
$entityManager->persist($room); $entityManager->persist($room);
//If booking is nice, let's update current availability. //If booking is nice, let's update current availability.
$repoAvailability->updateAvailabilityForRoomCategoryOnPeriod($roomCategory, $arrivalDate, $departureDate, $selectedAmount, true); //Update using "diff" mode. $repoAvailability->updateAvailabilityForRoomCategoryOnPeriod($roomCategory, $createRequest->arrivalDate, $createRequest->departureDate, $selectedAmount, true); //Update using "diff" mode.
} }
$entityManager->commit(); $entityManager->commit();
$entityManager->flush(); $entityManager->flush();
} catch (\Throwable $th) { } catch (\Throwable $th) {
$entityManager->rollback(); $entityManager->rollback();
throw $th; throw $th;
+33 -45
View File
@@ -16,6 +16,8 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Routing\Attribute\Route;
use OpenApi\Attributes as OA; use OpenApi\Attributes as OA;
use Symfony\Component\HttpKernel\Attribute\MapRequestPayload;
use Symfony\Component\HttpKernel\Exception\HttpException;
class SearchRoomsController extends AbstractController class SearchRoomsController extends AbstractController
{ {
@@ -23,7 +25,7 @@ class SearchRoomsController extends AbstractController
* Get availability for all rooms on period. * Get availability for all rooms on period.
* For each room, the minimal availability will be returned. * For each room, the minimal availability will be returned.
*/ */
#[Route('/api/search/availability', name: 'app_search_availability', methods: ["POST"])] #[Route('/api/search/availability', name: 'app_search_availability', methods: ["POST"], format: "json")]
#[OA\Tag(name: "Searchs")] #[OA\Tag(name: "Searchs")]
#[OA\Response( #[OA\Response(
response: 200, response: 200,
@@ -42,26 +44,22 @@ class SearchRoomsController extends AbstractController
#[OA\RequestBody( #[OA\RequestBody(
content: new OA\JsonContent( content: new OA\JsonContent(
type: 'object', type: 'object',
properties: [
new OA\Property(
property: "filter",
ref: new Model(type: SearchAvailabilityPeriodRequest::class), ref: new Model(type: SearchAvailabilityPeriodRequest::class),
),
],
) )
)] )]
public function getAvailabilityForPeriod(Request $request, RoomAvailabilityRepository $repoAvailability): Response public function getAvailabilityForPeriod(
{ Request $request,
$payload = $request->toArray(); RoomAvailabilityRepository $repoAvailability,
if (\is_null($payload)) { #[MapRequestPayload()] SearchAvailabilityPeriodRequest $searchRequest
throw new \Exception('Invalid Payload', 400); ): Response {
if (\is_null($searchRequest)) {
throw new HttpException('Invalid Payload', 400);
} }
$filter = $payload["filter"];
$startDate = new \DateTime($filter["startDate"]); if ($searchRequest->startDate >= $searchRequest->endDate) {
$endDate = new \DateTime($filter["endDate"]); throw new HttpException(400, "startDate cant be before endDate");
}
$rs = $repoAvailability->getAvailabilityForPeriod($startDate, $endDate); $rs = $repoAvailability->getAvailabilityForPeriod($searchRequest->startDate, $searchRequest->endDate);
return $this->json(["results" => $rs]); return $this->json(["results" => $rs]);
} }
@@ -70,20 +68,18 @@ class SearchRoomsController extends AbstractController
* Get Availability for all rooms on each day of a period. * Get Availability for all rooms on each day of a period.
* (Not used on Front-end APP) * (Not used on Front-end APP)
*/ */
#[Route('/api/search/availabilityDetails', name: 'app_search_availabilityDetails', methods: ["POST"])] #[Route('/api/search/availabilityDetails', name: 'app_search_availabilityDetails', methods: ["POST"], format: "json")]
#[OA\Tag(name: "Searchs")] #[OA\Tag(name: "Searchs")]
public function getAvailabilityForPeriodDetails(Request $request, RoomAvailabilityRepository $repoAvailability): Response public function getAvailabilityForPeriodDetails(
{ Request $request,
$payload = $request->toArray(); RoomAvailabilityRepository $repoAvailability,
if (\is_null($payload)) { #[MapRequestPayload()] SearchAvailabilityPeriodRequest $searchRequest
): Response {
if (\is_null($searchRequest)) {
throw new \Exception('Invalid Payload', 400); throw new \Exception('Invalid Payload', 400);
} }
$filter = $payload["filter"];
$startDate = new \DateTime($filter["startDate"]); $rs = $repoAvailability->getAvailabilityForPeriodDetails($searchRequest->startDate, $searchRequest->endDate);
$endDate = new \DateTime($filter["endDate"]);
$rs = $repoAvailability->getAvailabilityForPeriodDetails($startDate, $endDate);
return $this->json(["results" => $rs]); return $this->json(["results" => $rs]);
} }
@@ -93,7 +89,7 @@ class SearchRoomsController extends AbstractController
* Returns price for a room category. * Returns price for a room category.
* This price is the total for all the selected days by guest number. * This price is the total for all the selected days by guest number.
*/ */
#[Route('/api/search/fares', name: 'app_search_faresForCategory', methods: ["POST"])] #[Route('/api/search/fares', name: 'app_search_faresForCategory', methods: ["POST"], format: "json")]
#[OA\Tag(name: "Searchs")] #[OA\Tag(name: "Searchs")]
#[OA\Response( #[OA\Response(
response: 200, response: 200,
@@ -112,37 +108,29 @@ class SearchRoomsController extends AbstractController
#[OA\RequestBody( #[OA\RequestBody(
content: new OA\JsonContent( content: new OA\JsonContent(
type: 'object', type: 'object',
properties: [
new OA\Property(
property: "filter",
ref: new Model(type: SearchFareCategoryRequest::class), ref: new Model(type: SearchFareCategoryRequest::class),
),
],
) )
)] )]
public function getFaresForCategoryOnPeriod(Request $request, RoomCategoryRepository $repoCat, PricesService $priceService): Response public function getFaresForCategoryOnPeriod(
{ Request $request,
$payload = $request->toArray(); RoomCategoryRepository $repoCat,
if (\is_null($payload)) { PricesService $priceService,
#[MapRequestPayload()] SearchFareCategoryRequest $searchRequest
): Response {
if (\is_null($searchRequest)) {
throw new \Exception('Invalid Payload', 400); throw new \Exception('Invalid Payload', 400);
} }
$filter = $payload["filter"];
$catId = $filter["roomCategory"]; $roomCategory = $repoCat->find($searchRequest->roomCategory);
$roomCategory = $repoCat->find($catId);
if ($roomCategory === null) { if ($roomCategory === null) {
throw new \Exception('Invalid Category', 400); throw new \Exception('Invalid Category', 400);
} }
$startDate = new \DateTime($filter["startDate"]); if ($searchRequest->startDate >= $searchRequest->endDate) {
$endDate = new \DateTime($filter["endDate"]);
$daysDiff = $startDate->diff($endDate)->days;
if (!$daysDiff || $startDate > $endDate) {
throw new \Exception('Invalid time interval', 400); throw new \Exception('Invalid time interval', 400);
} }
$fareList = $priceService->getFinalPricesForSearch($roomCategory, $startDate, $endDate); $fareList = $priceService->getFinalPricesForSearch($roomCategory, $searchRequest->startDate, $searchRequest->endDate);
$rs = []; $rs = [];
foreach ($fareList as $key => $value) { foreach ($fareList as $key => $value) {
$rs[] = ["guestNumber" => $key, "price" => $value]; $rs[] = ["guestNumber" => $key, "price" => $value];
+19 -17
View File
@@ -7,6 +7,7 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types; use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Ignore;
#[ORM\Entity(repositoryClass: BookingRepository::class)] #[ORM\Entity(repositoryClass: BookingRepository::class)]
class Booking class Booking
@@ -14,29 +15,30 @@ class Booking
#[ORM\Id] #[ORM\Id]
#[ORM\GeneratedValue] #[ORM\GeneratedValue]
#[ORM\Column] #[ORM\Column]
#[Ignore]
private ?int $id = null; private ?int $id = null;
#[ORM\Column(length: 20)]
private ?string $refNumber = null;
#[ORM\Column(type: Types::DATE_MUTABLE)] #[ORM\Column(type: Types::DATE_MUTABLE)]
private ?\DateTimeInterface $ArrivalDate = null; private ?\DateTimeInterface $arrivalDate = null;
#[ORM\Column(type : Types::DATE_MUTABLE)] #[ORM\Column(type : Types::DATE_MUTABLE)]
private ?\DateTimeInterface $DepartureDate = null; private ?\DateTimeInterface $departureDate = null;
#[ORM\Column(type : Types::DATETIMETZ_MUTABLE)] #[ORM\Column(type : Types::DATETIMETZ_MUTABLE)]
private ?\DateTimeInterface $BookingTime = null; private ?\DateTimeInterface $bookingTime = null;
#[ORM\OneToOne(mappedBy : 'Booking', cascade: ['persist', 'remove'])] #[ORM\OneToOne(mappedBy: 'booking', cascade: ['persist', 'remove'])]
private ?BookingCustomer $bookingCustomer = null; private ?BookingCustomer $bookingCustomer = null;
/** /**
* @var Collection<int, BookingRoom> * @var Collection<int, BookingRoom>
*/ */
#[ORM\OneToMany(targetEntity: BookingRoom::class, mappedBy: 'Booking', orphanRemoval: true, cascade: ['persist'])] #[ORM\OneToMany(targetEntity: BookingRoom::class, mappedBy: 'booking', orphanRemoval: true, cascade: ['persist'])]
private Collection $bookingRooms; private Collection $bookingRooms;
#[ORM\Column(length: 20)]
private ?string $refNumber = null;
public function __construct() public function __construct()
{ {
$this->bookingRooms = new ArrayCollection(); $this->bookingRooms = new ArrayCollection();
@@ -49,36 +51,36 @@ class Booking
public function getArrivalDate(): ?\DateTimeInterface public function getArrivalDate(): ?\DateTimeInterface
{ {
return $this->ArrivalDate; return $this->arrivalDate;
} }
public function setArrivalDate(\DateTimeInterface $ArrivalDate): static public function setArrivalDate(\DateTimeInterface $arrivalDate): static
{ {
$this->ArrivalDate = $ArrivalDate; $this->arrivalDate = $arrivalDate;
return $this; return $this;
} }
public function getDepartureDate(): ?\DateTimeInterface public function getDepartureDate(): ?\DateTimeInterface
{ {
return $this->DepartureDate; return $this->departureDate;
} }
public function setDepartureDate(\DateTimeInterface $DepartureDate): static public function setDepartureDate(\DateTimeInterface $departureDate): static
{ {
$this->DepartureDate = $DepartureDate; $this->departureDate = $departureDate;
return $this; return $this;
} }
public function getBookingTime(): ?\DateTimeInterface public function getBookingTime(): ?\DateTimeInterface
{ {
return $this->BookingTime; return $this->bookingTime;
} }
public function setBookingTime(\DateTimeInterface $BookingTime): static public function setBookingTime(\DateTimeInterface $bookingTime): static
{ {
$this->BookingTime = $BookingTime; $this->bookingTime = $bookingTime;
return $this; return $this;
} }
+21 -22
View File
@@ -12,88 +12,87 @@ class BookingCustomer
#[ORM\Id] #[ORM\Id]
#[ORM\GeneratedValue] #[ORM\GeneratedValue]
#[ORM\Column] #[ORM\Column]
#[Ignore]
private ?int $id = null; private ?int $id = null;
#[ORM\OneToOne(inversedBy: 'bookingCustomer', cascade: ['persist', 'remove'])] #[ORM\OneToOne(inversedBy: 'bookingCustomer', cascade: ['persist', 'remove'])]
#[ORM\JoinColumn(nullable: false, onDelete: "CASCADE")] #[ORM\JoinColumn(nullable: false, onDelete: "CASCADE")]
#[Ignore] #[Ignore]
private ?Booking $Booking = null; private ?Booking $booking = null;
#[ORM\Column(length: 64)] #[ORM\Column(length: 64)]
private ?string $Name = null; private ?string $name = null;
#[ORM\Column(length: 255)] #[ORM\Column(length: 255)]
private ?string $Surname = null; private ?string $surname = null;
#[ORM\Column(length: 255)] #[ORM\Column(length: 255)]
private ?string $Email = null; private ?string $email = null;
#[ORM\Column(length: 255)] #[ORM\Column(length: 255)]
private ?string $PhoneNumber = null; private ?string $phoneNumber = null;
public function getId(): ?int public function getId(): ?int
{ {
return $this->id; return $this->id;
} }
#[Ignore]
public function getBooking(): ?Booking public function getBooking(): ?Booking
{ {
return $this->Booking; return $this->booking;
} }
#[Ignore] public function setBooking(Booking $booking): static
public function setBooking(Booking $Booking): static
{ {
$this->Booking = $Booking; $this->booking = $booking;
return $this; return $this;
} }
public function getName(): ?string public function getName(): ?string
{ {
return $this->Name; return $this->name;
} }
public function setName(string $Name): static public function setName(string $name): static
{ {
$this->Name = $Name; $this->name = $name;
return $this; return $this;
} }
public function getSurname(): ?string public function getSurname(): ?string
{ {
return $this->Surname; return $this->surname;
} }
public function setSurname(string $Surname): static public function setSurname(string $surname): static
{ {
$this->Surname = $Surname; $this->surname = $surname;
return $this; return $this;
} }
public function getEmail(): ?string public function getEmail(): ?string
{ {
return $this->Email; return $this->email;
} }
public function setEmail(string $Email): static public function setEmail(string $email): static
{ {
$this->Email = $Email; $this->email = $email;
return $this; return $this;
} }
public function getPhoneNumber(): ?string public function getPhoneNumber(): ?string
{ {
return $this->PhoneNumber; return $this->phoneNumber;
} }
public function setPhoneNumber(string $PhoneNumber): static public function setPhoneNumber(string $phoneNumber): static
{ {
$this->PhoneNumber = $PhoneNumber; $this->phoneNumber = $phoneNumber;
return $this; return $this;
} }
+21 -24
View File
@@ -12,56 +12,53 @@ class BookingRoom
#[ORM\Id] #[ORM\Id]
#[ORM\GeneratedValue] #[ORM\GeneratedValue]
#[ORM\Column] #[ORM\Column]
#[Ignore]
private ?int $id = null; private ?int $id = null;
#[ORM\ManyToOne(inversedBy: 'bookingRooms')] #[ORM\ManyToOne(inversedBy: 'bookingRooms')]
#[ORM\JoinColumn(nullable: false, onDelete: "CASCADE")] #[ORM\JoinColumn(nullable: false, onDelete: "CASCADE")]
#[Ignore] #[Ignore]
private ?Booking $Booking = null; private ?Booking $booking = null;
#[ORM\ManyToOne] #[ORM\ManyToOne]
#[ORM\JoinColumn(nullable: false)] #[ORM\JoinColumn(nullable: false)]
#[Ignore] #[Ignore]
private ?RoomCategory $RoomCategory = null; private ?RoomCategory $roomCategory = null;
#[ORM\Column] #[ORM\Column]
private ?int $GuestNumber = null; private ?int $guestNumber = null;
#[ORM\Column] #[ORM\Column]
private ?int $RoomPrice = null; private ?int $roomPrice = null;
#[ORM\Column] #[ORM\Column]
private ?int $Amount = null; private ?int $amount = null;
public function getId(): ?int public function getId(): ?int
{ {
return $this->id; return $this->id;
} }
#[Ignore]
public function getBooking(): ?Booking public function getBooking(): ?Booking
{ {
return $this->Booking; return $this->booking;
} }
#[Ignore] public function setBooking(?Booking $booking): static
public function setBooking(?Booking $Booking): static
{ {
$this->Booking = $Booking; $this->booking = $booking;
return $this; return $this;
} }
#[Ignore]
public function getRoomCategory(): ?RoomCategory public function getRoomCategory(): ?RoomCategory
{ {
return $this->RoomCategory; return $this->roomCategory;
} }
#[Ignore] public function setRoomCategory(?RoomCategory $roomCategory): static
public function setRoomCategory(?RoomCategory $RoomCategory): static
{ {
$this->RoomCategory = $RoomCategory; $this->roomCategory = $roomCategory;
return $this; return $this;
} }
@@ -73,36 +70,36 @@ class BookingRoom
public function getGuestNumber(): ?int public function getGuestNumber(): ?int
{ {
return $this->GuestNumber; return $this->guestNumber;
} }
public function setGuestNumber(int $GuestNumber): static public function setGuestNumber(int $guestNumber): static
{ {
$this->GuestNumber = $GuestNumber; $this->guestNumber = $guestNumber;
return $this; return $this;
} }
public function getRoomPrice(): ?int public function getRoomPrice(): ?int
{ {
return $this->RoomPrice; return $this->roomPrice;
} }
public function setRoomPrice(int $RoomPrice): static public function setRoomPrice(int $roomPrice): static
{ {
$this->RoomPrice = $RoomPrice; $this->roomPrice = $roomPrice;
return $this; return $this;
} }
public function getAmount(): ?int public function getAmount(): ?int
{ {
return $this->Amount; return $this->amount;
} }
public function setAmount(int $Amount): static public function setAmount(int $amount): static
{ {
$this->Amount = $Amount; $this->amount = $amount;
return $this; return $this;
} }
+1 -1
View File
@@ -164,7 +164,7 @@ class FareTable
/** /**
* Obtiene las tarifas que aplican al GuestNumber indicado. * Obtiene las tarifas que aplican al GuestNumber indicado.
* @param int $guestNumber GuestNumber para búsqueda. * @param int $guestNumber GuestNumber para búsqueda.
* @return RoomFare[] Lista de tarifas. * @return Collection<RoomFare> Lista de tarifas.
*/ */
public function getRoomFaresByGuestNumber(int $guestNumber) public function getRoomFaresByGuestNumber(int $guestNumber)
{ {
+1 -4
View File
@@ -18,6 +18,7 @@ class RoomCategoryBedType
#[ORM\Id] #[ORM\Id]
#[ORM\ManyToOne] #[ORM\ManyToOne]
#[ORM\JoinColumn(nullable: false)] #[ORM\JoinColumn(nullable: false)]
#[Ignore]
private ?BedType $bedType = null; private ?BedType $bedType = null;
#[ORM\Column] #[ORM\Column]
@@ -40,13 +41,11 @@ class RoomCategoryBedType
return $this; return $this;
} }
#[Ignore]
public function getRoomCategory(): ?RoomCategory public function getRoomCategory(): ?RoomCategory
{ {
return $this->roomCategory; return $this->roomCategory;
} }
#[Ignore]
public function setRoomCategory(?RoomCategory $roomCategory): static public function setRoomCategory(?RoomCategory $roomCategory): static
{ {
$this->roomCategory = $roomCategory; $this->roomCategory = $roomCategory;
@@ -54,13 +53,11 @@ class RoomCategoryBedType
return $this; return $this;
} }
#[Ignore]
public function getBedType(): ?BedType public function getBedType(): ?BedType
{ {
return $this->bedType; return $this->bedType;
} }
#[Ignore]
public function setBedType(?BedType $bedType): static public function setBedType(?BedType $bedType): static
{ {
$this->bedType = $bedType; $this->bedType = $bedType;
-3
View File
@@ -29,7 +29,6 @@ class RoomCategoryPhoto
#[Ignore] #[Ignore]
private ?RoomCategory $roomCategory = null; private ?RoomCategory $roomCategory = null;
#[Ignore]
public function getId(): ?int public function getId(): ?int
{ {
return $this->id; return $this->id;
@@ -71,13 +70,11 @@ class RoomCategoryPhoto
return $this; return $this;
} }
#[Ignore]
public function getRoomCategory(): ?RoomCategory public function getRoomCategory(): ?RoomCategory
{ {
return $this->roomCategory; return $this->roomCategory;
} }
#[Ignore]
public function setRoomCategory(?RoomCategory $roomCategory): static public function setRoomCategory(?RoomCategory $roomCategory): static
{ {
$this->roomCategory = $roomCategory; $this->roomCategory = $roomCategory;
+1 -1
View File
@@ -19,7 +19,7 @@ class BookingCreateRequest
public BookingCustomer $customerDetails; public BookingCustomer $customerDetails;
/** /**
* @var array<BookingCreateRoomItem> * @var BookingCreateRoomItem[]
*/ */
#[OA\Property( #[OA\Property(
description: 'Rooms to book', description: 'Rooms to book',
+1 -1
View File
@@ -7,7 +7,7 @@ use OpenApi\Attributes as OA;
class BookingCreateRoomItem class BookingCreateRoomItem
{ {
#[OA\Property(description: 'Room category ID')] #[OA\Property(description: 'Room category ID')]
public string $roomCategory; public int $roomCategory;
#[OA\Property(description: 'Guest number for the room')] #[OA\Property(description: 'Guest number for the room')]
public int $guestNumber; public int $guestNumber;
+1 -1
View File
@@ -39,7 +39,7 @@ class ConfigVariableService
} }
} }
private function AddConfigVariable(string $key, string $value, string $section) : Returntype { private function AddConfigVariable(string $key, string $value, string $section): void {
} }
+1 -1
View File
@@ -127,7 +127,7 @@ class PricesService
/** /**
* Calcula el precio a aplicar según las condiciones de las tarifas. * Calcula el precio a aplicar según las condiciones de las tarifas.
* @param RoomFare[] $roomFareList Lista con las posibles tarifas. * @param Collection<RoomFare> $roomFareList Lista con las posibles tarifas.
* @param DateTimeInterface $fareCondDate Fecha utilizada para las condiciones. * @param DateTimeInterface $fareCondDate Fecha utilizada para las condiciones.
* *
*/ */