chenqinghong
2024-05-07 3ec06a830367465068963156dcc1d8e522571c13
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
Quintiq file version 2.0
#parent: #root
Method CheckFulfillmentForManualPostponedSalesDemand (
  MacroPlan macroplan
)
{
  TextBody:
  [*
    salessegmentname := 'Carrefour Austria'; 
    salessegment := select( macroplan, SalesSegment_MP, s, true, s.Name() = salessegmentname ); 
    
    sopyear := macroplan.StartOfPlanning().Year(); 
    startdate := Date::Construct( sopyear, 1, 1 );  
    postponeddate := Date::Construct( sopyear, 2, 1 ); 
    product := select( macroplan, Product_MP, p, true, p.Name() = 'Lowfat Vanilla 6 pk' ); 
    
    sd := select( salessegment, SalesDemand, sd, true, sd.StartDate() = startdate and sd.Product_MP() = product ); 
    
    // Verify 100% fulfillment for sales demand with manual postponement
    this.Run().AssertEqual( sd.Quantity(), sd.FulfilledQuantity(), 'Expecting complete fulfillment for ' + salessegmentname + ' ' + product.ID() + [String] startdate );
    
    // Verify manual postponed sdip is still present
    this.Run().AssertEqual( 1, 
                            counter( sd, SalesDemandInPeriod, sdip, sdip.StartDate() = postponeddate and sdip.ProductID() = product.ID() and sdip.IsManuallyPostponed() ), 
                            'Expecting manual postponed sales demand to be kept in place' );
    // Verify it is the only manual postponed sales demand 
    this.Run().AssertEqual( 1, 
                            counter( macroplan, SalesDemand.SalesDemandInPeriod, sdip, sdip.IsManuallyPostponed() ), 
                            'Expecting only 1 manually postponed sales demand, namely the single one created for the test' );
  *]
  InterfaceProperties { Accessibility: 'Module' }
}