Browse Source

Revert "PRS 8.20c"

This reverts commit afe8b575a22975582eb82ea36826b2db3b732d71.
frogsoftware 9 hours ago
parent
commit
65382f99b8

+ 1 - 1
prs.classes/Entities/Job/Requisitions/JobRequisitionItem.cs

@@ -445,4 +445,4 @@ namespace Comal.Classes
 
         public override AggregateCalculation Calculation => AggregateCalculation.Concat;
     }
-  }
+}

+ 0 - 1
prs.classes/Entities/Stock/StockHolding/StockHolding.cs

@@ -180,7 +180,6 @@ namespace Comal.Classes
                     holding.Style.ID = first.Style.ID;
                     holding.Job.ID = first.Job.ID;
                     holding.Dimensions.CopyFrom(first.Dimensions);
-                    grouped.Add(holding);
                 }
                 holding.Recalculate(selected);
 

+ 7 - 136
prs.desktop/Panels/Reservation Management/ReservationManagementItemGrid.cs

@@ -16,7 +16,6 @@ using System.Threading.Tasks;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Media;
-using Microsoft.Xaml.Behaviors.Core;
 using Brush = System.Windows.Media.Brush;
 
 namespace PRSDesktop;
@@ -33,7 +32,6 @@ public class ReservationManagementItemGrid : DynamicDataGrid<JobRequisitionItem>
     private Button ArchiveButton;
     private Button CreatePickingList;
     private Button CreateOrder;
-    private Button ConsolidateHoldings;
     
     public bool ShowColors { get; set; } 
     
@@ -193,129 +191,8 @@ public class ReservationManagementItemGrid : DynamicDataGrid<JobRequisitionItem>
 
         ArchiveButton = AddButton("Archive", PRSDesktop.Resources.archive.AsBitmapImage(), ArchiveButton_Clicked);
         ArchiveButton.IsEnabled = false;
-        
-        ConsolidateHoldings = AddButton("Consolidate", PRSDesktop.Resources.product.AsBitmapImage(), ConsolidateHoldings_Clicked);
-        ConsolidateHoldings.IsEnabled = false;
-    }
-
-    private bool ConsolidateHoldings_Clicked(Button button, CoreRow[] rows)
-    {
-        ContextMenu menu = new ContextMenu();
-
-        menu.Items.Add( 
-            new MenuItem()
-            {
-                Header = "Move to Location",
-                Command = new ActionCommand(() =>
-                {
-                    MultiSelectDialog<StockLocation> dlg =
-                        new MultiSelectDialog<StockLocation>(new Filter<StockLocation>(x => x.Active).IsEqualTo(true),
-                            null, false);
-                    if (dlg.ShowDialog() == true)
-                        ConsolidateStockLocations(rows, dlg.Items().First());
-                })
-            }
-        );
-
-        menu.Items.Add(new Separator());
-        
-        menu.Items.Add( 
-            new MenuItem()
-            {
-                Header = "Create New Location",
-                Command = new ActionCommand(() =>
-                {
-                    var _location = new StockLocation();
-                    var _grid = DynamicGridUtils.CreateDynamicGrid<StockLocation>(typeof(DynamicDataGrid<>));
-                    if (_grid.EditItems( [ _location ] ))
-                    {
-                        ConsolidateStockLocations(rows, _location);
-                    }
-
-                })
-            }
-        );
-        
-        menu.IsOpen = true;
-
-        return false;
-
-    }
-
-    private void ConsolidateStockLocations(CoreRow[] rows, StockLocation location)
-    {
-        Progress.ShowModal("Consolidating Items", progress =>
-        {
-            var _ids = rows.Select(r => r.Get<JobRequisitionItem, Guid>(x => x.ID))
-                .Distinct()
-                .ToArray();
-            
-            var _allmovements = Client.Query(
-                new Filter<StockMovement>(x => x.JobRequisitionItem.ID).InList(_ids),
-                Columns.None<StockMovement>()
-                    .Add(x=>x.Product.ID)
-                    .Add(x=>x.Style.ID)
-                    .Add(x=>x.Location.ID)
-                    .Add(x=>x.Job.ID)
-                    .Add(x=>x.Units)
-                    .Add(x=>x.Cost)
-                    .Add(x=>x.JobRequisitionItem.ID)
-                    .AddDimensionsColumns(x=>x.Dimensions)
-            );
-            
-            if (_allmovements.Rows.Any())
-            {
-
-                progress.Report("Creating Batch");
-                var _batch = new StockMovementBatch();
-                _batch.TimeStamp = DateTime.Now;
-                _batch.Type = StockMovementBatchType.Transfer;
-                _batch.Employee.ID = App.EmployeeID;
-                Client.Save(_batch, "Consolidating requisition items into single location");
-                
-                progress.Report("Creating Transactions");
-                List<StockMovement> _updates = new();
-                foreach (var _id in _ids)
-                {
-                    var _movements = _allmovements.Rows
-                        .Where(r => r.Get<StockMovement,Guid>(x=>x.JobRequisitionItem.ID) == _id)
-                        .ToObjects<StockMovement>()
-                        .ToArray();
-
-                    var _holdings = StockHoldingExtensions.GroupMovements(_movements).ToArray();
-                    foreach (var _holding in _holdings)
-                    {
-                        var _transout = _holding.CreateMovement();
-                        _transout.Employee.ID = _batch.Employee.ID;
-                        _transout.Issued = _holding.Units;
-                        _transout.Cost = _holding.AverageValue;
-                        _transout.Type = StockMovementType.TransferOut;
-                        _transout.JobRequisitionItem.ID = _id;
-                        _transout.Batch.ID = _batch.ID;
-                        _transout.Notes = $"Consolidating requisition item holdings from {_holding.Location.Code} to {location.Code}";
-                        _updates.Add(_transout);
-
-                        var _transin = _holding.CreateMovement();
-                        _transin.Date = _transout.Date.AddTicks(1);
-                        _transin.Employee.ID = _batch.Employee.ID;
-                        _transin.Location.ID = location.ID;
-                        _transin.Received = _holding.Units;
-                        _transin.Cost = _holding.AverageValue;
-                        _transin.Type = StockMovementType.TransferIn;
-                        _transin.Transaction = _transout.Transaction;
-                        _transin.JobRequisitionItem.ID = _id;
-                        _transin.Batch.ID = _batch.ID;
-                        _transin.Notes = $"Consolidating requisition item holdings from {_holding.Location.Code} to {location.Code}";
-                        _updates.Add(_transin);
-                    }
-                    
-                }
-                Client.Save(_updates,$"Consolidated requisition item holdings to {location.Code}");
-            }
-        });
-
     }
-
+    
     #region CreatePurchaseOrder
     
     private bool DoCreatePurchaseOrder(Button button, CoreRow[]? rows)
@@ -546,18 +423,12 @@ public class ReservationManagementItemGrid : DynamicDataGrid<JobRequisitionItem>
     protected override void SelectItems(CoreRow[]? rows)
     {
         base.SelectItems(rows);
-        
-        ArchiveButton.Visibility = Options.MultiSelect ? Visibility.Visible : Visibility.Collapsed;
-        CreateOrder.Visibility = Options.MultiSelect ? Visibility.Visible : Visibility.Collapsed;
-        CreatePickingList.Visibility = Options.MultiSelect ? Visibility.Visible : Visibility.Collapsed;
-        ConsolidateHoldings.Visibility = Options.MultiSelect ? Visibility.Visible : Visibility.Collapsed;
-
-        bool bAny = rows?.Any() == true;
-        ArchiveButton.IsEnabled = bAny;
-        CreateOrder.IsEnabled = bAny;
-        CreatePickingList.IsEnabled = bAny;
-        ConsolidateHoldings.IsEnabled = bAny;
-        
+        if(rows?.Any() == true)
+        {
+            ArchiveButton.IsEnabled = true;
+            CreateOrder.IsEnabled = true;
+            CreatePickingList.IsEnabled = true;
+        }
     }
 
     #region Action Column Buttons

+ 1 - 3
prs.desktop/Panels/Reservation Management/ReservationManagementPanel.xaml.cs

@@ -677,9 +677,7 @@ public partial class ReservationManagementPanel : UserControl, IPanel<JobRequisi
         _updatingSubstitution = true;
         try
         {
-            var row = Mode == PanelMode.Reserve && e.Rows?.Length == 1
-                ? e.Rows.FirstOrDefault()
-                : null;
+            var row = e.Rows?.SingleOrDefault();
             var visible =
                 row != null
                 && row.Get<JobRequisitionItem, double>(x => x.InStock).IsEffectivelyEqual(0.0)

+ 86 - 142
prs.desktop/Panels/Stock Forecast/StockForecastGrid.cs

@@ -15,7 +15,6 @@ using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Media;
 using System.Windows.Media.Imaging;
-using StockMovement = Comal.Classes.StockMovement;
 
 namespace PRSDesktop;
 
@@ -53,7 +52,7 @@ public class StockForecastItem : BaseObject
     public void AddJobBOM(Guid jobID, double quantity)
     {
         var item = JobInfo.GetValueOrAdd(jobID);
-        item.BOM = Math.Max(0.0, item.BOM + quantity);
+        item.BOM += quantity;
     }
     public void AddJobPO(Guid jobID, double quantity)
     {
@@ -389,31 +388,8 @@ public class StockForecastGrid : DynamicItemsListGrid<StockForecastItem>, IDataM
             return "";
         }
     }
-    
-    private void ShowDetailGrid(String title, params Func<IDynamicDataGrid?>[] gridfuncs)
-    {
-        var _window = new ThemableWindow { Title = title };
-        var _tabcontrol = new DynamicTabControl() { TabStripPlacement = Dock.Bottom, Margin = new Thickness(5) };
-        _window.Content = _tabcontrol;
-        foreach (var gridfunc in gridfuncs)
-        {
-            var _grid = gridfunc();
-            if (_grid != null)
-            {
-                _tabcontrol.Items.Add(
-                    new DynamicTabItem()
-                    {
-                        Header = CoreUtils.Neatify(_grid.DataType.Name.Split('.').Last()),
-                        Content = _grid
-                    }
-                );
-                _grid.Refresh(true,true);
-            }
-        }
-        _window.ShowDialog();
-    }
-    
-    private IDynamicDataGrid BuildDetailGrid<TEntity>(
+
+    private void ShowDetailGrid<TEntity>(
         String tag, 
         Expression<Func<TEntity,object?>> productcol, 
         Guid productid, 
@@ -426,38 +402,41 @@ public class StockForecastGrid : DynamicItemsListGrid<StockForecastItem>, IDataM
         Func<CoreRow,bool>? rowfilter
     )
     {
-        var _grid = (Activator.CreateInstance(typeof(DynamicDataGrid<>).MakeGenericType(typeof(TEntity))) as IDynamicDataGrid);
-        if (_grid == null)
+        var grid = (Activator.CreateInstance(typeof(DynamicDataGrid<>).MakeGenericType(typeof(TEntity))) as IDynamicDataGrid);
+        if (grid == null)
         {
             MessageWindow.ShowError($"Cannot create Grid for [{typeof(TEntity).Name}]", "", shouldLog: false);
-            return null;
+            return;
         }
-        _grid.ColumnsTag = $"{ColumnsTag}.{tag}";
-        _grid.Reconfigure(options =>
+        grid.ColumnsTag = $"{ColumnsTag}.{tag}";
+        grid.Reconfigure(options =>
         {
             options.Clear();
             options.FilterRows = true;
             options.SelectColumns = true;
         });
-        _grid.OnDefineFilter += t =>
+        grid.OnDefineFilter += t =>
         {
-            var _filter = new Filter<TEntity>(productcol).IsEqualTo(productid);
+            var filter = new Filter<TEntity>(productcol).IsEqualTo(productid);
             if(dimensions is not null)
-                _filter = _filter.And(CoreUtils.GetFullPropertyName(dimcol, ".")).DimensionEquals(dimensions);
+            {
+                filter = filter.And(CoreUtils.GetFullPropertyName(dimcol, ".")).DimensionEquals(dimensions);
+            }
             
             if (styleid.HasValue)
-                _filter = _filter.And(stylecol).IsEqualTo(styleid);
+                filter = filter.And(stylecol).IsEqualTo(styleid);
 
             if (jobcol != null)
-                _filter = _filter.And(new Filter<TEntity>(jobcol).InList(JobIDs));
+                filter = filter.And(new Filter<TEntity>(jobcol).InList(JobIDs));
                 
             if (extrafilter != null)
-                _filter = _filter.And(extrafilter);
+                filter = filter.And(extrafilter);
             
-            return _filter;
+            return filter;
         };
-        _grid.OnFilterRecord += row => rowfilter?.Invoke(row) ?? true;
-        return _grid;
+        grid.OnFilterRecord += row => rowfilter?.Invoke(row) ?? true;
+        var window = DynamicGridUtils.CreateGridWindow($"Viewing {CoreUtils.Neatify(tag)} Calculation", grid);
+        window.ShowDialog();
     }
 
     protected override void DoDoubleClick(object sender, DynamicGridCellClickEventArgs args)
@@ -472,103 +451,70 @@ public class StockForecastGrid : DynamicItemsListGrid<StockForecastItem>, IDataM
         switch (tag)
         {
             case ColumnTag.GeneralStockHoldings:
-                ShowDetailGrid(
-                    "Stock Holdings", 
-                    () => BuildDetailGrid<StockHolding>(
-                        ColumnTag.GeneralStockHoldings.ToString(), 
-                        x => x.Product.ID, 
-                     item.Product.ID, 
-                        x => x.Style.ID, 
-                        styleid, 
-                        x => x.Dimensions,
-                        item.Dimensions,
-                        null,
-                        new Filter<StockHolding>(x=>x.Job.ID).IsEqualTo(Guid.Empty),
-                        null
-                    )
-                );               
+                ShowDetailGrid<StockHolding>(
+                    ColumnTag.GeneralStockHoldings.ToString(), 
+                    x => x.Product.ID, 
+                    item.Product.ID, 
+                    x => x.Style.ID, 
+                    styleid, 
+                    x => x.Dimensions,
+                    item.Dimensions,
+                    null,
+                    new Filter<StockHolding>(x=>x.Job.ID).IsEqualTo(Guid.Empty),
+                    null);               
                 break;
             case ColumnTag.GeneralPurchaseOrders:
-                ShowDetailGrid(
-                    "Purchase Orders", 
-                    () => BuildDetailGrid<PurchaseOrderItem>(
-                        ColumnTag.GeneralPurchaseOrders.ToString(), 
-                        x => x.Product.ID, 
-                        item.Product.ID, 
-                        x => x.Style.ID, 
-                        styleid, 
-                        x => x.Dimensions,
-                        item.Dimensions,
-                        null,
-                        new Filter<PurchaseOrderItem>(x=>x.Job.ID).IsEqualTo(Guid.Empty)
-                            .And(x=>x.ReceivedDate).IsEqualTo(DateTime.MinValue),
-                        null
-                    )
-                );
+                ShowDetailGrid<PurchaseOrderItem>(
+                    ColumnTag.GeneralPurchaseOrders.ToString(), 
+                    x => x.Product.ID, 
+                    item.Product.ID, 
+                    x => x.Style.ID, 
+                    styleid, 
+                    x => x.Dimensions,
+                    item.Dimensions,
+                    null,
+                    new Filter<PurchaseOrderItem>(x=>x.Job.ID).IsEqualTo(Guid.Empty)
+                        .And(x=>x.ReceivedDate).IsEqualTo(DateTime.MinValue),
+                    null);
                 break;
             case ColumnTag.JobStockRequired:
-                ShowDetailGrid(
-                    "Bills Of Materials", 
-                    () => BuildDetailGrid<JobBillOfMaterialsItem>(
-                        ColumnTag.JobStockRequired.ToString(), 
-                        x => x.Product.ID, 
-                        item.Product.ID, 
-                        x => x.Style.ID, 
-                        styleid, 
-                        x => x.Dimensions,
-                        item.Dimensions,
-                        x => x.Job.ID,
-                        new Filter<JobBillOfMaterialsItem>(x=>x.BillOfMaterials.Approved).IsNotEqualTo(DateTime.MinValue),
-                        null
-                    ),
-                    () => BuildDetailGrid<StockMovement>(
-                        "JobStockIssued", 
-                        x => x.Product.ID, 
-                        item.Product.ID, 
-                        x => x.Style.ID, 
-                        styleid, 
-                        x => x.Dimensions,
-                        item.Dimensions,
-                        x => x.Job.ID,
-                        new Filter<StockMovement>(x=>x.Type).IsEqualTo(StockMovementType.Issue),
-                        null
-                    )
-                    
-                );
+                ShowDetailGrid<JobBillOfMaterialsItem>(
+                    ColumnTag.JobStockRequired.ToString(), 
+                    x => x.Product.ID, 
+                    item.Product.ID, 
+                    x => x.Style.ID, 
+                    styleid, 
+                    x => x.Dimensions,
+                    item.Dimensions,
+                    x => x.Job.ID,
+                    new Filter<JobBillOfMaterialsItem>(x=>x.BillOfMaterials.Approved).IsNotEqualTo(DateTime.MinValue),
+                    null);
                 break;
             case ColumnTag.JobStockHoldings:
-                ShowDetailGrid(
-                    "Stock Holdings", 
-                    () => BuildDetailGrid<StockHolding>(
-                        ColumnTag.JobStockHoldings.ToString(), 
-                        x => x.Product.ID, 
-                        item.Product.ID, 
-                        x => x.Style.ID, 
-                        styleid, 
-                        x => x.Dimensions,
-                        item.Dimensions,
-                        x => x.Job.ID,
-                        null,
-                        null
-                    )
-                );
+                ShowDetailGrid<StockHolding>(
+                    ColumnTag.JobStockHoldings.ToString(), 
+                    x => x.Product.ID, 
+                    item.Product.ID, 
+                    x => x.Style.ID, 
+                    styleid, 
+                    x => x.Dimensions,
+                    item.Dimensions,
+                    x => x.Job.ID,
+                    null,
+                    null);
                 break;
             case ColumnTag.JobPurchaseOrders:
-                ShowDetailGrid(
-                    "Purchase Orders", 
-                    () => BuildDetailGrid<PurchaseOrderItem>(
-                        ColumnTag.GeneralPurchaseOrders.ToString(), 
-                        x => x.Product.ID, 
-                        item.Product.ID, 
-                        x => x.Style.ID, 
-                        styleid, 
-                        x => x.Dimensions,
-                        item.Dimensions,
-                        x => x.Job.ID,
-                        new Filter<PurchaseOrderItem>(x=>x.ReceivedDate).IsEqualTo(DateTime.MinValue),
-                        null
-                    )
-                );                  
+                ShowDetailGrid<PurchaseOrderItem>(
+                    ColumnTag.GeneralPurchaseOrders.ToString(), 
+                    x => x.Product.ID, 
+                    item.Product.ID, 
+                    x => x.Style.ID, 
+                    styleid, 
+                    x => x.Dimensions,
+                    item.Dimensions,
+                    x => x.Job.ID,
+                    new Filter<PurchaseOrderItem>(x=>x.ReceivedDate).IsEqualTo(DateTime.MinValue),
+                    null);                  
                 break;
         }
     }
@@ -744,7 +690,6 @@ public class StockForecastGrid : DynamicItemsListGrid<StockForecastItem>, IDataM
                 filter: new Filter<PurchaseOrderItem>(x => x.ReceivedDate).IsEqualTo(DateTime.MinValue),
                 columns: Columns.None<PurchaseOrderItem>().Add(x => x.Qty)),
             GetQuery<JobBillOfMaterialsItem>(
-                filter: new Filter<JobBillOfMaterialsItem>(x=>x.BillOfMaterials.Approved).IsNotEqualTo(DateTime.MinValue),
                 columns: Columns.None<JobBillOfMaterialsItem>().Add(x => x.Quantity)),
             GetQuery<StockMovement>(
                 filter: new Filter<StockMovement>(x => x.Type).IsEqualTo(StockMovementType.Issue),
@@ -824,21 +769,20 @@ public class StockForecastGrid : DynamicItemsListGrid<StockForecastItem>, IDataM
                 var jobBOMItems = results.Get<JobBillOfMaterialsItem>();
                 foreach(var bomItem in jobBOMItems.Rows)
                 {
-                    var key = GetKey(bomItem);
-                    var item = GetItem(key);
+                    var item = GetItem(GetKey(bomItem));
 
-                    item.JobBOM = Math.Max(0.0, item.JobBOM + bomItem.Get<JobBillOfMaterialsItem, double>(x => x.Quantity));
+                    item.JobBOM += bomItem.Get<JobBillOfMaterialsItem, double>(x => x.Quantity);
                     item.AddJobBOM(bomItem.Get<JobBillOfMaterialsItem, Guid>(x => x.Job.ID), bomItem.Get<JobBillOfMaterialsItem, double>(x => x.Quantity));
                 }
 
-                // var movements = results.Get<StockMovement>();
-                // foreach(var mvt in movements.Rows)
-                // {
-                //     var item = GetItem(GetKey(mvt));
-                //
-                //     item.JobBOM = Math.Max(0.0, item.JobBOM + mvt.Get<StockMovement, double>(x => x.Units));
-                //     item.AddJobBOM(mvt.Get<StockMovement, Guid>(x => x.Job.ID), mvt.Get<StockMovement, double>(x => x.Units));
-                // }
+                var movements = results.Get<StockMovement>();
+                foreach(var mvt in movements.Rows)
+                {
+                    var item = GetItem(GetKey(mvt));
+
+                    item.JobBOM -= mvt.Get<StockMovement, double>(x => x.Units);
+                    item.AddJobBOM(mvt.Get<StockMovement, Guid>(x => x.Job.ID), -mvt.Get<StockMovement, double>(x => x.Units));
+                }
 
                 _supplierProducts = results.GetArray<SupplierProduct>();
 

+ 1 - 1
prs.desktop/prsdesktop.iss

@@ -8,7 +8,7 @@
 #define public Dependency_Path_NetCoreCheck "dependencies\"
 
 #define MyAppName "PRS Desktop"
-#define MyAppVersion "8.20c"
+#define MyAppVersion "8.20b"
 #define MyAppPublisher "PRS Digital"
 #define MyAppURL "https://www.prs-software.com.au"
 #define MyAppExeName "PRSDesktop.exe"

+ 1 - 1
prs.licensing/PRSLicensing.iss

@@ -8,7 +8,7 @@
 #define public Dependency_Path_NetCoreCheck "dependencies\"
 
 #define MyAppName "PRS Licensing"
-#define MyAppVersion "8.20c"
+#define MyAppVersion "8.20b"
 #define MyAppPublisher "PRS Digital"
 #define MyAppURL "https://www.prs-software.com.au"
 #define MyAppExeName "PRSLicensing.exe"

+ 1 - 1
prs.server/PRSServer.iss

@@ -8,7 +8,7 @@
 #define public Dependency_Path_NetCoreCheck "dependencies\"
 
 #define MyAppName "PRS Server"
-#define MyAppVersion "8.20c"
+#define MyAppVersion "8.20b"
 #define MyAppPublisher "PRS Digital"
 #define MyAppURL "https://www.prs-software.com.au"
 #define MyAppExeName "PRSServer.exe"