Quintiq file version 2.0 
 | 
#parent: #root 
 | 
Method GetIsBalanceSlackAllowed ( 
 | 
  const ProductInStockingPointInPeriod pispip, 
 | 
  const constcontent ProductInStockingPointInPeriods smartplanpispips, 
 | 
  constcontent ProductInStockingPoint_MPs intermediatepisps, 
 | 
  const RunContextForCapacityPlanning runcontext 
 | 
) const as Boolean 
 | 
{ 
 | 
  Description: 
 | 
  [* 
 | 
    Determines whether we allow slack on the balance constraint. 
 | 
    For smart plans that should only plan one step upstream we remove some of the balance slacks to make sure that we actually plan the step 
 | 
    and that the balance violations occur at the input side rather than at the end or at an intermediate stage. 
 | 
  *] 
 | 
  TextBody: 
 | 
  [* 
 | 
    // Martijn Dec-7-2016 (created) 
 | 
    // If this is not a smart plan run or if we are not only planning one step upstream, then we always allow balance slack. 
 | 
    // Or if it is a single step smart plan and the pispip is not the end product and it is either not an intermediate product or it is a by product, then we allow the slack 
 | 
    isallowed := not runcontext.IsSmartPlan() 
 | 
                 or not runcontext.IsOnlyPlanOneStepUpstream() 
 | 
                 or ( not exists( smartplanpispips, Elements.ProductInStockingPoint_MP, pisp, pisp = pispip.ProductInStockingPoint_MP() ) 
 | 
                      and ( pispip.ProductInStockingPoint_MP().Product_MP().IsDerivedByProduct() 
 | 
                            or not exists( intermediatepisps, Elements, pisp, pisp = pispip.ProductInStockingPoint_MP() ) ) ) 
 | 
     
 | 
    return isallowed; 
 | 
  *] 
 | 
  InterfaceProperties { Accessibility: 'Module' } 
 | 
} 
 |