renhao
2023-09-21 1aa9f2bb83dd9e4b7517f1cbf06b0db53979bb31
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 CreateOrEditProductInTripFromListTrip (
  internal[GUIComponent] parent,
  Trip trip,
  ProductInStockingPointInPeriodPlanningLeaf pispip
) as ProductInTrip id:Method_DialogCreateEditProductInTrip_CreateOrEditProductInTripFromListTrip
{
  #keys: '[113694.0.1674978443]'
  Body:
  [*
    // Create/Edit product in trip from trip list.
    
    productintrip := select( trip, ProductInTrip, pit,
                             pit.Product_MP() = pispip.ProductInStockingPoint_MP().Product_MP() );
    
    data := shadow( productintrip );
    
    if( isnull( data ) )
    {
      data := trip.ProductInTrip( relshadow, 
                                  Product_MP := pispip.ProductInStockingPoint_MP().Product_MP(),
                                  Quantity := trip.GetSuggestedQuantity( pispip ),
                                  ArrivalPISPIP := pispip,
                                  TripID := trip.ID(),
                                  ProductID := guard( pispip.ProductInStockingPoint_MP().Product_MP().ID(), '' )
                                  ); // This is needed to recalculate relations AsArrivalPISPIP
    }
    
    Dialog.Data( data );
    Dialog.EnableDisableComponents( false );
    
    result := this.DoModal( parent );
    pit := data.WrappedInstance();
    
    if( result > 0 )
    {
      pit := ProductInTrip::CreateOrUpdateForTrip( trip,
                                                   pispip,
                                                   data.Quantity() );
    }
    
    return pit;
  *]
}