<?php

declare(strict_types=1);

namespace App\Services\Booking;

/**
 * What a booking will cost, broken down.
 *
 * Copied onto the booking at the moment of sale. Changing a room rate later
 * must never rewrite what somebody already paid, so nothing downstream ever
 * recalculates a price from the room record.
 */
final readonly class Quote
{
    /** @param array<int, array{name: string, unit_price: string, quantity: int, total: string, charge_unit: string, room_addon_id: ?int, is_quote_required: bool}> $addons */
    public function __construct(
        public string $roomSubtotal,
        public string $addonsSubtotal,
        public string $total,
        public array $addons = [],
        public bool $paidByPackage = false,
        public int $studioSlotsUsed = 0,
        public int $engineerSlotsUsed = 0,
    ) {}

    public function isFree(): bool
    {
        return bccomp($this->total, '0.00', 2) === 0;
    }
}
