39 lines
1.6 KiB
C#
39 lines
1.6 KiB
C#
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
namespace Distribution.Models
|
|
{
|
|
public class Order : Template
|
|
{
|
|
public Guid? FK_SaleId { get; set; }
|
|
[ForeignKey("FK_SaleId")]
|
|
public Sale? Sale { get; set; }
|
|
|
|
public Guid CreatedByUserId { get; set; }
|
|
[ForeignKey("CreatedByUserId")]
|
|
public User CreatedByUser { get; set; }
|
|
|
|
/// <summary>Set once an Invoice is created for this PO (either mode). No DB-level FK
|
|
/// constraint — configured explicitly in Fluent API per order_invoice_lifecycle.md.</summary>
|
|
public Guid? InvoiceId { get; set; }
|
|
|
|
public DateTime OrderDate { get; set; }
|
|
public Guid FK_StoreId { get; set; }
|
|
[ForeignKey("FK_StoreId")]
|
|
public Store Store { get; set; }
|
|
public decimal TotalAmount { get; set; }
|
|
public OrderStatus Status { get; set; } = OrderStatus.Pending;
|
|
public DateTime? FulfilledAt { get; set; }
|
|
|
|
/// <summary>Null = Shop PO (items editable). Set = Confirmed PO (items locked). Not modeled
|
|
/// as an explicit field in order_invoice_lifecycle.md's diagram, but required to implement
|
|
/// its Business Rule 1 (item edits gated on confirmation) independent of Invoice existing —
|
|
/// Mode B confirms a PO with no Invoice at all.</summary>
|
|
public DateTime? ConfirmedAt { get; set; }
|
|
public Guid? ConfirmedByUserId { get; set; }
|
|
[ForeignKey("ConfirmedByUserId")]
|
|
public User? ConfirmedByUser { get; set; }
|
|
|
|
public ICollection<OrderItem> OrderItems { get; set; } = new List<OrderItem>();
|
|
}
|
|
}
|