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() );
    }
  *]
}
