瀏覽代碼

Fixed POIA NominatedJob aggregate to only pick allocations that have been nominated.

Kenric Nugteren 9 月之前
父節點
當前提交
83ab53ec80

+ 1 - 1
prs.classes/Entities/PurchaseOrder/PurchaseOrderItem.cs

@@ -270,7 +270,7 @@ namespace Comal.Classes
     
     public class PurchaseOrderItemAllocationNominatedJob : IChildEntityDefinition<PurchaseOrderItemAllocation>
     {
-        public Filter<PurchaseOrderItemAllocation>? Filter { get; set; } = null;
+        public Filter<PurchaseOrderItemAllocation>? Filter { get; set; } = new Filter<PurchaseOrderItemAllocation>(x => x.Nominated).IsEqualTo(true);
 
         public SortOrder<PurchaseOrderItemAllocation>? Sort { get; set; }
             = new SortOrder<PurchaseOrderItemAllocation>(x => x.Job.JobNumber, SortDirection.Descending).ThenBy(x => x.Created, SortDirection.Descending);

+ 1 - 1
prs.classes/Entities/PurchaseOrder/PurchaseOrderItemAllocation.cs

@@ -28,7 +28,7 @@ namespace Comal.Classes
         
         public double Quantity { get; set; }
 
-        [CheckBoxEditor]
+        [NullEditor]
         public bool Nominated { get; set; }
     }
 

+ 2 - 2
prs.desktop/Panels/Jobs/Summary/JobSummaryGrid.cs

@@ -133,7 +133,7 @@ internal class JobSummaryGrid : DynamicDataGrid<JobMaterial>, IMasterDetailContr
         });
         MessageWindow.ShowMessage("The selected stock holdings have been cancelled.","Done");
 
-        return updates.Any();
+        return updates.Count != 0;
     }
     
     private bool CancelRequisitions(System.Windows.Controls.Button btn, CoreRow[] rows)
@@ -173,7 +173,7 @@ internal class JobSummaryGrid : DynamicDataGrid<JobMaterial>, IMasterDetailContr
             }
         });
         MessageWindow.ShowMessage("The selected requisitions have been cancelled.","Done");
-        return updates.Any();
+        return updates.Count != 0;
     }
 
 

+ 37 - 0
prs.desktop/Panels/PurchaseOrders/PurchaseOrderItemAllocationGrid.cs

@@ -0,0 +1,37 @@
+using Comal.Classes;
+using InABox.Core;
+using InABox.DynamicGrid;
+using InABox.WPF;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Media.Imaging;
+
+namespace PRSDesktop.Panels.PurchaseOrders;
+
+public class PurchaseOrderItemAllocationGrid : DynamicOneToManyGrid<PurchaseOrderItem, PurchaseOrderItemAllocation>
+{
+    private static readonly BitmapImage tick = PRSDesktop.Resources.tick.AsBitmapImage();
+
+    protected override void Init()
+    {
+        base.Init();
+
+        ActionColumns.Add(new DynamicTickColumn<PurchaseOrderItemAllocation, bool>(x => x.Nominated, tick, tick, null, Nominated_Click));
+    }
+
+    private bool Nominated_Click(CoreRow? row)
+    {
+        if (row is null) return false;
+
+        var selectedItem = LoadItem(row);
+        foreach(var item in Items)
+        {
+            item.Nominated = false;
+        }
+        selectedItem.Nominated = true;
+        return true;
+    }
+}