using NTP.Application.Common; using NTP.Domain.Grains.Orders; namespace NTP.Application.Grains.Orders; public interface ITenderOrderRepository { /// Legacy getTenderOrders query (non-deleted orders, active EN/EX GN locations), newest first. Task> SearchAsync(DateTime? orderDate, PageRequest page, CancellationToken ct = default); Task InsertAsync(NewTenderOrder order, CancellationToken ct = default); /// Status and date of an order (null when the id does not exist). Task<(string? StatusCode, DateTime OrderDate)?> GetHeaderAsync(long id, CancellationToken ct = default); /// Permits with SCRN = order id in shipment status REQST/PLND (orders already distributed). Task HasDistributedPermitsAsync(long id, CancellationToken ct = default); Task MarkDeletedAsync(long id, CancellationToken ct = default); Task SetMobileShowAsync(long id, bool show, string userId, CancellationToken ct = default); } public interface IOrderLookupRepository { /// CARGOTYPE where DOMAIN='GN'. Task> GetCargoTypesAsync(CancellationToken ct = default); /// LOCATIONS where DOMAIN='GN', STATUS=1 and TYPE = EN (loading) or EX (destination). Task> GetLocationsAsync(string type, CancellationToken ct = default); /// Invoice.cfc getLocations: GN exit locations with AREA IS NULL and STATUS=1. Task> GetBillingDestinationsAsync(CancellationToken ct = default); /// register.getDistination: GN exit locations of GN_TYPE 'PCKD', ordered by SORTORDER. Task> GetPackedDestinationsAsync(CancellationToken ct = default); /// GN exit locations of one GN_TYPE ('PCKD', 'BULK', 'BULK_GALLAB'), ordered by SORTORDER. Task> GetDestinationsByGnTypeAsync(string gnType, CancellationToken ct = default); /// NTP_TENDERS_COMPANIES with STATUSCODE='ACTIVE' (grains.cfc getCompanies). Task> GetCompaniesAsync(CancellationToken ct = default); } public interface IQuotaRepository { /// All GN DESTINATIONS left-joined with their active DESTINATION_QUOTA row of the date. Task> GetListAsync(DateTime date, PageRequest page, CancellationToken ct = default); Task DestinationExistsAsync(long destinationId, CancellationToken ct = default); Task GetActiveAsync(long destinationId, DateTime date, CancellationToken ct = default); Task DeactivateAsync(long destinationId, DateTime date, string userId, CancellationToken ct = default); Task InsertAsync(long destinationId, DateTime date, int quota, string userId, int doneQuota, CancellationToken ct = default); } public interface IBillingRepository { Task GetPermitBillingInfoAsync(long pn, CancellationToken ct = default); Task GetWageRateAsync(long destination, DateTime loadDate, CancellationToken ct = default); Task GetFineRateAsync(DateTime loadDate, CancellationToken ct = default); Task InsertAsync(NewGrainsBilling billing, CancellationToken ct = default); Task> SearchAsync(BillingQuery query, PageRequest page, CancellationToken ct = default); Task GetDetailAsync(long id, CancellationToken ct = default); /// INVOICE.STATUSCODE of the invoice a billing belongs to (null when there is no INVOICE row). Task GetInvoiceStatusAsync(string scac, string invoiceNumber, CancellationToken ct = default); Task MarkDeletedAsync(long id, CancellationToken ct = default); Task UpdateRerouteAsync(long id, decimal? price, string? name, CancellationToken ct = default); } public interface IInvoiceRepository { Task> SearchAsync(long? invoiceNumber, PageRequest page, CancellationToken ct = default); Task ExistsAsync(long id, CancellationToken ct = default); /// Recomputes FINALCOST of every billing of the invoice, then sets the invoice ARCHIVED. Task ArchiveAsync(long id, CancellationToken ct = default); Task ActivateAsync(long id, CancellationToken ct = default); } public interface IGrainsWeightRepository { /// permits by PN in status CLOSE/RESD/ACTRL, company 327, domain GN (permitAutoComplete). Task GetPermitAsync(long pn, CancellationToken ct = default); Task GetWeightsAsync(long permitId, CancellationToken ct = default); Task UpdateWeightsAsync(long weightsId, string empty, string gross, string document, string userId, CancellationToken ct = default); Task InsertWeightsAsync(long permitId, string empty, string gross, string document, string userId, CancellationToken ct = default); } public interface ICompanyDestinationRepository { Task> GetLocationIdsAsync(long scac, CancellationToken ct = default); /// Deletes the company's rows whose LOCATIONID is in and inserts the new ones. Task ReplaceAsync(long scac, IReadOnlyCollection scopeLocationIds, IReadOnlyCollection newLocationIds, string userId, CancellationToken ct = default); } public interface IOrderReportRepository { Task> GetTenderTypeTotalsAsync(DateTime orderDate, CancellationToken ct = default); Task> GetTenderDestinationTotalsAsync(DateTime orderDate, CancellationToken ct = default); Task> GetFinancialBillingPageAsync(long scac, long invoiceNumber, PageRequest page, CancellationToken ct = default); Task> GetFinancialBillingAsync(long scac, long invoiceNumber, CancellationToken ct = default); /// Distinct invoice numbers already present in GRAINS_BILLING for a company (newest first). Task> GetInvoiceNumbersAsync(long scac, CancellationToken ct = default); }