/// <summary>
/// Calculates the
delivery percent possible for the whole order and updates this amount in the
/// temporary table.
/// </summary>
protected void
deliverPossiblePctCalc()
{
Counter numberOfOrderLines;
Counter
numberOfOrderLinesDeliverable;
Percent deliverPossiblePct;
InventReleaseOrderPickingTmp releaseOrderPickingTmp;
SalesLine salesLineLocal;
InventTable inventTable;
InventTransOriginSalesLine inventTransOriginSalesLine;
InventTrans inventTrans;
InventDim inventDimSalesLine;
SysQueryRun queryRun;
InventQty qtyPhysicalInvent;
InventQty qtyRemainToDeliver;
InventQty qtyReservedOrdered;
releaseOrderPickingTmp.linkPhysicalTableInstance(inventReleaseOrderPickingTmp);
queryRun = new
SysQueryRun(this.createOrderLinesPossibleQuery());
while
(queryRun.next())
{
salesLineLocal =
queryRun.get(salesLineLocal.TableId);
if
(!salesLineRecIdSet.in(salesLineLocal.RecId))
{
inventDimSalesLine =
this.findInventDim(salesLineLocal.InventDimId);
qtyPhysicalInvent =
this.findQtyPhysicalInvent(salesLineLocal.ItemId,inventDimSalesLine);
if
(qtyPhysicalInvent > 0)
{
qtyReservedOrdered =
this.findQtyReservedOrdered(salesLineLocal.InventTransId);
qtyRemainToDeliver =
this.findQtyRemainToDeliver(salesLineLocal, qtyReservedOrdered);
if
(qtyRemainToDeliver > 0)
{
this.updateNumberOfOrderLinesDeliverableMap(salesLineLocal.SalesId,
this.allOrdersDeliverable(salesLineLocal.ItemId,inventDimSalesLine));
}
}
}
}
while
select count(RecId)
from inventReleaseOrderPickingTmp
group
by OrderId
{
// find
total number of order lines found deliverable (AllOrderDeliverable == Yes)
numberOfOrderLinesDeliverable =
numberOfOrderLinesDeliverableMap.lookup(inventReleaseOrderPickingTmp.OrderId);
if
(numberOfOrderLinesDeliverable)
{
//
find total number of possible order lines for this order
select
count(RecId) from salesLineLocal
where
salesLineLocal.SalesId ==
inventReleaseOrderPickingTmp.OrderId
&&
salesLineLocal.SalesStatus ==
SalesStatus::Backorder
&&
salesLineLocal.Blocked
== NoYes::No
&&
salesLineLocal.DeliveryType !=
TradeLineDlvType::DropShip
&&(salesLineLocal.SalesType ==
SalesType::Subscription
|| salesLineLocal.SalesType ==
SalesType::Sales
||
salesLineLocal.SalesType ==
SalesType::ItemReq)
exists
join inventTransOriginSalesLine
where
inventTransOriginSalesLine.SalesLineDataAreaId == salesLineLocal.DataAreaId
&&
inventTransOriginSalesLine.SalesLineInventTransId ==
salesLineLocal.InventTransId
exists join
inventTrans
where inventTrans.InventTransOrigin ==
inventTransOriginSalesLine.InventTransOrigin
&&
(inventTrans.StatusIssue
== StatusIssue::ReservPhysical
|| inventTrans.StatusIssue == StatusIssue::ReservOrdered
|| inventTrans.StatusIssue == StatusIssue::OnOrder)
notexists join
inventTable
where inventTable.ItemId == inventTrans.ItemId
&& inventTable.ItemType == ItemType::Service;
numberOfOrderLines = any2int(salesLineLocal.RecId);
//
calculate the possible deliverypct for the entire order
deliverPossiblePct = numberOfOrderLinesDeliverable * 100 / minOne(numberOfOrderLines);
update_recordset
releaseOrderPickingTmp
setting
DeliverPossiblePct = deliverPossiblePct
where releaseOrderPickingTmp.OrderId ==
inventReleaseOrderPickingTmp.OrderId;
}
}
}
|