yypsybs
2023-09-09 3cb5a54def670d97301f07170fcaad213bfc54f2
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 EditPostponedSalesDemandCostFromListProductInStockingPointInPeriod (
  internal[GUIComponent] parent,
  structured[ProductInStockingPointInPeriodPlanning] selection
) id:Method_DialogCreateEditPostponedSalesDemandCost_EditPostponedSalesDemandCostFromListProductInStockingPointInPeriod
{
  #keys: '[108486.0.1971276166]'
  Body:
  [*
    // Edit the cost of the selection pispip from periods list
    
    Dialog.EnableDisableComponent( true );
    
    // Need this for excluding itself in pre-condition primary keys checking.
    data := shadow( selection.Element( 0 ).PostponedSalesDemandCost() );
    pisp := selection.Element( 0 ).ProductInStockingPoint_MP();
    product := pisp.Product_MP();
    stockingpoint := pisp.StockingPoint_MP();
    
    // In case selection.Element( 0 ) doesn't bind to any inventory specification, calling SetDefaultValue method will return null error.
    // Check start in case of editing from PISPIP later than the existing PSDC, the Start date will be off if we pass in existing PSDC
    if( isnull( data )
        or data.Start() <> selection.Element( 0 ).Start().Date() )
    {
      data := selection.Element( 0 ).ProductInStockingPoint_MP().Product_MP().PostponedSalesDemandCost( relshadow, ProductID := product.ID(), StockingPointID := stockingpoint.ID(), Start := selection.Element( 0 ).Start().Date() );
    }
    
    data.StockingPoint_MP( relset, selection.Element( 0 ).ProductInStockingPoint_MP().StockingPoint_MP() );
    
    Dialog.Data( data );
    
    // Need this so that when the pispip doesn't not have an postponed sd cost, the fields in this Dialog will not be blank.
    Dialog.SetDefaultValue( selection.Element( 0 ) );
    
    result := this.DoModal( parent );
    
    if ( result > 0 )
    {
      PostponedSalesDemandCost::CreateOrUpdateForPISPIPs( selection,
                                                          data.Penalty() );
    
    }
  *]
}