Forráskód Böngészése

Added code to link stock movements and assignments when a new progress claim is made.

Kenric Nugteren 10 hónapja
szülő
commit
e1ed712b2c

+ 40 - 0
prs.desktop/Grids/StockMovementGrid.cs

@@ -0,0 +1,40 @@
+using Comal.Classes;
+using InABox.Core;
+using InABox.DynamicGrid;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PRSDesktop;
+
+public class StockMovementGrid : DynamicDataGrid<StockMovement>, IDefaultGrid
+{
+    public override DynamicGridColumns GenerateColumns()
+    {
+        return StandardColumns();
+    }
+
+    public static DynamicGridColumns StandardColumns()
+    {
+        var columns = new DynamicGridColumns();
+
+        columns.Add<StockMovement, DateTime>(x => x.Date, 120, "Date", "dd MMM yyyy hh:mm", Alignment.MiddleCenter);
+        columns.Add<StockMovement, string>(x => x.Job.JobNumber, 120, "Job Number", "", Alignment.MiddleCenter);
+        columns.Add<StockMovement, string>(x => x.Location.Code, 120, "Location", "", Alignment.MiddleCenter);
+        columns.Add<StockMovement, string>(x => x.Product.Code, 120, "Product Code", "", Alignment.MiddleCenter);
+        columns.Add<StockMovement, string>(x => x.Product.Name, 0, "Product Name", "", Alignment.MiddleLeft);
+        columns.Add<StockMovement, string>(x => x.Style.Code, 120, "Style", "", Alignment.MiddleCenter);
+        columns.Add<StockMovement, string>(x => x.Dimensions.UnitSize, 120, "Size", "", Alignment.MiddleCenter);
+
+        columns.Add<StockMovement, double>(x => x.Received, 70, "Received", "F2", Alignment.MiddleRight);
+        columns.Add<StockMovement, double>(x => x.Issued, 70, "Issued", "F2", Alignment.MiddleRight);
+        columns.Add<StockMovement, double>(x => x.Cost, 70, "Cost", "C2", Alignment.MiddleRight);
+
+        columns.Add<StockMovement, string>(x => x.Employee.Code, 120, "Employee", "", Alignment.MiddleCenter);
+        columns.Add<StockMovement, StockMovementType>(x => x.Type, 120, "Type", "", Alignment.MiddleCenter);
+
+        return columns;
+    }
+}

+ 25 - 0
prs.desktop/Panels/Invoices/InvoiceGrid.cs

@@ -126,6 +126,31 @@ namespace PRSDesktop
                     }
                     }
                     Client.Save(lines, "Progress claim created by user.");
                     Client.Save(lines, "Progress claim created by user.");
 
 
+                    var results = Client.QueryMultiple(
+                        new KeyedQueryDef<StockMovement>(
+                            new Filter<StockMovement>(x => x.Invoice.ID).IsEqualTo(Guid.Empty)
+                                .And(x => x.Type).IsEqualTo(StockMovementType.Issue)
+                                .And(x => x.Job.ID).IsEqualTo(Master.ID),
+                            Columns.Required<StockMovement>().Add(x => x.ID).Add(x => x.Invoice.ID)),
+                        new KeyedQueryDef<Assignment>(
+                            new Filter<Assignment>(x => x.JobLink.ID).IsEqualTo(Master.ID)
+                                .And(x => x.Invoice.ID).IsEqualTo(Guid.Empty),
+                            Columns.Required<Assignment>().Add(x => x.Invoice.ID)));
+
+                    var movements = results.GetObjects<StockMovement>().ToList();
+                    foreach(var mvt in movements)
+                    {
+                        mvt.Invoice.ID = invoice.ID;
+                    }
+                    Client.Save(movements, "Attached to new progress claim.");
+
+                    var assignments = results.GetObjects<Assignment>().ToList();
+                    foreach(var ass in assignments)
+                    {
+                        ass.Invoice.ID = invoice.ID;
+                    }
+                    Client.Save(assignments, "Attached to new progress claim.");
+
                     Refresh(false, true);
                     Refresh(false, true);
                 }
                 }
 
 

+ 7 - 0
prs.desktop/Panels/Invoices/InvoiceStockMovementGrid.cs

@@ -38,6 +38,11 @@ public class InvoiceStockMovementGrid : DynamicDataGrid<StockMovement>, ISpecifi
         ShowAllButton = AddButton("Show All", null, ToggleShowAll);
         ShowAllButton = AddButton("Show All", null, ToggleShowAll);
     }
     }
 
 
+    public override DynamicGridColumns GenerateColumns()
+    {
+        return StockMovementGrid.StandardColumns();
+    }
+
     protected override void DoReconfigure(DynamicGridOptions options)
     protected override void DoReconfigure(DynamicGridOptions options)
     {
     {
         base.DoReconfigure(options);
         base.DoReconfigure(options);
@@ -149,6 +154,8 @@ public class InvoiceStockMovementGrid : DynamicDataGrid<StockMovement>, ISpecifi
             criteria.Add(new Filter<StockMovement>().None());
             criteria.Add(new Filter<StockMovement>().None());
         else
         else
         {
         {
+            criteria.Add(new Filter<StockMovement>(x => x.Job.ID).IsEqualTo(Invoice.JobLink.ID));
+            criteria.Add(new Filter<StockMovement>(x => x.Type).IsEqualTo(StockMovementType.Issue));
             if (_showall)
             if (_showall)
                 criteria.Add(new Filter<StockMovement>(x => x.Invoice.ID).IsEqualTo(Invoice.ID).Or(x => x.Invoice).NotLinkValid());
                 criteria.Add(new Filter<StockMovement>(x => x.Invoice.ID).IsEqualTo(Invoice.ID).Or(x => x.Invoice).NotLinkValid());
             else
             else

+ 5 - 22
prs.desktop/Panels/Products/Locations/StockMovementGrid.cs → prs.desktop/Panels/Products/Locations/ProductStockMovementGrid.cs

@@ -15,13 +15,13 @@ using Syncfusion.UI.Xaml.Diagram.Controls;
 
 
 namespace PRSDesktop;
 namespace PRSDesktop;
 
 
-public class StockMovementGrid : DynamicDataGrid<StockMovement>, IDataModelSource, ISpecificGrid
+public class ProductStockMovementGrid : DynamicDataGrid<StockMovement>, IDataModelSource, ISpecificGrid
 {
 {
     public static readonly DependencyProperty AllowNullLocationProperty =
     public static readonly DependencyProperty AllowNullLocationProperty =
-        DependencyProperty.Register("AllowNullLocation", typeof(bool), typeof(StockMovementGrid), new UIPropertyMetadata(null));
+        DependencyProperty.Register("AllowNullLocation", typeof(bool), typeof(ProductStockMovementGrid), new UIPropertyMetadata(null));
 
 
     public static readonly DependencyProperty AllowNullBatchProperty =
     public static readonly DependencyProperty AllowNullBatchProperty =
-        DependencyProperty.Register("AllowNullBatch", typeof(bool), typeof(StockMovementGrid), new UIPropertyMetadata(null));
+        DependencyProperty.Register("AllowNullBatch", typeof(bool), typeof(ProductStockMovementGrid), new UIPropertyMetadata(null));
 
 
     private Button AllButton;
     private Button AllButton;
     private bool bShowAll = true;
     private bool bShowAll = true;
@@ -35,7 +35,7 @@ public class StockMovementGrid : DynamicDataGrid<StockMovement>, IDataModelSourc
     private static readonly BitmapImage? warning = PRSDesktop.Resources.warning.AsBitmapImage();
     private static readonly BitmapImage? warning = PRSDesktop.Resources.warning.AsBitmapImage();
     private static readonly BitmapImage? refresh = PRSDesktop.Resources.refresh.AsBitmapImage();
     private static readonly BitmapImage? refresh = PRSDesktop.Resources.refresh.AsBitmapImage();
 
 
-    public StockMovementGrid()
+    public ProductStockMovementGrid()
     {
     {
         ColumnsTag = "StockMovementGrid";
         ColumnsTag = "StockMovementGrid";
     }
     }
@@ -79,24 +79,7 @@ public class StockMovementGrid : DynamicDataGrid<StockMovement>, IDataModelSourc
 
 
     public override DynamicGridColumns GenerateColumns()
     public override DynamicGridColumns GenerateColumns()
     {
     {
-        var columns = new DynamicGridColumns();
-
-        columns.Add<StockMovement, DateTime>(x => x.Date, 120, "Date", "dd MMM yyyy hh:mm", Alignment.MiddleCenter);
-        columns.Add<StockMovement, string>(x => x.Job.JobNumber, 120, "Job Number", "", Alignment.MiddleCenter);
-        columns.Add<StockMovement, string>(x => x.Location.Code, 120, "Location", "", Alignment.MiddleCenter);
-        columns.Add<StockMovement, string>(x => x.Product.Code, 120, "Product Code", "", Alignment.MiddleCenter);
-        columns.Add<StockMovement, string>(x => x.Product.Name, 0, "Product Name", "", Alignment.MiddleLeft);
-        columns.Add<StockMovement, string>(x => x.Style.Code, 120, "Style", "", Alignment.MiddleCenter);
-        columns.Add<StockMovement, string>(x => x.Dimensions.UnitSize, 120, "Size", "", Alignment.MiddleCenter);
-
-        columns.Add<StockMovement, double>(x => x.Received, 70, "Received", "F2", Alignment.MiddleRight);
-        columns.Add<StockMovement, double>(x => x.Issued, 70, "Issued", "F2", Alignment.MiddleRight);
-        columns.Add<StockMovement, double>(x => x.Cost, 70, "Cost", "C2", Alignment.MiddleRight);
-
-        columns.Add<StockMovement, string>(x => x.Employee.Code, 120, "Employee", "", Alignment.MiddleCenter);
-        columns.Add<StockMovement, StockMovementType>(x => x.Type, 120, "Type", "", Alignment.MiddleCenter);
-
-        return columns;
+        return StockMovementGrid.StandardColumns();
     }
     }
 
 
     public DateTime StartDate { get; set; } = DateTime.MinValue;
     public DateTime StartDate { get; set; } = DateTime.MinValue;

+ 1 - 1
prs.desktop/Panels/Products/Locations/StockLocationPanel.xaml

@@ -50,7 +50,7 @@
                             VerticalContentAlignment="Center"/>
                             VerticalContentAlignment="Center"/>
                     </Grid>
                     </Grid>
                 </Border>
                 </Border>
-                <local:StockMovementGrid x:Name="Movements" Margin="0,2,0,0" DockPanel.Dock="Top" AllowNullLocation="False"
+                <local:ProductStockMovementGrid x:Name="Movements" Margin="0,2,0,0" DockPanel.Dock="Top" AllowNullLocation="False"
                                      AllowNullBatch="True" OnFilterRecord="Movements_OnOnFilterRecord" />
                                      AllowNullBatch="True" OnFilterRecord="Movements_OnOnFilterRecord" />
 
 
             </DockPanel>
             </DockPanel>

+ 1 - 1
prs.desktop/Panels/Products/Movements/StockMovementPanel.xaml

@@ -100,7 +100,7 @@
             </syncfusion:SfGridSplitter.PreviewStyle>
             </syncfusion:SfGridSplitter.PreviewStyle>
 
 
         </syncfusion:SfGridSplitter>
         </syncfusion:SfGridSplitter>
-        <local:StockMovementGrid x:Name="Movements" AllowNullLocation="True" AllowNullBatch="True" Grid.Row="1"
+        <local:ProductStockMovementGrid x:Name="Movements" AllowNullLocation="True" AllowNullBatch="True" Grid.Row="1"
                                  Grid.Column="2" OnReconfigure="Movements_OnReconfigure"/>
                                  Grid.Column="2" OnReconfigure="Movements_OnReconfigure"/>
     </Grid>
     </Grid>
 </UserControl>
 </UserControl>