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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
Quintiq file version 2.0
#parent: #root
Method SynchronizeSalesDemandInPeriod (
  Boolean resetoptimizerfulfillment
)
{
  Description: 'Synchronize sales demand in period on base period modification.'
  TextBody:
  [*
    // desmondt Nov-5-2015 (modified)
    oldsdips := selectset( this, SalesDemandInPeriod, sdip, true );
    newsdips := construct( SalesDemandInPeriods );
    
    // If quantity had been updated, reset the optimizer fulfillment sales demand in the Pispip and the pispips onwards so that the calc system fulfilled quantity will kicks in
    /* e.g
    Period         Jan  Feb  March April
    SalesDemandInPeriod HasOptimizerFulfillment
    Sales demand 1 true true true  true
    Sales demand 2 true true true  true
    Sales demand 3 true true true  true 
    
    When a sales demand quantity in Feb had been updated, ALL sales demand from Feb ~ April will be reseted.
    
    Period         Jan  Feb  March April
    SalesDemandInPeriod HasOptimizerFulfillment
    Sales demand 1 true false false  false
    Sales demand 2 true false false  false
    Sales demand 3 true false false  false
    */
    if( resetoptimizerfulfillment )
    {
      sdip := this.First();
      if( not isnull( sdip )
          and not isnull( sdip.AsSalesDemandInPeriodBase() ) )
      {
        sdip.AsSalesDemandInPeriodBase().ResetSalesDemandFulfillmentForThisPeriodOnwards();
      }
    }
    
    if( this.StartDate().IsFinite() and this.EndDate().IsFinite() )
    {
      // SDiPs to get generated on planning period level
      pispips := this.GetPlanningPISPIPs();
      traverse( pispips, Elements, pispip ) 
      { 
        sdip := this.GetSalesDemandInPeriod( pispip );
        if( not isnull( sdip ) )
        {
          newsdips.Add( sdip );
        }
      }
    }
    
    // Get the difference(obsolete) SDIP
    deprecatedsdips := oldsdips.Difference( newsdips );
    
    // Remove the obsolete SDIP
    SalesDemandInPeriod::Delete( deprecatedsdips );
  *]
  InterfaceProperties { Accessibility: 'Extensible' }
}