QuoteProposalCostSheet.cs 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using System;
  2. using System.Linq;
  3. using System.Linq.Expressions;
  4. using InABox.Core;
  5. namespace Comal.Classes
  6. {
  7. public class QuoteProposalCostSheetExTax : IFormula<QuoteProposalCostSheet, double>
  8. {
  9. public Expression<Func<QuoteProposalCostSheet, double>> Value => x => x.CostSheet.ExTax;
  10. public Expression<Func<QuoteProposalCostSheet, double>>[] Modifiers => new Expression<Func<QuoteProposalCostSheet, double>>[] { x => x.Qty };
  11. public FormulaOperator Operator => FormulaOperator.Multiply;
  12. public FormulaType Type => FormulaType.Virtual;
  13. }
  14. public class QuoteProposalCostSheetTax : IFormula<QuoteProposalCostSheet, double>
  15. {
  16. public Expression<Func<QuoteProposalCostSheet, double>> Value => x => x.CostSheet.Tax;
  17. public Expression<Func<QuoteProposalCostSheet, double>>[] Modifiers => new Expression<Func<QuoteProposalCostSheet, double>>[] { x => x.Qty };
  18. public FormulaOperator Operator => FormulaOperator.Multiply;
  19. public FormulaType Type => FormulaType.Virtual;
  20. }
  21. public class QuoteProposalCostSheetIncTax : IFormula<QuoteProposalCostSheet, double>
  22. {
  23. public Expression<Func<QuoteProposalCostSheet, double>> Value => x => x.CostSheet.IncTax;
  24. public Expression<Func<QuoteProposalCostSheet, double>>[] Modifiers => new Expression<Func<QuoteProposalCostSheet, double>>[] { x => x.Qty };
  25. public FormulaOperator Operator => FormulaOperator.Multiply;
  26. public FormulaType Type => FormulaType.Virtual;
  27. }
  28. [UserTracking(typeof(Quote))]
  29. public class QuoteProposalCostSheet : Entity, IRemotable, IPersistent, IQuoteProposalCostSheet, ILicense<QuotesManagementLicense>
  30. {
  31. [NullEditor]
  32. [EntityRelationship(DeleteAction.Cascade)]
  33. public QuoteProposalLink Proposal { get; set; }
  34. private class QuoteCostSheetLookup : LookupDefinitionGenerator<QuoteCostSheet, QuoteProposalCostSheet>
  35. {
  36. public override Filter<QuoteCostSheet> DefineFilter(QuoteProposalCostSheet[] items)
  37. {
  38. if (items == null || items.Length != 1)
  39. return LookupFactory.DefineFilter<QuoteCostSheet>();
  40. return new Filter<QuoteCostSheet>(x => x.Quote.ID).IsEqualTo(items.First().Proposal.Quote.ID);
  41. }
  42. public override Columns<QuoteProposalCostSheet> DefineFilterColumns()
  43. => Columns.None<QuoteProposalCostSheet>().Add(x => x.Proposal.Quote.ID);
  44. }
  45. [LookupDefinition(typeof(QuoteCostSheetLookup))]
  46. [EntityRelationship(DeleteAction.Cascade)]
  47. public QuoteCostSheetLink CostSheet { get; set; }
  48. [IntegerEditor]
  49. public int Qty { get; set; }
  50. [CurrencyEditor(Editable = Editable.Hidden, Summary = Summary.Sum)]
  51. [Formula(typeof(QuoteProposalCostSheetExTax))]
  52. public double ExTax { get; set; }
  53. [CurrencyEditor(Editable = Editable.Hidden, Summary = Summary.Sum)]
  54. [Formula(typeof(QuoteProposalCostSheetTax))]
  55. public double Tax { get; set; }
  56. [CurrencyEditor(Visible = Visible.Default, Editable = Editable.Hidden, Summary = Summary.Sum)]
  57. [Formula(typeof(QuoteProposalCostSheetIncTax))]
  58. public double IncTax { get; set; }
  59. [NullEditor]
  60. public long Sequence { get; set; }
  61. }
  62. }