|
@@ -447,12 +447,12 @@ public partial class ReservationManagementPanel : UserControl, IPanel<JobRequisi
|
|
|
if(window.ShowDialog() == true)
|
|
|
{
|
|
|
var orders = new List<Tuple<PurchaseOrder, List<(PurchaseOrderItem, JobRequisitionItemLink)>>>();
|
|
|
+
|
|
|
foreach(var perSupplier in window.Results.GroupBy(x => x.Supplier.ID))
|
|
|
{
|
|
|
var order = new PurchaseOrder();
|
|
|
order.RaisedBy.ID = App.EmployeeID;
|
|
|
- order.IssuedBy.ID = App.EmployeeID;
|
|
|
- order.IssuedDate = DateTime.Now;
|
|
|
+
|
|
|
order.DueDate = DateTime.Today.AddDays(7);
|
|
|
order.Notes = [$"Treatment purchase order raised by {App.EmployeeName} from Reservation Management screen"];
|
|
|
|
|
@@ -490,6 +490,27 @@ public partial class ReservationManagementPanel : UserControl, IPanel<JobRequisi
|
|
|
orders.Add(new(order, orderItems));
|
|
|
}
|
|
|
|
|
|
+ var issue = false;
|
|
|
+ if(Security.IsAllowed<CanIssueTreatmentPurchaseOrders>())
|
|
|
+ {
|
|
|
+ if (_globalSettings.AutoIssueTreatmentPOs)
|
|
|
+ {
|
|
|
+ issue = true;
|
|
|
+ }
|
|
|
+ else if(MessageWindow.ShowYesNo($"Do you wish to mark the purchase order{(orders.Count != 1 ? "s" : "")} as issued?", "Mark as issued?"))
|
|
|
+ {
|
|
|
+ issue = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (issue)
|
|
|
+ {
|
|
|
+ foreach(var (order, _) in orders)
|
|
|
+ {
|
|
|
+ order.IssuedBy.ID = App.EmployeeID;
|
|
|
+ order.IssuedDate = DateTime.Now;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
Client.Save(orders.Select(x => x.Item1), "Treatment PO created from Reservation Management screen");
|
|
|
foreach(var (order, orderItems) in orders)
|
|
|
{
|
|
@@ -507,6 +528,11 @@ public partial class ReservationManagementPanel : UserControl, IPanel<JobRequisi
|
|
|
return jriPOI;
|
|
|
}), "Treatment PO created from Reservation Management screen");
|
|
|
|
|
|
+ MessageWindow.ShowMessage(
|
|
|
+ $"{orders.Count} treatment purchase order{(orders.Count != 1 ? "s" : "")} {(issue ? "issued" : "raised")}:\n" +
|
|
|
+ $"- {string.Join(',', orders.Select(x => x.Item1.PONumber))}",
|
|
|
+ "Success");
|
|
|
+
|
|
|
JobRequiItems.SelectedRows = [];
|
|
|
JobRequiItems.Refresh(false, true);
|
|
|
}
|