From e3d483737974976103a082a73e429da70aef48bd Mon Sep 17 00:00:00 2001 From: DeepnaPooja Date: Wed, 16 Sep 2026 16:25:52 +0530 Subject: [PATCH] Add order invoice fields --- Distribution/Models/Order.cs | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/Distribution/Models/Order.cs b/Distribution/Models/Order.cs index ef7448f..99ed0e9 100644 --- a/Distribution/Models/Order.cs +++ b/Distribution/Models/Order.cs @@ -1,12 +1,20 @@ -using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations.Schema; namespace Distribution.Models { public class Order : Template { - public Guid FK_SaleId { get; set; } + public Guid? FK_SaleId { get; set; } [ForeignKey("FK_SaleId")] - public Sale Sale { get; set; } + public Sale? Sale { get; set; } + + public Guid CreatedByUserId { get; set; } + [ForeignKey("CreatedByUserId")] + public User CreatedByUser { get; set; } + + /// 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. + public Guid? InvoiceId { get; set; } public DateTime OrderDate { get; set; } public Guid FK_StoreId { get; set; } @@ -16,6 +24,15 @@ namespace Distribution.Models public OrderStatus Status { get; set; } = OrderStatus.Pending; public DateTime? FulfilledAt { get; set; } + /// 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. + public DateTime? ConfirmedAt { get; set; } + public Guid? ConfirmedByUserId { get; set; } + [ForeignKey("ConfirmedByUserId")] + public User? ConfirmedByUser { get; set; } + public ICollection OrderItems { get; set; } = new List(); } }