using System; using System.Collections.Generic; using System.Linq.Expressions; using InABox.Core; namespace Comal.Classes { public class DeliveryItemDocumentCount : CoreAggregate { public override Expression> Aggregate => x => x.ID; public override AggregateCalculation Calculation => AggregateCalculation.Count; public override Dictionary>, Expression>> Links => new Dictionary>, Expression>>() { { DeliveryDocument => DeliveryDocument.EntityLink.ID, DeliveryItem => DeliveryItem.Delivery.ID } }; } public class DeliveryItemArea : IFormula { public Expression> Value => x => x.Height; public Expression>[] Modifiers => new Expression>[] { x => x.Width, x => 0.000001F }; public FormulaOperator Operator => FormulaOperator.Multiply; public FormulaType Type => FormulaType.Virtual; } public class DeliveryItemVolume : IFormula { public Expression> Value => x => x.Height; public Expression>[] Modifiers => new Expression>[] { x => x.Width, x => x.Length }; public FormulaOperator Operator => FormulaOperator.Multiply; public FormulaType Type => FormulaType.Virtual; } public enum DeliveryItemType { ManufacturedItem, RequisitionItem, TreatmentItem, EquipmentItem, OtherItem } [UserTracking(typeof(Delivery))] [Caption("Delivery Items")] public class DeliveryItem : Entity, IPersistent, IRemotable, IOneToMany, IOneToMany, IOneToMany, IOneToMany, ILicense, IExportable { // If Packet then Packet.Title // If requisition then Requisition.Title public string Title { get; set; } // if PAcket, then Packet.Description // If Requitision then BOX X OF Y [TextBoxEditor] public string Description { get; set; } = ""; // If Packet, then Packet.Refreence // If Requisition then Requi.Employee [TextBoxEditor] public string Reference { get; set; } [TextBoxEditor(Editable = Editable.Hidden)] [SecondaryIndex] public string Barcode { get; set; } public int Sequence { get; set; } public string Piece { get; set; } [SecondaryIndex] public DateTime DeliveredDate { get; set; } public DateTime InstalledDate { get; set; } public DateTime DueDate { get; set; } public JobLink JobLink { get; set; } private class ManufacturingPacketLookup : LookupDefinitionGenerator { // Overriding the default ManufacturingPacket lookup to have no restrictions. public override Filter DefineFilter(DeliveryItem[] items) { return new Filter().All(); } } [LookupDefinition(typeof(ManufacturingPacketLookup))] [EntityRelationship(DeleteAction.Cascade)] public ManufacturingPacketLink ManufacturingPacketLink { get; set; } public RequisitionLink RequisitionLink { get; set; } public SetoutLink SetoutLink { get; set; } public ShipmentLink ShipmentLink { get; set; } [CodeEditor(Editable = Editable.Disabled)] public string ShipmentCode { get; set; } //public PackableList CustomAttributes { get; set; } [MemoEditor] public string Attributes { get; set; } = ""; public Location Location { get; set; } public DeliveryLink Delivery { get; set; } public PurchaseOrderItemLink OrderItem { get; set; } public double Cost { get; set; } public double Height { get; set; } public double Width { get; set; } public double Length { get; set; } [DoubleEditor(Editable = Editable.Hidden)] [Formula(typeof(DeliveryItemArea))] public double Area { get; set; } [DoubleEditor(Editable = Editable.Hidden)] [Formula(typeof(DeliveryItemVolume))] public double Volume { get; set; } [Aggregate(typeof(DeliveryItemDocumentCount))] [IntegerEditor(Editable = Editable.Hidden)] public int Documents { get; set; } [EnumLookupEditor(typeof(DeliveryItemType))] public DeliveryItemType Type { get; set; } = DeliveryItemType.OtherItem; public override string ToString() { return string.Format("{0} : {1}", Barcode, Title); } static DeliveryItem() { LinkedProperties.Register(x=>x.ShipmentLink, x => x.Code, x => x.ShipmentCode); } } }