yanweiyuan3
2023-10-27 d1d15b61dfcf7fd0f800b32359f082cf580ed556
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
Quintiq file version 2.0
#parent: #root
Method New (
  FormInventoryCosts formInventoryCosts,
  structured[ProductInStockingPoint_MP] pisp,
  Account_MP account
) id:Method_DialogCreateEditInventoryCost_New
{
  #keys: '[145730.0.2100900206]'
  Body:
  [*
    // Create new inventory costs for one or more PISPs
    if( isnull( account ) )
    {
      if( DataHolderSelectedAccounts.Data().Size() > 0 )
      {
        account := DataHolderSelectedAccounts.Data().Element( 0 );
      }
      else
      {
        account := MacroPlan.GetDefaultAccount( Form.GetCostType() );
      }
    }
    
    if( pisp.Size() = 0 )
    {
      // Select one pisp & populate into dialog
      filteredpisp := select( DataHolderPISP.Data(), Elements, e, e.IsLeaf() );
      pisp.Add( filteredpisp );
    }
    
    // Create shadow obj & set default value when creating new cost
    firstPisp := pisp.First();
    obj := firstPisp.Product_MP().InventoryValueAndCost( relshadow,
                                                         ID := MacroPlan.IDHolder().GetInventoryValueAndHoldingCostID(),
                                                         ProductID := firstPisp.ProductID(),
                                                         StockingPointID := firstPisp.StockingPointID(),
                                                         AccountName := account.Name(),
                                                         Account_MP := account,
                                                         CostDriver := account.DefaultCostDriver(),
                                                         Cost := account.DefaultCost(),
                                                         StockingPoint_MP := firstPisp.StockingPoint_MP(),
                                                         LengthOfTime := account.DefaultLengthOfTime(),
                                                         TimeUnit := account.DefaultTimeUnit(),
                                                         Start := MacroPlan.StartOfPlanning().Date() );
                            
    DataHolderDialogData.Data( &obj );
    DataHolderPISPs.Data( pisp.Copy() );
    DataHolderForm.Data( formInventoryCosts ); // Form that opens the dialog, to select the newly created object in list
    
    this.Initialize();
  *]
}