|
@@ -160,15 +160,24 @@ public class ProgressClaimGrid : DynamicItemsListGrid<ProgressClaim>
|
|
|
|
|
|
|
|
query.Add(
|
|
query.Add(
|
|
|
Filter<Invoice>.Where(x =>x.JobLink.ID).IsEqualTo(JobID),
|
|
Filter<Invoice>.Where(x =>x.JobLink.ID).IsEqualTo(JobID),
|
|
|
- Columns.None<Invoice>().Add(x => x.ID).Add(x => x.Retained));
|
|
|
|
|
|
|
+ Columns.None<Invoice>()
|
|
|
|
|
+ .Add(x => x.ID)
|
|
|
|
|
+ .Add(x => x.Retained)
|
|
|
|
|
+ .Add(x=>x.Number)
|
|
|
|
|
+ .Add(x=>x.Date)
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
- if (InvoiceID != Guid.Empty)
|
|
|
|
|
- query.Add(
|
|
|
|
|
- Filter<InvoiceLine>.Where(x =>x.InvoiceLink.ID).IsEqualTo(InvoiceID),
|
|
|
|
|
- Columns.None<InvoiceLine>()
|
|
|
|
|
- .Add(x => x.ID)
|
|
|
|
|
- .Add(x => x.Scope.ID)
|
|
|
|
|
- .Add(x => x.ExTax));
|
|
|
|
|
|
|
+ query.Add(
|
|
|
|
|
+ Filter<InvoiceLine>.Where(x =>x.InvoiceLink.JobLink.ID).IsEqualTo(JobID),
|
|
|
|
|
+ Columns.None<InvoiceLine>()
|
|
|
|
|
+ .Add(x => x.ID)
|
|
|
|
|
+ .Add(x=>x.InvoiceLink.ID)
|
|
|
|
|
+ .Add(x=>x.InvoiceLink.Number)
|
|
|
|
|
+ .Add(x=>x.InvoiceLink.Date)
|
|
|
|
|
+ .Add(x => x.Scope.ID)
|
|
|
|
|
+ .Add(x => x.ExTax),
|
|
|
|
|
+ new SortOrder<InvoiceLine>(x=>x.InvoiceLink.Number)
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
query.Query();
|
|
query.Query();
|
|
|
|
|
|
|
@@ -182,35 +191,49 @@ public class ProgressClaimGrid : DynamicItemsListGrid<ProgressClaim>
|
|
|
|
|
|
|
|
Invoices = query.Get<Invoice>().ToArray<Invoice>();
|
|
Invoices = query.Get<Invoice>().ToArray<Invoice>();
|
|
|
|
|
|
|
|
- Invoice = Invoices.FirstOrDefault(x => x.ID == InvoiceID) ?? new Invoice();
|
|
|
|
|
-
|
|
|
|
|
- InvoiceLines = InvoiceID != Guid.Empty
|
|
|
|
|
- ? query.Get<InvoiceLine>().ToObjects<InvoiceLine>().ToList()
|
|
|
|
|
- : new List<InvoiceLine>();
|
|
|
|
|
-
|
|
|
|
|
|
|
+ Invoice = Invoices.FirstOrDefault(x => x.ID == InvoiceID) ?? new Invoice() { Date = DateTime.Today };
|
|
|
|
|
+
|
|
|
|
|
+ InvoiceLines = query.Get<InvoiceLine>().ToObjects<InvoiceLine>().ToList();
|
|
|
|
|
|
|
|
var items = new List<ProgressClaim>();
|
|
var items = new List<ProgressClaim>();
|
|
|
foreach(var scope in Scopes)
|
|
foreach(var scope in Scopes)
|
|
|
{
|
|
{
|
|
|
var newItem = new ProgressClaim();
|
|
var newItem = new ProgressClaim();
|
|
|
newItem.JobScope.CopyFrom(scope);
|
|
newItem.JobScope.CopyFrom(scope);
|
|
|
|
|
+
|
|
|
|
|
+ var prev = Invoice.ID == Guid.Empty
|
|
|
|
|
+ ? InvoiceLines
|
|
|
|
|
+ : InvoiceLines.Where(x => x.Scope.ID == scope.ID && x.InvoiceLink.Date < Invoice.Date);
|
|
|
|
|
+
|
|
|
|
|
+ var current = InvoiceLines.Where(x => x.InvoiceLink.ID == Invoice.ID && x.Scope.ID == scope.ID);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ newItem.PreviouslyClaimed = prev.Sum(x=>x.ExTax);
|
|
|
|
|
+ newItem.PreviouslyClaimedPercent = scope.ExTax.IsEffectivelyEqual(0.0)
|
|
|
|
|
+ ? 0.0
|
|
|
|
|
+ : newItem.PreviouslyClaimed / scope.ExTax * 100;
|
|
|
|
|
+
|
|
|
|
|
+ newItem.Cost = current.Sum(x => x.ExTax);
|
|
|
|
|
+ newItem.PercentCost = scope.ExTax.IsEffectivelyEqual(0.0)
|
|
|
|
|
+ ? 0.0
|
|
|
|
|
+ : (newItem.PreviouslyClaimed + newItem.Cost) / scope.ExTax * 100;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ // if (invoiceline != null)
|
|
|
|
|
+ // {
|
|
|
|
|
+ // newItem.PreviouslyClaimed = scope.InvoiceExTax - invoiceline.ExTax;
|
|
|
|
|
+ // newItem.PreviouslyClaimedPercent = scope.ExTax.IsEffectivelyEqual(0.0) ? 0.0 : (scope.InvoiceExTax - invoiceline.ExTax) / scope.ExTax * 100;
|
|
|
|
|
+ // newItem.PercentCost = scope.ExTax.IsEffectivelyEqual(0.0) ? 0.0 : scope.InvoiceExTax / scope.ExTax * 100;
|
|
|
|
|
+ // newItem.Cost = invoiceline.ExTax;
|
|
|
|
|
+ // }
|
|
|
|
|
+ // else
|
|
|
|
|
+ // {
|
|
|
|
|
+ // newItem.PreviouslyClaimed = scope.InvoiceExTax;
|
|
|
|
|
+ // newItem.PreviouslyClaimedPercent = scope.ExTax.IsEffectivelyEqual(0.0) ? 0.0 : scope.InvoiceExTax / scope.ExTax * 100;
|
|
|
|
|
+ // newItem.PercentCost = newItem.PreviouslyClaimedPercent;
|
|
|
|
|
+ // newItem.Cost = 0;
|
|
|
|
|
+ // }
|
|
|
|
|
|
|
|
- var invoiceline = InvoiceLines.FirstOrDefault(x =>
|
|
|
|
|
- x.Scope.ID == scope.ID || (x.Scope.ID == Guid.Empty && scope.ID == scope.Job.DefaultScope.ID));
|
|
|
|
|
- if (invoiceline != null)
|
|
|
|
|
- {
|
|
|
|
|
- newItem.PreviouslyClaimed = scope.InvoiceExTax - invoiceline.ExTax;
|
|
|
|
|
- newItem.PreviouslyClaimedPercent = scope.ExTax.IsEffectivelyEqual(0.0) ? 0.0 : (scope.InvoiceExTax - invoiceline.ExTax) / scope.ExTax * 100;
|
|
|
|
|
- newItem.PercentCost = scope.ExTax.IsEffectivelyEqual(0.0) ? 0.0 : scope.InvoiceExTax / scope.ExTax * 100;
|
|
|
|
|
- newItem.Cost = invoiceline.ExTax;
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- newItem.PreviouslyClaimed = scope.InvoiceExTax;
|
|
|
|
|
- newItem.PreviouslyClaimedPercent = scope.ExTax.IsEffectivelyEqual(0.0) ? 0.0 : scope.InvoiceExTax / scope.ExTax * 100;
|
|
|
|
|
- newItem.PercentCost = newItem.PreviouslyClaimedPercent;
|
|
|
|
|
- newItem.Cost = 0;
|
|
|
|
|
- }
|
|
|
|
|
newItem.Materials = scope.MaterialsExTax;
|
|
newItem.Materials = scope.MaterialsExTax;
|
|
|
newItem.Labour = assignments.GetValueOrDefault(scope.ID);
|
|
newItem.Labour = assignments.GetValueOrDefault(scope.ID);
|
|
|
newItem.GLCodeID = Job.Account.ID != Guid.Empty
|
|
newItem.GLCodeID = Job.Account.ID != Guid.Empty
|