Bladeren bron

Fody AutoProperty + Database Migration Scripts

frogsoftware 11 maanden geleden
bovenliggende
commit
f78919e7e7

+ 15 - 0
prs.classes/Entities/Job/Requisitions/JobRequisitionItemPurchaseOrderItem.cs

@@ -6,6 +6,21 @@ using System.Text;
 
 namespace Comal.Classes
 {
+
+    public class PurchaseOrderItemAllocation : Entity, IRemotable, IPersistent, ILicense<ProjectManagementLicense>
+    {
+        public PurchaseOrderItemLink Item { get; set; }
+        
+        public JobLink Job { get; set; }
+        
+        public JobRequisitionItemLink JobRequisitionItem { get; set; }
+        
+        public double Quantity { get; set; }
+        
+    }
+    
+    
+    
     
     public class JobRequisitionItemPurchaseOrderItem : Entity, IRemotable, IPersistent, IOneToMany<JobRequisitionItem>, ILicense<ProjectManagementLicense>
     {

+ 1 - 0
prs.classes/FodyWeavers.xml

@@ -1,4 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
 <Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
+  <AutoProperties />
   <PropertyChanged />
 </Weavers>

+ 1 - 0
prs.classes/FodyWeavers.xsd

@@ -53,6 +53,7 @@
             </xs:attribute>
           </xs:complexType>
         </xs:element>
+        <xs:element name="AutoProperties" minOccurs="0" maxOccurs="1" type="xs:anyType" />
       </xs:all>
       <xs:attribute name="VerifyAssembly" type="xs:boolean">
         <xs:annotation>

+ 1 - 0
prs.classes/PRSClasses.csproj

@@ -29,6 +29,7 @@
     </ItemGroup>
 
     <ItemGroup>
+      <PackageReference Include="AutoProperties.Fody" Version="1.25.0" />
       <PackageReference Include="Fody" Version="6.8.1" PrivateAssets="All">
         <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
       </PackageReference>

+ 4 - 1
prs.desktop/FodyWeavers.xml

@@ -1 +1,4 @@
-<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd" />
+<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
+    <AutoProperties />
+    <PropertyChanged />
+</Weavers>

+ 0 - 7
prs.desktop/Grids/EntityDocumentGrids/BillDocumentGrid.cs

@@ -1,12 +1,5 @@
 using Comal.Classes;
 using InABox.DynamicGrid;
-using java.lang;
-using Syncfusion.UI.Xaml.CellGrid.Styles;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
 
 namespace PRSDesktop
 {

+ 54 - 55
prs.desktop/Panels/Stock Forecast/OrderScreen/StockForecastOrderingGrid.cs

@@ -47,7 +47,6 @@ public class StockForecastOrderData
     }
 }
 
-
 public enum StockForecastOrderingType
 {
     StockOrder,
@@ -108,13 +107,13 @@ public class StockForecastOrderingItem : BaseObject
     [EnumLookupEditor(typeof(SupplierProductOrderStrategy))]
     public SupplierProductOrderStrategy OrderStrategy { get; set; }
 
-    private StockForecastOrderingItemQuantity[] Quantities = [];
+    public StockForecastOrderingItemQuantity[] Quantities = [];
 
     public StockForecastOrderingItemQuantity GetQuantity(int i) => Quantities[i];
 
     public double GetTotalQuantity(StockForecastOrderingType type) => type == StockForecastOrderingType.StockOrder
-        ? Quantities.Sum(x => x.StockTotal)
-        : Quantities.Sum(x => x.JobTotal);
+        ? Quantities.Sum(x => x.Total)
+        : Quantities.Sum(x => x.Total);
 
     public void SetQuantities(StockForecastOrderingItemQuantity[] quantities)
     {
@@ -198,18 +197,18 @@ public class StockForecastOrderingGrid : DynamicItemsListGrid<StockForecastOrder
                         continue;
                     }
 
-                    if(OrderType == StockForecastOrderingType.StockOrder && qty.StockTotal > 0)
+                    if(OrderType == StockForecastOrderingType.StockOrder && qty.Total > 0)
                     {
-                        yield return new(supplier, null, item, qty.StockTotal, supplierProduct);
+                        yield return new(supplier, null, item, qty.Total, supplierProduct);
                     }
                     else
                     {
-                        foreach(var (jobID, q) in qty.JobTotals)
+                        foreach(var q in item.Quantities)
                         {
-                            if(q > 0)
-                            {
-                                yield return new(supplier, new() { ID = jobID }, item, q, supplierProduct);
-                            }
+                            //if(q > 0)
+                            //{
+                                yield return new(supplier, new() { ID = Guid.Empty }, item, q.Total, supplierProduct);
+                            //}
                         }
                     }
                 }
@@ -422,12 +421,12 @@ public class StockForecastOrderingGrid : DynamicItemsListGrid<StockForecastOrder
 
     private SupplierProduct? SelectSupplierProduct(IEnumerable<SupplierProduct> supplierProducts, StockForecastOrderingItem item)
     {
-
+        return null;
     }
 
     private double GetRequiredQuantity(StockForecastOrderingItem item, SupplierProduct supplierProduct)
     {
-
+        return 0;
     }
 
     protected override DynamicGridColumns LoadColumns()
@@ -538,13 +537,13 @@ public class StockForecastOrderingGrid : DynamicItemsListGrid<StockForecastOrder
                     quantities[newIdx] = newQty;
                     if (OrderType == StockForecastOrderingType.StockOrder)
                     {
-                        newQty.StockTotal = 0;
+                        newQty.Total = 0;
                     }
                     else
                     {
-                        foreach (var id in item.GetJobRequiredQuantities().Keys)
+                        foreach (var id in item.Quantities)
                         {
-                            newQty.JobTotals[id] = 0;
+                            newQty.Total = 0;
                         }
                     }
                     item.SetQuantities(quantities);
@@ -630,11 +629,11 @@ public class StockForecastOrderingGrid : DynamicItemsListGrid<StockForecastOrder
                     Background = new SolidColorBrush(Colors.LightYellow),
                     BorderThickness = new Thickness(0.0),
                     MinValue = 0.0,
-                    Value = Item.GetQuantity(SupplierIndex).StockTotal
+                    Value = Item.GetQuantity(SupplierIndex).Total
                 };
                 editor.ValueChanged += (o, e) =>
                 {
-                    Item.GetQuantity(SupplierIndex).StockTotal = editor.Value ?? default;
+                    Item.GetQuantity(SupplierIndex).Total = editor.Value ?? default;
                 };
                 Content = editor;
             }
@@ -653,7 +652,7 @@ public class StockForecastOrderingGrid : DynamicItemsListGrid<StockForecastOrder
                     Background = new SolidColorBrush(Colors.White),
                     BorderThickness = new Thickness(0.0),
                     IsReadOnly = true,
-                    Text = string.Format("{0:F2}", Item.GetQuantity(SupplierIndex).JobTotal)
+                    Text = string.Format("{0:F2}", Item.GetQuantity(SupplierIndex).Total)
                 };
                 Grid.SetColumn(editor, 0);
                 grid.Children.Add(editor);
@@ -672,39 +671,39 @@ public class StockForecastOrderingGrid : DynamicItemsListGrid<StockForecastOrder
                 btn.Click += (o, e) =>
                 {
                     var qty = Item.GetQuantity(SupplierIndex);
-
-                    Parent.LoadJobData(qty.JobTotals.Keys);
-
-                    var items = qty.JobTotals.Select(x =>
-                    {
-                        var item = new StockForecastOrderingJobItem
-                        {
-                            JobID = x.Key,
-                            RequiredQuantity = Item.GetJobRequiredQuantities().GetValueOrDefault(x.Key),
-                            Quantity = x.Value
-                        };
-                        if(item.JobID == Guid.Empty)
-                        {
-                            item.Job = "General Stock";
-                        }
-                        else if(Parent.JobDetails.TryGetValue(item.JobID, out var job))
-                        {
-                            item.Job = $"{job.JobNumber}: {job.Name}";
-                        }
-                        return item;
-                    }).ToList();
-
-                    var window = new StockForecastOrderJobScreen();
-                    window.Items = items;
-                    if(window.ShowDialog() == true)
-                    {
-                        foreach(var item in items)
-                        {
-                            qty.JobTotals[item.JobID] = item.Quantity;
-                        }
-                        qty.DoChanged();
-                        editor.Text = string.Format("{0:F2}", Item.GetQuantity(SupplierIndex).JobTotal);
-                    }
+                    
+                    // Parent.LoadJobData(qty.JobTotals.Keys);
+                    //
+                    // var items = qty.JobTotals.Select(x =>
+                    // {
+                    //     var item = new StockForecastOrderingJobItem
+                    //     {
+                    //         JobID = x.Key,
+                    //         RequiredQuantity = Item.GetJobRequiredQuantities().GetValueOrDefault(x.Key),
+                    //         Quantity = x.Value
+                    //     };
+                    //     if(item.JobID == Guid.Empty)
+                    //     {
+                    //         item.Job = "General Stock";
+                    //     }
+                    //     else if(Parent.JobDetails.TryGetValue(item.JobID, out var job))
+                    //     {
+                    //         item.Job = $"{job.JobNumber}: {job.Name}";
+                    //     }
+                    //     return item;
+                    // }).ToList();
+                    //
+                    // var window = new StockForecastOrderJobScreen();
+                    // window.Items = items;
+                    // if(window.ShowDialog() == true)
+                    // {
+                    //     foreach(var item in items)
+                    //     {
+                    //         qty.JobTotals[item.JobID] = item.Quantity;
+                    //     }
+                    //     qty.DoChanged();
+                    //     editor.Text = string.Format("{0:F2}", Item.GetQuantity(SupplierIndex).JobTotal);
+                    // }
                 };
                 grid.Children.Add(btn);
 
@@ -766,8 +765,8 @@ public class StockForecastOrderingGrid : DynamicItemsListGrid<StockForecastOrder
 
             var instance = LoadItem(row);
             var qty = OrderType == StockForecastOrderingType.StockOrder
-                ? instance.GetQuantity(idx).StockTotal
-                : instance.GetQuantity(idx).JobTotal;
+                ? instance.GetQuantity(idx).Total
+                : instance.GetQuantity(idx).Total;
             var supplierProduct = GetSupplierProduct(instance, Suppliers[idx].ID);
             if(supplierProduct is not null)
             {
@@ -885,7 +884,7 @@ public class StockForecastOrderingGrid : DynamicItemsListGrid<StockForecastOrder
                     if(supplierProduct is not null)
                     {
                         var qty = item.GetQuantity(SupplierIndex);
-                        Sum += qty.GetTotal(Grid.OrderType) * supplierProduct.CostPrice;
+                        Sum += qty.Total /*GetTotal(Grid.OrderType)*/ * supplierProduct.CostPrice;
                     }
                 }
             }

+ 2 - 2
prs.desktop/Panels/Stock Forecast/StockForecastGrid.cs

@@ -596,9 +596,9 @@ public class StockForecastGrid : DynamicItemsListGrid<StockForecastItem>, IDataM
         var selectedIDs = Data.Rows.Select(x => x.Get<ProductInstance, Guid>(x => x.ID));
 
         var items = new HashSet<string>();
-        foreach(var item in Items)
+        foreach(var row in Data.Rows)
         {
-            var value = GetColumnCalculatedData(tag, item);
+            var value = GetColumnCalculatedData(tag, row);
             if (value.HasValue)
             {
                 items.Add(value.Value.ToString("F2"));

+ 1 - 0
prs.licensing/FodyWeavers.xml

@@ -1,3 +1,4 @@
 <Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
+  <AutoProperties />
   <PropertyChanged />
 </Weavers>

+ 1 - 0
prs.licensing/FodyWeavers.xsd

@@ -53,6 +53,7 @@
             </xs:attribute>
           </xs:complexType>
         </xs:element>
+        <xs:element name="AutoProperties" minOccurs="0" maxOccurs="1" type="xs:anyType" />
       </xs:all>
       <xs:attribute name="VerifyAssembly" type="xs:boolean">
         <xs:annotation>

+ 1 - 0
prs.licensing/PRSLicensing.csproj

@@ -20,6 +20,7 @@
   </ItemGroup>
 
   <ItemGroup>
+    <PackageReference Include="AutoProperties.Fody" Version="1.25.0" />
     <PackageReference Include="Fody" Version="6.8.1">
       <PrivateAssets>all</PrivateAssets>
       <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

+ 9 - 9
prs.logikal/PRSLogikal.csproj

@@ -36,29 +36,29 @@
     </PropertyGroup>
     <ItemGroup>
         <Reference Include="H.Formatters, Version=2.0.59.0, Culture=neutral, PublicKeyToken=155b585918bc2f0b, processorArchitecture=MSIL">
-          <HintPath>..\packages\H.Formatters.2.0.59\lib\net451\H.Formatters.dll</HintPath>
+          <HintPath>..\..\packages\H.Formatters.2.0.59\lib\net451\H.Formatters.dll</HintPath>
         </Reference>
         <Reference Include="H.Formatters.BinaryFormatter, Version=2.0.59.0, Culture=neutral, PublicKeyToken=155b585918bc2f0b, processorArchitecture=MSIL">
-          <HintPath>..\packages\H.Formatters.BinaryFormatter.2.0.59\lib\net451\H.Formatters.BinaryFormatter.dll</HintPath>
+          <HintPath>..\..\packages\H.Formatters.BinaryFormatter.2.0.59\lib\net451\H.Formatters.BinaryFormatter.dll</HintPath>
         </Reference>
         <Reference Include="H.Formatters.Newtonsoft.Json, Version=13.0.59.0, Culture=neutral, PublicKeyToken=155b585918bc2f0b, processorArchitecture=MSIL">
-          <HintPath>..\packages\H.Formatters.Newtonsoft.Json.13.0.59\lib\net451\H.Formatters.Newtonsoft.Json.dll</HintPath>
+          <HintPath>..\..\packages\H.Formatters.Newtonsoft.Json.13.0.59\lib\net451\H.Formatters.Newtonsoft.Json.dll</HintPath>
         </Reference>
         <Reference Include="H.Pipes, Version=2.0.59.0, Culture=neutral, PublicKeyToken=155b585918bc2f0b, processorArchitecture=MSIL">
-          <HintPath>..\packages\H.Pipes.2.0.59\lib\net462\H.Pipes.dll</HintPath>
+          <HintPath>..\..\packages\H.Pipes.2.0.59\lib\net462\H.Pipes.dll</HintPath>
         </Reference>
         <Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
           <HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
         </Reference>
         <Reference Include="mscorlib" />
         <Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
-          <HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
+          <HintPath>..\..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
         </Reference>
-        <Reference Include="Ofcas.Lk.Api.Client.Core">
-          <HintPath>..\..\Users\frank.vandenbos\.nuget\packages\ofcas.lk.api.client.core\3.0.2.8\lib\net452\Ofcas.Lk.Api.Client.Core.dll</HintPath>
+        <Reference Include="Ofcas.Lk.Api.Client.Core, Version=3.0.2.8, Culture=neutral, PublicKeyToken=1057fec7ec2b2be5, processorArchitecture=MSIL">
+          <HintPath>..\..\packages\Ofcas.Lk.Api.Client.Core.3.0.2.8\lib\net472\Ofcas.Lk.Api.Client.Core.dll</HintPath>
         </Reference>
-        <Reference Include="Ofcas.Lk.Api.Shared">
-          <HintPath>..\..\Users\frank.vandenbos\.nuget\packages\ofcas.lk.api.client.core\3.0.2.8\lib\net452\Ofcas.Lk.Api.Shared.dll</HintPath>
+        <Reference Include="Ofcas.Lk.Api.Shared, Version=3.0.2.8, Culture=neutral, PublicKeyToken=1057fec7ec2b2be5, processorArchitecture=MSIL">
+          <HintPath>..\..\packages\Ofcas.Lk.Api.Client.Core.3.0.2.8\lib\net472\Ofcas.Lk.Api.Shared.dll</HintPath>
         </Reference>
         <Reference Include="System"/>
         <Reference Include="System.Core"/>

+ 6 - 5
prs.logikal/packages.config

@@ -1,11 +1,12 @@
 <?xml version="1.0" encoding="utf-8"?>
 <packages>
-  <package id="H.Formatters" version="2.0.59" targetFramework="net48" />
-  <package id="H.Formatters.BinaryFormatter" version="2.0.59" targetFramework="net48" />
-  <package id="H.Formatters.Newtonsoft.Json" version="13.0.59" targetFramework="net48" />
-  <package id="H.Pipes" version="2.0.59" targetFramework="net48" />
+  <package id="H.Formatters" version="2.0.59" targetFramework="net472" />
+  <package id="H.Formatters.BinaryFormatter" version="2.0.59" targetFramework="net472" />
+  <package id="H.Formatters.Newtonsoft.Json" version="13.0.59" targetFramework="net472" />
+  <package id="H.Pipes" version="2.0.59" targetFramework="net472" />
   <package id="Microsoft.Bcl.AsyncInterfaces" version="8.0.0" targetFramework="net48" />
-  <package id="Newtonsoft.Json" version="13.0.3" targetFramework="net48" />
+  <package id="Newtonsoft.Json" version="13.0.3" targetFramework="net472" />
+  <package id="Ofcas.Lk.Api.Client.Core" version="3.0.2.8" targetFramework="net472" />
   <package id="System.Runtime.CompilerServices.Unsafe" version="4.5.3" targetFramework="net48" />
   <package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net48" />
 </packages>

+ 1 - 0
prs.server/FodyWeavers.xml

@@ -1,3 +1,4 @@
 <Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
+  <AutoProperties />
   <PropertyChanged />
 </Weavers>

+ 1 - 0
prs.server/FodyWeavers.xsd

@@ -53,6 +53,7 @@
             </xs:attribute>
           </xs:complexType>
         </xs:element>
+        <xs:element name="AutoProperties" minOccurs="0" maxOccurs="1" type="xs:anyType" />
       </xs:all>
       <xs:attribute name="VerifyAssembly" type="xs:boolean">
         <xs:annotation>

+ 1 - 0
prs.server/PRSServer.csproj

@@ -62,6 +62,7 @@
 
     <ItemGroup>
         <PackageReference Include="ACMESharpCore" Version="2.2.0.148" />
+        <PackageReference Include="AutoProperties.Fody" Version="1.25.0" />
         <PackageReference Include="bblanchon.PDFium.Win32" Version="127.0.6504" />
         <PackageReference Include="Core.System.Configuration.Install" Version="1.1.0" />
         <PackageReference Include="Core.System.ServiceProcess" Version="2.0.1" />

+ 1 - 0
prs.shared/Database Update Scripts/DatabaseUpdateScripts.cs

@@ -49,5 +49,6 @@ public static class DatabaseUpdateScripts
         DataUpdater.RegisterUpdateScript<Update_7_77>();
         DataUpdater.RegisterUpdateScript<Update_8_02>();
         DataUpdater.RegisterUpdateScript<Update_8_04>();
+        DataUpdater.RegisterUpdateScript<Update_8_14>();
     }
 }

+ 0 - 7
prs.shared/Database Update Scripts/Update_7_52.cs

@@ -1,14 +1,7 @@
 using Comal.Classes;
-using Comal.Stores;
 using InABox.Core;
 using InABox.Database;
 using PRS.Shared.Database_Update_Scripts.Utils;
-using PRSStores;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using static ICSharpCode.AvalonEdit.Document.TextDocumentWeakEventManager;
 
 namespace PRS.Shared;
 

+ 1 - 1
prs.shared/Database Update Scripts/Update_8_04.cs

@@ -37,4 +37,4 @@ internal class Update_8_04 : DatabaseUpdateScript
         JobRequisitionItemUtils.RefreshStatuses(DbFactory.FindStore<JobRequisitionItem>(Guid.Empty, "", Platform.Server, CoreUtils.GetVersion(), Logger.New()));
         return true;
     }
-}
+}

+ 115 - 0
prs.shared/Database Update Scripts/Update_8_14.cs

@@ -0,0 +1,115 @@
+using Comal.Classes;
+using InABox.Core;
+using InABox.Database;
+
+namespace PRS.Shared.Database_Update_Scripts;
+
+internal class Update_8_14 : DatabaseUpdateScript
+{
+
+    private static readonly int CHUNK_SIZE = 500;
+    private static readonly bool DESTRUCTIVE = false;
+    
+    public override VersionNumber Version => new(8, 14);
+    
+    public override bool Update()
+    {
+        var _provider = DbFactory.NewProvider(Logger.Main);
+        Clear_POIAs(_provider);
+        var _poias = Migrate_JRIPOIs(_provider);
+        Migrate_POIs(_provider, _poias);
+        return true;
+    }
+
+    private void Clear_POIAs(IProvider provider)
+    {
+        Logger.Send(LogType.Information, "", "Clearing Existing Allocations");
+        var _queue = provider.Query(
+            new Filter<PurchaseOrderItemAllocation>().All(),
+            Columns.None<PurchaseOrderItemAllocation>().Add(x => x.ID)
+        ).Rows.ToQueue();
+
+        while (_queue.Any())
+        {
+            List<PurchaseOrderItemAllocation> _poias = _queue
+                .Dequeue(CHUNK_SIZE)
+                .Select(x => x.ToObject<PurchaseOrderItemAllocation>())
+                .ToList();
+            provider.Delete(_poias, "");
+
+            Logger.Send(LogType.Information, "", $"- Deleted {_poias.Count} Allocations ({_queue.Count} remaining)");
+        }
+    }
+
+    private List<PurchaseOrderItemAllocation> Migrate_JRIPOIs(IProvider provider)
+    {
+        var _result = new List<PurchaseOrderItemAllocation>();
+        Logger.Send(LogType.Information,"","Migrating JobRequisitionItems");
+        var _queue = provider.Query(
+            new Filter<JobRequisitionItemPurchaseOrderItem>().All(),
+            Columns.None<JobRequisitionItemPurchaseOrderItem>()
+                .Add(x=>x.PurchaseOrderItem.ID)
+                .Add(x=>x.PurchaseOrderItem.Qty)
+                .Add(x=>x.JobRequisitionItem.ID)
+                .Add(x=>x.JobRequisitionItem.Job.ID)
+        ).Rows.ToQueue();
+        
+        while (_queue.Any())
+        {
+            List<PurchaseOrderItemAllocation> _poias = new();
+            var _jripois = _queue.Dequeue(CHUNK_SIZE).Select(x=>x.ToObject<JobRequisitionItemPurchaseOrderItem>()).ToList();
+            foreach (var _jripoi in _jripois)
+            {
+                var _poia = new PurchaseOrderItemAllocation();
+                _poia.Item.ID = _jripoi.ID;
+                _poia.Job.ID = _jripoi.JobRequisitionItem.Job.ID;
+                _poia.JobRequisitionItem.ID = _jripoi.JobRequisitionItem.ID;
+                _poia.Quantity = _jripoi.PurchaseOrderItem.Qty;
+                _poias.Add(_poia);
+                CoreUtils.SetPropertyValue(_jripoi,"Job.ID",Guid.Empty);
+            }
+            provider.Save(_poias);
+            if (DESTRUCTIVE)
+                provider.Delete(_jripois,"");
+            Logger.Send(LogType.Information, "", $"- Created {_poias.Count} Allocations ({_queue.Count} remaining)");
+            _result.AddRange(_poias);
+        }
+
+        return _result;
+    }
+    
+    private void Migrate_POIs(IProvider provider, List<PurchaseOrderItemAllocation> poias)
+    {
+        Logger.Send(LogType.Information,"","Migrating PurchaseOrderItems");
+        var _ids = poias.Select(x => x.Item.ID).Distinct().ToArray();
+        var _queue = provider.Query(
+            new Filter<PurchaseOrderItem>("Job.ID").IsNotEqualTo(Guid.Empty),
+            Columns.Required<PurchaseOrderItem>().Add("Job.ID")
+        ).Rows.ToQueue();
+        
+        while (_queue.Any())
+        {
+            List<PurchaseOrderItemAllocation> _poias = new();
+            var _pois = _queue.Dequeue(CHUNK_SIZE)
+                .Where(r => !_ids.Contains(r.Get<PurchaseOrderItemAllocation,Guid>(c=>c.ID)))
+                .Select(x=>x.ToObject<PurchaseOrderItem>())
+                .ToList();
+            foreach (var _poi in _pois)
+            {
+                var _poia = new PurchaseOrderItemAllocation();
+                _poia.Item.ID = _poi.ID;
+                _poia.Job.ID = (Guid)(CoreUtils.GetPropertyValue(_poi, "Job.ID") ?? Guid.Empty);
+                _poia.Quantity = _poi.Qty;
+                _poias.Add(_poia);
+                CoreUtils.SetPropertyValue(_poi,"Job.ID",Guid.Empty);
+            }
+            provider.Save(_poias);
+            if(DESTRUCTIVE)
+                provider.Save(_pois);
+            Logger.Send(LogType.Information, "", $"- Created {_poias.Count} Allocations ({_queue.Count} remaining)");
+        }
+    }
+
+
+}
+

+ 1 - 0
prs.stores/FodyWeavers.xml

@@ -1,3 +1,4 @@
 <Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
+  <AutoProperties />
   <PropertyChanged />
 </Weavers>

+ 1 - 0
prs.stores/FodyWeavers.xsd

@@ -53,6 +53,7 @@
             </xs:attribute>
           </xs:complexType>
         </xs:element>
+        <xs:element name="AutoProperties" minOccurs="0" maxOccurs="1" type="xs:anyType" />
       </xs:all>
       <xs:attribute name="VerifyAssembly" type="xs:boolean">
         <xs:annotation>

+ 1 - 0
prs.stores/PRSStores.csproj

@@ -7,6 +7,7 @@
   </PropertyGroup>
 
   <ItemGroup>
+    <PackageReference Include="AutoProperties.Fody" Version="1.25.0" />
     <PackageReference Include="Fody" Version="6.8.1">
       <PrivateAssets>all</PrivateAssets>
       <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>