QuoteProposal.cs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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 QuoteProposalExTax : CoreAggregate<QuoteProposal, QuoteProposalCostSheet, double>
  8. {
  9. public override Expression<Func<QuoteProposalCostSheet, double>> Aggregate => x => x.ExTax;
  10. public override AggregateCalculation Calculation => AggregateCalculation.Sum;
  11. public override Dictionary<Expression<Func<QuoteProposalCostSheet, object>>, Expression<Func<QuoteProposal, object>>> Links =>
  12. new Dictionary<Expression<Func<QuoteProposalCostSheet, object>>, Expression<Func<QuoteProposal, object>>>()
  13. {
  14. { QuoteProposalCostSheet => QuoteProposalCostSheet.Proposal.ID, QuoteProposal => QuoteProposal.ID }
  15. };
  16. }
  17. public class QuoteProposalTax : CoreAggregate<QuoteProposal, QuoteProposalCostSheet, double>
  18. {
  19. public override Expression<Func<QuoteProposalCostSheet, double>> Aggregate => x => x.Tax;
  20. public override AggregateCalculation Calculation => AggregateCalculation.Sum;
  21. public override Dictionary<Expression<Func<QuoteProposalCostSheet, object>>, Expression<Func<QuoteProposal, object>>> Links =>
  22. new Dictionary<Expression<Func<QuoteProposalCostSheet, object>>, Expression<Func<QuoteProposal, object>>>()
  23. {
  24. { QuoteProposalCostSheet => QuoteProposalCostSheet.Proposal.ID, QuoteProposal => QuoteProposal.ID }
  25. };
  26. }
  27. public class QuoteProposalIncTax : CoreAggregate<QuoteProposal, QuoteProposalCostSheet, double>
  28. {
  29. public override Expression<Func<QuoteProposalCostSheet, double>> Aggregate => x => x.IncTax;
  30. public override AggregateCalculation Calculation => AggregateCalculation.Sum;
  31. public override Dictionary<Expression<Func<QuoteProposalCostSheet, object>>, Expression<Func<QuoteProposal, object>>> Links =>
  32. new Dictionary<Expression<Func<QuoteProposalCostSheet, object>>, Expression<Func<QuoteProposal, object>>>()
  33. {
  34. { QuoteProposalCostSheet => QuoteProposalCostSheet.Proposal.ID, QuoteProposal => QuoteProposal.ID }
  35. };
  36. }
  37. public class QuoteProposalExTaxCondition : ICondition<QuoteProposal, double, double>
  38. {
  39. public Expression<Func<QuoteProposal, double>> Left => x => x.ExTax;
  40. public Condition Condition => Condition.Equals;
  41. public Expression<Func<QuoteProposal, double>> Right => x => 0.00F;
  42. public Expression<Func<QuoteProposal, double>> True => x => x.CostSheetsExTax;
  43. public Expression<Func<QuoteProposal, double>> False => x => x.ExTax;
  44. public ConditionType Type => ConditionType.Virtual;
  45. }
  46. public class QuoteProposalTaxCondition : ICondition<QuoteProposal, double, double>
  47. {
  48. public Expression<Func<QuoteProposal, double>> Left => x => x.ExTax;
  49. public Condition Condition => Condition.Equals;
  50. public Expression<Func<QuoteProposal, double>> Right => x => 0.00F;
  51. public Expression<Func<QuoteProposal, double>> True => x => x.CostSheetsTax;
  52. public Expression<Func<QuoteProposal, double>> False => x => x.Tax;
  53. public ConditionType Type => ConditionType.Virtual;
  54. }
  55. public class QuoteProposalIncTaxCondition : ICondition<QuoteProposal, double, double>
  56. {
  57. public Expression<Func<QuoteProposal, double>> Left => x => x.ExTax;
  58. public Condition Condition => Condition.Equals;
  59. public Expression<Func<QuoteProposal, double>> Right => x => 0.00F;
  60. public Expression<Func<QuoteProposal, double>> True => x => x.CostSheetsIncTax;
  61. public Expression<Func<QuoteProposal, double>> False => x => x.IncTax;
  62. public ConditionType Type => ConditionType.Virtual;
  63. }
  64. [UserTracking(typeof(Quote))]
  65. public class QuoteProposal : Entity, IRemotable, IPersistent, IQuoteProposal, ITaxable, IOneToMany<Quote>, ILicense<QuotesManagementLicense>
  66. {
  67. [RichTextEditor(Visible = Visible.Hidden)]
  68. [EditorSequence("Preamble", 1)]
  69. public string Preamble { get; set; }
  70. [RichTextEditor(Visible = Visible.Hidden)]
  71. [EditorSequence("Summary", 1)]
  72. public string Summary { get; set; }
  73. [NullEditor]
  74. [Aggregate(typeof(QuoteProposalExTax))]
  75. public double CostSheetsExTax { get; set; }
  76. [NullEditor]
  77. [Aggregate(typeof(QuoteProposalTax))]
  78. public double CostSheetsTax { get; set; }
  79. [NullEditor]
  80. [Aggregate(typeof(QuoteProposalIncTax))]
  81. public double CostSheetsIncTax { get; set; }
  82. [EditorSequence(4)]
  83. public TaxCodeLink TaxCode { get; set; }
  84. [NullEditor]
  85. [EntityRelationship(DeleteAction.Cascade)]
  86. public QuoteLink Quote { get; set; }
  87. [DateEditor(Visible = Visible.Default)]
  88. [EditorSequence(1)]
  89. public DateTime Date { get; set; }
  90. [TextBoxEditor(Visible = Visible.Default)]
  91. [EditorSequence(2)]
  92. public string Description { get; set; }
  93. [CurrencyEditor(Visible = Visible.Default, Editable = Editable.Hidden)]
  94. [Condition(typeof(QuoteProposalExTaxCondition))]
  95. public double ProposalExTax { get; set; }
  96. [CurrencyEditor(Visible = Visible.Optional, Editable = Editable.Hidden)]
  97. [Condition(typeof(QuoteProposalTaxCondition))]
  98. public double ProposalTax { get; set; }
  99. [CurrencyEditor(Visible = Visible.Optional, Editable = Editable.Hidden)]
  100. [Condition(typeof(QuoteProposalIncTaxCondition))]
  101. public double ProposalIncTax { get; set; }
  102. [CheckBoxEditor]
  103. [EditorSequence(7)]
  104. public bool Default { get; set; }
  105. [NullEditor]
  106. public long Sequence { get; set; }
  107. [DoubleEditor(Visible = Visible.Optional)]
  108. [EditorSequence(3)]
  109. public double ExTax { get; set; }
  110. [NullEditor]
  111. public double TaxRate { get; set; }
  112. [DoubleEditor(Visible = Visible.Optional, Editable = Editable.Disabled)]
  113. [EditorSequence(5)]
  114. public double Tax { get; set; }
  115. [DoubleEditor(Visible = Visible.Optional)]
  116. [EditorSequence(6)]
  117. public double IncTax { get; set; }
  118. static QuoteProposal()
  119. {
  120. LinkedProperties.Register<QuoteProposal, TaxCodeLink, double>(x => x.TaxCode, x => x.Rate, x => x.TaxRate);
  121. }
  122. }
  123. }