using ERPCore.Domain.Enums;
using ERPCore.Dtos.Common;
using ERPCore.Dtos.Hrm;

namespace ERPCore.Services.Interfaces;

/// <summary>Attendance upload/validate/confirm pipeline (FR-HR-ATT, docs/13-BACKEND-HRM-API.md §4).</summary>
public interface IAttendanceUploadService
{
    Task<PagedResponse<AttendanceUploadBatchDto>> ListBatchesAsync(
        PageQuery query, AttendanceBatchStatus? status, int? periodYear, int? periodMonth, CancellationToken ct = default);
    Task<AttendanceUploadBatchDto?> GetBatchAsync(int batchId, CancellationToken ct = default);
    Task<AttendanceUploadBatchDto> UploadAsync(
        Stream fileContent, string fileName, DateTime periodStart, DateTime periodEnd, int actorUserId, CancellationToken ct = default);

    Task<List<AttendanceRecordDto>> ListRecordsAsync(int batchId, RowValidationStatus? status, CancellationToken ct = default);
    Task<AttendanceRecordDto> UpdateRecordAsync(int batchId, int recordId, UpdateAttendanceRecordRequest request, int actorUserId, CancellationToken ct = default);
    Task ResolveDuplicateAsync(int batchId, ResolveDuplicateRequest request, CancellationToken ct = default);

    Task<AttendanceUploadBatchDto> ValidateAsync(int batchId, CancellationToken ct = default);
    Task<AttendanceUploadBatchDto> ConfirmAsync(int batchId, int actorUserId, CancellationToken ct = default);
    Task<AttendanceUploadBatchDto> UnlockAsync(int batchId, string reason, int actorUserId, CancellationToken ct = default);

    /// <summary>Generates the upload template in the same column shape the parser expects.</summary>
    (byte[] Content, string ContentType, string FileName) GenerateTemplate(bool asCsv);
}
