Selaa lähdekoodia

Reservation Management Holdings now display negative quantities
Empty Stock Holdings remain active if allocations remain unfulfilled

frogsoftware 11 kuukautta sitten
vanhempi
commit
ed7c5e2faf

+ 1 - 1
prs.desktop/Panels/Products/Locations/StockHoldingGrid.cs

@@ -169,7 +169,7 @@ public class StockHoldingGrid : DynamicDataGrid<StockHolding>
                 if (holdings.Contains(holding))
                     holdings.Remove(holding);
 
-                if (holding.Units.IsEffectivelyEqual(0.0f))
+                if (holding.Units.IsEffectivelyEqual(0.0) && holding.Available.IsEffectivelyEqual(0.0))
                 {
                     if(holding.ID != Guid.Empty)
                     {

+ 4 - 4
prs.desktop/Panels/Reservation Management/ReservationManagementHoldingsGrid.xaml.cs

@@ -258,9 +258,9 @@ public partial class ReservationManagementHoldingsGrid
             || element.DataContext is not ReservationManagementHoldingsModel model
             || element.Tag is not List<StockMovement> mvts) return;
 
-        if (mvts == model.StockOfCurrentStyle && model.UnitsOfCurrentStyle <= 0
-            || mvts == model.StockOfNoStyle && model.UnitsOfNoStyle <= 0
-            || mvts == model.StockOfOtherStyles && model.UnitsOfOtherStyles <= 0)
+        if (mvts == model.StockOfCurrentStyle && model.UnitsOfCurrentStyle.IsEffectivelyEqual(0.0)
+            || mvts == model.StockOfNoStyle && model.UnitsOfNoStyle.IsEffectivelyEqual(0.0)
+            || mvts == model.StockOfOtherStyles && model.UnitsOfOtherStyles.IsEffectivelyEqual(0.0))
         {
             return;
         }
@@ -300,7 +300,7 @@ public partial class ReservationManagementHoldingsGrid
             }
         }
 
-        var filteredHoldings = holdings.Where(x => x.Value.Units.IsEffectivelyGreaterThan(0))
+        var filteredHoldings = holdings.Where(x => !x.Value.Units.IsEffectivelyEqual(0.0))
             .Select(x => new StockSelectionPage.Holding(x.Value, x.Key.requiItemID));
 
         var page = new StockSelectionPage(

+ 5 - 4
prs.desktop/Panels/Reservation Management/ReservationManagementHoldingsModel.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Windows;
 using Comal.Classes;
+using InABox.Core;
 
 namespace PRSDesktop;
 
@@ -20,11 +21,11 @@ public class ReservationManagementHoldingsModel
     public double UnitsOfNoStyle { get; set; }
     public double UnitsOfOtherStyles { get; set; }
 
-    public bool CurrentStylePositive => UnitsOfCurrentStyle > 0;
-    public bool NoStylePositive => UnitsOfNoStyle > 0;
-    public bool OtherStylesPositive => UnitsOfOtherStyles > 0;
+    public bool CurrentStylePositive => !UnitsOfCurrentStyle.IsEffectivelyEqual(0.0);
+    public bool NoStylePositive => !UnitsOfNoStyle.IsEffectivelyEqual(0.0);
+    public bool OtherStylesPositive => !UnitsOfOtherStyles.IsEffectivelyEqual(0.0);
 
-    public bool Empty => UnitsOfCurrentStyle <= 0 && UnitsOfNoStyle <= 0 && UnitsOfOtherStyles <= 0;
+    public bool Empty => UnitsOfCurrentStyle.IsEffectivelyEqual(0.0) && UnitsOfNoStyle.IsEffectivelyEqual(0.0) && UnitsOfOtherStyles.IsEffectivelyEqual(0.0);
 
     public bool AlreadyAllocated { get; set; }
     public Guid JobID { get; set; }

+ 2 - 1
prs.desktop/Panels/Reservation Management/StockSelectionPage.xaml

@@ -27,7 +27,8 @@
         </Border>
 
         <local:StockSelectionGrid x:Name="Grid" Grid.Row="1" Margin="5"
-                                  PropertyChanged="Grid_PropertyChanged"/>
+                                  PropertyChanged="Grid_PropertyChanged"
+                                  AfterRefresh="Grid_OnAfterRefresh"/>
 
         <DockPanel Grid.Row="2" LastChildFill="False">
             <Button x:Name="CancelButton" Click="CancelButton_Click"

+ 16 - 4
prs.desktop/Panels/Reservation Management/StockSelectionPage.xaml.cs

@@ -96,10 +96,15 @@ public partial class StockSelectionPage : ThemableWindow, INotifyPropertyChanged
         private set
         {
             _canEdit = value;
-            foreach(var item in Grid.Items)
-            {
-                item.Editable = value;
-            }
+            UpdateItems();
+        }
+    }
+
+    private void UpdateItems()
+    {
+        foreach(var item in Grid.Items)
+        {
+            item.Editable = _canEdit && item.Quantity.IsEffectivelyGreaterThan(0.0);
         }
     }
 
@@ -147,6 +152,8 @@ public partial class StockSelectionPage : ThemableWindow, INotifyPropertyChanged
             }
         }
 
+        //UpdateItems();
+
         Grid.Refresh(true, true);
     }
 
@@ -243,4 +250,9 @@ public partial class StockSelectionPage : ThemableWindow, INotifyPropertyChanged
     {
         PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
     }
+
+    private void Grid_OnAfterRefresh(object sender, AfterRefreshEventArgs args)
+    {
+        UpdateItems();
+    }
 }

+ 1 - 1
prs.stores/StockHoldingStore.cs

@@ -81,7 +81,7 @@ public class StockHoldingStore : BaseStore<StockHolding>
         holding.AverageValue = holding.Units != 0 ? holding.Value / holding.Units : 0.0F;
 
         // Automagically clean up empty holdings
-        if (holding.Units.IsEffectivelyEqual(0.0F))
+        if (holding.Units.IsEffectivelyEqual(0.0) && holding.Available.IsEffectivelyEqual(0.0))
         {
             if (holding.ID != Guid.Empty)
                 DbFactory.Provider.Delete(holding, "");