ProductLookups.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System;
  2. using InABox.Core;
  3. namespace Comal.Classes
  4. {
  5. public class ProductLookups : EntityLookup<Product>, ILookupDefinition<Product, StockMovement>, ILookupDefinition<Product, EmployeeProduct>
  6. {
  7. // EmployeeProduct records also require a Default Location to pull from
  8. public Filter<Product> DefineFilter(EmployeeProduct[] items)
  9. {
  10. return DefineFilter().And(x => x.NonStock).IsEqualTo(false).And(x => x.DefaultLocation).LinkValid();
  11. }
  12. // You should not be able to create a stock movement for a non-stock item
  13. public Filter<Product> DefineFilter(StockMovement[] items)
  14. {
  15. return DefineFilter().And(x => x.NonStock).IsEqualTo(false);
  16. }
  17. public override Columns<Product> DefineColumns()
  18. {
  19. return new Columns<Product>(
  20. x => x.ID,
  21. x => x.Code,
  22. x => x.Name
  23. );
  24. }
  25. public override Filter<Product> DefineFilter()
  26. {
  27. return new Filter<Product>(x => x.Expired).IsEqualTo(DateTime.MinValue);
  28. }
  29. public override SortOrder<Product> DefineSortOrder()
  30. {
  31. return new SortOrder<Product>(x => x.Code);
  32. }
  33. }
  34. }