<?php

namespace App\Domain\Shared\DTOs;

use App\Domain\Shared\Enums\ProrationMode;

readonly class ProrationResult
{
    public function __construct(
        public bool $applied,
        public int  $originalAmount,
        public int  $proratedAmount,
        public ProrationMode $mode,
        public int  $renewalDay,
        public string $description,
        /** Sessions the group holds in the whole month; 0 when unknown. */
        public int $totalSessions = 0,
        /** Sessions still to come on or after the join date. */
        public int $remainingSessions = 0,
    ) {}

    /**
     * A result that charges the full amount — the answer whenever proration is
     * off, the mode is a full month, or there is no timetable to count.
     */
    public static function fullMonth(int $amount, int $renewalDay, string $description = ''): self
    {
        return new self(
            applied: false,
            originalAmount: $amount,
            proratedAmount: $amount,
            mode: ProrationMode::FullMonth,
            renewalDay: $renewalDay,
            description: $description,
        );
    }
}
