//Cancel SO
-->Open Order in X++
private void toCancelSo()
{
//info(strFmt("%1 -- %2 ",transDate,salesOrder));
Query query;
QueryBuildDataSource qbds;
QueryBuildRange qbrSalesId,qbrDate;
QueryRun qr;
InventTrans inventTrans;
InventMovement inventMovement;
InventTransWMS_Pick inventTranspick;
TmpInventTransWMS TmpInventTransWMS;
;
query = new query();
qbds= query.addDataSource(tableNum(SalesTable));
qbds.addRange(fieldNum(SalesTable,SalesType)).value("Sales Order");
if (transDate != dateNull())
{
qbds.addRange(fieldNum(SalesTable,ShippingDateRequested)).value(SysQuery::range(dateNull(),transDate));
}
//qbds.addRange(fieldNum(SalesTable,CustAccount)).value("R0003");
if (salesOrder != "")
{
qbrSalesId = qbds.addRange(fieldNum(SalesTable,SalesId));
qbrSalesId.value(salesOrder);
}
qr = new QueryRun(query);
while(qr.next())
{
salesTable = qr.get(tableNum(SalesTable));
ttsBegin;
while select forupdate salesLine
where salesLine.SalesId == salesTable.SalesId
&& salesLine.SalesStatus == SalesStatus::Backorder
{
inventTrans = InventTrans::findTransId(salesLine.InventTransId);
if (!inventTrans)
{
salesLine.RemainInventPhysical = 0;
salesLine.RemainSalesPhysical = 0;
salesLine.update();
}
else if(inventTrans.StatusIssue == StatusIssue::OnOrder
|| inventTrans.StatusIssue == StatusIssue::ReservOrdered
|| inventTrans.StatusIssue == StatusIssue::ReservPhysical
|| inventTrans.StatusIssue == StatusIssue::None)
{
salesLine.RemainInventPhysical = 0;
salesLine.RemainSalesPhysical = 0;
salesLine.update();
}
}
ttsCommit;
}
}
/*
Identifying the Status of a Line
if(salesLine.remainSalesFinancial != 0)
{
// I am delivered
}
or
if(invnetTrans.statusIssue == StatusIssue::Deducted)
{
// I am delivered
}
-->Open Order in X++
private void toCancelSo()
{
//info(strFmt("%1 -- %2 ",transDate,salesOrder));
Query query;
QueryBuildDataSource qbds;
QueryBuildRange qbrSalesId,qbrDate;
QueryRun qr;
InventTrans inventTrans;
InventMovement inventMovement;
InventTransWMS_Pick inventTranspick;
TmpInventTransWMS TmpInventTransWMS;
;
query = new query();
qbds= query.addDataSource(tableNum(SalesTable));
qbds.addRange(fieldNum(SalesTable,SalesType)).value("Sales Order");
if (transDate != dateNull())
{
qbds.addRange(fieldNum(SalesTable,ShippingDateRequested)).value(SysQuery::range(dateNull(),transDate));
}
//qbds.addRange(fieldNum(SalesTable,CustAccount)).value("R0003");
if (salesOrder != "")
{
qbrSalesId = qbds.addRange(fieldNum(SalesTable,SalesId));
qbrSalesId.value(salesOrder);
}
qr = new QueryRun(query);
while(qr.next())
{
salesTable = qr.get(tableNum(SalesTable));
ttsBegin;
while select forupdate salesLine
where salesLine.SalesId == salesTable.SalesId
&& salesLine.SalesStatus == SalesStatus::Backorder
{
inventTrans = InventTrans::findTransId(salesLine.InventTransId);
if (!inventTrans)
{
salesLine.RemainInventPhysical = 0;
salesLine.RemainSalesPhysical = 0;
salesLine.update();
}
else if(inventTrans.StatusIssue == StatusIssue::OnOrder
|| inventTrans.StatusIssue == StatusIssue::ReservOrdered
|| inventTrans.StatusIssue == StatusIssue::ReservPhysical
|| inventTrans.StatusIssue == StatusIssue::None)
{
salesLine.RemainInventPhysical = 0;
salesLine.RemainSalesPhysical = 0;
salesLine.update();
}
}
ttsCommit;
}
}
/*
Identifying the Status of a Line
if(salesLine.remainSalesFinancial != 0)
{
// I am delivered
}
or
if(invnetTrans.statusIssue == StatusIssue::Deducted)
{
// I am delivered
}
if(inventTrans.statusIssue == StatusIssue::Picked) { // I am Picked
}
cancel Status as deleivered
ttsbegin; salesLine = SalesLine::find(_salesID, _lineNum, true); salesLine.SalesDeliverNow = -1; salesLine.setInventDeliverNow(); salesLine.doUpdate(); salesFormLetter = SalesFormLetter::construct(DocumentStatus::PackingSlip); salesFormLetter.progressHide(); salesFormLetter.update(salesTable, SystemDateGet(), SalesUpdate::DeliverNow, AccountOrder::None, false, false); ttsCommit;
cancel Status as Picked
ttsBegin;
salesLine = salesLine::find(_salesID, _lineNum, true);
inventMovement = InventMovement::construct(salesLine);
inventTranspick = new InventTransWMS_Pick(inventMovement,tmpInventTransWMS);
TmpInventTransWMS.clear();
TmpInventTransWMS.initFromInventTrans(inventTrans::findTransId(salesLine.InventTransId));
TmpInventTransWMS.LineNum = _LineNum;
TmpInventTransWMS.InventDimId = InventTrans::findTransId(salesLine.InventTransId).InventDimId;
TmpInventTransWMS.InventQty = ( ABS( InventTrans::findTransId(salesLine.InventTransId).Qty ) * -1 );
TmpInventTransWMS.insert();
if( TmpInventTransWMS.InventQty != 0 )
{
if( inventTranspick.validateTmp(TmpInventTransWMS) )
{
InventTransWMS_Pick::updateInvent(inventTranspick,TmpInventTransWMS);
}
}
//cancel order
salesLine.RemainSalesPhysical = 0;
salesLine.remainInventPhysical = 0;
salesLine.update();
ttsCommit;
Cancel a Return Order in AX
SalesLine returnLine;
SalesTable returnTableUpdate;
Counter numberOfRecords;
SalesTable salesTable;
PurchTable purchTable;
PurchLine purchLine;
;
ttsbegin;
if (_returnTable.ReturnStatus == ReturnStatusHeader::Created && !_returnTable.existRegisteredReceivedInvoicedLines() && !_returnTable.type().interCompanyIsDerivedOrder())
{
while select forupdate returnLine
where returnLine.SalesId == _returnTable.SalesId
&& returnLine.InventTransId
{
if (returnLine.interCompanySalesLineExist())
{
purchLine = PurchLine::findInventTransId(returnLine.InventRefTransId,true);
purchTable = PurchTable::find(purchLine.PurchId);
purchLine.SkipUpdate = InterCompanySkipUpdate::Internal;
purchLine.delete(false);
if (!purchTable.existPurchLine())
{
if (purchTable.InterCompanyCompanyId
&& purchTable.InterCompanySalesId)
{
changecompany(purchTable.InterCompanyCompanyId)
{
salesTable = null;
salesTable = SalesTable::find(purchTable.InterCompanySalesId,true);
if (salesTable)
salesTable.delete();
}
}
}
}
returnLine.SalesQty = 0;
returnLine.salesQtyModified();
returnLine.DeliveryType = TradeLineDlvType::None;
returnLine.SkipUpdate = InterCompanySkipUpdate::Internal;
returnLine.update();
}
returnLine.skipDataMethods(true);
update_recordset returnLine
setting ReturnStatus = ReturnStatusLine::Canceled,
CostPrice = 0,
InventTransIdReturn = '',
SalesStatus = SalesStatus::Canceled,
ReturnClosedDate = systemdateget()
where returnLine.SalesId == _returnTable.SalesId;
returnTableUpdate = SalesTable::find(_returnTable.SalesId, true);
returnTableUpdate.ReturnStatus = ReturnStatusHeader::Canceled;
returnTableUpdate.SalesStatus = SalesStatus::Canceled;
returnTableUpdate.InterCompanyDirectDelivery = false;
returnTableUpdate.update();
}
ttscommit;
*/