|
@@ -23,6 +23,7 @@ using Brush = System.Windows.Media.Brush;
|
|
|
using Button = System.Windows.Controls.Button;
|
|
|
using ContextMenu = System.Windows.Controls.ContextMenu;
|
|
|
using MenuItem = System.Windows.Controls.MenuItem;
|
|
|
+using FluentResults;
|
|
|
|
|
|
namespace PRSDesktop;
|
|
|
|
|
@@ -98,18 +99,29 @@ public class ReservationManagementItemGrid : DynamicDataGrid<JobRequisitionItem>
|
|
|
var qty = row.Get<JobRequisitionItem, double>(x => x.Qty);
|
|
|
if(row.Get<JobRequisitionItem, double>(x => x.Issued) >= qty)
|
|
|
{
|
|
|
+ // Everything has been issued.
|
|
|
return Colors.Silver.ToBrush(0.5);
|
|
|
}
|
|
|
else if(row.Get<JobRequisitionItem, double>(x => x.Allocated) + row.Get<JobRequisitionItem, double>(x => x.Issued) >= qty)
|
|
|
{
|
|
|
+ // Everything has been allocated.
|
|
|
return Colors.LightGreen.ToBrush(0.5);
|
|
|
}
|
|
|
else if(row.Get<JobRequisitionItem, double>(x => x.InStock) + row.Get<JobRequisitionItem, double>(x => x.Issued) >= qty)
|
|
|
{
|
|
|
+ // Everything is in stock, but needs treatment
|
|
|
return Colors.Orange.ToBrush(0.5);
|
|
|
}
|
|
|
+ else if(row.Get<JobRequisitionItem, double>(x => x.OnOrder)
|
|
|
+ + row.Get<JobRequisitionItem, double>(x => x.InStock)
|
|
|
+ + row.Get<JobRequisitionItem, double>(x => x.Issued) >= qty)
|
|
|
+ {
|
|
|
+ // Ordered, but not received.
|
|
|
+ return Colors.LightYellow.ToBrush();
|
|
|
+ }
|
|
|
else
|
|
|
{
|
|
|
+ // Not enough in stock.
|
|
|
return Colors.LightSalmon.ToBrush(0.5);
|
|
|
}
|
|
|
}
|
|
@@ -646,33 +658,44 @@ public class ReservationManagementItemGrid : DynamicDataGrid<JobRequisitionItem>
|
|
|
column.AddSeparator();
|
|
|
column.AddItem("View Holdings", PRSDesktop.Resources.warehouse, ViewStockHoldings);
|
|
|
column.AddItem("View Stock Movements", PRSDesktop.Resources.forklift, ViewStockMovements);
|
|
|
+
|
|
|
var viewOrder = column.AddItem("View Purchase Order", PRSDesktop.Resources.purchase, null);
|
|
|
+ viewOrder.AddItem("Loading...", null, null, enabled: false);
|
|
|
|
|
|
- var orders = Client.Query(
|
|
|
+ var task = Task.Run(() =>
|
|
|
+ {
|
|
|
+ return Client.Query(
|
|
|
new Filter<PurchaseOrderItemAllocation>(x => x.JobRequisitionItem.ID).IsEqualTo(row.Get<JobRequisitionItem, Guid>(x => x.ID)),
|
|
|
Columns.None<PurchaseOrderItemAllocation>()
|
|
|
.Add(x => x.Item.PurchaseOrderLink.ID)
|
|
|
.Add(x => x.Item.PurchaseOrderLink.PONumber)
|
|
|
- .Add(x => x.Item.PurchaseOrderLink.SupplierLink.Name)
|
|
|
- ).ToTuples<PurchaseOrderItemAllocation, Guid, String, String>(
|
|
|
- x => x.Item.PurchaseOrderLink.ID,
|
|
|
- x => x.Item.PurchaseOrderLink.PONumber,
|
|
|
- x => x.Item.PurchaseOrderLink.SupplierLink.Name)
|
|
|
- .ToArray();
|
|
|
- if(orders.Length > 0)
|
|
|
+ .Add(x => x.Item.PurchaseOrderLink.SupplierLink.Name))
|
|
|
+ .ToTuples<PurchaseOrderItemAllocation, Guid, String, String>(
|
|
|
+ x => x.Item.PurchaseOrderLink.ID,
|
|
|
+ x => x.Item.PurchaseOrderLink.PONumber,
|
|
|
+ x => x.Item.PurchaseOrderLink.SupplierLink.Name)
|
|
|
+ .ToArray();
|
|
|
+ });
|
|
|
+ task.ContinueWith(orders =>
|
|
|
{
|
|
|
- foreach (var tuple in orders)
|
|
|
+ viewOrder.Items.Clear();
|
|
|
+
|
|
|
+ if (orders.Result.Length > 0)
|
|
|
{
|
|
|
- if(tuple.Item1 != Guid.Empty)
|
|
|
+ foreach (var tuple in orders.Result)
|
|
|
{
|
|
|
- column.AddItem($"{tuple.Item2}: {tuple.Item3}", PRSDesktop.Resources.purchase, (r) => ViewPurchaseOrder(tuple.Item1), viewOrder);
|
|
|
+ if (tuple.Item1 != Guid.Empty)
|
|
|
+ {
|
|
|
+ viewOrder.AddItem($"{tuple.Item2}: {tuple.Item3}", PRSDesktop.Resources.purchase, tuple.Item1, ViewPurchaseOrder);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- viewOrder.IsEnabled = false;
|
|
|
- }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ viewOrder.IsEnabled = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ }, TaskScheduler.FromCurrentSynchronizationContext());
|
|
|
}
|
|
|
}
|
|
|
|