<?php

declare(strict_types=1);

namespace App\Modules\Ledger\Domain;

class CoffeeEntry
{
    public function __construct(
        private readonly string $id,
        private readonly string $tenantId,
        private readonly string $memberId,
        private readonly int $strokes,
        private readonly float $unitPrice,
        private readonly string $bookedAt
    ) {
    }

    public function id(): string
    {
        return $this->id;
    }

    public function tenantId(): string
    {
        return $this->tenantId;
    }

    public function memberId(): string
    {
        return $this->memberId;
    }

    public function strokes(): int
    {
        return $this->strokes;
    }

    public function unitPrice(): float
    {
        return $this->unitPrice;
    }

    public function bookedAt(): string
    {
        return $this->bookedAt;
    }

    public function totalCost(): float
    {
        return $this->strokes * $this->unitPrice;
    }

    public function isDeletable(): bool
    {
        return true;
    }

    public function canBeDeletedByResponsible(): bool
    {
        return $this->isDeletable();
    }

    /**
     * @return array<string, mixed>
     */
    public function toArray(): array
    {
        return [
            'id' => $this->id(),
            'tenant_id' => $this->tenantId(),
            'member_id' => $this->memberId(),
            'strokes' => $this->strokes(),
            'unit_price' => $this->unitPrice(),
            'booked_at' => $this->bookedAt(),
            'total_cost' => $this->totalCost(),
            'deletable' => $this->canBeDeletedByResponsible(),
        ];
    }
}
