NTP_V2/src/NTP.Application/Grains/Orders/OrdersRepositories.cs

112 lines
6.2 KiB
C#

using NTP.Application.Common;
using NTP.Domain.Grains.Orders;
namespace NTP.Application.Grains.Orders;
public interface ITenderOrderRepository
{
/// <summary>Legacy getTenderOrders query (non-deleted orders, active EN/EX GN locations), newest first.</summary>
Task<PagedResult<TenderOrderRow>> SearchAsync(DateTime? orderDate, PageRequest page, CancellationToken ct = default);
Task<long> InsertAsync(NewTenderOrder order, CancellationToken ct = default);
/// <summary>Status and date of an order (null when the id does not exist).</summary>
Task<(string? StatusCode, DateTime OrderDate)?> GetHeaderAsync(long id, CancellationToken ct = default);
/// <summary>Permits with SCRN = order id in shipment status REQST/PLND (orders already distributed).</summary>
Task<bool> 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
{
/// <summary>CARGOTYPE where DOMAIN='GN'.</summary>
Task<IReadOnlyList<LookupOptionDto>> GetCargoTypesAsync(CancellationToken ct = default);
/// <summary>LOCATIONS where DOMAIN='GN', STATUS=1 and TYPE = EN (loading) or EX (destination).</summary>
Task<IReadOnlyList<LookupOptionDto>> GetLocationsAsync(string type, CancellationToken ct = default);
/// <summary>Invoice.cfc getLocations: GN exit locations with AREA IS NULL and STATUS=1.</summary>
Task<IReadOnlyList<LookupOptionDto>> GetBillingDestinationsAsync(CancellationToken ct = default);
/// <summary>register.getDistination: GN exit locations of GN_TYPE 'PCKD', ordered by SORTORDER.</summary>
Task<IReadOnlyList<LookupOptionDto>> GetPackedDestinationsAsync(CancellationToken ct = default);
/// <summary>GN exit locations of one GN_TYPE ('PCKD', 'BULK', 'BULK_GALLAB'), ordered by SORTORDER.</summary>
Task<IReadOnlyList<LookupOptionDto>> GetDestinationsByGnTypeAsync(string gnType, CancellationToken ct = default);
/// <summary>NTP_TENDERS_COMPANIES with STATUSCODE='ACTIVE' (grains.cfc getCompanies).</summary>
Task<IReadOnlyList<CompanyOptionDto>> GetCompaniesAsync(CancellationToken ct = default);
}
public interface IQuotaRepository
{
/// <summary>All GN DESTINATIONS left-joined with their active DESTINATION_QUOTA row of the date.</summary>
Task<PagedResult<QuotaRow>> GetListAsync(DateTime date, PageRequest page, CancellationToken ct = default);
Task<bool> DestinationExistsAsync(long destinationId, CancellationToken ct = default);
Task<ActiveQuota?> 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<PermitBillingInfo?> GetPermitBillingInfoAsync(long pn, CancellationToken ct = default);
Task<WageRate?> GetWageRateAsync(long destination, DateTime loadDate, CancellationToken ct = default);
Task<FineRate?> GetFineRateAsync(DateTime loadDate, CancellationToken ct = default);
Task<long> InsertAsync(NewGrainsBilling billing, CancellationToken ct = default);
Task<PagedResult<BillingRow>> SearchAsync(BillingQuery query, PageRequest page, CancellationToken ct = default);
Task<BillingDetailRow?> GetDetailAsync(long id, CancellationToken ct = default);
/// <summary>INVOICE.STATUSCODE of the invoice a billing belongs to (null when there is no INVOICE row).</summary>
Task<string?> 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<PagedResult<InvoiceRow>> SearchAsync(long? invoiceNumber, PageRequest page, CancellationToken ct = default);
Task<bool> ExistsAsync(long id, CancellationToken ct = default);
/// <summary>Recomputes FINALCOST of every billing of the invoice, then sets the invoice ARCHIVED.</summary>
Task ArchiveAsync(long id, CancellationToken ct = default);
Task ActivateAsync(long id, CancellationToken ct = default);
}
public interface IGrainsWeightRepository
{
/// <summary>permits by PN in status CLOSE/RESD/ACTRL, company 327, domain GN (permitAutoComplete).</summary>
Task<PermitWeightsRow?> GetPermitAsync(long pn, CancellationToken ct = default);
Task<SavedWeightsRow?> 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<IReadOnlyList<long>> GetLocationIdsAsync(long scac, CancellationToken ct = default);
/// <summary>Deletes the company's rows whose LOCATIONID is in <paramref name="scopeLocationIds"/> and inserts the new ones.</summary>
Task ReplaceAsync(long scac, IReadOnlyCollection<long> scopeLocationIds, IReadOnlyCollection<long> newLocationIds,
string userId, CancellationToken ct = default);
}
public interface IOrderReportRepository
{
Task<IReadOnlyList<TenderTypeTotalRow>> GetTenderTypeTotalsAsync(DateTime orderDate, CancellationToken ct = default);
Task<IReadOnlyList<TenderDestinationTotalRow>> GetTenderDestinationTotalsAsync(DateTime orderDate, CancellationToken ct = default);
Task<PagedResult<FinancialBillingRow>> GetFinancialBillingPageAsync(long scac, long invoiceNumber, PageRequest page, CancellationToken ct = default);
Task<IReadOnlyList<FinancialBillingRow>> GetFinancialBillingAsync(long scac, long invoiceNumber, CancellationToken ct = default);
/// <summary>Distinct invoice numbers already present in GRAINS_BILLING for a company (newest first).</summary>
Task<IReadOnlyList<long>> GetInvoiceNumbersAsync(long scac, CancellationToken ct = default);
}