| 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
 | | Quintiq file version 2.0 |  | #parent: #root |  | StaticMethod UpdateMarginAcount ( |  |   Period_MP period, |  |   KPIValueInPeriods periods, |  |   Scenario scenario, |  |   DateTime start, |  |   DateTime end |  | ) |  | { |  |   TextBody: |  |   [* |  |     marginaccount := select( period, MacroPlan.Account_MP, a, a.IsMargin() ); |  |      |  |     if( not isnull( marginaccount ) ) |  |     { |  |       totalsales := sum( periods, Elements, p, |  |                          p.KPIValue().KPI().astype( Account ).AccountTypeName() =  Translations::MP_Account_AccountTypeSales() |  |                          and not p.KPIValue().KPI().astype( Account ).HasParent(), |  |                          p.Value() ); |  |      |  |       totalcosts := sum( periods, Elements, p, |  |                          p.KPIValue().KPI().astype( Account ).AccountTypeName() =  Translations::MP_Account_AccountTypeCostOfSales() |  |                          and not p.KPIValue().KPI().astype( Account ).HasParent(), |  |                          p.Value() ); |  |      |  |       kpiv := select( scenario, KPIValue, kpivalue, kpivalue.KPI().Name() = marginaccount.Name() ); |  |      |  |       value := totalsales - totalcosts; |  |       KPIValueInPeriod::Create( kpiv, start, end, value, kpiv.KPI().Name() ); |  |     } |  |   *] |  | } | 
 |