Add procurement domain models (PurchaseOrder, GoodsReceipt, PurchaseReturn)

This commit is contained in:
2026-08-24 16:51:22 +05:30
parent ac1b2fbc4b
commit c8d23afe59
7 changed files with 136 additions and 1 deletions
+5 -1
View File
@@ -19,7 +19,9 @@ namespace Distribution.Models
Transfer,
Damage,
Adjustment,
Load
Load,
PurchaseReceipt,
PurchaseReturn
}
public enum LoadingSheetStatus
@@ -38,4 +40,6 @@ namespace Distribution.Models
public enum CancelRequestType { VehicleBreakdown, DriverUnavailable, RouteIssue, Other }
public enum CancelRequestStatus { Pending, Approved, Rejected }
public enum PurchaseOrderStatus { Issued, PartiallyReceived, Received, Closed, Cancelled }
}
+26
View File
@@ -0,0 +1,26 @@
using System.ComponentModel.DataAnnotations.Schema;
namespace Distribution.Models
{
public class GoodsReceipt : Template
{
public Guid FK_PurchaseOrderId { get; set; }
[ForeignKey("FK_PurchaseOrderId")]
public PurchaseOrder PurchaseOrder { get; set; }
public Guid FK_ReceivedByUserId { get; set; }
/// <summary>
/// Warehouse the accepted quantities are received into. Not listed as a field in
/// docs/15_procurement.md's GoodsReceipt table, but required to write StockBalance/
/// StockMovement rows (both keyed by LocationId+LocationType) for the accepted quantities.
/// </summary>
public Guid FK_WarehouseId { get; set; }
[ForeignKey("FK_WarehouseId")]
public Warehouse Warehouse { get; set; }
public DateTime ReceivedAt { get; set; } = DateTime.Now;
public ICollection<GoodsReceiptItem> Items { get; set; } = [];
}
}
+21
View File
@@ -0,0 +1,21 @@
using System.ComponentModel.DataAnnotations.Schema;
namespace Distribution.Models
{
public class GoodsReceiptItem : Template
{
public Guid FK_GoodsReceiptId { get; set; }
[ForeignKey("FK_GoodsReceiptId")]
public GoodsReceipt GoodsReceipt { get; set; }
public Guid FK_PurchaseOrderItemId { get; set; }
[ForeignKey("FK_PurchaseOrderItemId")]
public PurchaseOrderItem PurchaseOrderItem { get; set; }
/// <summary>Added to warehouse stock.</summary>
public int AcceptedQuantity { get; set; }
/// <summary>Damaged/short at receipt, not added to stock.</summary>
public int RejectedQuantity { get; set; } = 0;
}
}
+19
View File
@@ -0,0 +1,19 @@
using System.ComponentModel.DataAnnotations.Schema;
namespace Distribution.Models
{
public class PurchaseOrder : Template
{
public Guid FK_SupplierId { get; set; }
[ForeignKey("FK_SupplierId")]
public Supplier Supplier { get; set; }
public Guid FK_CreatedByUserId { get; set; }
public PurchaseOrderStatus Status { get; set; } = PurchaseOrderStatus.Issued;
public string? CancelReason { get; set; }
public ICollection<PurchaseOrderItem> Items { get; set; } = [];
}
}
+32
View File
@@ -0,0 +1,32 @@
using System.ComponentModel.DataAnnotations.Schema;
namespace Distribution.Models
{
public class PurchaseOrderItem : Template
{
public Guid FK_PurchaseOrderId { get; set; }
[ForeignKey("FK_PurchaseOrderId")]
public PurchaseOrder PurchaseOrder { get; set; }
public Guid FK_ItemId { get; set; }
[ForeignKey("FK_ItemId")]
public Item Item { get; set; }
public int Quantity { get; set; }
/// <summary>Agreed cost per unit at the time the PO was issued.</summary>
public decimal UnitCost { get; set; }
/// <summary>Running total, incremented by createGoodsReceipt; drives PurchaseOrder.Status.</summary>
public int ReceivedQuantity { get; set; } = 0;
/// <summary>
/// Set by cancelPurchaseOrderLine. Outstanding qty for receiving purposes is
/// Quantity - ReceivedQuantity - CancelledQuantity.
/// </summary>
public int CancelledQuantity { get; set; } = 0;
/// <summary>True once this line is individually cancelled.</summary>
public bool IsCancelled { get; set; } = false;
}
}
+15
View File
@@ -0,0 +1,15 @@
using System.ComponentModel.DataAnnotations.Schema;
namespace Distribution.Models
{
public class PurchaseReturn : Template
{
public Guid FK_PurchaseOrderId { get; set; }
[ForeignKey("FK_PurchaseOrderId")]
public PurchaseOrder PurchaseOrder { get; set; }
public string Reason { get; set; }
public ICollection<PurchaseReturnItem> Items { get; set; } = [];
}
}
+18
View File
@@ -0,0 +1,18 @@
using System.ComponentModel.DataAnnotations.Schema;
namespace Distribution.Models
{
public class PurchaseReturnItem : Template
{
public Guid FK_PurchaseReturnId { get; set; }
[ForeignKey("FK_PurchaseReturnId")]
public PurchaseReturn PurchaseReturn { get; set; }
public Guid FK_ItemId { get; set; }
[ForeignKey("FK_ItemId")]
public Item Item { get; set; }
/// <summary>Returned quantity, decremented from warehouse stock.</summary>
public int Quantity { get; set; }
}
}