using System; using System.Collections.Generic; using System.Linq.Expressions; using InABox.Core; namespace Comal.Classes { public class StockLocationHoldings : CoreAggregate { public override Expression> Aggregate => x => x.Product.ID; public override Filter Filter => new Filter(x=>x.Value).IsGreaterThan(0.000001).Or(x=>x.Value).IsLessThan(-0.000001); public override Dictionary>, Expression>> Links => new Dictionary>, Expression>>() { { StockHolding => StockHolding.Location.ID, StockLocation => StockLocation.ID }, }; public override AggregateCalculation Calculation => AggregateCalculation.Count; } public class StockLocationLastStocktake : CoreAggregate { public override Expression> Aggregate => x => x.Date; public override Filter Filter => new Filter(x => x.Batch).LinkValid().And(x => x.Batch.Type) .IsEqualTo(StockMovementBatchType.Stocktake); public override Dictionary>, Expression>> Links => new Dictionary>, Expression>>() { { StockMovement => StockMovement.Location.ID, StockLocation => StockLocation.ID } }; public override AggregateCalculation Calculation => AggregateCalculation.Maximum; } [UserTracking(typeof(StockMovement))] public class StockLocation : Entity, IRemotable, IPersistent, IStockLocation, ILicense, IExportable, IImportable { [EntityRelationship(DeleteAction.SetNull)] [EditorSequence(3)] public StockWarehouseLink Warehouse { get; set; } [EntityRelationship(DeleteAction.SetNull)] [EditorSequence(4)] public StockAreaLink Area { get; set; } /// /// Is the location a "shelf" (ie permanent) or "pack" (ie transient) /// [EnumLookupEditor(typeof(StockLocationType))] [EditorSequence(6)] public StockLocationType Type { get; set; } /// /// Mark this location as the default receival location for the warehouse /// [EditorSequence(8)] public bool Default { get; set; } /// /// Mark this location as a favourite which shows up in Timebench Transfer module for quick selection /// [EditorSequence(9)] public bool Favourite { get; set; } = false; [Aggregate(typeof(StockLocationLastStocktake))] [NullEditor] public DateTime LastStocktake { get; set; } [UniqueCodeEditor(Visible = Visible.Default, Editable = Editable.Enabled)] [EditorSequence(1)] public string Code { get; set; } [TextBoxEditor] [EditorSequence(2)] public string Description { get; set; } [EditorSequence(5)] public JobLink Job { get; set; } [Aggregate(typeof(StockLocationHoldings))] [DoubleEditor(Editable = Editable.Hidden)] [EditorSequence(6)] public double Holdings { get; set; } /// /// Is the Stock Location Active? /// [EditorSequence(7)] public bool Active { get; set; } } }