Ver Fonte

Added TreatmentPO category system in 8.58 from version 9

Kenric Nugteren há 2 semanas atrás
pai
commit
f0bb8cdf3c

+ 18 - 0
prs.classes/Settings/TreatmentPOSettings.cs

@@ -0,0 +1,18 @@
+using InABox.Configuration;
+using InABox.Core;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Comal.Classes
+{
+    public class TreatmentPOSettings : BaseObject, IGlobalConfigurationSettings
+    {
+        [Comment("Default purchase order cateogry to use for treatment purchase orders")]
+        [Caption("Treatment PO Category")]
+        [EditorSequence(6)]
+        public PurchaseOrderCategoryLink DefaultTreatmentPurchaseOrderCategory { get; set; }
+    }
+}

+ 16 - 1
prs.desktop/Panels/Factory/FactoryPanel.xaml.cs

@@ -291,13 +291,27 @@ namespace PRSDesktop
         {
             var ids = Kanbans.Where(x => !x.ColorKey.Equals(QA_COLOR)).Select(x => Guid.Parse(x.ID)).ToArray();
 
-            var treatments = new Client<ManufacturingTreatment>().Query(Filter<ManufacturingTreatment>.Where(x => x.Packet.ID).InList(ids));
+            var treatments = Client.Query(
+                Filter<ManufacturingTreatment>.Where(x => x.Packet.ID).InList(ids),
+                Columns.None<ManufacturingTreatment>()
+                    .Add(x => x.ID)
+                    .Add(x => x.Parameter)
+                    .Add(x => x.Product.ID)
+                    .Add(x => x.Product.Code)
+                    .Add(x => x.Packet.ID)
+                    .Add(x => x.Packet.Setout.Job.ID)
+                    .Add(x => x.Packet.Setout.Job.JobNumber)
+                    .Add(x => x.Packet.Serial)
+                    .Add(x => x.Packet.Title)
+                    .Add(x => x.Packet.Quantity));
             var window = new ManufacturingTreatmentWindow(treatments);
             if (window.ShowDialog() != true)
                 return;
 
             Progress.Show("Creating Purchase Order");
 
+            var treatmentPOSettings = new GlobalConfiguration<TreatmentPOSettings>().Load();
+
             var order = new PurchaseOrder();
             order.Supplier.ID = window.SupplierID;
             order.Supplier.Name = window.SupplierName; //supplier != null ? supplier.Name : "Unknown Supplier";
@@ -305,6 +319,7 @@ namespace PRSDesktop
             order.IssuedBy.ID = App.EmployeeID;
             order.IssuedDate = DateTime.Today;
             order.DueDate = DateTime.Today.AddDays(7);
+            order.Category.CopyFrom(treatmentPOSettings.DefaultTreatmentPurchaseOrderCategory);
             Client.Save(order, $"Materials Processing Request raised by {App.EmployeeName} from Factory Floor");
 
             Progress.SetMessage("Processing Order");

+ 0 - 2
prs.desktop/Panels/Factory/ManufacturingTreatmentWindow.xaml.cs

@@ -116,8 +116,6 @@ namespace PRSDesktop
         {
             var productid = Treatments.SelectedValue != null ? (Guid)Treatments.SelectedValue : CoreUtils.FullGuid;
             selected.Clear();
-            var treatments = _treatments.Rows.Where(row => row.Get<ManufacturingTreatment, Guid>(col => col.Product.ID).Equals(productid));
-            //selected.AddRange(treatments.Select(row => row.Get<ManufacturingTreatment, Guid>(col => col.ID)));
 
             var suppdict = new Dictionary<Guid, string>();
             var _suppliers = new Client<SupplierProduct>().Query(Filter<SupplierProduct>.Where(x => x.Product.ID).IsEqualTo(productid));

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

@@ -48,7 +48,16 @@ public partial class ReservationManagementPanel : UserControl, IPanel<JobRequisi
         host.CreateSetupAction(new PanelAction() { Caption = "Reservation Management Settings", Image = PRSDesktop.Resources.specifications, OnExecute = ConfigSettingsClick });
 
         if (Security.IsAllowed<CanCreateTreatmentPO>())
-          host.CreatePanelAction(new PanelAction("Treatment PO", PRSDesktop.Resources.purchase, TreatmentPO_Click));
+            host.CreatePanelAction(new PanelAction("Treatment PO", PRSDesktop.Resources.purchase, TreatmentPO_Click));
+        host.CreateSetupActionIf<CanCreateTreatmentPO>("Treatment PO Settings", PRSDesktop.Resources.purchase, action =>
+        {
+            var config = new GlobalConfiguration<TreatmentPOSettings>();
+            var settings = config.Load();
+            if (DynamicGridUtils.EditObject(settings))
+            {
+                config.Save(settings);
+            }
+        });
     }
 
     private void ConfigSettingsClick(PanelAction obj)

+ 10 - 0
prs.desktop/Setups/ManufacturingSetupActions.cs

@@ -1,4 +1,5 @@
 using Comal.Classes;
+using InABox.Configuration;
 using InABox.DynamicGrid;
 using InABox.Wpf;
 using PRSDesktop.Components.Spreadsheet;
@@ -33,5 +34,14 @@ public static class ManufacturingSetupActions
             var list = new MasterList(typeof(ManufacturingLostTime));
             list.ShowDialog();
         });
+        host.CreateSetupActionIf<CanCreateTreatmentPO>("Treatment PO Settings", PRSDesktop.Resources.purchase, action =>
+        {
+            var config = new GlobalConfiguration<TreatmentPOSettings>();
+            var settings = config.Load();
+            if (DynamicGridUtils.EditObject(settings))
+            {
+                config.Save(settings);
+            }
+        });
     }
 }