Bläddra i källkod

Added database paging for DeliveryItems, StockMovements, Supplier Products and Timesheets
Improved Stock Movement generation for Picking List Items

frogsoftware 1 år sedan
förälder
incheckning
635e3b70e1

+ 1 - 0
prs.classes/Entities/Job/JobLink.cs

@@ -7,6 +7,7 @@ namespace Comal.Classes
     {
         [SecondaryIndex]
         [Caption("Job Number")]
+        [RequiredColumn]
         [CodePopupEditor(typeof(Job), CodeColumn = "JobNumber")]
         public override Guid ID { get; set; }
 

+ 1 - 0
prs.classes/Entities/Requisition/Requisition.cs

@@ -59,6 +59,7 @@ namespace Comal.Classes
         public string Title { get; set; }
 
         [EditorSequence(4)]
+        [RequiredColumn]
         [EntityRelationship(DeleteAction.Cascade)]
         public JobLink JobLink { get; set; }
         

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

@@ -82,6 +82,7 @@ namespace Comal.Classes
 
         [DateTimeEditor]
         [EditorSequence(0)]
+        [SecondaryIndex]
         public DateTime Date { get; set; }
 
         private class ProductLookupGenerator : LookupDefinitionGenerator<Product, StockMovement>

+ 5 - 0
prs.desktop/PRSDesktop.csproj

@@ -838,6 +838,11 @@
       <PackageReference Include="NAudio" Version="2.2.1" />
       <PackageReference Include="NDesk.Options.Core" Version="1.2.8" />
       <PackageReference Include="net.sf.mpxj" Version="12.10.1" />
+      <PackageReference Include="Ofcas.Framework.Translation" Version="1.0.0.397" />
+      <PackageReference Include="Ofcas.Lk.Api.Client.Core" Version="3.0.2.8" />
+      <PackageReference Include="Ofcas.Lk.Api.Client.Ui" Version="3.0.2.8" />
+      <PackageReference Include="Ofcas.Lk.Api.Core" Version="3.0.0.98" />
+      <PackageReference Include="Ofcas.Lk.Api.Ui" Version="3.0.0.98" />
       <PackageReference Include="OpenExchangeRates.NET" Version="1.3.0" />
       <PackageReference Include="Scriban" Version="5.10.0" />
       <PackageReference Include="SharpAvi" Version="3.0.1" />

+ 31 - 1
prs.desktop/Panels/DeliveredOnSite/DeliveredOnSitePanel.xaml.cs

@@ -3,15 +3,23 @@ using System.Collections.Generic;
 using System.ComponentModel;
 using System.Linq;
 using System.Linq.Expressions;
+using System.Threading.Tasks;
 using System.Windows.Controls;
 using System.Windows.Input;
 using Comal.Classes;
 using InABox.Configuration;
 using InABox.Core;
+using InABox.DynamicGrid;
 using InABox.Wpf;
 
 namespace PRSDesktop
 {
+    
+    public class DeliveredOnSiteGlobalSettings : BaseObject, IGlobalConfigurationSettings
+    {
+        public int PageSize { get; set; } = 5000;
+    }
+    
     /// <summary>
     ///     Interaction logic for InstallationPanel.xaml
     /// </summary>
@@ -20,11 +28,19 @@ namespace PRSDesktop
         private bool _changing = false;
         private string _search = "";
 
-        public DeliveredOnSiteSettings _settings;
+        private DeliveredOnSiteSettings _settings = new();
+        private DeliveredOnSiteGlobalSettings _globalSettings = new();
+        
 
         public DeliveredOnSitePanel()
         {
+            Task[] setup = new Task[]
+            {
+                Task.Run(() => _settings = new UserConfiguration<DeliveredOnSiteSettings>().Load()),
+                Task.Run(() => _globalSettings = new GlobalConfiguration<DeliveredOnSiteGlobalSettings>().Load())
+            };
             InitializeComponent();
+            Task.WaitAll(setup);
         }
 
         public bool IsReady { get; set; }
@@ -38,6 +54,7 @@ namespace PRSDesktop
         public void Setup()
         {
             LoadSettings();
+            Items.Options.PageSize = _globalSettings.PageSize;
             Items.Refresh(true, false);
         }
 
@@ -47,6 +64,19 @@ namespace PRSDesktop
 
         public void CreateToolbarButtons(IPanelHost host)
         {
+            host.CreateSetupAction(new PanelAction() { Caption = "Delivered On Site Settings", Image = PRSDesktop.Resources.product, OnExecute =
+                (obj) =>
+                {
+                    var grid = new DynamicItemsListGrid<DeliveredOnSiteGlobalSettings>();
+                    if (grid.EditItems(new DeliveredOnSiteGlobalSettings[] { _globalSettings }))
+                    {
+                        new GlobalConfiguration<DeliveredOnSiteGlobalSettings>().Save(_globalSettings);
+                        Items.Options.PageSize = _globalSettings.PageSize;
+                        Refresh();
+                    }   
+                    
+                }
+            });
             //host.CreateToolbarButton(new PanelAction() { Caption = "Design Report", OnExecute = DesignReport, Image = PRSDesktop.Resources.edit });
             //host.CreateToolbarButton(new PanelAction() { Caption = "View Report", OnExecute = ViewReport, Image = PRSDesktop.Resources.refresh });
         }

+ 31 - 3
prs.desktop/Panels/Products/Movements/StockMovementPanel.xaml.cs

@@ -2,6 +2,7 @@
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.Linq;
+using System.Threading.Tasks;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Media.Imaging;
@@ -13,16 +14,27 @@ using InABox.Wpf;
 
 namespace PRSDesktop;
 
+public class StockMovementGlobalSettings : BaseObject, IGlobalConfigurationSettings
+{
+    public int PageSize { get; set; } = 5000;
+}
+
 /// <summary>
 ///     Interaction logic for StockMovementPanel.xaml
 /// </summary>
 public partial class StockMovementPanel : UserControl, IPanel<StockMovement>
 {
-    public StockMovementSettings _settings;
-
+    private StockMovementSettings _settings = new();
+    private StockMovementGlobalSettings _globalSettings = new();
     public StockMovementPanel()
     {
+        Task[] setup = new Task[]
+        {
+            Task.Run(() => _settings = new UserConfiguration<StockMovementSettings>().Load()),
+            Task.Run(() => _globalSettings = new GlobalConfiguration<StockMovementGlobalSettings>().Load())
+        };
         InitializeComponent();
+        Task.WaitAll(setup);
     }
 
     public bool IsReady { get; set; }
@@ -32,6 +44,21 @@ public partial class StockMovementPanel : UserControl, IPanel<StockMovement>
     public void CreateToolbarButtons(IPanelHost host)
     {
         ProductSetupActions.Standard(host);
+        
+        host.CreateSetupAction(new PanelAction() { Caption = "Stock Movements Settings", Image = PRSDesktop.Resources.product, OnExecute =
+            (obj) =>
+            {
+                var grid = new DynamicItemsListGrid<StockMovementGlobalSettings>();
+                if (grid.EditItems(new StockMovementGlobalSettings[] { _globalSettings }))
+                {
+                    new GlobalConfiguration<StockMovementGlobalSettings>().Save(_globalSettings);
+                    Movements.Options.PageSize = _globalSettings.PageSize;
+                    Refresh();
+                }   
+                    
+            }
+        });
+        
         PostUtils.CreateToolbarButtons(host,
             () => (DataModel(Selection.Selected) as IDataModel<StockMovement>)!,
             () => Movements.Refresh(false, true),
@@ -73,6 +100,7 @@ public partial class StockMovementPanel : UserControl, IPanel<StockMovement>
     {
         LoadSettings();
         Batches.Refresh(true, false);
+        Movements.Options.PageSize = _globalSettings.PageSize;
         Movements.Refresh(true, false);
         Batches.OnSelectItem += Batches_OnSelectItem;
     }
@@ -83,7 +111,7 @@ public partial class StockMovementPanel : UserControl, IPanel<StockMovement>
 
     private void LoadSettings()
     {
-        _settings = new UserConfiguration<StockMovementSettings>().Load();
+        
         StartPicker.SelectedDate = _settings.StartDate;
         EndPicker.SelectedDate = _settings.EndDate;
         View.SelectedIndex = _settings.View;

+ 26 - 0
prs.desktop/Panels/ReadyToGo/ReadyToGoPanel.xaml.cs

@@ -6,18 +6,30 @@ using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Input;
 using Comal.Classes;
+using InABox.Configuration;
 using InABox.Core;
+using InABox.DynamicGrid;
 using InABox.Wpf;
 
 namespace PRSDesktop
 {
+    
+    public class ReadyToGoGlobalSettings : BaseObject, IGlobalConfigurationSettings
+    {
+        public int PageSize { get; set; } = 5000;
+    }
+    
     /// <summary>
     ///     Interaction logic for ItemsPanel.xaml
     /// </summary>
     public partial class ReadyToGoPanel : UserControl, IPanel<DeliveryItem>
     {
+
+        private ReadyToGoGlobalSettings _globalSettings = new();
+        
         public ReadyToGoPanel()
         {
+            _globalSettings = new GlobalConfiguration<ReadyToGoGlobalSettings>().Load();
             InitializeComponent();
         }
 
@@ -33,6 +45,7 @@ namespace PRSDesktop
 
         public void Setup()
         {
+            Items.Options.PageSize = _globalSettings.PageSize;
             Items.Refresh(true, false);
         }
 
@@ -42,6 +55,19 @@ namespace PRSDesktop
 
         public void CreateToolbarButtons(IPanelHost host)
         {
+            host.CreateSetupAction(new PanelAction() { Caption = "Delivered On Site Settings", Image = PRSDesktop.Resources.product, OnExecute =
+                (obj) =>
+                {
+                    var grid = new DynamicItemsListGrid<ReadyToGoGlobalSettings>();
+                    if (grid.EditItems(new ReadyToGoGlobalSettings[] { _globalSettings }))
+                    {
+                        new GlobalConfiguration<ReadyToGoGlobalSettings>().Save(_globalSettings);
+                        Items.Options.PageSize = _globalSettings.PageSize;
+                        Refresh();
+                    }   
+                    
+                }
+            });
         }
 
 

+ 3 - 0
prs.desktop/Panels/Suppliers/SupplierPanel.xaml.cs

@@ -139,7 +139,10 @@ public partial class SupplierPanel : UserControl, IPanel<Supplier>
         Suppliers.ColumnsTag = _settings.View == DynamicSplitPanelView.Master ? _settings.View.ToString() : "";
         Suppliers.Refresh(true, false);
         SupplierContacts.Refresh(true,false);
+        
+        SupplierProducts.Options.PageSize = _globalSettings.ProductsPageSize;
         SupplierProducts.Refresh(true,false);
+        
         SupplierSpreadsheets.Refresh(true,false);
     }
 

+ 33 - 3
prs.desktop/Panels/Timesheets/TimesheetPanel.xaml.cs

@@ -2,26 +2,41 @@
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.Linq;
+using System.Threading.Tasks;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Input;
 using Comal.Classes;
 using InABox.Configuration;
 using InABox.Core;
+using InABox.DynamicGrid;
 using InABox.Wpf;
 
 namespace PRSDesktop
 {
+    
+    public class TimesheetGlobalSettings : BaseObject, IGlobalConfigurationSettings
+    {
+        public int PageSize { get; set; } = 5000;
+    }
+    
     /// <summary>
     ///     Interaction logic for TimesheetPanel.xaml
     /// </summary>
     public partial class TimesheetPanel : UserControl, IPanel<TimeSheet>
     {
-        public TimeSheetSettings _settings;
-
+        private TimeSheetSettings _settings = new();
+        private TimesheetGlobalSettings _globalSettings = new();
+        
         public TimesheetPanel()
         {
+            Task[] setup = new Task[]
+            {
+                Task.Run(() => _settings = new UserConfiguration<TimeSheetSettings>().Load()),
+                Task.Run(() => _globalSettings = new GlobalConfiguration<TimesheetGlobalSettings>().Load())
+            };
             InitializeComponent();
+            Task.WaitAll(setup);
         }
 
         public event DataModelUpdateEvent? OnUpdateDataModel;
@@ -31,7 +46,7 @@ namespace PRSDesktop
         public void Setup()
         {
             LoadSettings();
-
+            TimeSheets.Options.PageSize = _globalSettings.PageSize;
             TimeSheets.Refresh(true, false);
         }
 
@@ -52,6 +67,21 @@ namespace PRSDesktop
             HumanResourcesSetupActions.EmployeeOvertimeRules(host);
             HumanResourcesSetupActions.EmployeeOvertime(host);
             HumanResourcesSetupActions.EmployeeStandardLeave(host);
+            
+            host.CreateSetupSeparator();
+            host.CreateSetupAction(new PanelAction() { Caption = "Timesheets Settings", Image = PRSDesktop.Resources.product, OnExecute =
+                (obj) =>
+                {
+                    var grid = new DynamicItemsListGrid<TimesheetGlobalSettings>();
+                    if (grid.EditItems(new TimesheetGlobalSettings[] { _globalSettings }))
+                    {
+                        new GlobalConfiguration<TimesheetGlobalSettings>().Save(_globalSettings);
+                        TimeSheets.Options.PageSize = _globalSettings.PageSize;
+                        Refresh();
+                    }   
+                    
+                }
+            });
 
             host.CreatePanelAction(new PanelAction() { Caption = "Process Leave", Image = PRSDesktop.Resources.leave, OnExecute = ProcessLeave });
 

+ 11 - 6
prs.stores/RequisitionStore.cs

@@ -295,11 +295,14 @@ namespace Comal.Stores
                 var dimensions = item.Product.DefaultInstance.Dimensions;
 
                 var txnid = Guid.NewGuid();
-                if(holdingQty < qty)
+                if (holdingQty.IsEffectivelyLessThan(qty))
                 {
                     // Don't pull more than the required quantity, meaning if the holding is negative, it will remain negative.
-                    var extraRequired = Math.Max(qty - holdingQty, qty);
-
+                    var extraRequired = qty - Math.Max(0.0,holdingQty); 
+                    
+                    // We're goping to redirect this general stock direct to the target job, so reduce the amount required from the selected holding
+                    qty = holdingQty; 
+                    
                     // We don't have enough stock in this case, so transfer the necessary stock from general. We don't check for quantity in general stock,
                     // but instead will let general stock go negative if not enough. Obviously we have the stock, because its being sent to site. So if we do
                     // get negatives, it means probably our number are wrong I think.
@@ -310,8 +313,8 @@ namespace Comal.Stores
                     from.Issued = extraRequired;
                     from.Type = StockMovementType.TransferOut;
 
-                    // ... to the job.
-                    var to = CreateStockMovement(entity.Employee, entity.Filled, batch, item.Product, item.Location, item.Style, item.JobLink, item.JobRequisitionItem, dimensions, txnid, true,
+                    // ... to the job -  note this is the final (entity) job, not the holding job
+                    var to = CreateStockMovement(entity.Employee, entity.Filled, batch, item.Product, item.Location, item.Style, entity.JobLink, item.JobRequisitionItem, dimensions, txnid, true,
                         $"Requisition #{entity.Number} Internal Transfer");
                     to.Received = extraRequired;
                     to.Type = StockMovementType.TransferIn;
@@ -346,7 +349,9 @@ namespace Comal.Stores
                 var mvt = CreateStockMovement(entity.Employee, entity.Filled, batch, item.Product, item.Location, item.Style, entity.JobLink, link, dimensions, txnid,
                     false,
                     $"Requisition #{entity.Number}");
-                mvt.Issued = qty;
+                
+                // Now we can issue to full original quantity to the entity job :-)
+                mvt.Issued = item.ActualQuantity;
                 mvt.Type = StockMovementType.Issue;
                 updates.Add(mvt);
             }