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
Quintiq file version 2.0
#parent: #root
DeclarativeOwningNMRelation CalcAsBaseProductInStockingPointPeriodInPeriod
{
  #keys: '1[134266.1.22295573]'
  Expression:
  [*
    // soh yee Sep-15-2015 (created)
    
    //           __________________________
    // Quarter: |__________________________|
    // Month:   |________|________|________|
    // Week:    |_|_|_|_|_|_|_|_|_|_|_|_|_|_|
    
    // System periods will be created as for splitting the week to two months
    // This logic will create the N:M of the system periods to Week, and to Month.
    // By checking that the Month1 can only link to Week1 to Week4 directly, so we will create N:M for Week5 to Month1 and Month2
    // Month2 can link to Week6 to Week8 week directly, so we will create N:M for Week9 to Month2 and Month3
    pispips := construct( ProductInStockingPointInPeriods );
    
    if( this.IsBase() )
    {
      pispips := selectset( this,ProductInStockingPoint_MP.ProductInStockingPointInPeriod, pispip,
                            not pispip.Period_MP().IsDeleted()
                            and not pispip.IsBase(),
                            this.Period_MP().IsInPeriod( pispip.Start(), pispip.End() )
                            and guard( ( this.Start() < pispip.StockingPointInPeriod().ChildOfPeriodStart()
                                         or this.End() > pispip.StockingPointInPeriod().ChildOfPeriodEnd() ), false ) );
    }
    
    
    return &pispips;
  *]
  HelperRelation: ProductInStockingPointInPeriod
  InstantiationType: ProductInStockingPointPeriodInPeriod
  Relation: AsBaseProductInStockingPointPeriodInPeriod
}