ProductInstance.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using InABox.Core;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq.Expressions;
  5. using System.Text;
  6. namespace Comal.Classes
  7. {
  8. public class ProductInstanceFreeStockAggregate : CoreAggregate<ProductInstance, StockMovement, double>
  9. {
  10. public override Expression<Func<StockMovement, double>> Aggregate => x => x.Qty;
  11. public override Filter<StockMovement> Filter => new Filter<StockMovement>(x => x.Job).NotLinkValid();
  12. public override Dictionary<Expression<Func<StockMovement, object>>, Expression<Func<ProductInstance, object>>>
  13. Links =>
  14. new Dictionary<Expression<Func<StockMovement, object>>, Expression<Func<ProductInstance, object>>>()
  15. {
  16. { StockMovement => StockMovement.Product.ID, Instance => Instance.Product.ID },
  17. { StockMovement => StockMovement.Style.ID, Instance => Instance.Style.ID },
  18. { StockMovement => StockMovement.Dimensions.UnitSize, Instance => Instance.Dimensions.UnitSize },
  19. };
  20. public override AggregateCalculation Calculation => AggregateCalculation.Sum;
  21. }
  22. public class ProductInstance : DimensionedEntity<StockDimensions>, IRemotable, IPersistent, IProductInstance,
  23. ISequenceable, ILicense<ProductManagementLicense>
  24. {
  25. [NullEditor] public long Sequence { get; set; }
  26. [NullEditor] public ProductLink Product { get; set; }
  27. [EditorSequence(1)]
  28. public ProductStyleLink Style { get; set; }
  29. [EditorSequence(2)]
  30. [RequiredColumn]
  31. [DimensionsEditor(typeof(StockDimensions), AllowEditingUnit = false)]
  32. public override StockDimensions Dimensions { get; set; }
  33. [IntegerEditor]
  34. [EditorSequence(3)]
  35. [LoggableProperty]
  36. public int MinimumStockLevel { get; set; }
  37. [Aggregate(typeof(ProductInstanceFreeStockAggregate))]
  38. [DoubleEditor(Editable = Editable.Hidden)]
  39. public double FreeStock { get; set; }
  40. [CurrencyEditor(Visible = Visible.Optional)]
  41. [EditorSequence(5)]
  42. [LoggableProperty]
  43. public double NettCost { get; set; }
  44. [CurrencyEditor(Visible = Visible.Optional)]
  45. [EditorSequence(4)]
  46. [LoggableProperty]
  47. public double AverageCost { get; set; }
  48. [CurrencyEditor(Visible = Visible.Optional, Editable = Editable.Disabled)]
  49. [EditorSequence(5)]
  50. [LoggableProperty]
  51. public double LastCost { get; set; }
  52. }
  53. }