yanweiyuan3
2023-08-09 588bc7829387dfc761cc25f06f77d4c81818bd10
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
Quintiq file version 2.0
#parent: #root
Method GetCumulativeProduction (
  const IncomingShelfLifeDay itday
) const as Real
{
  TextBody:
  [*
    // compute cumulative production for pispip when restricted to 'itday' 
    
    value := 0.0; 
    productintrips := this.GetIncomingProductInTrips( itday); // incoming trips to pispip.ProductInStockingPoint, that add itday to shelf life, and that depart in period pispip.Period
    value := value + sum( productintrips, Elements, pit, true, pit.Quantity()) ; 
    
    // New supply, inventory supply and actual goes into itday with 0 lead time
    if ( itday.ShelfLifeDays() = 0 ) 
    {
      supplynontrip := sum( this, Supply_MP.astype( NewSupply ), ns, not ns.IsNewSupplyOfTrip(), ns.Quantity() ); 
      value := value + supplynontrip  
      value := value - sum( productintrips, Elements, pit, true, pit.Quantity() ); 
      // inventory supply in future period with manufacture date = current period start is considered production for the current period
      nextpsipipstoconsider := this.GetNextPISPIPWithinShelfLife( DateTime::MaxDateTime() ); 
      traverse( nextpsipipstoconsider, Elements.Supply_MP.astype( InventorySupply ), invsup, invsup.GetManufacturingPISPIP() = this ) 
      {
        value := value + invsup.Quantity(); 
      }
      
      //contributions: inventory actual';
      lastpispipwithactual := this.ProductInStockingPoint_MP().LastPlanningPISPIPWithActual(); 
      if ( this.IsPeriodFrozen() and not isnull( lastpispipwithactual ) ) 
      {
        value := 0.0; 
        actualtoconsider := selectset( lastpispipwithactual, ActualProductInStockingPointInPeriod, a, true, true ); 
        traverse( actualtoconsider, Elements, actualpispip, actualpispip.GetManufacturingPISPIP() = this  ) 
        {
          value := value + actualpispip.ActualInventoryLevelEnd(); 
        }
      }  
    }
    
    value := value +  guard( this.PreviousPlanningPISPIP().GetCumulativeProduction( itday ), 0.0 ); 
    
    return value;
  *]
}