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
57
58
59
60
61
62
63
64
65
66
67
68
69
  | Quintiq file version 2.0 
 |  #parent: #root 
 |  Method CreateUpdateSalesDemand ( 
 |    Product_MP owner_i, 
 |    StockingPoint_MP stockingpoint_i, 
 |    const LibDEC_ManufacturingDemand salesDemandExternal_i, 
 |    String id_i, 
 |    Date startdate_i, 
 |    Date enddate_i, 
 |    Real quantity_i, 
 |    Real price_i, 
 |    String priorityName_i, 
 |    Real demanduncertaintypercentage_i, 
 |    Boolean isexcludedfromfulfillmentkpi_i 
 |  ) as Forecast 
 |  { 
 |    TextBody: 
 |    [* 
 |      // Create/Update sales demand 
 |      // Get sales demand instance 
 |      salesDemand := Forecast::FindSalesDemandIndex( id_i ); 
 |       
 |      // Populate variables 
 |      salesSegmentName := salesDemandExternal_i.CommercialSegmentID(); 
 |      currencyName := salesDemandExternal_i.CurrencyID(); 
 |      unitOfMeasureName := salesDemandExternal_i.UnitOfMeasureID(); 
 |       
 |      // Check if sales demand exists, if it doesn't exist, create a new one 
 |      if( isnull( salesDemand ) ) 
 |      { 
 |        salesDemand := Forecast::Create( owner_i, 
 |                                         stockingpoint_i, 
 |                                         id_i, 
 |                                         startdate_i, 
 |                                         enddate_i, 
 |                                         quantity_i, 
 |                                         price_i, 
 |                                         priorityName_i, 
 |                                         salesSegmentName, 
 |                                         currencyName, 
 |                                         unitOfMeasureName, 
 |                                         demanduncertaintypercentage_i, 
 |                                         isexcludedfromfulfillmentkpi_i, 
 |                                         false ) 
 |      } 
 |      // Else, simply update the values of the existing sales demand 
 |      else 
 |      { 
 |        salesDemand.Update( owner_i, 
 |                            stockingpoint_i, 
 |                            startdate_i, 
 |                            enddate_i, 
 |                            quantity_i, 
 |                            price_i, 
 |                            priorityName_i, 
 |                            demanduncertaintypercentage_i, 
 |                            salesSegmentName, 
 |                            currencyName, 
 |                            unitOfMeasureName, 
 |                            isexcludedfromfulfillmentkpi_i, 
 |                                false ); 
 |      } 
 |       
 |      // mark NOT soft deleted 
 |      salesDemand.IsSoftDeleted( false ); 
 |       
 |      return salesDemand; 
 |    *] 
 |  } 
 |  
  |