using System; using System.Linq; using System.Linq.Expressions; using InABox.Core; namespace Comal.Classes { public class QuoteProposalCostSheetExTax : IFormula { public Expression> Value => x => x.CostSheet.ExTax; public Expression>[] Modifiers => new Expression>[] { x => x.Qty }; public FormulaOperator Operator => FormulaOperator.Multiply; public FormulaType Type => FormulaType.Virtual; } public class QuoteProposalCostSheetTax : IFormula { public Expression> Value => x => x.CostSheet.Tax; public Expression>[] Modifiers => new Expression>[] { x => x.Qty }; public FormulaOperator Operator => FormulaOperator.Multiply; public FormulaType Type => FormulaType.Virtual; } public class QuoteProposalCostSheetIncTax : IFormula { public Expression> Value => x => x.CostSheet.IncTax; public Expression>[] Modifiers => new Expression>[] { x => x.Qty }; public FormulaOperator Operator => FormulaOperator.Multiply; public FormulaType Type => FormulaType.Virtual; } [UserTracking(typeof(Quote))] public class QuoteProposalCostSheet : Entity, IRemotable, IPersistent, IQuoteProposalCostSheet, ILicense { [NullEditor] [EntityRelationship(DeleteAction.Cascade)] public QuoteProposalLink Proposal { get; set; } private class QuoteCostSheetLookup : LookupDefinitionGenerator { public override Filter DefineFilter(QuoteProposalCostSheet[] items) { if (items == null || items.Length != 1) return LookupFactory.DefineFilter(); return new Filter(x => x.Quote.ID).IsEqualTo(items.First().Proposal.Quote.ID); } public override Columns DefineFilterColumns() => Columns.None().Add(x => x.Proposal.Quote.ID); } [LookupDefinition(typeof(QuoteCostSheetLookup))] [EntityRelationship(DeleteAction.Cascade)] public QuoteCostSheetLink CostSheet { get; set; } [IntegerEditor] public int Qty { get; set; } [CurrencyEditor(Editable = Editable.Hidden, Summary = Summary.Sum)] [Formula(typeof(QuoteProposalCostSheetExTax))] public double ExTax { get; set; } [CurrencyEditor(Editable = Editable.Hidden, Summary = Summary.Sum)] [Formula(typeof(QuoteProposalCostSheetTax))] public double Tax { get; set; } [CurrencyEditor(Visible = Visible.Default, Editable = Editable.Hidden, Summary = Summary.Sum)] [Formula(typeof(QuoteProposalCostSheetIncTax))] public double IncTax { get; set; } [NullEditor] public long Sequence { get; set; } } }