namespace PowderCoating.Web.Helpers;
///
/// Checks whether an accounting entry date falls within a locked period.
/// The lock date is stored on the Company as BookLockedThrough and is set by CompanyAdmin
/// users to prevent backdating entries into periods that have already been closed.
///
public static class AccountingPeriodValidator
{
/// Returns true when the entry date is on or before the lock date (period is closed).
public static bool IsLocked(DateTime entryDate, DateTime? lockedThrough) =>
lockedThrough.HasValue && entryDate.Date <= lockedThrough.Value.Date;
/// User-facing message to display when a write is blocked by period locking.
public static string LockedMessage(DateTime? lockedThrough) =>
$"This period is locked — books are closed through {lockedThrough!.Value:MMMM d, yyyy}. " +
"Unlock the period in Company Settings → Accounting to make changes.";
}