123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- using System;
- using System.Collections.Generic;
- using System.Linq.Expressions;
- using InABox.Core;
- namespace Comal.Classes
- {
- public class JobFinancialInvoiceExTax : CoreAggregate<JobScope, InvoiceLine, double>
- {
- public override Expression<Func<InvoiceLine, double>> Aggregate => x => x.ExTax;
- public override AggregateCalculation Calculation => AggregateCalculation.Sum;
- public override Dictionary<Expression<Func<InvoiceLine, object>>, Expression<Func<JobScope, object>>> Links =>
- new Dictionary<Expression<Func<InvoiceLine, object>>, Expression<Func<JobScope, object>>>()
- {
- { InvoiceLine => InvoiceLine.Scope.ID, JobPrice => JobPrice.ID }
- };
- }
- public class JobFinancialInvoiceTax : CoreAggregate<JobScope, InvoiceLine, double>
- {
- public override Expression<Func<InvoiceLine, double>> Aggregate => x => x.Tax;
- public override AggregateCalculation Calculation => AggregateCalculation.Sum;
- public override Dictionary<Expression<Func<InvoiceLine, object>>, Expression<Func<JobScope, object>>> Links =>
- new Dictionary<Expression<Func<InvoiceLine, object>>, Expression<Func<JobScope, object>>>()
- {
- { InvoiceLine => InvoiceLine.Scope.ID, JobPrice => JobPrice.ID }
- };
- }
- public class JobFinancialInvoiceIncTax : CoreAggregate<JobScope, InvoiceLine, double>
- {
- public override Expression<Func<InvoiceLine, double>> Aggregate => x => x.IncTax;
- public override AggregateCalculation Calculation => AggregateCalculation.Sum;
- public override Dictionary<Expression<Func<InvoiceLine, object>>, Expression<Func<JobScope, object>>> Links =>
- new Dictionary<Expression<Func<InvoiceLine, object>>, Expression<Func<JobScope, object>>>()
- {
- { InvoiceLine => InvoiceLine.Scope.ID, JobPrice => JobPrice.ID }
- };
- }
- public class JobFinancialUninvoicedExTax : IFormula<JobScope, double>
- {
- public Expression<Func<JobScope, double>> Value => x => x.ExTax;
- public Expression<Func<JobScope, double>>[] Modifiers => new Expression<Func<JobScope, double>>[] { x => x.InvoiceExTax };
- public FormulaOperator Operator => FormulaOperator.Subtract;
- public FormulaType Type => FormulaType.Virtual;
- }
- public interface IJobScopedItem
- {
- JobLink JobLink { get; set; }
- JobScopeLink JobScope { get; set; }
- }
- [UserTracking(typeof(Job))]
- public class JobScope : Entity, IRemotable, IPersistent, ITaxable, IStringAutoIncrement<JobScope>, ILicense<ProjectManagementLicense>
- {
- [NullEditor]
- public InternalJobLink Job { get; set; }
- [EnumLookupEditor(typeof(JobScopeType), Visible = Visible.Default)]
- [EditorSequence(1)]
- public JobScopeType Type { get; set; } = JobScopeType.Variation;
- [CodeEditor(Visible = Visible.Default, Editable = Editable.Enabled)]
- [EditorSequence(2)]
- public string Number { get; set; }
- [MemoEditor(Visible = Visible.Default)]
- [EditorSequence(3)]
- public string Description { get; set; }
- [EditorSequence(5)]
- public TaxCodeLink TaxCode { get; set; }
- [EditorSequence(7)]
- public JobScopeStatusLink Status { get; set; }
- [CurrencyEditor(Visible = Visible.Default, Editable = Editable.Hidden, Summary = Summary.Sum)]
- [Aggregate(typeof(JobFinancialInvoiceExTax))]
- public double InvoiceExTax { get; set; }
- [CurrencyEditor(Visible = Visible.Optional, Editable = Editable.Hidden, Summary = Summary.Sum)]
- [Aggregate(typeof(JobFinancialInvoiceTax))]
- public double InvoiceTax { get; set; }
- [CurrencyEditor(Visible = Visible.Optional, Editable = Editable.Hidden, Summary = Summary.Sum)]
- [Aggregate(typeof(JobFinancialInvoiceIncTax))]
- public double InvoiceIncTax { get; set; }
- [CurrencyEditor(Visible = Visible.Optional, Editable = Editable.Hidden, Summary = Summary.Sum)]
- [Formula(typeof(JobFinancialUninvoicedExTax))]
- public double UninvoiceIncTax { get; set; }
- public Expression<Func<JobScope, string>> AutoIncrementField() => x => x.Number;
- public Filter<JobScope> AutoIncrementFilter() => new Filter<JobScope>(x => x.Job.ID).IsEqualTo(Job.ID);
- public String AutoIncrementPrefix() => "";
- public string AutoIncrementFormat() => "{0:D3}";
- [CurrencyEditor(Summary = Summary.Sum, Visible = Visible.Default)]
- [EditorSequence(4)]
- public double ExTax { get; set; }
- [NullEditor]
- public double TaxRate { get; set; }
- [NullEditor(Summary = Summary.Sum, Visible = Visible.Optional)]
- public double Tax { get; set; }
- [CurrencyEditor(Summary = Summary.Sum, Visible = Visible.Optional)]
- [EditorSequence(6)]
- public double IncTax { get; set; }
- static JobScope()
- {
- LinkedProperties.Register<JobScope, TaxCodeLink, double>(x=>x.TaxCode, x => x.Rate, x => x.TaxRate);
- }
- public static void LinkScopeProperties<TScoped>() where TScoped : IJobScopedItem
- {
- LinkedProperties.Register<TScoped, JobScopeLink, Guid>(ass => ass.JobLink.DefaultScope, scope => scope.ID, ass => ass.JobScope.ID);
- LinkedProperties.Register<TScoped, JobScopeLink, String>(ass => ass.JobLink.DefaultScope, scope => scope.Number, ass => ass.JobScope.Number);
- LinkedProperties.Register<TScoped, JobScopeLink, String>(ass => ass.JobLink.DefaultScope, scope => scope.Description, ass => ass.JobScope.Description);
- }
- }
- }
|