I have a sales order with a pre-payment on it. The pre-payment has a balance meaning that the Applied to Order value is less than the value of the pre-payment and less than the value of the order.
In my case I have a detail line on the sales order that is increasing in value and I would like to bump up the Applied to Order value accordingly.
However, when I try to do this via code, I get an error: Entry must be less or equal to $X. $X is always the value of the Applied to Order amount.
Is there something that I’m missing that I need to do to the order so that I can change the SOAdjust record?
public PXAction<SOOrder> TestPreAuthEdit;
[PXButton(CommitChanges = true, IsLockedOnToolbar = true, Category = "")]
[PXUIField(DisplayName = "Test Pre Auth Edit", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select, Enabled = true)]
public virtual IEnumerable testPreAuthEdit(PXAdapter adapter)
{
SOOrder order = Base.Document.Current;
foreach (SOLine line in Base.Transactions.Select())
{
InventoryItem item = InventoryItem.PK.Find(Base, line.InventoryID);
if (item == null) continue;
if (item.InventoryCD.Trim() == "ITEMCODE") //This is just to locate a line on the SO
{
Base.Caches[typeof(SOLine)].SetValueExt<SOLine.curyUnitPrice>(line, line.CuryUnitPrice + 10);
Base.Caches[typeof(SOLine)].Update(line);
Base.Caches[typeof(SOOrder)].Update(order);
}
}
Base.Save.PressButton(); //I've tried with and without this line
foreach (SOAdjust payment in Base.Adjustments.Select()) //I only have one prepayment so I'm not worried about the loop
{
Base.Caches[typeof(SOAdjust)].SetValueExt<SOAdjust.curyAdjdAmt>(payment, payment.CuryAdjdAmt + 10);
Base.Caches[typeof(SOAdjust)].Update(payment);
}
return adapter.Get();
}
Best answer by Django
View original