| 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
 | | Quintiq file version 2.0 |  | #parent: #root |  | StaticMethod Assign ( |  |   Account_MP owner, |  |   Unit unit, |  |   String costdriver |  | ) as UnitAccount |  | { |  |   Description: 'Create assignment between account and unit' |  |   TextBody: |  |   [* |  |     // Find any unit acount that has the same account and cost driver |  |     unitaccount := select( unit, UnitAccount, ua, |  |                            ua.Account_MP() = owner |  |                            and ua.CostDriver() = costdriver ); |  |      |  |     // If we cannot find any, create a new unit account |  |     if( isnull( unitaccount ) ) |  |     { |  |       unitaccount := owner.AccountAssignment( relnew, |  |                                               UnitAccount, |  |                                               Unit := unit, |  |                                               UnitID := unit.ID(), |  |                                               CostDriver := costdriver ); |  |      |  |       unitaccount.Update( owner, costdriver ); |  |     } |  |      |  |     return unitaccount; |  |   *] |  | } | 
 |