BillAggregates.cs 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 BillExTax : CoreAggregate<Bill, BillLine, double>
  8. {
  9. public override Expression<Func<BillLine, double>> Aggregate => x => x.ExTax;
  10. public override AggregateCalculation Calculation => AggregateCalculation.Sum;
  11. public override Dictionary<Expression<Func<BillLine, object>>, Expression<Func<Bill, object>>> Links =>
  12. new Dictionary<Expression<Func<BillLine, object>>, Expression<Func<Bill, object>>>()
  13. {
  14. { BillLine => BillLine.BillLink.ID, Bill => Bill.ID }
  15. };
  16. }
  17. public class BillTax : CoreAggregate<Bill, BillLine, double>
  18. {
  19. public override Expression<Func<BillLine, double>> Aggregate => x => x.Tax;
  20. public override AggregateCalculation Calculation => AggregateCalculation.Sum;
  21. public override Dictionary<Expression<Func<BillLine, object>>, Expression<Func<Bill, object>>> Links =>
  22. new Dictionary<Expression<Func<BillLine, object>>, Expression<Func<Bill, object>>>()
  23. {
  24. { BillLine => BillLine.BillLink.ID, Bill => Bill.ID }
  25. };
  26. }
  27. public class BillIncTax : CoreAggregate<Bill, BillLine, double>
  28. {
  29. public override Expression<Func<BillLine, double>> Aggregate => x => x.IncTax;
  30. public override AggregateCalculation Calculation => AggregateCalculation.Sum;
  31. public override Dictionary<Expression<Func<BillLine, object>>, Expression<Func<Bill, object>>> Links =>
  32. new Dictionary<Expression<Func<BillLine, object>>, Expression<Func<Bill, object>>>()
  33. {
  34. { BillLine => BillLine.BillLink.ID, Bill => Bill.ID }
  35. };
  36. }
  37. public class BillAmountPaid : CoreAggregate<Bill, BillPayment, double>
  38. {
  39. public override Expression<Func<BillPayment, double>> Aggregate => x => x.Amount;
  40. public override AggregateCalculation Calculation => AggregateCalculation.Sum;
  41. public override Dictionary<Expression<Func<BillPayment, object>>, Expression<Func<Bill, object>>> Links =>
  42. new Dictionary<Expression<Func<BillPayment, object>>, Expression<Func<Bill, object>>>()
  43. {
  44. { BillPayment => BillPayment.BillLink.ID, Bill => Bill.ID }
  45. };
  46. }
  47. public class BillBalance : IFormula<Bill, double>
  48. {
  49. public Expression<Func<Bill, double>> Value => x => x.IncTax;
  50. public Expression<Func<Bill, double>>[] Modifiers => new Expression<Func<Bill, double>>[] { x => x.AmountPaid };
  51. public FormulaOperator Operator => FormulaOperator.Subtract;
  52. public FormulaType Type => FormulaType.Virtual;
  53. }
  54. public class BillDocumentCount : CoreAggregate<Bill, BillDocument, Guid>
  55. {
  56. public override Expression<Func<BillDocument, Guid>> Aggregate => x => x.ID;
  57. public override AggregateCalculation Calculation => AggregateCalculation.Count;
  58. public override Dictionary<Expression<Func<BillDocument, object>>, Expression<Func<Bill, object>>> Links =>
  59. new Dictionary<Expression<Func<BillDocument, object>>, Expression<Func<Bill, object>>>()
  60. {
  61. { BillDocument => BillDocument.EntityLink.ID, Bill => Bill.ID }
  62. };
  63. }
  64. }