CostSheet.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq.Expressions;
  4. using InABox.Core;
  5. namespace Comal.Classes
  6. {
  7. public class CostSheetDocumentCount : CoreAggregate<CostSheet, CostSheetDocument, Guid>
  8. {
  9. public override Expression<Func<CostSheetDocument, Guid>> Aggregate => x => x.ID;
  10. public override AggregateCalculation Calculation => AggregateCalculation.Count;
  11. public override Dictionary<Expression<Func<CostSheetDocument, object>>, Expression<Func<CostSheet, object>>> Links =>
  12. new Dictionary<Expression<Func<CostSheetDocument, object>>, Expression<Func<CostSheet, object>>>()
  13. {
  14. { CostSheetDocument => CostSheetDocument.EntityLink.ID, Delivery => Delivery.ID }
  15. };
  16. }
  17. [UserTracking(typeof(Quote))]
  18. public class CostSheet : Entity, ICostSheet, IRemotable, IPersistent, IIssues, ILicense<QuotesManagementLicense>
  19. {
  20. [UniqueCodeEditor(Visible = Visible.Default, Editable = Editable.Enabled)]
  21. [EditorSequence(1)]
  22. public string Code { get; set; }
  23. [TextBoxEditor]
  24. [EditorSequence(2)]
  25. public string Description { get; set; }
  26. [EntityRelationship(DeleteAction.SetNull)]
  27. [EditorSequence(3)]
  28. public CostSheetTypeLink Type { get; set; }
  29. [EntityRelationship(DeleteAction.SetNull)]
  30. [EditorSequence(4)]
  31. public CostSheetBrandLink Brand { get; set; }
  32. [CheckBoxEditor]
  33. [EditorSequence(5)]
  34. public bool Active { get; set; } = true;
  35. [Aggregate(typeof(CostSheetDocumentCount))]
  36. [IntegerEditor(Editable = Editable.Hidden)]
  37. [EditorSequence(6)]
  38. public int Documents { get; set; }
  39. [NullEditor]
  40. public string Issues { get; set; }
  41. [EditorSequence(6)]
  42. public DigitalFormLink Form { get; set; }
  43. public override string ToString()
  44. {
  45. return string.Format("{0}: {1}", Code, Description);
  46. }
  47. }
  48. public class DigitalFormCostSheetLookup : LookupDefinitionGenerator<DigitalForm, CostSheet>
  49. {
  50. public override Filter<DigitalForm> DefineFilter(CostSheet[] items)
  51. {
  52. return new Filter<DigitalForm>(x => x.Active).IsEqualTo(true).And(x => x.AppliesTo).IsEqualTo(nameof(Quote));
  53. }
  54. public override Columns<CostSheet> DefineFilterColumns()
  55. => new Columns<CostSheet>(ColumnTypeFlags.Required);
  56. }
  57. }