#nullable enable
using Baya.Application.Models.Common;
using Baya.Application.Models.Holidays;

namespace Baya.Application.Contracts.Holidays;

/// <summary>
/// The Iranian holiday calendar seam. Lookups are cached. Payout scheduling (later phase) calls
/// <see cref="NextBusinessDay"/> to shift a payout off bank-closed days. Mock reads the seeded
/// <c>iranian_holidays</c> table; the real path syncs an external banking-holiday feed.
/// </summary>
public interface IHolidayCalendar
{
    ValueTask<bool> IsHoliday(DateOnly date, CancellationToken cancellationToken = default);

    /// <summary>True if PAYA/SATNA banks are closed that day (a seeded bank-closed holiday).</summary>
    ValueTask<bool> IsBankClosed(DateOnly date, CancellationToken cancellationToken = default);

    /// <summary>The next day banks are open — skips bank-closed holidays and the Iranian banking weekend (Friday).</summary>
    ValueTask<DateOnly> NextBusinessDay(DateOnly date, CancellationToken cancellationToken = default);

    ValueTask<PagedResult<HolidayDto>> ListAsync(DateOnly? from, DateOnly? to, int page, int pageSize, CancellationToken cancellationToken = default);

    /// <summary>Inserts or updates the holiday for <paramref name="date"/> then evicts the cached lookups for it.</summary>
    ValueTask UpsertAsync(DateOnly date, string nameFa, string type, bool isBankClosed, CancellationToken cancellationToken = default);

    /// <summary>Deletes the holiday for <paramref name="date"/>; returns <c>false</c> if none existed.</summary>
    ValueTask<bool> DeleteAsync(DateOnly date, CancellationToken cancellationToken = default);
}
