I am new to E10, and in particular C#, so I am asking for some input on getting a customization to work for POs.
I have created a data directive to essentially treat the Release 1 of a PO like Release 1 of a Sales Order when Lock Line Quantity is set. I want to add more PO releases but keep the line quantity the same. I do that by adjusting Release 1 up/down as new releases are added/updated/deleted.
It works well except for when I try to delete the line. Epicor comes back with an error stating that at least one release must exist, even though one or more do.
Below is the data directive I have written:
// Blanket PO 7/26/2019 MLW
// Blanket PO functionality - treating like a locked line and master release for Release 1.
// Subsequent releases will decrement/increment Release 1, but leave the Line quantity the same.
//fetch PO releases
var NewRel = (from row in ttPORel
select row).ToList();
foreach (var ttPORelRow in NewRel)
{
decimal Rel1Qty = decimal.Zero;
decimal XRel1Qty = decimal.Zero;
decimal OpenPerc = decimal.Zero;
decimal LineQty = decimal.Zero;
MessageText = "";
Balance = 0;
var PORel = (from PORel_Row in Db.PORel
where PORel_Row.Company == ttPORelRow.Company && PORel_Row.PONum == ttPORelRow.PONum && PORel_Row.POLine == ttPORelRow.POLine && PORel_Row.PORelNum == 1
select PORel_Row).FirstOrDefault();
// Adjust Release 1 based on action to other releases
if (PORel != null)
{
if (string.Equals(ttPORelRow.RowMod, IceRow.ROWSTATE_ADDED, StringComparison.OrdinalIgnoreCase) && ttPORelRow.PORelNum != 1)
{
Rel1Qty = PORel.RelQty - ttPORelRow.RelQty;
XRel1Qty = PORel.XRelQty - ttPORelRow.XRelQty;
if (Rel1Qty < 0)
{
CallContext.Current.ExceptionManager.AddBLException("Too large a quantity has been entered. Review the first release to see balance open on blanket.");
}
else
{
PORel.RelQty = Rel1Qty;
PORel.XRelQty = XRel1Qty;
}
}
if (string.Equals(ttPORelRow.RowMod, IceRow.ROWSTATE_UPDATED, StringComparison.OrdinalIgnoreCase) && ttPORelRow.PORelNum != 1)
{
Rel1Qty = PORel.RelQty - (ttPORelRow.RelQty - ttPORelRow.ReqChgQty);
XRel1Qty = PORel.XRelQty - (ttPORelRow.XRelQty - (ttPORelRow.XRelQty / ttPORelRow.RelQty * ttPORelRow.ReqChgQty));
if (Rel1Qty < 0)
{
CallContext.Current.ExceptionManager.AddBLException("Too large a quantity has been entered. Review the first release to see balance open on blanket.");
}
else
{
PORel.RelQty = Rel1Qty;
PORel.XRelQty = XRel1Qty;
}
}
if (string.Equals(ttPORelRow.RowMod, IceRow.ROWSTATE_DELETED, StringComparison.OrdinalIgnoreCase) && ttPORelRow.PORelNum != 1)
{
Rel1Qty = PORel.RelQty + ttPORelRow.RelQty;
XRel1Qty = PORel.XRelQty + ttPORelRow.XRelQty;
if (Rel1Qty < 0)
{
CallContext.Current.ExceptionManager.AddBLException("Too large a quantity has been entered. Review the first release to see balance open on blanket.");
}
else
{
PORel.RelQty = Rel1Qty;
PORel.XRelQty = XRel1Qty;
}
}
Balance = PORel.RelQty;
}
Rel1Qty = 0;
XRel1Qty = 0;
OpenPerc = 0;
LineQty = 0;
}