41 lines
2.7 KiB
C#
41 lines
2.7 KiB
C#
using AyCode.Core.Serializers.Attributes;
|
|
using AyCode.Core.Serializers.Toons;
|
|
using FruitBank.Common.Enums;
|
|
using LinqToDB.Mapping;
|
|
using Mango.Nop.Core.Entities;
|
|
|
|
namespace FruitBank.Common.Entities;
|
|
|
|
[AcBinarySerializable(false, true, false, true, false, false)]
|
|
[Table(Name = FruitBankConstClient.PreOrderDbTableName)]
|
|
[System.ComponentModel.DataAnnotations.Schema.Table(FruitBankConstClient.PreOrderDbTableName)]
|
|
[ToonDescription("Customer advance order placed before the goods physically arrive", Purpose = "Header of a customer pre-order against an upcoming inbound delivery. When a supplier shipping document confirms incoming stock, pending items are allocated first-come-first-served by PreOrderId (only within the conversion window — PreOrderConversionWindowDays, 4 days, of DateOfReceipt) and the preorder is converted into a real NopCommerce Order once any quantity is fulfilled. Preorders past DateOfReceipt are swept closed, dropping any still-Pending items.")]
|
|
public sealed class PreOrder : MgEntityBase
|
|
{
|
|
[ToonDescription(Purpose = "FK to the nopCommerce Customer who placed the preorder.")]
|
|
public int CustomerId { get; set; }
|
|
|
|
[ToonDescription(Purpose = "nopCommerce multi-store scope.")]
|
|
public int StoreId { get; set; }
|
|
|
|
[ToonDescription(Purpose = "Requested delivery date. Drives the conversion window (only preorders within PreOrderConversionWindowDays — 4 days — of this date are eligible for allocation) and the expiry sweep — once this date is past, any still-Pending items are Dropped.")]
|
|
public DateTime DateOfReceipt { get; set; }
|
|
|
|
[ToonDescription(Purpose = "Header lifecycle: Pending / Confirmed (all items Fulfilled) / PartiallyFulfilled (some Dropped or partial, none left Pending) / Cancelled.",
|
|
BusinessRule = "set by RefreshPreOrderStatusAsync from item states: items.All(Fulfilled) => Confirmed; (any Dropped or PartiallyFulfilled) && none Pending => PartiallyFulfilled; else Pending. Cancelled is set explicitly.")]
|
|
public PreOrderStatus Status { get; set; }
|
|
|
|
[ToonDescription(Purpose = "Optional free-text note entered by the customer when placing the preorder.")]
|
|
public string? CustomerNote { get; set; }
|
|
|
|
public DateTime CreatedOnUtc { get; set; }
|
|
|
|
[ToonDescription(Purpose = "Bumped to UtcNow on every status / allocation change.")]
|
|
public DateTime UpdatedOnUtc { get; set; }
|
|
|
|
[ToonDescription(Purpose = "FK to the real NopCommerce Order created from this preorder. Null until the first item is fulfilled; set once on first conversion and reused so subsequent shipping documents append items to the same order.")]
|
|
public int? OrderId { get; set; }
|
|
|
|
public List<PreOrderItem> PreOrderItems { get; set; } = [];
|
|
}
|