QuoteContract.cs 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 QuoteContractExTax : CoreAggregate<QuoteContract, QuoteContractProposal, double>
  9. {
  10. public override Expression<Func<QuoteContractProposal, double>> Aggregate => x => x.Proposal.ProposalExTax;
  11. public override AggregateCalculation Calculation => AggregateCalculation.Sum;
  12. public override Dictionary<Expression<Func<QuoteContractProposal, object>>, Expression<Func<QuoteContract, object>>> Links =>
  13. new Dictionary<Expression<Func<QuoteContractProposal, object>>, Expression<Func<QuoteContract, object>>>()
  14. {
  15. { QuoteContractProposal => QuoteContractProposal.Contract.ID, QuoteContract => QuoteContract.ID }
  16. };
  17. }
  18. public class QuoteContractTax : CoreAggregate<QuoteContract, QuoteContractProposal, double>
  19. {
  20. public override Expression<Func<QuoteContractProposal, double>> Aggregate => x => x.Proposal.ProposalTax;
  21. public override AggregateCalculation Calculation => AggregateCalculation.Sum;
  22. public override Dictionary<Expression<Func<QuoteContractProposal, object>>, Expression<Func<QuoteContract, object>>> Links =>
  23. new Dictionary<Expression<Func<QuoteContractProposal, object>>, Expression<Func<QuoteContract, object>>>()
  24. {
  25. { QuoteContractProposal => QuoteContractProposal.Contract.ID, QuoteContract => QuoteContract.ID }
  26. };
  27. }
  28. public class QuoteContractIncTax : CoreAggregate<QuoteContract, QuoteContractProposal, double>
  29. {
  30. public override Expression<Func<QuoteContractProposal, double>> Aggregate => x => x.Proposal.ProposalIncTax;
  31. public override AggregateCalculation Calculation => AggregateCalculation.Sum;
  32. public override Dictionary<Expression<Func<QuoteContractProposal, object>>, Expression<Func<QuoteContract, object>>> Links =>
  33. new Dictionary<Expression<Func<QuoteContractProposal, object>>, Expression<Func<QuoteContract, object>>>()
  34. {
  35. { QuoteContractProposal => QuoteContractProposal.Contract.ID, QuoteContract => QuoteContract.ID }
  36. };
  37. }
  38. [UserTracking(typeof(Quote))]
  39. public class QuoteContract : Entity, IRemotable, IPersistent, IQuoteContract, ILicense<QuotesManagementLicense>, IOneToMany<Quote>
  40. {
  41. [NullEditor]
  42. [EntityRelationship(DeleteAction.Cascade)]
  43. public QuoteLink Quote { get; set; }
  44. [TextBoxEditor]
  45. [EditorSequence(1)]
  46. public string Description { get; set; }
  47. [CurrencyEditor(Editable = Editable.Hidden, Summary = Summary.Sum)]
  48. [Aggregate(typeof(QuoteContractExTax))]
  49. public double ExTax { get; set; }
  50. [CurrencyEditor(Editable = Editable.Hidden, Summary = Summary.Sum)]
  51. [Aggregate(typeof(QuoteContractTax))]
  52. public double Tax { get; set; }
  53. [CurrencyEditor(Visible = Visible.Default, Editable = Editable.Hidden, Summary = Summary.Sum)]
  54. [Aggregate(typeof(QuoteContractIncTax))]
  55. public double IncTax { get; set; }
  56. [DateTimeEditor]
  57. [EditorSequence(2)]
  58. public DateTime Confirmed { get; set; }
  59. private class QuoteContractJobScopeLookup : LookupDefinitionGenerator<JobScope, QuoteContract>
  60. {
  61. public override Filter<JobScope> DefineFilter(QuoteContract[] items)
  62. {
  63. if (items?.Any() != true)
  64. return LookupFactory.DefineFilter<JobScope>();
  65. return new Filter<JobScope>(x => x.Job.ID).IsEqualTo(items.First().Quote.Job.ID);
  66. }
  67. public override Columns<QuoteContract> DefineFilterColumns()
  68. => new Columns<QuoteContract>(ColumnTypeFlags.Required);
  69. }
  70. [LookupDefinition(typeof(QuoteContractJobScopeLookup))]
  71. [EditorSequence(3)]
  72. public JobScopeLink JobScope { get; set; }
  73. }
  74. }