Hello
I have an Item that I want to cancel on an IC SO.
One qty is "Delivered" and I want to use "Deliver remainder" to cancel the line ( add -1 in the Deliver remainder).
When I add "-1" and press "ok", error message "Quantity ordered may not be reduced because there are not enough inventory transactions with on order'status" apperars.
Here ( see below) is the "code" of the error message.
Can anyone see what I should do to make the line to be cancel?
: -----------------------------------
void synchronizeEX()
{
PurchLine purchLine;
InventQty newRemainInventPhysical;
InventQty newRemainPurchSalesPhysical;
PdsCWInventQty newPdsCWRemainInventPhysical;
boolean interCompanyStocked;
boolean isStocked = salesLine.isStocked();
if (salesLine.InterCompanyInventTransId)
{
changecompany(salesLine.salesTable().InterCompanyCompanyId)
{
setPrefix(strFmt("Company: %1",TradeInterCompany::curCompanyName()));
purchLine = PurchLine::findInventTransId(salesLine.InterCompanyInventTransId,true);
//
// NO unit conversion is performed externally, since the unit is always alike
//
interCompanyStocked = purchLine.isStocked();
if (isStocked && !interCompanyStocked && diffInventPhysical)
{
diffInventPhysical = 0;
}
if (diffInventPhysical)
{
diffInventPhysical = UnitOfMeasureConverter::convert(diffPurchSalesPhysical,
UnitOfMeasure::unitOfMeasureIdBySymbol(purchLine.PurchUnit),
UnitOfMeasure::unitOfMeasureIdBySymbol(purchLine.inventTable().inventUnitId()),
NoYes::Yes,
InventTable::itemProduct(purchLine.ItemId));
}
if (!isStocked && interCompanyStocked && !diffInventPhysical)
{
diffInventPhysical = purchLine.calcQtyOrdered(diffPurchSalesPhysical);
}
newRemainInventPhysical = purchLine.RemainInventPhysical - diffInventPhysical;
newRemainPurchSalesPhysical = purchLine.RemainPurchPhysical - diffPurchSalesPhysical;
newPdsCWRemainInventPhysical = purchLine.PdsCWRemainInventPhysical - diffPdsCWRemainInventPhysical;
if (salesLine.creditNoteLine())
{
if (newRemainInventPhysical > 0 || newRemainPurchSalesPhysical > 0)
{
throw error("Quantity ordered may not be reduced because there are not enough inventory transactions with on order'status");
}
}
else
{
if (newRemainInventPhysical < 0 || newRemainPurchSalesPhysical < 0)
{
throw error("Quantity ordered may not be reduced because there are not enough inventory transactions with on order'status");
}
}
//
// Remain physical must not be negative
//
purchLine.RemainInventPhysical = newRemainInventPhysical;
purchLine.RemainPurchPhysical = newRemainPurchSalesPhysical;
purchLine.PdsCWRemainInventPhysical = newPdsCWRemainInventPhysical;
setPrefix(#PreFixField(PurchLine, PurchId));
if (!purchLine.validateWrite())
{
throw error("@SYS18738");
}
InterCompanyUpdateRemPhys::synchronize(purchLine,
diffInventPhysical,
diffPurchSalesPhysical,
InterCompanySkipUpdate::InterCompany,
diffPdsCWRemainInventPhysical);
// Rereading the PurchLine buffer in order to avoid update conflicts.
// In certain drop shipment scenarios, the PurchLine buffer is updated in the call to InterCompanyUpdateRemPhys::synchronize().
if (purchLine.ItemRefType == InventRefType::Sales
&& purchLine.InventRefTransId
&& purchLine.isDropShipment())
{
purchLine.reread();
purchLine.RemainInventPhysical = newRemainInventPhysical;
purchLine.RemainPurchPhysical = newRemainPurchSalesPhysical;
purchLine.PdsCWRemainInventPhysical = newPdsCWRemainInventPhysical;
}
purchLine.update();
}
}
}
regards BCC