305 lines
12 KiB
C#
305 lines
12 KiB
C#
namespace NTP.Application.Grains.Orders;
|
|
|
|
/// <summary>Envelope for write operations: <c>message</c> is the legacy Arabic success text (toasted by the client).</summary>
|
|
public sealed record OrdersResult(string Message, long? Id = null);
|
|
|
|
public sealed record LookupOptionDto(long Id, string? Name);
|
|
|
|
/// <summary>NTP_TENDERS_COMPANIES (ACTIVE) row: Label = "scac-company name" (legacy getCompanies.companycode).</summary>
|
|
public sealed record CompanyOptionDto(long Scac, string? Label);
|
|
|
|
// ---------------------------------------------------------------- tender orders
|
|
public sealed record TenderOrderQuery(DateTime? OrderDate);
|
|
|
|
/// <summary>Raw row of the legacy getTenderOrders query.</summary>
|
|
public sealed class TenderOrderRow
|
|
{
|
|
public long Id { get; set; }
|
|
public DateTime OrderDate { get; set; }
|
|
public int? MobileShift { get; set; }
|
|
public int Quantity { get; set; }
|
|
public string? Ct { get; set; }
|
|
public string? StatusCode { get; set; }
|
|
public string? CargoType { get; set; }
|
|
public string? Location { get; set; }
|
|
public string? Destination { get; set; }
|
|
public string? Type { get; set; }
|
|
public int? MobileShow { get; set; }
|
|
public int UsedQuota { get; set; }
|
|
}
|
|
|
|
// Type: COMP, AHALE or null (= everyone).
|
|
// Ct: PCKD, BULK or BULK_GALLAB.
|
|
// MobileShow: MOBILE_SHOW flag; null when the column is empty (legacy then showed no toggle).
|
|
// CanDelete: Legacy only showed the delete icon when the order date is after today.
|
|
public sealed record TenderOrderDto(
|
|
long Id,
|
|
string OrderDate,
|
|
int? MobileShift,
|
|
int Quantity,
|
|
int UsedQuota,
|
|
string? CargoType,
|
|
string? Location,
|
|
string? Destination,
|
|
string? Type,
|
|
string? Ct,
|
|
bool IsTipper,
|
|
bool? MobileShow,
|
|
bool CanDelete);
|
|
|
|
// Shift: Mobile shift: 1 morning, 2 evening, 3 night (legacy form field SHIFT).
|
|
// Type: AHALE or COMP (required unless cargo type is 41).
|
|
public sealed record CreateTenderOrderRequest(
|
|
long CargoType,
|
|
long Location,
|
|
long Destination,
|
|
DateTime OrderDate,
|
|
int Shift,
|
|
int Quantity,
|
|
bool IsTipper,
|
|
string? Type);
|
|
|
|
public sealed record MobilePublishRequest(bool Show);
|
|
|
|
// ---------------------------------------------------------------- quotas
|
|
public sealed class QuotaRow
|
|
{
|
|
public long DestinationId { get; set; }
|
|
public string? Name { get; set; }
|
|
public int? Quota { get; set; }
|
|
public int? DoneQuota { get; set; }
|
|
public string? CreatedBy { get; set; }
|
|
public DateTime? CreationDate { get; set; }
|
|
}
|
|
|
|
public sealed record QuotaDto(
|
|
long DestinationId, string? Name, string QuotaDate, int? Quota, int DoneQuota, string? CreatedBy, DateTime? CreationDate);
|
|
|
|
public sealed record ActiveQuota(long Id, int Quota, int DoneQuota);
|
|
|
|
public sealed record SetQuotaRequest(long DestinationId, DateTime QuotaDate, int Quota);
|
|
|
|
// ---------------------------------------------------------------- billing
|
|
/// <summary>Result of the legacy getBillingInfo query (events-based weights for a CLOSEd permit).</summary>
|
|
public sealed class PermitBillingInfo
|
|
{
|
|
public long Pn { get; set; }
|
|
public long Scac { get; set; }
|
|
public string? CompanyName { get; set; }
|
|
public long? CargoType { get; set; }
|
|
public string? Tn { get; set; }
|
|
public long? Origin { get; set; }
|
|
public DateTime? LoadDate { get; set; }
|
|
public decimal Ltw { get; set; }
|
|
public decimal Lgw { get; set; }
|
|
public long? Destination { get; set; }
|
|
public DateTime? DischargeDate { get; set; }
|
|
public decimal Dtw { get; set; }
|
|
public decimal Dgw { get; set; }
|
|
public long? LastInvoice { get; set; }
|
|
/// <summary>PERMITS.SHIPMENTSTATUSCODE (legacy BILLINGSTATUS).</summary>
|
|
public string? ShipmentStatusCode { get; set; }
|
|
}
|
|
|
|
/// <summary>Billing screen prefill (page JS getAllInformation + price table).</summary>
|
|
public sealed record BillingPermitDto(
|
|
long Pn, long Scac, string? CompanyName, long? CargoType, string? Tn, long? Destination,
|
|
string? LoadDate, string? DischargeDate, decimal Lnw, decimal? Dnw, long? LastInvoice,
|
|
decimal? Price, decimal? FinePrice);
|
|
|
|
public sealed record AddBillingRequest(
|
|
long Pn,
|
|
long Scac,
|
|
long InvoiceNumber,
|
|
string SerialNo,
|
|
DateTime LoadDate,
|
|
DateTime DischargeDate,
|
|
long Destination,
|
|
long CargoType,
|
|
string Tn,
|
|
decimal Lnw = 0,
|
|
decimal Dnw = 0,
|
|
decimal DemurrageFine = 0,
|
|
decimal OtherFine = 0);
|
|
|
|
/// <summary>GRAINS_WAGE row valid on the loading date: <c>Wage</c> is the price per ton (legacy PRICE).</summary>
|
|
public sealed record WageRate(decimal Wage);
|
|
|
|
/// <summary>Permit identity needed to close it when a billing is entered.</summary>
|
|
public sealed class PermitRef
|
|
{
|
|
public long Id { get; set; }
|
|
public string? ShipmentStatusCode { get; set; }
|
|
}
|
|
public sealed record FineRate(decimal Allowance, decimal Fine);
|
|
|
|
public sealed record BillingQuery(string? Tn, long? Pn, long? Scac, string? InvoiceNumber = null)
|
|
{
|
|
public bool HasFilter => !string.IsNullOrWhiteSpace(Tn) || Pn.HasValue || Scac.HasValue || !string.IsNullOrWhiteSpace(InvoiceNumber);
|
|
}
|
|
|
|
public sealed class BillingRow
|
|
{
|
|
public long Id { get; set; }
|
|
public string? CargoType { get; set; }
|
|
public string? Scac { get; set; }
|
|
public long Pn { get; set; }
|
|
public string? Tn { get; set; }
|
|
public DateTime? LoadDate { get; set; }
|
|
public string? Destination { get; set; }
|
|
public DateTime? DischargeDate { get; set; }
|
|
public decimal? Lnw { get; set; }
|
|
public decimal? Dnw { get; set; }
|
|
public decimal? Price { get; set; }
|
|
public decimal? FinePrice { get; set; }
|
|
public string? InvoiceNumber { get; set; }
|
|
public string? CreateUserId { get; set; }
|
|
}
|
|
|
|
public sealed record BillingDto(
|
|
long Id, string? CargoType, string? Scac, long Pn, string? Tn, string? LoadDate, string? Destination,
|
|
string? DischargeDate, decimal? Lnw, decimal? Dnw, decimal? Price, decimal? FinePrice, string? InvoiceNumber, string? CreateUserId);
|
|
|
|
/// <summary>Billing row as the delete / reroute screens need it (legacy deleteInvoice, getBillingInfoForReroute).</summary>
|
|
public sealed class BillingDetailRow
|
|
{
|
|
public long Id { get; set; }
|
|
public long Pn { get; set; }
|
|
public string? Tn { get; set; }
|
|
public string? CompanyName { get; set; }
|
|
public string? SerialNo { get; set; }
|
|
public string? CargoType { get; set; }
|
|
public string? Destination { get; set; }
|
|
public DateTime? LoadDate { get; set; }
|
|
public DateTime? DischargeDate { get; set; }
|
|
public decimal? Lnw { get; set; }
|
|
public decimal? Dnw { get; set; }
|
|
public decimal? Price { get; set; }
|
|
public string? InvoiceNumber { get; set; }
|
|
public string? Scac { get; set; }
|
|
public decimal? DemurrageFine { get; set; }
|
|
public decimal? OtherFine { get; set; }
|
|
public decimal? ReroutePrice { get; set; }
|
|
public string? RerouteName { get; set; }
|
|
public string? CreateUserId { get; set; }
|
|
}
|
|
|
|
public sealed record BillingRerouteDto(
|
|
long Id, long Pn, string? Tn, string? CompanyName, string? SerialNo, string? CargoType, string? Destination,
|
|
string? LoadDate, string? DischargeDate, decimal? Lnw, decimal? Dnw, decimal? Price, string? InvoiceNumber,
|
|
decimal? DemurrageFine, decimal? OtherFine, decimal? ReroutePrice, string? RerouteName);
|
|
|
|
public sealed record RerouteRequest(decimal? ReroutePrice, string? RerouteName);
|
|
|
|
// ---------------------------------------------------------------- invoices
|
|
public sealed class InvoiceRow
|
|
{
|
|
public long Id { get; set; }
|
|
public long InvoiceNumber { get; set; }
|
|
public string? StatusCode { get; set; }
|
|
public int Cnt { get; set; }
|
|
public string? CompanyName { get; set; }
|
|
public long Scac { get; set; }
|
|
public string? InvoiceDate { get; set; }
|
|
}
|
|
|
|
public sealed record InvoiceDto(
|
|
long Id, long InvoiceNumber, string? StatusCode, int Count, string? CompanyName, long Scac, string? InvoiceDate);
|
|
|
|
// ---------------------------------------------------------------- weights (addGrainsWeights.cfm)
|
|
public sealed class PermitWeightsRow
|
|
{
|
|
public long Id { get; set; }
|
|
public string? ShipmentStatusCode { get; set; }
|
|
public string? Tn { get; set; }
|
|
public string? Trn { get; set; }
|
|
public string? Drvr { get; set; }
|
|
}
|
|
|
|
public sealed class SavedWeightsRow
|
|
{
|
|
public long Id { get; set; }
|
|
public string? EmptyWeight { get; set; }
|
|
public string? GrossWeight { get; set; }
|
|
public string? DocumentNumber { get; set; }
|
|
}
|
|
|
|
public sealed record PermitWeightsDto(
|
|
long Pn, string? Tn, string? Trn, string? Driver, string? EmptyWeight, string? GrossWeight, string? DocumentNumber);
|
|
|
|
public sealed record SaveWeightsRequest(long Pn, string EmptyWeight, string GrossWeight, string DocumentNumber);
|
|
|
|
// ---------------------------------------------------------------- company destinations (compdest.cfm)
|
|
/// <summary>Destinations a company can be linked to, by kind: packed (مشول), bulk (سائب) and bulk tipper (سائب قلاب).</summary>
|
|
public sealed record DestinationGroupsDto(IReadOnlyList<LookupOptionDto> Packed, IReadOnlyList<LookupOptionDto> Bulk, IReadOnlyList<LookupOptionDto> BulkGallab);
|
|
|
|
public sealed record CompanyDestinationsDto(long Scac, IReadOnlyList<long> LocationIds);
|
|
public sealed record SaveCompanyDestinationsRequest(IReadOnlyList<long> LocationIds);
|
|
|
|
// ---------------------------------------------------------------- reports
|
|
public sealed class TenderTypeTotalRow
|
|
{
|
|
public string? Type { get; set; }
|
|
public decimal Quantity { get; set; }
|
|
}
|
|
|
|
public sealed class TenderDestinationTotalRow
|
|
{
|
|
public string? Destination { get; set; }
|
|
public string? Type { get; set; }
|
|
public decimal Quantity { get; set; }
|
|
}
|
|
|
|
public sealed record TenderTypeSummaryDto(string? Type, decimal Quantity, decimal Percent);
|
|
|
|
public sealed record TenderDestinationSummaryDto(
|
|
string? Destination, decimal Individuals, decimal IndividualsPercent, decimal Companies, decimal CompaniesPercent, decimal Total);
|
|
|
|
public sealed record TenderOrderReportDto(
|
|
string OrderDate,
|
|
IReadOnlyList<TenderTypeSummaryDto> ByType,
|
|
decimal TypeTotal,
|
|
IReadOnlyList<TenderDestinationSummaryDto> ByDestination,
|
|
decimal TotalIndividuals,
|
|
decimal TotalCompanies);
|
|
|
|
/// <summary>Row of view/table billing1 (GNB datasource in legacy) used by FinancialBilling*.cfm.</summary>
|
|
public sealed class FinancialBillingRow
|
|
{
|
|
public long Id { get; set; }
|
|
public string? CargoType { get; set; }
|
|
public string? CompanyName { get; set; }
|
|
public long Pn { get; set; }
|
|
public string? Tn { get; set; }
|
|
public object? LoadDate { get; set; }
|
|
public string? Name { get; set; }
|
|
public object? DischargeDate { get; set; }
|
|
public decimal Lnw { get; set; }
|
|
public decimal Dnw { get; set; }
|
|
public decimal Price { get; set; }
|
|
public decimal FinePrice { get; set; }
|
|
public string? SerialNo { get; set; }
|
|
public string? Origin { get; set; }
|
|
public decimal FinalCost { get; set; }
|
|
public decimal LoseFine { get; set; }
|
|
public long InvoiceNumber { get; set; }
|
|
public long Scac { get; set; }
|
|
public decimal OtherFine { get; set; }
|
|
public decimal DemurrageFine { get; set; }
|
|
}
|
|
|
|
public sealed record FinancialBillingDto(
|
|
long Id, string? CargoType, string? CompanyName, long Pn, string? Tn, string? LoadDate, string? Destination,
|
|
string? DischargeDate, decimal Lnw, decimal Dnw, decimal Difference, decimal Price, decimal FinePrice,
|
|
string? SerialNo, string? Origin, decimal LoseFine, decimal DemurrageFine, decimal OtherFine, decimal FinalCost,
|
|
long InvoiceNumber, long Scac);
|
|
|
|
public sealed record FinancialBillingTotals(
|
|
decimal Lnw, decimal Dnw, decimal LoseFine, decimal DemurrageFine, decimal OtherFine, decimal FinalCost);
|
|
|
|
/// <summary>Same JSON shape as PagedResult plus totals over the whole invoice.</summary>
|
|
public sealed record FinancialBillingPage(
|
|
IReadOnlyList<FinancialBillingDto> Items, int Page, int PageSize, long TotalCount, FinancialBillingTotals Totals);
|
|
|
|
public sealed record ExportFile(byte[] Content, string ContentType, string FileName);
|