Quintiq file version 2.0
|
#parent: #root
|
StaticMethod GetProcessQuantity (
|
ProductInStockingPointInPeriod pispip,
|
output String tooltip
|
) declarative remote as Real
|
{
|
Description: 'Return quantities of a pispip related sales demands.'
|
TextBody:
|
[*
|
quantity := 0.0
|
fulfilledQuantity := 0.0
|
unfulfilledQuantity := 0.0
|
totalQuantity := 0.0
|
totalFulfilledQuantity := 0.0
|
totalUnfulfileldQuantity := 0.0
|
// Insert table tag for tooltip
|
// Product
|
tooltip := "<table>";
|
tooltip := tooltip + '<tr><td><b>Product: </b></td><td>'
|
+ pispip.ProductInStockingPoint_MP().Product_MP().Name() + '</td></tr>';
|
|
// Routing name
|
tooltip := tooltip + '<tr><td><b>Stocking point: </b></td><td>'
|
+ pispip.ProductInStockingPoint_MP().StockingPoint_MP().Name() + '</td></tr>';
|
|
// Period
|
tooltip := tooltip + '<tr><td><b>Period: </b></td><td>'
|
+ pispip.Start().Format( 'D-MM-Y' ) + ' until ' + pispip.End().Format( 'D-MM-Y' ) + '</td></tr>';
|
|
// A separating line
|
tooltip := tooltip + '</table><hr>';
|
|
// Headers
|
tooltip := tooltip + '<table><tr><td><b>Sales segment:</b></td>'
|
+ '<td><b>Quantity:</b></td>'
|
+ '<td><b>Fulfilled:</b></td>'
|
+ '<td><b>Unfulfilled:</b></td>'
|
+ '<td><b>Price:</b></td><td></tr>';
|
|
// Sort them w.r.t sales segment name for grouping
|
sdips := selectsortedset( pispip, SalesDemandInPeriodBase, sdip, true, sdip.SalesSegmentName() );
|
ssName := sdips.Element( 0 ).SalesSegmentName();
|
|
traverse( sdips, Elements, e )
|
{
|
// When we see a different sales segment, create a new row for tooltip
|
if( ssName <> e.SalesSegmentName() )
|
{
|
tooltip := tooltip + '<tr><td>' + ssName + '</td>'
|
+ '<td>' + quantity.AsQUILL() + '</td>'
|
+ '<td>' + fulfilledQuantity.AsQUILL() + '</td>'
|
+ '<td>' + unfulfilledQuantity.AsQUILL() + '</td>'
|
+ '<td>' + e.Price().AsQUILL() + '</td>';
|
|
// Reset value
|
ssName := e.SalesSegmentName();
|
quantity := 0;
|
unfulfilledQuantity := 0;
|
fulfilledQuantity := 0;
|
}
|
|
quantity := quantity + e.Quantity();
|
fulfilledQuantity := fulfilledQuantity + e.FulfilledQuantity();
|
unfulfilledQuantity := unfulfilledQuantity + e.UnfulfilledQuantity();
|
totalQuantity := totalQuantity + e.Quantity();
|
totalFulfilledQuantity := totalFulfilledQuantity + e.FulfilledQuantity();
|
totalUnfulfileldQuantity := totalUnfulfileldQuantity + e.UnfulfilledQuantity();
|
}
|
// Last row handling
|
tooltip := tooltip + '<tr><td>' + ssName + '</td>'
|
+ '<td>' + quantity.AsQUILL() + '</td>'
|
+ '<td>' + fulfilledQuantity.AsQUILL() + '</td>'
|
+ '<td>' + unfulfilledQuantity.AsQUILL() + '</td>'
|
+ '<td>' + sdips.Element( sdips.Size() - 1 ).Price().AsQUILL() + '</td>';
|
|
// Sum for multi sales segment demands
|
if( selectuniquevalues( sdips, Elements, e, true, e.SalesSegmentName() ).Size() > 1 )
|
{
|
tooltip := tooltip + '<tr><td><b>All</b></td>'
|
+ '<td>' + totalQuantity.AsQUILL() + '</td>'
|
+ '<td>' + totalFulfilledQuantity.AsQUILL() + '</td>'
|
+ '<td>' + totalUnfulfileldQuantity.AsQUILL() + '</td></table>'
|
}
|
|
// Return fulfilled quantity sum
|
return totalFulfilledQuantity;
|
*]
|
}
|