|
@@ -528,13 +528,13 @@ internal class JobSummaryGrid : DynamicDataGrid<JobMaterial>, IMasterDetailContr
|
|
|
private void ViewOnOrder(CoreRow row)
|
|
|
{
|
|
|
var item = row.ToObject<JobMaterial>();
|
|
|
- ShowDetailGrid<PurchaseOrderItemAllocation>(
|
|
|
+ ShowDetailGrid<PurchaseOrderItem>(
|
|
|
OnOrderColumn.Property,
|
|
|
- x => x.Item.Product.ID,
|
|
|
+ x => x.Product.ID,
|
|
|
item.Product.ID,
|
|
|
- x => x.Item.Style.ID,
|
|
|
+ x => x.Style.ID,
|
|
|
StyleColumnVisible() ? item.Style.ID : null,
|
|
|
- x => x.Item.Dimensions,
|
|
|
+ x => x.Dimensions,
|
|
|
DimensionsColumnVisible() ? item.Dimensions : null,
|
|
|
x => x.Job.ID,
|
|
|
null,
|
|
@@ -565,19 +565,19 @@ internal class JobSummaryGrid : DynamicDataGrid<JobMaterial>, IMasterDetailContr
|
|
|
private void ViewFreeOnOrder(CoreRow row)
|
|
|
{
|
|
|
var item = row.ToObject<JobMaterial>();
|
|
|
- ShowDetailGrid<PurchaseOrderItemAllocation>(
|
|
|
+ ShowDetailGrid<PurchaseOrderItem>(
|
|
|
FreeOnOrderColumn.Property,
|
|
|
- x => x.Item.Product.ID,
|
|
|
+ x => x.Product.ID,
|
|
|
item.Product.ID,
|
|
|
- x => x.Item.Style.ID,
|
|
|
+ x => x.Style.ID,
|
|
|
StyleColumnVisible() ? item.Style.ID : null,
|
|
|
- x => x.Item.Dimensions,
|
|
|
+ x => x.Dimensions,
|
|
|
DimensionsColumnVisible() ? item.Dimensions : null,
|
|
|
null,
|
|
|
|
|
|
IncludeReserves
|
|
|
- ? new Filter<PurchaseOrderItemAllocation>(x => x.Job.ID).IsNotEqualTo(Master?.ID ?? Guid.Empty)
|
|
|
- : new Filter<PurchaseOrderItemAllocation>(x => x.Job.JobStatus.Active).IsEqualTo(false),
|
|
|
+ ? new Filter<PurchaseOrderItem>(x => x.Job.ID).IsNotEqualTo(Master?.ID ?? Guid.Empty)
|
|
|
+ : new Filter<PurchaseOrderItem>(x => x.Job.JobStatus.Active).IsEqualTo(false),
|
|
|
null
|
|
|
);
|
|
|
}
|
|
@@ -691,27 +691,6 @@ internal class JobSummaryGrid : DynamicDataGrid<JobMaterial>, IMasterDetailContr
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
-
|
|
|
- private CoreRow[] GetAllocationRows(IEnumerable<CoreRow> rows, Columns<PurchaseOrderItemAllocation> columns, Guid? jobID, Key key, Func<CoreRow, bool>? extrafilter = null)
|
|
|
- {
|
|
|
- int jobcol = columns.IndexOf(x => x.Job.ID);
|
|
|
- int productcol = columns.IndexOf(x => x.Item.Product.ID);
|
|
|
- int stylecol = key.StyleID.HasValue ? columns.IndexOf(x => x.Item.Style.ID) : -1;
|
|
|
- int unitcol = columns.IndexOf(x => x.Item.Dimensions.UnitSize);
|
|
|
-
|
|
|
- var dimCols = Dimensions.GetFilterColumnIndices<PurchaseOrderItemAllocation>(columns, x => x.Item.Dimensions);
|
|
|
-
|
|
|
- var subset = rows
|
|
|
- .Where(r =>
|
|
|
- (!jobID.HasValue || Guid.Equals(jobID, r.Values[jobcol]))
|
|
|
- && Guid.Equals(key.ProductID, r.Values[productcol])
|
|
|
- && (!key.StyleID.HasValue || Guid.Equals(key.StyleID, r.Values[stylecol]))
|
|
|
- && (key.Dimensions is null || key.Dimensions.Equals(r.ToDimensions<StockDimensions>(dimCols)))
|
|
|
- && ((extrafilter == null) || extrafilter(r))
|
|
|
- );
|
|
|
-
|
|
|
- return subset.ToArray();
|
|
|
- }
|
|
|
|
|
|
private CoreRow[] GetRows<TSource>(IEnumerable<CoreRow> rows, Columns<TSource> columns, Guid? jobID, Key key, Func<CoreRow, bool>? extrafilter = null) where TSource : IJobMaterial
|
|
|
{
|
|
@@ -779,22 +758,22 @@ internal class JobSummaryGrid : DynamicDataGrid<JobMaterial>, IMasterDetailContr
|
|
|
.Add(x => x.Units)
|
|
|
.Add(x => x.Job.ID)
|
|
|
.Add(x => x.Job.JobStatus.Active)),
|
|
|
- new KeyedQueryDef<PurchaseOrderItemAllocation>(
|
|
|
- new Filter<PurchaseOrderItemAllocation>(x => x.Item.ReceivedDate).IsEqualTo(DateTime.MinValue)
|
|
|
- .And(x => x.Item.Product.ID).InList(pids)
|
|
|
- .And(new Filter<PurchaseOrderItemAllocation>(x => x.Job.ID).IsEqualTo(Guid.Empty).Or(x => x.Job.ID).IsNotEqualTo(Master?.ID ?? Guid.Empty)),
|
|
|
- Columns.None<PurchaseOrderItemAllocation>().Add(x => x.Item.Product.ID)
|
|
|
- .Add(x => x.Item.Style.ID)
|
|
|
- .AddDimensionsColumns(x => x.Item.Dimensions, Dimensions.ColumnsType.Local)
|
|
|
- .Add(x => x.Quantity)
|
|
|
+ new KeyedQueryDef<PurchaseOrderItem>(
|
|
|
+ new Filter<PurchaseOrderItem>(x => x.ReceivedDate).IsEqualTo(DateTime.MinValue)
|
|
|
+ .And(x => x.Product.ID).InList(pids)
|
|
|
+ .And(new Filter<PurchaseOrderItem>(x => x.Job.ID).IsEqualTo(Guid.Empty).Or(x => x.Job.ID).IsNotEqualTo(Master?.ID ?? Guid.Empty)),
|
|
|
+ Columns.None<PurchaseOrderItem>().Add(x => x.Product.ID)
|
|
|
+ .Add(x => x.Style.ID)
|
|
|
+ .AddDimensionsColumns(x => x.Dimensions, Dimensions.ColumnsType.Local)
|
|
|
+ .Add(x => x.Qty)
|
|
|
.Add(x => x.Job.ID)
|
|
|
.Add(x => x.Job.JobStatus.Active)));
|
|
|
|
|
|
var freestock = results.Get<StockHolding>();
|
|
|
var freestockcolumns = Columns.None<StockHolding>().Add(freestock.Columns.Select(x => x.ColumnName));
|
|
|
|
|
|
- var freeorders = results.Get<PurchaseOrderItemAllocation>();
|
|
|
- var freeordercolumns = Columns.None<PurchaseOrderItemAllocation>().Add(freeorders.Columns.Select(x => x.ColumnName));
|
|
|
+ var freeorders = results.Get<PurchaseOrderItem>();
|
|
|
+ var freeordercolumns = Columns.None<PurchaseOrderItem>().Add(freeorders.Columns.Select(x => x.ColumnName));
|
|
|
|
|
|
var hasStyle = StyleColumnVisible();
|
|
|
var hasDimensions = DimensionsColumnVisible();
|
|
@@ -849,8 +828,8 @@ internal class JobSummaryGrid : DynamicDataGrid<JobMaterial>, IMasterDetailContr
|
|
|
x => x.FreeOnHand);
|
|
|
newrow.Set<JobMaterial, double>(x => x.FreeOnHand, freeonhand);
|
|
|
|
|
|
- var freeorderrows = GetAllocationRows(freeorders.Rows, freeordercolumns, null, key,
|
|
|
- IncludeReserves ? null : (r) => !r.Get<PurchaseOrderItemAllocation, bool>(x => x.Job.JobStatus.Active));
|
|
|
+ var freeorderrows = GetRows(freeorders.Rows, freeordercolumns, null, key,
|
|
|
+ IncludeReserves ? null : (r) => !r.Get<PurchaseOrderItem, bool>(x => x.Job.JobStatus.Active));
|
|
|
var freeonorder = Aggregate(freeorderrows, freeordercolumns, hasStyle, false, x => x.Quantity, newrow,
|
|
|
x => x.FreeOnOrder);
|
|
|
newrow.Set<JobMaterial, double>(x => x.FreeOnOrder, freeonorder);
|
|
@@ -938,46 +917,6 @@ internal class JobSummaryGrid : DynamicDataGrid<JobMaterial>, IMasterDetailContr
|
|
|
Progress.Close();
|
|
|
return result;
|
|
|
}
|
|
|
-
|
|
|
- private void PurchaseOrderOnSave(IDynamicEditorForm form, PurchaseOrder[] items)
|
|
|
- {
|
|
|
- Progress.ShowModal("Working", progress =>
|
|
|
- {
|
|
|
-
|
|
|
- var poItems = new Client<PurchaseOrderItem>().Query(
|
|
|
- new Filter<PurchaseOrderItem>(x => x.PurchaseOrderLink.ID).InList(items.Select(x=>x.ID).ToArray()),
|
|
|
- Columns.None<PurchaseOrderItem>()
|
|
|
- .Add(x => x.ID)
|
|
|
- .Add(x => x.Product.ID)
|
|
|
- .Add(x => x.Qty)
|
|
|
- .Add(x => x.Dimensions.UnitSize)
|
|
|
- .Add(x => x.Dimensions.Value)
|
|
|
- .Add(x => x.Style.ID)
|
|
|
- .Add(x => x.DueDate)
|
|
|
- ).Rows.ToObjects<PurchaseOrderItem>().ToArray();
|
|
|
-
|
|
|
- if (poItems.Any())
|
|
|
- {
|
|
|
- List<PurchaseOrderItemAllocation> poias = new();
|
|
|
- var jobID = Master?.ID ?? Guid.Empty;
|
|
|
- if(jobID != Guid.Empty)
|
|
|
- {
|
|
|
- foreach (var poItem in poItems)
|
|
|
- {
|
|
|
- var poia = new PurchaseOrderItemAllocation();
|
|
|
- poia.Item.ID = poItem.ID;
|
|
|
- poia.Job.ID = jobID;
|
|
|
- poia.Quantity = poItem.Qty;
|
|
|
- poias.Add(poia);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (poias.Any())
|
|
|
- Client.Save(poias, "Updated on Create Purchase Order from BOM Dashboard");
|
|
|
-
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
|
|
|
#endregion
|
|
|
}
|