Explorar el Código

Removed reference to POIA.Nominated

Kenric Nugteren hace 7 meses
padre
commit
0dc88773b8

+ 2 - 26
prs.desktop/Panels/PurchaseOrders/PurchaseOrderItemAllocationGrid.cs

@@ -13,36 +13,12 @@ namespace PRSDesktop.Panels.PurchaseOrders;
 
 
 public class PurchaseOrderItemAllocationGrid : DynamicOneToManyGrid<PurchaseOrderItem, PurchaseOrderItemAllocation>
 public class PurchaseOrderItemAllocationGrid : DynamicOneToManyGrid<PurchaseOrderItem, PurchaseOrderItemAllocation>
 {
 {
-    private static readonly BitmapImage tick = PRSDesktop.Resources.tick.AsBitmapImage();
-
-    protected override void Init()
-    {
-        base.Init();
-
-        HiddenColumns.Add(x => x.Nominated);
-
-        ActionColumns.Add(new DynamicTickColumn<PurchaseOrderItemAllocation, bool>(x => x.Nominated, tick, tick, null, Nominated_Click));
-    }
-
     protected override void DoValidate(PurchaseOrderItemAllocation[] items, List<string> errors)
     protected override void DoValidate(PurchaseOrderItemAllocation[] items, List<string> errors)
     {
     {
         base.DoValidate(items, errors);
         base.DoValidate(items, errors);
-        if(items.Any(x => x.Job.ID == Guid.Empty))
-        {
-            errors.Add("[Job] may not be blank.");
-        }
-    }
-
-    private bool Nominated_Click(CoreRow? row)
-    {
-        if (row is null) return false;
-
-        var selectedItem = LoadItem(row);
-        foreach(var item in Items)
+        if(items.Any(x => x.Job.ID == Item.Job.ID && x.JobRequisitionItem.ID == Guid.Empty))
         {
         {
-            item.Nominated = false;
+            errors.Add("[Job] may not be equivalent to the Job on the PurchaseOrderItem.");
         }
         }
-        selectedItem.Nominated = true;
-        return true;
     }
     }
 }
 }

+ 14 - 36
prs.desktop/Panels/PurchaseOrders/SupplierPurchaseOrderItemOneToMany.cs

@@ -50,6 +50,7 @@ public class SupplierPurchaseOrderItemOneToMany : DynamicOneToManyGrid<PurchaseO
         HiddenColumns.Add(x => x.Product.Code);
         HiddenColumns.Add(x => x.Product.Code);
         HiddenColumns.Add(x => x.Product.Name);
         HiddenColumns.Add(x => x.Product.Name);
         HiddenColumns.Add(x => x.Style.ID);
         HiddenColumns.Add(x => x.Style.ID);
+        HiddenColumns.Add(x => x.Job.ID);
 
 
         HiddenColumns.Add(x => x.TaxCode.ID);
         HiddenColumns.Add(x => x.TaxCode.ID);
         HiddenColumns.Add(x => x.TaxCode.Code);
         HiddenColumns.Add(x => x.TaxCode.Code);
@@ -178,31 +179,23 @@ public class SupplierPurchaseOrderItemOneToMany : DynamicOneToManyGrid<PurchaseO
                     .And(x => x.ID).NotInList(_allocations.ToArray(x => x.ID)),
                     .And(x => x.ID).NotInList(_allocations.ToArray(x => x.ID)),
                 Columns.None<PurchaseOrderItemAllocation>()
                 Columns.None<PurchaseOrderItemAllocation>()
                     .Add(x => x.ID)
                     .Add(x => x.ID)
-                    .Add(x => x.Job.ID).Add(x => x.JobRequisitionItem.ID).Add(x => x.Quantity).Add(x => x.Nominated))
+                    .Add(x => x.Job.ID).Add(x => x.JobRequisitionItem.ID).Add(x => x.Quantity))
                 .ToObjects<PurchaseOrderItemAllocation>());
                 .ToObjects<PurchaseOrderItemAllocation>());
         }
         }
         var items = _allocations.ToList(SupplierPurchaseOrderItemSplit.FromAllocation);
         var items = _allocations.ToList(SupplierPurchaseOrderItemSplit.FromAllocation);
         if (SupplierPurchaseOrderItemSplitWindow.Execute(poi.Qty, items, out var value))
         if (SupplierPurchaseOrderItemSplitWindow.Execute(poi.Qty, items, out var value))
         {
         {
             var newLine = CreateItem();
             var newLine = CreateItem();
-            newLine.BillLine.ID = poi.BillLine.ID;
-            newLine.BillLine.Synchronise(poi.BillLine);
-            newLine.StockLocation.ID = poi.StockLocation.ID;
-            newLine.StockLocation.Synchronise(poi.StockLocation);
-            newLine.Consignment.ID = poi.Consignment.ID;
-            newLine.Consignment.Synchronise(poi.Consignment);
-            newLine.PurchaseGL.ID = poi.PurchaseGL.ID;
-            newLine.PurchaseGL.Synchronise(poi.PurchaseGL);
-            newLine.CostCentre.ID = poi.CostCentre.ID;
-            newLine.CostCentre.Synchronise(poi.CostCentre);
-            newLine.Product.ID = poi.Product.ID;
-            newLine.Product.Synchronise(poi.Product);
-            newLine.Style.ID = poi.Style.ID;
-            newLine.Style.Synchronise(poi.Style);
-            newLine.TaxCode.ID = poi.TaxCode.ID;
-            newLine.TaxCode.Synchronise(poi.TaxCode);
-            newLine.PurchaseOrderLink.ID = poi.PurchaseOrderLink.ID;
-            newLine.PurchaseOrderLink.Synchronise(poi.PurchaseOrderLink);
+            newLine.BillLine.CopyFrom(poi.BillLine);
+            newLine.StockLocation.CopyFrom(poi.StockLocation);
+            newLine.Consignment.CopyFrom(poi.Consignment);
+            newLine.PurchaseGL.CopyFrom(poi.PurchaseGL);
+            newLine.CostCentre.CopyFrom(poi.CostCentre);
+            newLine.Product.CopyFrom(poi.Product);
+            newLine.Style.CopyFrom(poi.Style);
+            newLine.Job.CopyFrom(poi.Job);
+            newLine.TaxCode.CopyFrom(poi.TaxCode);
+            newLine.PurchaseOrderLink.CopyFrom(poi.PurchaseOrderLink);
             newLine.Dimensions.CopyFrom(poi.Dimensions);
             newLine.Dimensions.CopyFrom(poi.Dimensions);
 
 
             // Copying across the posted reference; this would be a problem if we were to try to sync via a Poster two purchase order items with the
             // Copying across the posted reference; this would be a problem if we were to try to sync via a Poster two purchase order items with the
@@ -233,7 +226,6 @@ public class SupplierPurchaseOrderItemOneToMany : DynamicOneToManyGrid<PurchaseO
                 var newAllocation = new PurchaseOrderItemAllocation();
                 var newAllocation = new PurchaseOrderItemAllocation();
                 newAllocation.Job.CopyFrom(allocation.Job);
                 newAllocation.Job.CopyFrom(allocation.Job);
                 newAllocation.JobRequisitionItem.CopyFrom(allocation.JobRequisitionItem);
                 newAllocation.JobRequisitionItem.CopyFrom(allocation.JobRequisitionItem);
-                newAllocation.Nominated = allocation.Nominated;
 
 
                 newAllocation.Quantity = allocation.Quantity - item.SplitQuantity;
                 newAllocation.Quantity = allocation.Quantity - item.SplitQuantity;
                 allocation.Quantity = item.SplitQuantity;
                 allocation.Quantity = item.SplitQuantity;
@@ -597,15 +589,8 @@ public class SupplierPurchaseOrderItemOneToMany : DynamicOneToManyGrid<PurchaseO
                     poi.CostCentre.CopyFrom(sp.Product.CostCentre);
                     poi.CostCentre.CopyFrom(sp.Product.CostCentre);
                     poi.PurchaseGL.CopyFrom(sp.Product.PurchaseGL);
                     poi.PurchaseGL.CopyFrom(sp.Product.PurchaseGL);
                     poi.Description = sp.Product.Name;
                     poi.Description = sp.Product.Name;
+                    poi.Job.CopyFrom(sp.Job);
                     result.Add(poi);
                     result.Add(poi);
-                    
-                    if(sp.Job.ID != Guid.Empty)
-                    {
-                        var poia = new PurchaseOrderItemAllocation();
-                        poia.Job.CopyFrom(sp.Job);
-                        poia.Nominated = true;
-                        Allocations.Add(new(poi, poia));
-                    }
                 }
                 }
                 else if (pi != null)
                 else if (pi != null)
                 {
                 {
@@ -672,16 +657,9 @@ public class SupplierPurchaseOrderItemOneToMany : DynamicOneToManyGrid<PurchaseO
                     poi.Cost = sp.CostPrice;
                     poi.Cost = sp.CostPrice;
                     poi.CostCentre.CopyFrom(sp.Product.CostCentre);
                     poi.CostCentre.CopyFrom(sp.Product.CostCentre);
                     poi.PurchaseGL.CopyFrom(sp.Product.PurchaseGL);
                     poi.PurchaseGL.CopyFrom(sp.Product.PurchaseGL);
+                    poi.Job.CopyFrom(sp.Job);
                     poi.Description = sp.Product.Name;
                     poi.Description = sp.Product.Name;
                     result.Add(poi);
                     result.Add(poi);
-                    
-                    if(sp.Job.ID != Guid.Empty)
-                    {
-                        var poia = new PurchaseOrderItemAllocation();
-                        poia.Job.CopyFrom(sp.Job);
-                        poia.Nominated = true;
-                        Allocations.Add(new(poi, poia));
-                    }
                 }
                 }
                 return result;
                 return result;
             });
             });

+ 0 - 46
prs.shared/Database Update Scripts/Update_8_24.cs

@@ -17,7 +17,6 @@ internal class Update_8_24 : DatabaseUpdateScript
         var _provider = DbFactory.NewProvider(Logger.Main);
         var _provider = DbFactory.NewProvider(Logger.Main);
         Clear_POIAs(_provider);
         Clear_POIAs(_provider);
         Migrate_JRIPOIs(_provider);
         Migrate_JRIPOIs(_provider);
-        Update_POIs(_provider);
         return true;
         return true;
     }
     }
 
 
@@ -61,7 +60,6 @@ internal class Update_8_24 : DatabaseUpdateScript
                     _poia.Job.ID = Guid.TryParse(_jripoi.Get<string>("job.id"), out var jid) ? jid : Guid.Empty;
                     _poia.Job.ID = Guid.TryParse(_jripoi.Get<string>("job.id"), out var jid) ? jid : Guid.Empty;
                     _poia.JobRequisitionItem.ID = Guid.TryParse(_jripoi.Get<string>("jobrequisitionitem.id"), out var rid) ? rid : Guid.Empty;
                     _poia.JobRequisitionItem.ID = Guid.TryParse(_jripoi.Get<string>("jobrequisitionitem.id"), out var rid) ? rid : Guid.Empty;
                     _poia.Quantity = _jripoi.Get<double>("qty");
                     _poia.Quantity = _jripoi.Get<double>("qty");
-                    _poia.Nominated = !_ids.Contains(poi_id);
                     _poias.Add(_poia);
                     _poias.Add(_poia);
                     _ids.Add(poi_id);
                     _ids.Add(poi_id);
                 }
                 }
@@ -76,48 +74,4 @@ internal class Update_8_24 : DatabaseUpdateScript
         if (DESTRUCTIVE)
         if (DESTRUCTIVE)
             provider.DropTable("JobRequisitionItemPurchaseOrderItem");
             provider.DropTable("JobRequisitionItemPurchaseOrderItem");
     }
     }
-    
-    private void Update_POIs(IProvider provider)
-    {
-        Logger.Send(LogType.Information,"","Migrating PurchaseOrderItems");
-        
-        var _ids = provider.Query(
-            null,
-            Columns.None<PurchaseOrderItemAllocation>()
-                .Add(x=>x.Item.ID)
-            ).ExtractValues<PurchaseOrderItemAllocation,Guid>(x => x.Item.ID,true);
-        
-        var _queue = provider.Query(
-            new Filter<PurchaseOrderItem>("Job.ID").IsNotEqualTo(Guid.Empty),
-            Columns.Required<PurchaseOrderItem>().Add("Job.ID")
-        ).Rows.ToQueue();
-        
-        while (_queue.Any())
-        {
-            List<PurchaseOrderItemAllocation> _poias = new();
-            var _pois = _queue.Dequeue(CHUNK_SIZE)
-                .Select(x=>x.ToObject<PurchaseOrderItem>())
-                .ToList();
-            foreach (var _poi in _pois)
-            {
-                if (!_ids.Contains(_poi.ID))
-                {
-                    var _poia = new PurchaseOrderItemAllocation();
-                    _poia.Item.ID = _poi.ID;
-                    _poia.Job.ID = (Guid)(CoreUtils.GetPropertyValue(_poi, "Job.ID") ?? Guid.Empty);
-                    _poia.Quantity = _poi.Qty;
-                    _poia.Nominated = true;
-                    _poias.Add(_poia);
-                }
-                
-                CoreUtils.SetPropertyValue(_poi,"Job.ID",Guid.Empty);
-            }
-            provider.Save(_poias);
-            if(DESTRUCTIVE)
-                provider.Save(_pois.Where(x=>x.IsChanged()));
-            Logger.Send(LogType.Information, "", $"- Created {_poias.Count} Allocations ({_queue.Count} remaining)");
-        }
-    }
-
-
 }
 }

+ 2 - 2
prs.shared/Posters/Timberline/BillTimberlinePoster.cs

@@ -323,7 +323,7 @@ public class BillTimberlinePoster : ITimberlinePoster<Bill, BillTimberlineSettin
                 .Add(x => x.Description)
                 .Add(x => x.Description)
                 .Add(x => x.Cost)
                 .Add(x => x.Cost)
                 .Add(x => x.PostedReference)
                 .Add(x => x.PostedReference)
-                .Add(x => x.NominatedJob.Job.JobNumber)
+                .Add(x => x.Job.JobNumber)
                 );
                 );
 
 
         Script?.Execute(methodname: "BeforePost", parameters: new object[] { model });
         Script?.Execute(methodname: "BeforePost", parameters: new object[] { model });
@@ -428,7 +428,7 @@ public class BillTimberlinePoster : ITimberlinePoster<Bill, BillTimberlineSettin
                 if (purchaseOrderItems.TryGetValue(billLine.OrderItem.ID, out var poItem))
                 if (purchaseOrderItems.TryGetValue(billLine.OrderItem.ID, out var poItem))
                 {
                 {
                     apdf.Commitment = poItem.PurchaseOrderLink.PONumber;
                     apdf.Commitment = poItem.PurchaseOrderLink.PONumber;
-                    apdf.Job = poItem.NominatedJob.Job.JobNumber;
+                    apdf.Job = poItem.Job.JobNumber;
                     if (int.TryParse(poItem.PostedReference, out var itemNumber))
                     if (int.TryParse(poItem.PostedReference, out var itemNumber))
                     {
                     {
                         apdf.CommitmentLineItem = itemNumber;
                         apdf.CommitmentLineItem = itemNumber;

+ 2 - 2
prs.shared/Posters/Timberline/PurchaseOrderTimberlinePoster.cs

@@ -238,7 +238,7 @@ public class Module
                 .Add(x => x.Cost)
                 .Add(x => x.Cost)
                 .Add(x => x.Dimensions.UnitSize)
                 .Add(x => x.Dimensions.UnitSize)
                 .Add(x => x.IncTax)
                 .Add(x => x.IncTax)
-                .Add(x => x.NominatedJob.Job.JobNumber),
+                .Add(x => x.Job.JobNumber),
                 alias: "PurchaseOrder_PurchaseOrderItem");
                 alias: "PurchaseOrder_PurchaseOrderItem");
 
 
             Script?.Execute(methodname: "BeforePost", parameters: new object[] { model });
             Script?.Execute(methodname: "BeforePost", parameters: new object[] { model });
@@ -323,7 +323,7 @@ public class Module
                             // RetainagePercent = ,
                             // RetainagePercent = ,
                             DeliveryDate = purchaseOrderItem.ReceivedDate,
                             DeliveryDate = purchaseOrderItem.ReceivedDate,
                             //ScopeOfWork
                             //ScopeOfWork
-                            Job = purchaseOrderItem.NominatedJob.Job.JobNumber,
+                            Job = purchaseOrderItem.Job.JobNumber,
                             //Extra = purchaseOrderItem.Job
                             //Extra = purchaseOrderItem.Job
                             CostCode = purchaseOrderItem.CostCentre.Code,
                             CostCode = purchaseOrderItem.CostCentre.Code,
                             //Category = purchaseOrderItem.cat
                             //Category = purchaseOrderItem.cat