haorenhui
2023-10-30 6d6cc10d9e8e242661da7fd655dec155a09d676c
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
Quintiq file version 2.0
#parent: #root
Method ResetSalesDemand (
  MacroPlan macroplan
)
{
  Description: 'Reset all sales demand in demo data'
  TextBody:
  [*
    // Multiply all sales demands to 0, reset all plan
    SalesDemandBase::AdjustQuantity( macroplan.SalesDemand( relget ), SalesDemandBase::Adjust_Multiply(), 0.0 );
    
    // Reset optimizer/manual plan
    macroplan.ResetPeriodTasksAndResetKPI( true, true, null( OptimizerPuzzle ) );
    
    // Reset all external supply
    traverse( macroplan, Product_MP, e )
    {
      e.InventorySupply( relflush );
    }
    
    // Reset all actuals
    macroplan.Actual( relflush );
    
    // Assert make sure all actuals are reset, all sales demands zero, all external supply are removed
    hasActual := exists( macroplan, Actual, a, true );
    hasDemand := exists( macroplan, SalesDemand, e, e.Quantity() > 0 );
    hasExternalSupply := exists( macroplan, Product_MP, e, e.InventorySupply( relsize ) > 0 );
    // Check setup
    this.Run().AssertFalse( hasActual, "One or more actual pispip exist" );
    this.Run().AssertFalse( hasDemand, "One or more sales demand is not zero" );
    this.Run().AssertFalse( hasExternalSupply, "One or more product external supply is not zero" );
  *]
  InterfaceProperties { Accessibility: 'Module' }
}