| Quintiq file version 2.0 | 
| #parent: #root | 
| Method NewStockingPoint ( | 
|   internal[GUIComponent] parent, | 
|   Unit parentunit, | 
|   Group group, | 
|   Number x, | 
|   Number y | 
| ) as StockingPoint_MP id:Method_DialogCreateEditStockingPoint_NewStockingPoint | 
| { | 
|   #keys: '[11660.0.15276813]' | 
|   Body: | 
|   [* | 
|     // New stocking point | 
|      | 
|     data := MacroPlan.StockingPoint_MP( relshadow, | 
|                                         ID := '', | 
|                                         Unit := parentunit, | 
|                                         Currency_MP := MacroPlan.BaseCurrency(), | 
|                                         IsPlannedInfinite := true, | 
|                                         Start := Date::MinDate(), | 
|                                         End := Date::MaxDate(), | 
|                                         Group := group, | 
|                                         UnitOfMeasure_MP := MacroPlan.DefaultUnitOfMeasure() ); | 
|      | 
|     CheckBoxBelongsTo.Checked( not isnull( parentunit ) ); | 
|      | 
|     Dialog.Data( data ); | 
|      | 
|     Dialog.SetImage(); | 
|      | 
|     result := this.DoModal( parent ); | 
|      | 
|     if ( result > 0 ) | 
|     { | 
|       gridx := 0; | 
|       gridy := 0; | 
|       view := DataHolderView.Data(); | 
|       Node::NearestGridPoint( x, y, gridx, gridy, view.GridPointDistance() ); | 
|      | 
|       data.DefaultGridX( gridx ); | 
|       data.DefaultGridY( gridy ); | 
|      | 
|       unitid := ''; | 
|       if( CheckBoxBelongsTo.Checked() ) | 
|       { | 
|         unitid := SelectionBelongsTo.Data().ID(); | 
|       }             | 
|       data.UnitID( unitid ); | 
|      | 
|       // The validity of the stocking point. | 
|       if( CheckBoxHasStart.Checked() ) | 
|       { | 
|         data.Start( GUIDateTimeSelectorStart.DateTime().Date() ); | 
|       } | 
|       if( CheckBoxHasEnd.Checked() ) | 
|       { | 
|         data.End( GUIDateTimeSelectorEnd.DateTime().Date() ); | 
|       } | 
|      | 
|       data.Commit(); | 
|     } | 
|      | 
|     return data.WrappedInstance(); | 
|   *] | 
| } |