|
@@ -139,7 +139,7 @@ public partial class ReservationManagementPanel : UserControl, IPanel<JobRequisi
|
|
|
ProductSetupActions.Standard(host);
|
|
|
host.CreateSetupAction(new PanelAction() { Caption = "Reservation Management Settings", Image = PRSDesktop.Resources.specifications, OnExecute = ConfigSettingsClick });
|
|
|
|
|
|
- //host.CreatePanelAction(new PanelAction("Treatment PO", PRSDesktop.Resources.purchase, TreatmentPO_Click));
|
|
|
+ // host.CreatePanelAction(new PanelAction("Treatment PO", PRSDesktop.Resources.purchase, TreatmentPO_Click));
|
|
|
|
|
|
if(Mode == PanelMode.Purchase && SplitPanel.IsDetailVisible())
|
|
|
{
|
|
@@ -361,8 +361,16 @@ public partial class ReservationManagementPanel : UserControl, IPanel<JobRequisi
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- Client.EnsureColumns(jris.Values, Columns.None<JobRequisitionItem>().Add(x => x.Product.Name));
|
|
|
+ Client.EnsureColumns(jris.Values, Columns.None<JobRequisitionItem>()
|
|
|
+ .Add(x => x.Product.Code)
|
|
|
+ .Add(x => x.Product.Name)
|
|
|
+ .Add(x => x.Requisition.Number)
|
|
|
+ .Add(x => x.Job.JobNumber)
|
|
|
+ .Add(x => x.Dimensions.Value));
|
|
|
|
|
|
+ // Here, we grab every stock movement for the selected JRIs, and group them per JRI. For each JRI, any stock movements that are in the wrong style
|
|
|
+ // are grouped according to their holding key. Note that this mimics precisely the TreatmentRequired aggregate on JRI. Hence, these holdings represent
|
|
|
+ // the TreatmentRequired amounts; the 'Units' field is equivalent to TreatmentRequired.
|
|
|
var holdings = Client.Query(
|
|
|
new Filter<StockMovement>(x => x.JobRequisitionItem.ID).InList(jris.Keys.ToArray()),
|
|
|
Columns.None<StockMovement>()
|
|
@@ -417,6 +425,7 @@ public partial class ReservationManagementPanel : UserControl, IPanel<JobRequisi
|
|
|
.Add(x => x.Code)
|
|
|
.Add(x => x.StockTreatmentProduct.ID))
|
|
|
.ToObjects<ProductStyle>().ToDictionary(x => x.ID);
|
|
|
+ // We need to load the treatment product for the styles that we need.
|
|
|
var treatmentProducts = Client.Query(
|
|
|
new Filter<Product>(x => x.ID).InList(styles.Select(x => x.Value.StockTreatmentProduct.ID).ToArray()),
|
|
|
Columns.None<Product>()
|
|
@@ -428,6 +437,7 @@ public partial class ReservationManagementPanel : UserControl, IPanel<JobRequisi
|
|
|
.Add(x => x.TreatmentType.Description)
|
|
|
.Add(x => x.TreatmentType.Calculation))
|
|
|
.ToObjects<Product>().ToDictionary(x => x.ID);
|
|
|
+ // Also, the ProductTreatment contains the parameter we need.
|
|
|
var jriProductsParameters = Client.Query(
|
|
|
new Filter<ProductTreatment>(x => x.Product.ID).InList(jris.Values.Select(x => x.Product.ID).ToArray()),
|
|
|
Columns.None<ProductTreatment>()
|
|
@@ -463,6 +473,8 @@ public partial class ReservationManagementPanel : UserControl, IPanel<JobRequisi
|
|
|
}
|
|
|
|
|
|
var jriHoldings = holdings.GetValueOrDefault(id);
|
|
|
+ // We know here that the TreatmentRequired > 0, because of the check at the top of the function. Hence, there definitely should be holdings.
|
|
|
+ // This therefore shouldn't ever happen, but if it does, we've made a logic mistake, and this error will tell us that.
|
|
|
if(jriHoldings is null || jriHoldings.Count == 0)
|
|
|
{
|
|
|
MessageWindow.ShowError($"Internal error for requisition {jri.Requisition.Number} for job {jri.Job.JobNumber}", $"No holdings even though TreatmentRequired is greater than 0.");
|
|
@@ -472,6 +484,7 @@ public partial class ReservationManagementPanel : UserControl, IPanel<JobRequisi
|
|
|
double multiplier;
|
|
|
if (treatmentProduct.TreatmentType.Calculation.IsNullOrWhiteSpace())
|
|
|
{
|
|
|
+ // This is the default calculation.
|
|
|
multiplier = treatment.Parameter * jri.Dimensions.Value;
|
|
|
}
|
|
|
else
|
|
@@ -505,7 +518,8 @@ public partial class ReservationManagementPanel : UserControl, IPanel<JobRequisi
|
|
|
item.JRI.CopyFrom(jri);
|
|
|
|
|
|
item.Multiplier = multiplier;
|
|
|
- item.RequiredQuantity = holding.Units;// jri.TreatmentRequired - jri.TreatmentOnOrder;
|
|
|
+ // holding.Units should be TreatmentRequired
|
|
|
+ item.RequiredQuantity = holding.Units;
|
|
|
|
|
|
items.Add(item);
|
|
|
}
|