|
@@ -140,6 +140,7 @@ public class ReservationManagementItemGrid : DynamicDataGrid<JobRequisitionItem>
|
|
|
HiddenColumns.Add(x => x.Issued);
|
|
|
|
|
|
HiddenColumns.Add(x => x.Product.ID);
|
|
|
+ HiddenColumns.Add(x => x.Product.Name);
|
|
|
HiddenColumns.Add(x => x.Product.Code);
|
|
|
HiddenColumns.Add(x => x.Product.Group.ID);
|
|
|
HiddenColumns.Add(x => x.Product.Group.Code);
|
|
@@ -325,7 +326,6 @@ public class ReservationManagementItemGrid : DynamicDataGrid<JobRequisitionItem>
|
|
|
|
|
|
#region CreatePurchaseOrder
|
|
|
|
|
|
-
|
|
|
private bool PurchaseOrder_Click(Button button, CoreRow[] rows)
|
|
|
{
|
|
|
if(rows.Length == 0)
|
|
@@ -382,6 +382,8 @@ public class ReservationManagementItemGrid : DynamicDataGrid<JobRequisitionItem>
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ Window? PurchasingWindow;
|
|
|
+
|
|
|
private void AddToExistingOrder(CoreRow[] rows)
|
|
|
{
|
|
|
var dlg = new MultiSelectDialog<PurchaseOrder>(
|
|
@@ -391,6 +393,45 @@ public class ReservationManagementItemGrid : DynamicDataGrid<JobRequisitionItem>
|
|
|
if (dlg.ShowDialog())
|
|
|
{
|
|
|
var id = dlg.IDs().First();
|
|
|
+
|
|
|
+ var jris = rows.ToArray<JobRequisitionItem>();
|
|
|
+
|
|
|
+ var pois = new List<(PurchaseOrderItem poi, PurchaseOrderItemAllocation poia)>();
|
|
|
+
|
|
|
+ foreach (var jobRequisitionItem in jris)
|
|
|
+ {
|
|
|
+ // We only want stuff which doesn't have enough total stock allocated, which is the InStock and Issued added together.
|
|
|
+ if(!jobRequisitionItem.Qty.IsEffectivelyGreaterThan(jobRequisitionItem.InStock + jobRequisitionItem.Issued))
|
|
|
+ continue;
|
|
|
+
|
|
|
+ var poItem = new PurchaseOrderItem
|
|
|
+ {
|
|
|
+ Description = jobRequisitionItem.Product.Name,
|
|
|
+ Qty = jobRequisitionItem.Qty
|
|
|
+ };
|
|
|
+ poItem.Product.ID = jobRequisitionItem.Product.ID;
|
|
|
+ poItem.Product.Synchronise(jobRequisitionItem.Product);
|
|
|
+ poItem.Dimensions.CopyFrom(jobRequisitionItem.Dimensions);
|
|
|
+ poItem.Style.ID = jobRequisitionItem.Style.ID;
|
|
|
+ poItem.Style.Synchronise(jobRequisitionItem.Style);
|
|
|
+ poItem.PurchaseOrderLink.ID = id;
|
|
|
+
|
|
|
+ var allocation = new PurchaseOrderItemAllocation();
|
|
|
+ allocation.Job.CopyFrom(jobRequisitionItem.Job);
|
|
|
+ allocation.JobRequisitionItem.CopyFrom(jobRequisitionItem);
|
|
|
+
|
|
|
+ pois.Add((poItem, allocation));
|
|
|
+ }
|
|
|
+
|
|
|
+ Client.Save(pois.Select(x => x.poi), "Created from Reservation Management Screen");
|
|
|
+
|
|
|
+ foreach(var (poi, poia) in pois)
|
|
|
+ {
|
|
|
+ poia.Item.CopyFrom(poi);
|
|
|
+ }
|
|
|
+ Client.Save(pois.Select(x => x.poia), "Created from Reservation Management Screen");
|
|
|
+
|
|
|
+ ViewPurchaseOrder(id);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -564,7 +605,6 @@ public class ReservationManagementItemGrid : DynamicDataGrid<JobRequisitionItem>
|
|
|
CreateOrder.IsEnabled = bAny;
|
|
|
CreatePickingList.IsEnabled = bAny;
|
|
|
ConsolidateHoldings.IsEnabled = bAny;
|
|
|
-
|
|
|
}
|
|
|
|
|
|
#region Action Column Buttons
|