lazhen
2025-01-09 8afe90b633046db39042aada36b88193062f8cff
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
Quintiq file version 2.0
#parent: #root
Method GenerateDemands () id:Method_FormDemandSupply_GenerateDemands
{
  #keys: '[132448.0.712669067]'
  Body:
  [*
    // Generate all demand for visualization                         
    // Clear dataholder
    DataHolderGP.Data( null( shadow[GlobalParameters_MP], owning ) );
    
    // Ownership on GP so it is possible to display the DemandForVisualization
    owner := shadow( MacroPlan.GlobalParameters_MP() );
    
    DataHolderGP.Data( &owner );
    
    traverse( DataHolderDemandPISPIP.Data(), Elements, pispip )
    {
      pispName := pispip.ProductInStockingPoint_MP().Name();
      planningPISPIP := pispip;
      type := DemandForVisualization::GetPlanningDemandString();
      factor := 1.0;
      
      if( pispip.istype( ProductInStockingPointInPeriodNonPlanningBase ) )
      {
        planningPISPIP := pispip.astype( ProductInStockingPointInPeriodNonPlanningBase ).PlanningPISPIP();
        type := DemandForVisualization::GetDisaggregatedDemandString(); 
        factor := pispip.GetPlanningSystemRatio();
      } 
      
      if( not isnull( planningPISPIP )
          and planningPISPIP.istype( ProductInStockingPointInPeriodPlanningLeaf ) )  // If its original demand or disaggregated demand
      {                         
        traverse( planningPISPIP.astype( ProductInStockingPointInPeriodPlanningLeaf ).GetDemand_MPs(), Elements, demand )
        {
          quantity := demand.Quantity() * factor; // If its disaagregated 
                              
          Form.CreateDemandForVisualization( pispName, 
                                             type,
                                             quantity, 
                                             pispip.Start(),
                                             demand );   
        }
      }
      else
      { 
        if( pispip.istype( ProductInStockingPointInPeriodNonPlanningBase )
            and not isnull( pispip.astype( ProductInStockingPointInPeriodNonPlanningBase ).PlanningPISPIP() ) )
        {
          type := DemandForVisualization::GetDisaggregatedDemandString();
        }
        else
        {
          type := DemandForVisualization::GetAggregatedDemandString();
        }
        
        Form.CreateDemandForVisualization( pispName,
                                           type,
                                           pispip.DependentDemandAndSalesDemandQuantity(), // Pispip already have the demand information
                                           pispip.Start(),
                                           null( Demand_MP ) );
      }
    }
  *]
}