using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using InABox.Core; namespace Comal.Classes { public class QuoteContractExTax : CoreAggregate { public override Expression> Aggregate => x => x.Proposal.ProposalExTax; public override AggregateCalculation Calculation => AggregateCalculation.Sum; public override Dictionary>, Expression>> Links => new Dictionary>, Expression>>() { { QuoteContractProposal => QuoteContractProposal.Contract.ID, QuoteContract => QuoteContract.ID } }; } public class QuoteContractTax : CoreAggregate { public override Expression> Aggregate => x => x.Proposal.ProposalTax; public override AggregateCalculation Calculation => AggregateCalculation.Sum; public override Dictionary>, Expression>> Links => new Dictionary>, Expression>>() { { QuoteContractProposal => QuoteContractProposal.Contract.ID, QuoteContract => QuoteContract.ID } }; } public class QuoteContractIncTax : CoreAggregate { public override Expression> Aggregate => x => x.Proposal.ProposalIncTax; public override AggregateCalculation Calculation => AggregateCalculation.Sum; public override Dictionary>, Expression>> Links => new Dictionary>, Expression>>() { { QuoteContractProposal => QuoteContractProposal.Contract.ID, QuoteContract => QuoteContract.ID } }; } [UserTracking(typeof(Quote))] public class QuoteContract : Entity, IRemotable, IPersistent, IQuoteContract, ILicense, IOneToMany { [NullEditor] [EntityRelationship(DeleteAction.Cascade)] public QuoteLink Quote { get; set; } [TextBoxEditor] [EditorSequence(1)] public string Description { get; set; } [CurrencyEditor(Editable = Editable.Hidden, Summary = Summary.Sum)] [Aggregate(typeof(QuoteContractExTax))] public double ExTax { get; set; } [CurrencyEditor(Editable = Editable.Hidden, Summary = Summary.Sum)] [Aggregate(typeof(QuoteContractTax))] public double Tax { get; set; } [CurrencyEditor(Visible = Visible.Default, Editable = Editable.Hidden, Summary = Summary.Sum)] [Aggregate(typeof(QuoteContractIncTax))] public double IncTax { get; set; } [DateTimeEditor] [EditorSequence(2)] public DateTime Confirmed { get; set; } private class QuoteContractJobScopeLookup : LookupDefinitionGenerator { public override Filter DefineFilter(QuoteContract[] items) { if (items?.Any() != true) return LookupFactory.DefineFilter(); return new Filter(x => x.Job.ID).IsEqualTo(items.First().Quote.Job.ID); } public override Columns DefineFilterColumns() => new Columns(ColumnTypeFlags.Required); } [LookupDefinition(typeof(QuoteContractJobScopeLookup))] [EditorSequence(3)] public JobScopeLink JobScope { get; set; } } }