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
70
71
72
73
74
75
76
77
78
79
80
81
| Quintiq file version 2.0
| #parent: #root
| StaticMethod ValidateInput (
| output String feedback_o,
| ProductInStockingPoint_MPs owners,
| Account_MP account,
| String costDriver,
| Date start,
| String timeUnit,
| Number lengthOfTime,
| Real cost,
| InventoryValueAndCosts inventoryCosts
| ) declarative remote as Boolean
| {
| Description: '(Web) Validate one or more inventory cost'
| TextBody:
| [*
| // Traverse to check batch/single create/edit input
| hasPISP := InventoryValueAndCost::HasPISP( feedback_o, owners );
| isCreate := inventoryCosts.Size() = 0;
| isSingleEdit := inventoryCosts.Size() = 1;
| isWeb := true; // True to indicate specific to WC
| sanityfb := '';
|
| if( hasPISP )
| {
| if( isCreate )
| {
| traverse( owners, Elements, owner )
| {
| // Temporary local variable in order to not overwrite feedback_o
| fb := '';
| isValid := InventoryValueAndCost::ValidateInput( fb,
| sanityfb,
| owner.Product_MP(),
| owner.StockingPoint_MP(),
| account,
| costDriver,
| start,
| timeUnit,
| lengthOfTime,
| cost,
| null( AccountCost ), // Create mode thus neglect account cost argument
| isWeb );
|
| if( not isValid )
| {
| if( feedback_o <> '' )
| {
| feedback_o := feedback_o + String::NewLine(); // New line
| }
| feedback_o := feedback_o + fb;
| }
| }
| }
| else // Validate single & batch edit
| {
|
| // 1. traverse into cost, validate all owners
| traverse( inventoryCosts, Elements, invCost )
| {
| invCostOwner := ifexpr( isSingleEdit, owners.First(), invCost.ProductInStockingPoint_MP() );
| InventoryValueAndCost::ValidateInput( feedback_o,
| sanityfb,
| invCostOwner.Product_MP(),
| invCostOwner.StockingPoint_MP(),
| ifexpr( isSingleEdit, account, invCost.Account_MP() ),
| ifexpr( isSingleEdit, costDriver, invCost.CostDriver() ),
| ifexpr( isSingleEdit, start, invCost.Start() ),
| invCost.TimeUnit(),
| invCost.LengthOfTime(),
| cost, // Regardless of batch, always check cost
| invCost,
| isWeb );
| }
| }
|
| }
| return feedback_o = '';
| *]
| }
|
|