QuoteCostSheet.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Linq.Expressions;
  5. using InABox.Core;
  6. namespace Comal.Classes
  7. {
  8. public class QuoteCostSheetExTax : CoreAggregate<QuoteCostSheet, QuoteCostSheetItem, double>
  9. {
  10. public override Expression<Func<QuoteCostSheetItem, double>> Aggregate => x => x.ExTax;
  11. public override AggregateCalculation Calculation => AggregateCalculation.Sum;
  12. public override Dictionary<Expression<Func<QuoteCostSheetItem, object>>, Expression<Func<QuoteCostSheet, object>>> Links =>
  13. new Dictionary<Expression<Func<QuoteCostSheetItem, object>>, Expression<Func<QuoteCostSheet, object>>>()
  14. {
  15. { QuoteCostSheetItem => QuoteCostSheetItem.CostSheet.ID, QuoteCostSheet => QuoteCostSheet.ID }
  16. };
  17. }
  18. public class QuoteCostSheetTax : CoreAggregate<QuoteCostSheet, QuoteCostSheetItem, double>
  19. {
  20. public override Expression<Func<QuoteCostSheetItem, double>> Aggregate => x => x.Tax;
  21. public override AggregateCalculation Calculation => AggregateCalculation.Sum;
  22. public override Dictionary<Expression<Func<QuoteCostSheetItem, object>>, Expression<Func<QuoteCostSheet, object>>> Links =>
  23. new Dictionary<Expression<Func<QuoteCostSheetItem, object>>, Expression<Func<QuoteCostSheet, object>>>()
  24. {
  25. { QuoteCostSheetItem => QuoteCostSheetItem.CostSheet.ID, QuoteCostSheet => QuoteCostSheet.ID }
  26. };
  27. }
  28. public class QuoteCostSheetIncTax : CoreAggregate<QuoteCostSheet, QuoteCostSheetItem, double>
  29. {
  30. public override Expression<Func<QuoteCostSheetItem, double>> Aggregate => x => x.IncTax;
  31. public override AggregateCalculation Calculation => AggregateCalculation.Sum;
  32. public override Dictionary<Expression<Func<QuoteCostSheetItem, object>>, Expression<Func<QuoteCostSheet, object>>> Links =>
  33. new Dictionary<Expression<Func<QuoteCostSheetItem, object>>, Expression<Func<QuoteCostSheet, object>>>()
  34. {
  35. { QuoteCostSheetItem => QuoteCostSheetItem.CostSheet.ID, QuoteCostSheet => QuoteCostSheet.ID }
  36. };
  37. }
  38. [UserTracking(typeof(Quote))]
  39. public class QuoteCostSheet : Entity, IRemotable, IPersistent, IQuoteCostSheet, ILicense<QuotesManagementLicense>,
  40. IStringAutoIncrement<QuoteCostSheet>
  41. {
  42. [NullEditor]
  43. public long Sequence { get; set; }
  44. #region IAutoIncrement
  45. public Expression<Func<QuoteCostSheet, String>> AutoIncrementField() => x => x.Number;
  46. public String AutoIncrementPrefix() => "QC";
  47. public virtual string AutoIncrementFormat() => "{0:D6}";
  48. public Filter<QuoteCostSheet> AutoIncrementFilter() => null;
  49. #endregion
  50. [NullEditor]
  51. [Obsolete("Replaced with Parent")]
  52. [EntityRelationship(DeleteAction.Cascade)]
  53. public QuoteLink Quote { get; set; }
  54. [CodeEditor]
  55. [EditorSequence(1)]
  56. public string Number { get; set; }
  57. [TextBoxEditor(Visible = Visible.Default)]
  58. [EditorSequence(2)]
  59. public string Description { get; set; }
  60. private class QuoteCostSheetFormLookup : LookupDefinitionGenerator<QuoteForm, QuoteCostSheet>
  61. {
  62. public override Filter<QuoteForm> DefineFilter(QuoteCostSheet[] items)
  63. {
  64. if (items?.Any() != true)
  65. return LookupFactory.DefineFilter<QuoteForm>();
  66. return new Filter<QuoteForm>(x => x.Parent.ID).IsEqualTo(items.First().Quote.ID);
  67. }
  68. public override Columns<QuoteCostSheet> DefineFilterColumns()
  69. => new Columns<QuoteCostSheet>(ColumnTypeFlags.Required);
  70. }
  71. [LookupDefinition(typeof(QuoteCostSheetFormLookup))]
  72. [EditorSequence(3)]
  73. public QuoteFormLink Form { get; set; }
  74. [EntityRelationship(DeleteAction.SetNull)]
  75. [EditorSequence(4)]
  76. public CostSheetLink CostSheet { get; set; }
  77. [CurrencyEditor(Visible = Visible.Default, Editable = Editable.Hidden, Summary = Summary.Sum)]
  78. [Aggregate(typeof(QuoteCostSheetExTax))]
  79. public double ExTax { get; set; }
  80. [CurrencyEditor(Visible = Visible.Optional, Editable = Editable.Hidden, Summary = Summary.Sum)]
  81. [Aggregate(typeof(QuoteCostSheetTax))]
  82. public double Tax { get; set; }
  83. [CurrencyEditor(Visible = Visible.Optional, Editable = Editable.Hidden, Summary = Summary.Sum)]
  84. [Aggregate(typeof(QuoteCostSheetIncTax))]
  85. public double IncTax { get; set; }
  86. }
  87. }