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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
Quintiq file version 2.0
#parent: #root
Method GetSalesDemandInPeriodsConst () const declarative as constcontent owning BaseSalesDemandInPeriods
{
  Description: 'Related Sales Demand In Periods with this service level'
  TextBody:
  [*
    // edz1 Jul-8-2016 (created)
    
    hasproduct := not isnull( this.Product_MP() );
    hasstockingpoint := not isnull( this.StockingPoint_MP() );
    hassalessegment := not isnull( this.SalesSegment_MP() ); 
    
    salesdemandsinperiods := construct( BaseSalesDemandInPeriods, constcontent );
    pispips := construct( ProductInStockingPointInPeriods, constcontent );
    
    if( hasproduct )
    {
      if( hasstockingpoint )
      {
          if( hassalessegment ) // hasproduct=true, hasstockingpoint=true, hassalessegment=true
          {
              salesdemandsinperiods := selectset( this,
                                                  SalesSegment_MP.AllChildrenOfActiveSalesLevel.AsChildren.SalesDemandInPeriod,   //TODOVincent   //get all SDIP via active level SalesSegments  
                                                  sdip,
                                                  sdip.NeedsToBePlanned(),
                                                  this.Product_MP().IsParentOf( sdip.SalesDemand().Product_MP() )                    // matching prod/parent prod.
                                                  and sdip.ProductInStockingPoint_MP().StockingPoint_MP() = this.StockingPoint_MP()  // matching stockingpoint                
                                                  and Period_MP::IsInPeriod( sdip.AsSalesDemandInPeriodBase().Start(),        
                                                                             sdip.AsSalesDemandInPeriodBase().End(),
                                                                             this.StartDateTime(),
                                                                             this.EndDateTime() )
                                                );
          }
          else // hasproduct=true, hasstockingpoint=true, hassalessegment=false
          {
              pispips := selectset( this, 
                                    Product_MP.AllChildren.AsChildren.ProductInStockingPoint_MP.ProductInStockingPointInPeriod,     //get all PISPIPs of all children Products
                                    pispip,
                                    pispip.ProductInStockingPoint_MP().StockingPoint_MP() = this.StockingPoint_MP()                 // matching stockingpoint
                                    and Period_MP::IsInPeriod( this.StartDateTime(),                                             // matching start/end
                                                               this.EndDateTime(), 
                                                               pispip.Start(), 
                                                               pispip.End() ) 
                                  );
                                                                
              salesdemandsinperiods := selectset( pispips, 
                                                  Elements.astype( ProductInStockingPointInPeriodPlanningLeaf ).PlanningBaseSalesDemandInPeriod, 
                                                  sdip, 
                                                  sdip.NeedsToBePlanned() 
                                                );
          }
      }
      else if( hassalessegment ) // hasproduct=true, hasstockingpoint=false, hassalessegment=true
      {
          salesdemandsinperiods := selectset( this,
                                              SalesSegment_MP.AllChildrenOfActiveSalesLevel.AsChildren.SalesDemandInPeriod,    //get all SDIP via active level SalesSegments
                                              sdip,
                                              sdip.NeedsToBePlanned(),
                                              this.Product_MP().IsParentOf( sdip.SalesDemand().Product_MP() )                  //matching prod/parent prod.
                                              and Period_MP::IsInPeriod( sdip.AsSalesDemandInPeriodBase().Start(),        //matching start/end
                                                                         sdip.AsSalesDemandInPeriodBase().End(),
                                                                         this.StartDateTime(),
                                                                         this.EndDateTime() )
                                            );
      }
      else  // hasproduct=true, hasstockingpoint=false, hassalessegment=false
      {
          pispips := selectset ( this, 
                                 Product_MP.AllChildren.AsChildren.ProductInStockingPoint_MP.ProductInStockingPointInPeriod,  // get all PISPIPs of all children Products
                                 pispip,              
                                 Period_MP::IsInPeriod( this.StartDateTime(),                                              // matching start/end
                                                        this.EndDateTime(), 
                                                        pispip.Start(), 
                                                        pispip.End() )              
                               );
          salesdemandsinperiods := selectset( pispips, 
                                              Elements.astype( ProductInStockingPointInPeriodPlanningLeaf ).PlanningBaseSalesDemandInPeriod, 
                                              sdip, 
                                              sdip.NeedsToBePlanned() 
                                            );
      }
    }
    else if( hasstockingpoint )
    {
      if( hassalessegment ) // hasproduct=false, hasstockingpoint=true, hassalessegment=true
      {
        salesdemandsinperiods := selectset( this,
                                            SalesSegment_MP.AllChildrenOfActiveSalesLevel.AsChildren.SalesDemandInPeriod,    // get all SDIP via active level SalesSegments
                                            sd,
                                            sd.NeedsToBePlanned(),
                                            this.StockingPoint_MP() = sd.ProductInStockingPoint_MP().StockingPoint_MP()      // matching stockingpoint
                                            and Period_MP::IsInPeriod( sd.AsSalesDemandInPeriodBase().Start(),          // matching start/end
                                                                       sd.AsSalesDemandInPeriodBase().End(),
                                                                       this.StartDateTime(),
                                                                       this.EndDateTime() )
                                          );
      }
      else // hasproduct=false, hasstockingpooint=true, hassalessegment=false
      {
        pispips := selectset ( this,
                               StockingPoint_MP.ProductInStockingPoint_MP.ProductInStockingPointInPeriod,   // get all PISPIPs via StockingPoint
                               pispip,
                               Period_MP::IsInPeriod( this.StartDateTime(),                              // matching start/end
                                                      this.EndDateTime(), 
                                                      pispip.Start(), 
                                                      pispip.End() )
                             );
        salesdemandsinperiods := selectset( pispips, 
                                            Elements.astype( ProductInStockingPointInPeriodPlanningLeaf ).PlanningBaseSalesDemandInPeriod, 
                                            sdip, 
                                            sdip.NeedsToBePlanned() 
                                          );
      }
    }
    else // hasproduct=false, hasstockingpoint=false, hassalessegment=true
    {
      salesdemandsinperiods := selectset( this,
                                          SalesSegment_MP.AllChildrenOfActiveSalesLevel.AsChildren.SalesDemandInPeriod,    // get all SD via active level SalesSegments
                                          sdip,
                                          sdip.NeedsToBePlanned(),
                                          Period_MP::IsInPeriod( sdip.AsSalesDemandInPeriodBase().Start(),           // matching start/end
                                                                 sdip.AsSalesDemandInPeriodBase().End(),
                                                                 this.StartDateTime(),
                                                                 this.EndDateTime() )
                                        );
    }
    
    return &salesdemandsinperiods;
  *]
}