admin
2025-01-22 7e31442f0e9b07764e9c6a9680d3d4aeba5fe1de
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
Quintiq file version 2.0
#parent: #root
Method GetIsBlendedValueLessThanMaximum (
  output Strings feedback_o,
  output Strings sanitycheckfeedbacks_o
) declarative remote as Boolean
{
  Description: 'Returns true if the input blended value is within the maximum value as stated in the recipe used.'
  TextBody:
  [*
    // Adhi Aug-4-2015 (created)
    checkvalid := true;
    gp := this.MacroPlan().GlobalParameters_MP();
    
    // Get the recipe from operationoutput
    outputrecipe := select( this, NewSupply.ProductInStockingPointInPeriodPlanningLeaf.RecipeWithEffectiveDate.Recipe, recipe, true );
    
    // Do check for every ingredient in the recipe
    traverse( outputrecipe, BaseRecipeIngredient, recipeingredient )
    {
       blendedvalue := this.GetBlendedValue( recipeingredient );
    
       isvalid := blendedvalue <= recipeingredient.Maximum()
                  or gp.GetIsBalanceWithinTolerance( blendedvalue, recipeingredient.Maximum() );
    
       // If one failed, consider invalid. Do not put isvalid in the traverse above because we want to gather all messages.
       checkvalid := checkvalid and isvalid;
    
       if( not isnull( feedback_o ) and not isvalid )
       {
          instance := PeriodTaskOperation::GetInstanceText( this );
          percentage := GlobalParameters_MP::GetPercentageDifference( blendedvalue, recipeingredient.Maximum() );
          message := Translations::MP_PeriodTaskOperation_ViolateIsBlendedValueLessThanMaximum( blendedvalue, recipeingredient, percentage );
          feedback_o.Add( SanityCheckMessage::GetFormattedMessage( instance, message ) );
          sanitycheckfeedbacks_o.Add( SanityCheckCategoryLevel::GetSanityCheckCategoryPlanningIssue() );
       }
    }
    
    return checkvalid;
  *]
}