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
33
34
35
36
37
38
39
40
Quintiq file version 2.0
#parent: #root
Method EditDisaggregationFactorFromListProductInStockingPointInPeriod (
  internal[GUIComponent] parent,
  structured[ProductInStockingPointInPeriod] selection
) id:Method_DialogCreateEditDisaggregationFactor_EditDisaggregationFactorFromListProductInStockingPointInPeriod
{
  #keys: '[124808.0.1994363489]'
  Body:
  [*
    // Edit the cost of the selection pispip from periods list
    isbatchedit := selection.Size() > 1;
    
    Dialog.EnableDisableComponent( isbatchedit, false );
    
    pispip := selection.Element( 0 );
    pisp := pispip.ProductInStockingPoint_MP();
    // Need this for excluding itself in pre-condition primary keys checking.
    data := shadow( pispip.DisaggregationFactor() );
    
    if( isnull( data )
        or data.Start() <> pispip.Start().Date() )
    {
      data := pispip.ProductInStockingPoint_MP().Product_MP().DisaggregationFactor( relshadow, ProductID := pisp.ProductID(), StockingPointID := pisp.StockingPointID(), Start := pispip.Start().Date());
    }
    
    Dialog.Data( data );
    
    // Need this so that when the pispip doesn't not have a disaggregation factor, the fields in this Dialog will not be blank.
    Dialog.SetDefaultValue( selection.Element( 0 ) );
    
    result := this.DoModal( parent );
    
    if ( result > 0 )
    {
      DisaggregationFactor::CreateOrUpdateForProductInStockingPointInPeriods( selection,
                                                                              data.Factor() );
    }
  *]
}