haorenhui
2023-10-30 6d6cc10d9e8e242661da7fd655dec155a09d676c
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
46
47
48
49
50
51
52
53
54
55
56
Quintiq file version 2.0
#parent: #root
Method EditInventorySpecificationFromListPISPIP (
  internal[GUIComponent] parent,
  structured[ProductInStockingPointInPeriod] selection
) id:Method_DialogCreateEditInventorySpecification_EditInventorySpecificationFromListPISPIP
{
  #keys: '[105706.1.245085157]'
  Body:
  [*
    // Edit the inventory specification of the selection pispip from periods list
    pispip := selection.Element( 0 );
    isbatchedit := selection.Size() > 1;
    Dialog.ShowHideComponentForBatchEdit( isbatchedit, false );
    
    // Need this for excluding itself in pre-condition primary keys checking.
    data := shadow( pispip.InventorySpecification() );
    
    // 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 IS, the Start date will be off if we pass in existing IS
    if( isnull( data )
        or data.Start() <> pispip.Start().Date() )
    {
      pisp := pispip.ProductInStockingPoint_MP();
      data := pisp.Product_MP().InventorySpecification( relshadow, ProductID := pisp.ProductID(), StockingPointID := pisp.StockingPointID(), Start := pispip.Start().Date() );
      data.StockingPoint_MP( relset, pisp.StockingPoint_MP() );
    }
    
    Dialog.Data( data );
    
    // Need this so that when the pispip doesn't not have a inventory specification, the fields in this Dialog will not be blank.
    Dialog.SetDefaultValue( selection.Element( 0 ) );
    
    result := this.DoModal( parent );
    
    if ( result > 0 )
    {
      InventorySpecification::CreateOrUpdateForProductInStockingPointInPeriods( selection,
                                                                                false,
                                                                                false,
                                                                                0.0,
                                                                                0.0,
                                                                                not isbatchedit or CheckBoxBatchEditMinLevel.Checked(),
                                                                                data.HasMinLevelInDays(),
                                                                                data.MinLevelInDays(),
                                                                                data.MinLevelInQuantity(),
                                                                                not isbatchedit or CheckBoxBatchEditMaxLevel.Checked(),
                                                                                data.HasMaxLevel(),
                                                                                data.HasMaxLevelInDays(),
                                                                                data.MaxLevelInDays(),
                                                                                data.MaxLevelInQuantity(),
                                                                                false );
    
    }
  *]
}