mirror of
https://github.com/stokebob/BealeEngineering.git
synced 2026-03-21 07:37:16 +00:00
74 lines
2.1 KiB
C#
74 lines
2.1 KiB
C#
using BealeEngineering.Core.Logic.Utilities;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Text;
|
|
using System.Linq;
|
|
using System.ComponentModel;
|
|
|
|
namespace BealeEngineering.Core.Model.Client
|
|
{
|
|
public class PurchaseOrder : PurchaseOrderHeader
|
|
{
|
|
public int OrderLineCount
|
|
{
|
|
get
|
|
{
|
|
if (OrderLineList == null) { return 0; }
|
|
else { return OrderLineList.Count; }
|
|
}
|
|
}
|
|
|
|
public List<PurchaseOrderLine> OrderLineList { get; set; } = new List<PurchaseOrderLine>();
|
|
|
|
public class PurchaseOrderLine
|
|
{
|
|
int? clientPurchaseOrderLineId = null;
|
|
|
|
public int ClientPurchaseOrderLineID
|
|
{
|
|
get { return clientPurchaseOrderLineId.GetValueOrDefault(); }
|
|
set { clientPurchaseOrderLineId = value; }
|
|
}
|
|
|
|
public bool ClientPurchaseOrderLineIDIsSet
|
|
{
|
|
get
|
|
{
|
|
if (clientPurchaseOrderLineId == null || clientPurchaseOrderLineId < 1) { return false; }
|
|
else { return true; }
|
|
}
|
|
}
|
|
|
|
[Required()]
|
|
public int LineNumber { get; set; }
|
|
|
|
public string ProjectWorkNumber { get; set; }
|
|
|
|
[Required()]
|
|
public string Description { get; set; }
|
|
|
|
[Required()]
|
|
public decimal LineNetAmount { get; set; }
|
|
}
|
|
|
|
public override IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
|
{
|
|
var results = base.Validate(validationContext).ToList();
|
|
|
|
if (OrderLineCount == 0)
|
|
{
|
|
var result = new ValidationResult("No order lines set");
|
|
results.Add(result);
|
|
}
|
|
|
|
if (OrderTotal != OrderLineList.Sum(x => x.LineNetAmount))
|
|
{
|
|
var result = new ValidationResult("Order total does not equal sum of line list.");
|
|
results.Add(result);
|
|
}
|
|
return results;
|
|
}
|
|
}
|
|
}
|