using NTP.Application.Common;
namespace NTP.Application.Refinery.WageClaims;
/// A trip of a claim waiting for the Jopetrol transfer (REFINERY_TRIPS.TRIP_STATUS = 6).
public sealed class TransferTripRow
{
public long Id { get; set; }
public string? Pn { get; set; }
public string? StatusCode { get; set; }
}
///
/// SQL of refinery_wage_claimdao.cfc (+ the writes of refinery_wage_claimfactory.cfc). REFINERY_TRIPS is only read, except for the columns the
/// legacy claim code writes: WAGE_CLAIM_ID, STATUS_CODE (COMPLETE), TRIP_STATUS (7), LAST_UPDATE_DATE, UPDATED_BY.
///
public interface IWageClaimRepository
{
Task> SearchAsync(WageClaimQuery query, PageRequest page, CancellationToken ct = default);
Task GetAsync(long id, CancellationToken ct = default);
Task> ClaimTripsAsync(long claimId, PageRequest page, CancellationToken ct = default);
/// Trips of the given statuses without a wage claim (optionally limited to a loading date range): the create preview.
Task> CandidateTripsAsync(IReadOnlyList statuses, DateOnly? from, DateOnly? to, PageRequest page, CancellationToken ct = default);
Task CountCandidateTripsAsync(IReadOnlyList statuses, DateOnly from, DateOnly to, CancellationToken ct = default);
/// Takes the next claim number (legacy GenerateSerialNumber) and inserts the claim as NEW; returns its id. Run inside a transaction.
Task InsertClaimAsync(string createdBy, CancellationToken ct = default);
Task AttachTripsAsync(long claimId, IReadOnlyList statuses, DateOnly from, DateOnly to, CancellationToken ct = default);
Task SetClaimStatusAsync(long claimId, string status, string userLogin, CancellationToken ct = default);
Task> TripsToTransferAsync(long claimId, CancellationToken ct = default);
/// TRIP_STATUS 7 + REFINERY_TRIPS_LOG row TRANSFER_TO_REFINERY. Run inside a transaction.
Task MarkTripTransferredAsync(TransferTripRow trip, long userId, string? ip, CancellationToken ct = default);
Task AddLogAsync(long claimId, string method, string? oldData, string? newData, long userId, string? ip, CancellationToken ct = default);
Task> LogAsync(long claimId, PageRequest page, CancellationToken ct = default);
Task> ReportRowsAsync(long claimId, CancellationToken ct = default);
}