|
|
@@ -56,6 +56,59 @@ namespace Comal.Classes
|
|
|
public FormulaType Type => FormulaType.Virtual;
|
|
|
}
|
|
|
|
|
|
+ public class JobScopeActivityCost : CoreAggregate<JobScope, JobScopeActivity, double>
|
|
|
+ {
|
|
|
+ public override Expression<Func<JobScopeActivity, double>> Aggregate => x => x.Cost;
|
|
|
+
|
|
|
+ public override AggregateCalculation Calculation => AggregateCalculation.Sum;
|
|
|
+
|
|
|
+ public override Dictionary<Expression<Func<JobScopeActivity, object?>>, Expression<Func<JobScope, object?>>> Links =>
|
|
|
+ new Dictionary<Expression<Func<JobScopeActivity, object>>, Expression<Func<JobScope, object>>>()
|
|
|
+ {
|
|
|
+ { JobScopeActivity => JobScopeActivity.Scope.ID, JobScope => JobScope.ID }
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ public class JobScopeActivitySell : CoreAggregate<JobScope, JobScopeActivity, double>
|
|
|
+ {
|
|
|
+ public override Expression<Func<JobScopeActivity, double>> Aggregate => x => x.Sell;
|
|
|
+
|
|
|
+ public override AggregateCalculation Calculation => AggregateCalculation.Sum;
|
|
|
+
|
|
|
+ public override Dictionary<Expression<Func<JobScopeActivity, object?>>, Expression<Func<JobScope, object?>>> Links =>
|
|
|
+ new Dictionary<Expression<Func<JobScopeActivity, object>>, Expression<Func<JobScope, object>>>()
|
|
|
+ {
|
|
|
+ { JobScopeActivity => JobScopeActivity.Scope.ID, JobScope => JobScope.ID }
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ public class JobScopeCostCentreCost : CoreAggregate<JobScope, JobScopeCostCentre, double>
|
|
|
+ {
|
|
|
+ public override Expression<Func<JobScopeCostCentre, double>> Aggregate => x => x.Cost;
|
|
|
+
|
|
|
+ public override AggregateCalculation Calculation => AggregateCalculation.Sum;
|
|
|
+
|
|
|
+ public override Dictionary<Expression<Func<JobScopeCostCentre, object?>>, Expression<Func<JobScope, object?>>> Links =>
|
|
|
+ new Dictionary<Expression<Func<JobScopeCostCentre, object>>, Expression<Func<JobScope, object>>>()
|
|
|
+ {
|
|
|
+ { JobScopeCostCentre => JobScopeCostCentre.Scope.ID, JobScope => JobScope.ID }
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ public class JobScopeCostCentreSell : CoreAggregate<JobScope, JobScopeCostCentre, double>
|
|
|
+ {
|
|
|
+ public override Expression<Func<JobScopeCostCentre, double>> Aggregate => x => x.Sell;
|
|
|
+
|
|
|
+ public override AggregateCalculation Calculation => AggregateCalculation.Sum;
|
|
|
+
|
|
|
+ public override Dictionary<Expression<Func<JobScopeCostCentre, object?>>, Expression<Func<JobScope, object?>>> Links =>
|
|
|
+ new Dictionary<Expression<Func<JobScopeCostCentre, object>>, Expression<Func<JobScope, object>>>()
|
|
|
+ {
|
|
|
+ { JobScopeCostCentre => JobScopeCostCentre.Scope.ID, JobScope => JobScope.ID }
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
public interface IJobScopedItem
|
|
|
{
|
|
|
JobLink JobLink { get; set; }
|
|
|
@@ -110,35 +163,153 @@ namespace Comal.Classes
|
|
|
[LookupDefinition(typeof(JobScopeLookup))]
|
|
|
[EditorSequence(4)]
|
|
|
public JobScopeLink Parent { get; set; }
|
|
|
+
|
|
|
+ private class MaterialsCostAggregate : ComplexFormulaGenerator<JobScope, double>
|
|
|
+ {
|
|
|
+ public override IComplexFormulaNode<JobScope, double> GetFormula()
|
|
|
+ => Aggregate<JobScopeCostCentre>(AggregateCalculation.Sum, x => x.Property(p => p.Cost))
|
|
|
+ .WithLink(x => x.Scope.ID, x => x.ID);
|
|
|
+ }
|
|
|
|
|
|
- [CurrencyEditor(Summary = Summary.Sum, Visible = Visible.Default)]
|
|
|
+ [ComplexFormula(typeof(MaterialsCostAggregate))]
|
|
|
[EditorSequence(5)]
|
|
|
+ [CurrencyEditor(Summary = Summary.Sum, Visible = Visible.Optional, Editable = Editable.Hidden)]
|
|
|
+ public double MaterialsCost { get; set; }
|
|
|
+
|
|
|
+ private class MaterialsSellAggregate : ComplexFormulaGenerator<JobScope, double>
|
|
|
+ {
|
|
|
+ public override IComplexFormulaNode<JobScope, double> GetFormula()
|
|
|
+ => Aggregate<JobScopeCostCentre>(AggregateCalculation.Sum, x => x.Property(p => p.Sell))
|
|
|
+ .WithLink(x => x.Scope.ID, x => x.ID);
|
|
|
+ }
|
|
|
+
|
|
|
+ [ComplexFormula(typeof(MaterialsSellAggregate))]
|
|
|
+ [EditorSequence(6)]
|
|
|
+ [CurrencyEditor(Summary = Summary.Sum, Visible = Visible.Optional, Editable = Editable.Hidden)]
|
|
|
+ public double MaterialsSell { get; set; }
|
|
|
+
|
|
|
+ private class MaterialsMarginFormula : ComplexFormulaGenerator<JobScope, double>
|
|
|
+ {
|
|
|
+ public override IComplexFormulaNode<JobScope, double> GetFormula()
|
|
|
+ => Formula(FormulaOperator.Divide,
|
|
|
+ Formula(FormulaOperator.Subtract, Property(x => x.MaterialsSell), Property(x => x.MaterialsCost)),
|
|
|
+ Property(x => x.MaterialsSell)
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ [ComplexFormula(typeof(MaterialsMarginFormula))]
|
|
|
+ [EditorSequence(7)]
|
|
|
+ [DoubleEditor(Visible = Visible.Optional, Editable = Editable.Hidden)]
|
|
|
+ public double MaterialMargin { get; set; }
|
|
|
+
|
|
|
+ private class MaterialsMarkupFormula : ComplexFormulaGenerator<JobScope, double>
|
|
|
+ {
|
|
|
+ public override IComplexFormulaNode<JobScope, double> GetFormula()
|
|
|
+ => Formula(FormulaOperator.Divide,
|
|
|
+ Formula(FormulaOperator.Subtract, Property(x => x.MaterialsSell), Property(x => x.MaterialsCost)),
|
|
|
+ Property(x => x.MaterialsCost)
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ [ComplexFormula(typeof(MaterialsMarkupFormula))]
|
|
|
+ [EditorSequence(8)]
|
|
|
+ [DoubleEditor(Visible = Visible.Optional, Editable = Editable.Hidden)]
|
|
|
+ public double MaterialMarkup { get; set; }
|
|
|
+
|
|
|
+ private class LabourCostAggregate : ComplexFormulaGenerator<JobScope, double>
|
|
|
+ {
|
|
|
+ public override IComplexFormulaNode<JobScope, double> GetFormula()
|
|
|
+ => Aggregate<JobScopeActivity>(AggregateCalculation.Sum, x => x.Property(p => p.Cost))
|
|
|
+ .WithLink(x => x.Scope.ID, x => x.ID);
|
|
|
+ }
|
|
|
+
|
|
|
+ [ComplexFormula(typeof(LabourCostAggregate))]
|
|
|
+ [EditorSequence(9)]
|
|
|
+ [CurrencyEditor(Summary = Summary.Sum, Visible = Visible.Optional, Editable = Editable.Hidden)]
|
|
|
+ public double LabourCost { get; set; }
|
|
|
+
|
|
|
+ private class LabourSellAggregate : ComplexFormulaGenerator<JobScope, double>
|
|
|
+ {
|
|
|
+ public override IComplexFormulaNode<JobScope, double> GetFormula()
|
|
|
+ => Aggregate<JobScopeActivity>(AggregateCalculation.Sum, x => x.Property(p => p.Sell))
|
|
|
+ .WithLink(x => x.Scope.ID, x => x.ID);
|
|
|
+ }
|
|
|
+
|
|
|
+ [ComplexFormula(typeof(LabourSellAggregate))]
|
|
|
+ [EditorSequence(10)]
|
|
|
+ [CurrencyEditor(Summary = Summary.Sum, Visible = Visible.Optional, Editable = Editable.Hidden)]
|
|
|
+ public double LabourSell { get; set; }
|
|
|
+
|
|
|
+ private class LabourMarginFormula : ComplexFormulaGenerator<JobScope, double>
|
|
|
+ {
|
|
|
+ public override IComplexFormulaNode<JobScope, double> GetFormula()
|
|
|
+ => Formula(FormulaOperator.Divide,
|
|
|
+ Formula(FormulaOperator.Subtract, Property(x => x.LabourSell), Property(x => x.LabourCost)),
|
|
|
+ Property(x => x.LabourSell)
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ [ComplexFormula(typeof(LabourMarginFormula))]
|
|
|
+ [EditorSequence(11)]
|
|
|
+ [DoubleEditor(Visible = Visible.Optional, Editable = Editable.Hidden)]
|
|
|
+ public double LabourMargin { get; set; }
|
|
|
+
|
|
|
+ private class LabourMarkupFormula : ComplexFormulaGenerator<JobScope, double>
|
|
|
+ {
|
|
|
+ public override IComplexFormulaNode<JobScope, double> GetFormula()
|
|
|
+ => Formula(FormulaOperator.Divide,
|
|
|
+ Formula(FormulaOperator.Subtract, Property(x => x.LabourSell), Property(x => x.LabourCost)),
|
|
|
+ Property(x => x.LabourCost)
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ [ComplexFormula(typeof(LabourMarkupFormula))]
|
|
|
+ [EditorSequence(12)]
|
|
|
+ [DoubleEditor(Visible = Visible.Optional, Editable = Editable.Hidden)]
|
|
|
+ public double LabourMarkup { get; set; }
|
|
|
+
|
|
|
+
|
|
|
+ [CurrencyEditor(Summary = Summary.Sum, Visible = Visible.Default)]
|
|
|
+ [EditorSequence(13)]
|
|
|
public double ExTax { get; set; }
|
|
|
|
|
|
- [EditorSequence(6)]
|
|
|
+ [EditorSequence(14)]
|
|
|
public TaxCodeLink TaxCode { get; set; }
|
|
|
|
|
|
[CurrencyEditor(Summary = Summary.Sum, Visible = Visible.Optional)]
|
|
|
- [EditorSequence(7)]
|
|
|
+ [EditorSequence(15)]
|
|
|
public double IncTax { get; set; }
|
|
|
|
|
|
- [EditorSequence(8)]
|
|
|
+ [EditorSequence(16)]
|
|
|
public JobScopeStatusLink Status { get; set; }
|
|
|
|
|
|
- [CurrencyEditor(Visible = Visible.Default, Editable = Editable.Hidden, Summary = Summary.Sum)]
|
|
|
+ private class InvoiceExTaxAggregate : ComplexFormulaGenerator<JobScope, double>
|
|
|
+ {
|
|
|
+ public override IComplexFormulaNode<JobScope, double> GetFormula()
|
|
|
+ => Aggregate<InvoiceLine>(AggregateCalculation.Sum, x => x.Property(p => p.ExTax))
|
|
|
+ .WithLink(x => x.Scope.ID, x => x.ID);
|
|
|
+ }
|
|
|
+
|
|
|
+ [ComplexFormula(typeof(LabourSellAggregate))]
|
|
|
+
|
|
|
[Aggregate(typeof(JobScopeInvoiceExTax))]
|
|
|
+ [EditorSequence(17)]
|
|
|
+ [CurrencyEditor(Visible = Visible.Default, Editable = Editable.Hidden, Summary = Summary.Sum)]
|
|
|
public double InvoiceExTax { get; set; }
|
|
|
|
|
|
- [CurrencyEditor(Visible = Visible.Optional, Editable = Editable.Hidden, Summary = Summary.Sum)]
|
|
|
[Aggregate(typeof(JobScopeInvoiceTax))]
|
|
|
+ [EditorSequence(18)]
|
|
|
+ [CurrencyEditor(Visible = Visible.Optional, Editable = Editable.Hidden, Summary = Summary.Sum)]
|
|
|
public double InvoiceTax { get; set; }
|
|
|
|
|
|
- [CurrencyEditor(Visible = Visible.Optional, Editable = Editable.Hidden, Summary = Summary.Sum)]
|
|
|
[Aggregate(typeof(JobScopeInvoiceIncTax))]
|
|
|
+ [EditorSequence(19)]
|
|
|
+ [CurrencyEditor(Visible = Visible.Optional, Editable = Editable.Hidden, Summary = Summary.Sum)]
|
|
|
public double InvoiceIncTax { get; set; }
|
|
|
|
|
|
- [CurrencyEditor(Visible = Visible.Optional, Editable = Editable.Hidden, Summary = Summary.Sum)]
|
|
|
[Formula(typeof(JobScopeUninvoicedExTax))]
|
|
|
+ [EditorSequence(20)]
|
|
|
+ [CurrencyEditor(Visible = Visible.Optional, Editable = Editable.Hidden, Summary = Summary.Sum)]
|
|
|
public double UninvoiceIncTax { get; set; }
|
|
|
|
|
|
private class MaterialsExTaxFormula : ComplexFormulaGenerator<JobScope, double>
|
|
|
@@ -153,7 +324,7 @@ namespace Comal.Classes
|
|
|
[CurrencyEditor(Visible = Visible.Optional, Editable = Editable.Hidden, Summary = Summary.Sum)]
|
|
|
[ComplexFormula(typeof(MaterialsExTaxFormula))]
|
|
|
public double MaterialsExTax { get; set; }
|
|
|
-
|
|
|
+
|
|
|
private class UninvoicedMaterial : ComplexFormulaGenerator<JobScope, double>
|
|
|
{
|
|
|
public override IComplexFormulaNode<JobScope, double> GetFormula() =>
|