Quintiq file version 2.0
|
#parent: #root
|
FunctionOverride CalcQuantity
|
{
|
TextBody:
|
[*
|
//For hourly buckets, SD will be linked to the last hourly bucket of the day
|
value := 0.0
|
if( not isnull( this.AsSalesDemandInPeriodBase() ) )
|
{
|
qtyToPlan := ifexpr( this.IsPostponed(),
|
this.QuantityToPlan(),
|
// if not postponed the quantity is derived from the Sales Demand
|
this.GetUnPostponedQuantity() ); // Convert to stocking point uom, same as dependent demand.
|
|
postponedqty := sum( this,
|
PostponedSalesDemand,
|
sd,
|
sd.QuantityToPlan() );
|
|
// We need to have this piece of code here specifically because real value
|
// after arithmetic operation is inaccurate, and even when they are equal
|
// subtraction can result in values which are inaccurate, so we need to force it
|
// to be zero if they are equal. E.g., create two values, value1 := 0.12345 * 2,
|
// value2 := 0.2469, subtraction should net to zero, but you will get decimals
|
// value := ifexpr( qtyToPlan = postponedqty, 0.0, qtyToPlan - postponedqty );
|
// Tianma 20230714: Fixed a bug where small decimal points are not tolerated
|
value := ifexpr( GlobalParameters_MP::GetIsBalanceWithinAbsoluteTolerance( qtyToPlan, postponedqty, 0.0000001 ),
|
0.0,
|
qtyToPlan - postponedqty );
|
}
|
this.Quantity( value );
|
*]
|
}
|