123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- using System;
- using System.Collections.Generic;
- using System.Linq.Expressions;
- using InABox.Core;
- namespace Comal.Classes
- {
-
- public class StockLocationHoldings : CoreAggregate<StockLocation, StockMovement, double>
- {
- public override Expression<Func<StockMovement, double>> Aggregate => x => x.Qty;
- public override Filter<StockMovement> Filter => null;
- public override Dictionary<Expression<Func<StockMovement, object>>, Expression<Func<StockLocation, object>>> Links =>
- new Dictionary<Expression<Func<StockMovement, object>>, Expression<Func<StockLocation, object>>>()
- {
- { StockMovement => StockMovement.Location.ID, StockLocation => StockLocation.ID }
- };
- public override AggregateCalculation Calculation => AggregateCalculation.Maximum;
- }
-
- public class StockLocationLastStocktake : CoreAggregate<StockLocation, StockMovement, DateTime>
- {
- public override Expression<Func<StockMovement, DateTime>> Aggregate => x => x.Date;
- public override Filter<StockMovement> Filter => new Filter<StockMovement>(x => x.Batch).LinkValid().And(x => x.Batch.Type)
- .IsEqualTo(StockMovementBatchType.Stocktake);
- public override Dictionary<Expression<Func<StockMovement, object>>, Expression<Func<StockLocation, object>>> Links =>
- new Dictionary<Expression<Func<StockMovement, object>>, Expression<Func<StockLocation, object>>>()
- {
- { StockMovement => StockMovement.Location.ID, StockLocation => StockLocation.ID }
- };
- public override AggregateCalculation Calculation => AggregateCalculation.Maximum;
- }
-
- [UserTracking(typeof(StockMovement))]
- public class StockLocation : Entity, IRemotable, IPersistent, IStockLocation, ILicense<WarehouseLicense>, IExportable, IImportable
- {
- [EntityRelationship(DeleteAction.SetNull)]
- [EditorSequence(3)]
- public StockWarehouseLink Warehouse { get; set; }
- [EntityRelationship(DeleteAction.SetNull)]
- [EditorSequence(4)]
- public StockAreaLink Area { get; set; }
- /// <summary>
- /// Is the location a "shelf" (ie permanent) or "pack" (ie transient)
- /// </summary>
- [EnumLookupEditor(typeof(StockLocationType))]
- [EditorSequence(6)]
- public StockLocationType Type { get; set; }
- /// <summary>
- /// Mark this location as the default receival location for the warehouse
- /// </summary>
- [EditorSequence(8)]
- public bool Default { get; set; }
- /// <summary>
- /// Mark this location as a favourite which shows up in Timebench Transfer module for quick selection
- /// </summary>
- [EditorSequence(9)]
- public bool Favourite { get; set; }
-
- [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; }
- /// <summary>
- /// Is the Stock Location Active?
- /// </summary>
- [EditorSequence(7)]
- public bool Active { get; set; }
-
- protected override void Init()
- {
- base.Init();
- Area = new StockAreaLink();
- Warehouse = new StockWarehouseLink();
- Job = new JobLink();
- Favourite = false;
- }
- }
- }
|