Skip to content

Instantly share code, notes, and snippets.

@BrianMRO
Last active October 26, 2021 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BrianMRO/1fe79c336013f45f08b5ab377c3e62dc to your computer and use it in GitHub Desktop.
Save BrianMRO/1fe79c336013f45f08b5ab377c3e62dc to your computer and use it in GitHub Desktop.
Create Purchase Orders Without Merging Demand Into Single PO Lines - Additions Only
#region CreatePOOrders - Replace base version (clone and inject code)
public static PXRedirectRequiredException CreatePOOrders(List<POFixedDemand> list, DateTime? PurchDate, bool extSort)
{
...
POLine line = null;
//Sales Orders to Blanket should not be grouped together
//Drop Ships to Blankets are not grouped either
if (!orderedByPlantype.TryGetValue(demand.PlanType, out ordered))
{
ordered = orderedByPlantype[demand.PlanType] = new DocumentList<POLine>(docgraph);
}
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
// Get MyField from Plan - stored in INItemPlanExt
INItemPlan plan = demand as INItemPlan;
INItemPlanExt planExt = plan.GetExtension<INItemPlanExt>();
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
if (OrderType == POOrderType.RegularOrder && demand.PlanType != INPlanConstants.Plan6B)
{
var lineSearchValues = new List<FieldLookup>()
{
new FieldLookup<POLine.vendorID>(demand.VendorID),
new FieldLookup<POLine.vendorLocationID>(demand.VendorLocationID),
new FieldLookup<POLine.siteID>(demand.POSiteID),
new FieldLookup<POLine.inventoryID>(demand.InventoryID),
new FieldLookup<POLine.subItemID>(demand.SubItemID),
new FieldLookup<POLine.requestedDate>(soline?.ShipDate),
new FieldLookup<POLine.projectID>(soline?.ProjectID),
new FieldLookup<POLine.taskID>(soline?.TaskID),
new FieldLookup<POLine.costCodeID>(soline?.CostCodeID),
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
//Add MyField to Search
new FieldLookup<POLineExt.usrXXMyField>(planExt?.UsrXXMyField),
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
};
if (setup.CopyLineDescrSO == true && soline != null)
{
lineSearchValues.Add(new FieldLookup<POLine.tranDesc>(soline.TranDesc));
line = ordered.Find(lineSearchValues.ToArray());
if (line != null && setup.CopyLineNoteSO == true &&
(PXNoteAttribute.GetNote(docgraph.Caches[typeof(POLine)], line) != null || PXNoteAttribute.GetNote(docgraph.Caches[typeof(SOLineSplit3)], soline) != null))
{
line = null;
}
}
else
line = ordered.Find(lineSearchValues.ToArray());
}
line = line ?? new POLine();
...
line = docgraph.Transactions.Update(line);
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
// Save MyField to PO Line
POLineExt lineExt = line.GetExtension<POLineExt>();
lineExt.UsrXXMyField = planExt.UsrXXMyField;
docgraph.Caches[typeof(POLine)].Update(lineExt);
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
...
}
#endregion
#region CreateSplitDemand - Copy Private Static Method From Base For Accessibility
private static void CreateSplitDemand(PXCache cache, POFixedDemand demand)
{
...
}
#endregion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment