feat: groups price calculator admin crud, booking/offer flow and api
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
use App\Entity\Groups\AccommodationBooking;
|
||||
use Symfony\Component\Serializer\Attribute\Context;
|
||||
use Symfony\Component\Serializer\Attribute\Groups;
|
||||
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
|
||||
|
||||
final readonly class AccommodationBookingApiResponse
|
||||
{
|
||||
#[Groups(['api:single'])]
|
||||
public string $uuid;
|
||||
|
||||
#[Groups(['api:single'])]
|
||||
public string $status;
|
||||
|
||||
#[Groups(['api:single'])]
|
||||
#[Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d'])]
|
||||
public ?\DateTimeImmutable $dateFrom;
|
||||
|
||||
#[Groups(['api:single'])]
|
||||
#[Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d'])]
|
||||
public ?\DateTimeImmutable $dateTo;
|
||||
|
||||
#[Groups(['api:single'])]
|
||||
public int $nights;
|
||||
|
||||
#[Groups(['api:single'])]
|
||||
public int $paxCount;
|
||||
|
||||
#[Groups(['api:single'])]
|
||||
public int $minorsCount;
|
||||
|
||||
#[Groups(['api:single'])]
|
||||
public int $childrenCount;
|
||||
|
||||
#[Groups(['api:single'])]
|
||||
public ?string $groupName;
|
||||
|
||||
#[Groups(['api:single'])]
|
||||
public ?\DateTimeImmutable $acceptedAt;
|
||||
|
||||
#[Groups(['api:single'])]
|
||||
public AccommodationBookingPersonalData $personalData;
|
||||
|
||||
#[Groups(['api:single'])]
|
||||
public AccommodationBookingHotelInfo $accommodation;
|
||||
|
||||
#[Groups(['api:single'])]
|
||||
public AccommodationBookingBoardServiceInfo $boardService;
|
||||
|
||||
/**
|
||||
* @var list<AccommodationBookingAdditionalServiceItem>
|
||||
*/
|
||||
#[Groups(['api:single'])]
|
||||
public array $additionalServices;
|
||||
|
||||
#[Groups(['api:single'])]
|
||||
public ?int $accommodationDiscount;
|
||||
|
||||
#[Groups(['api:single'])]
|
||||
public ?int $boardServiceDiscount;
|
||||
|
||||
#[Groups(['api:single'])]
|
||||
public ?int $additionalServicesDiscount;
|
||||
|
||||
#[Groups(['api:single'])]
|
||||
public ?int $totalPrice;
|
||||
|
||||
#[Groups(['api:single'])]
|
||||
public ?string $pricingCurrency;
|
||||
|
||||
#[Groups(['api:single'])]
|
||||
public ?int $pricingVersion;
|
||||
|
||||
/**
|
||||
* @var array<string, mixed>|null
|
||||
*/
|
||||
#[Groups(['api:single'])]
|
||||
public ?array $priceBreakdown;
|
||||
|
||||
/**
|
||||
* @param array<string, mixed>|null $priceBreakdown
|
||||
*/
|
||||
public function __construct(AccommodationBooking $booking, ?array $priceBreakdown)
|
||||
{
|
||||
$this->uuid = $booking->getUuid();
|
||||
$this->status = $booking->isInquiry() ? 'inquiry' : 'booking';
|
||||
$this->dateFrom = $booking->getDateFrom();
|
||||
$this->dateTo = $booking->getDateTo();
|
||||
$this->nights = $booking->getNights();
|
||||
$this->paxCount = $booking->getPaxCount();
|
||||
$this->minorsCount = $booking->getMinorsCount();
|
||||
$this->childrenCount = $booking->getChildrenCount();
|
||||
$this->groupName = $booking->getGroupName();
|
||||
$this->acceptedAt = $booking->getAcceptedAt();
|
||||
$this->personalData = new AccommodationBookingPersonalData($booking);
|
||||
$this->accommodation = new AccommodationBookingHotelInfo($booking->getAccommodation());
|
||||
$this->boardService = new AccommodationBookingBoardServiceInfo($booking);
|
||||
$this->additionalServices = array_map(
|
||||
static fn (array $service) => new AccommodationBookingAdditionalServiceItem($service),
|
||||
$booking->getAdditionalServices(),
|
||||
);
|
||||
$this->accommodationDiscount = $booking->getAccommodationDiscount();
|
||||
$this->boardServiceDiscount = $booking->getBoardServiceDiscount();
|
||||
$this->additionalServicesDiscount = $booking->getAdditionalServicesDiscount();
|
||||
$this->totalPrice = $booking->getTotalPrice();
|
||||
$this->pricingCurrency = $booking->getPricingCurrency();
|
||||
$this->pricingVersion = $booking->getPricingVersion();
|
||||
$this->priceBreakdown = $priceBreakdown;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user