{strip}
{* **** Fee internal (Honorar intern) *************************************** *}
{if $deduct_hon_decr_costs}
    {$internal_planned_fees_prev=$data_item->planned_fees_prev-$data_item->hon_decr_costs_prev}
    {$internal_planned_fees=$data_item->planned_fees-$data_item->hon_decr_costs}
{else}
    {if isset($data_item->planned_fees_prev)}
        {$internal_planned_fees_prev=$data_item->planned_fees_prev}
    {else}
        {$internal_planned_fees_prev = 0}
    {/if}
    {if isset($data_item->planned_fees)}
        {$internal_planned_fees=$data_item->planned_fees}
    {else}
        {$internal_planned_fees = 0}
    {/if}
{/if}

{* **** Completed (Erbrachte Leistung) ************************************** *}
{if $use_type eq 'linear_delimitation'}
    {$completed_prev=$internal_planned_fees_prev*$data_item->completion_level_prev}
    {$completed=$internal_planned_fees*$data_item->completion_level}
{else}
    {if isset($data_item->completed_prev)}
        {$completed_prev=$data_item->completed_prev}
    {else}
        {$completed_prev = 0}
    {/if}
    {if isset($data_item->completed)}
        {$completed=$data_item->completed}
    {else}
        {$completed = 0}
    {/if}
{/if}
{assign var='completed_prev_sum' value=$completed_prev_sum+$completed_prev scope='global'}
{assign var='completed_sum' value=$completed_sum+$completed scope='global'}

{* **** Completed diff (Ergebnis) ******************************************* *}
{if isset($data_item->total_cost_prev)}
    {$completed_diff_prev = ($completed_prev)-$data_item->total_cost_prev}
{else}
    {$completed_diff_prev = $completed_prev}
{/if}
{if isset($data_item->total_cost_prev)}
    {$completed_diff = ($completed)-$data_item->total_cost}
{else}
    {$completed_diff = $completed}
{/if}
{assign var='completed_diff_prev_sum' value=$completed_diff_prev_sum+$completed_diff_prev scope='global'}
{assign var='completed_diff_sum' value=$completed_diff_sum+$completed_diff scope='global'}


{* **** Prognosis (Prognose Erfolg/Verlust) ********************************* *}
{$prognosis_prev='--'}
{$prognosis='--'}
{if isset($data_item->completion_level_prev) && $data_item->completion_level_prev>0}
    {$prognosis_prev=$internal_planned_fees_prev-($data_item->total_cost_prev*(1/$data_item->completion_level_prev))}
{/if}
{if $prognosis_prev eq 0}{$prognosis_prev='--'}{/if}
{if isset($data_item->completion_level) && $data_item->completion_level>0 && $internal_planned_fees>0}
    {$prognosis=$internal_planned_fees-($data_item->total_cost*(1/$data_item->completion_level))}
{/if}
{if $prognosis_prev!=='--'}
    {assign var='prognosis_prev_sum' value=$prognosis_prev_sum+$prognosis_prev scope='global'}
{/if}
{if $prognosis!=='--'}
    {assign var='prognosis_sum' value=$prognosis_sum+$prognosis scope='global'}
{/if}

{* **** Work in hand (Arbeitsvorrat) **************************************** *}
{$work_in_hand_prev=$internal_planned_fees_prev-$completed_prev}
{$work_in_hand=$internal_planned_fees-$completed}
{assign var='work_in_hand_prev_sum' value=$work_in_hand_prev_sum+$work_in_hand_prev scope='global'}
{assign var='work_in_hand_sum' value=$work_in_hand_sum+$work_in_hand scope='global'}

{* ********************************************************** Budget ********************************************************** *}

{* **** Completed (Erbrachte Leistung) ************************************** *}
{if $use_type eq 'linear_delimitation'}
    {$completed_budget_prev=$data_item->budget_plan_costs_prev*$data_item->completion_level_prev}
    {$completed_budget=$data_item->budget_plan_costs*$data_item->completion_level}
{else}
    {if isset($data_item->completed_budget_prev)}
        {$completed_budget_prev=$data_item->completed_budget_prev}
    {else}
        {$completed_budget_prev=0}
    {/if}
    {if isset($data_item->completed_budget)}
        {$completed_budget=$data_item->completed_budget}
    {else}
        {$completed_budget=0}
    {/if}
    
{/if}
{assign var='completed_budget_prev_sum' value=$completed_budget_prev_sum+$completed_budget_prev scope='global'}
{assign var='completed_budget_sum' value=$completed_budget_sum+$completed_budget scope='global'}

{* **** Completed diff (Ergebnis) ******************************************* *}
{if isset($data_item->total_cost_prev)}
    {$completed_budget_diff_prev = ($completed_budget_prev)-$data_item->total_cost_prev}
{else}
    {$completed_budget_diff_prev = $completed_budget_prev}
{/if}
{if isset($data_item->total_cost)}
    {$completed_budget_diff = ($completed_budget)-$data_item->total_cost}
{else}
    {$completed_budget_diff = $completed_budget}
{/if}
{assign var='completed_budget_diff_prev_sum' value=$completed_budget_diff_prev_sum+$completed_budget_diff_prev scope='global'}
{assign var='completed_budget_diff_sum' value=$completed_budget_diff_sum+$completed_budget_diff scope='global'}

{* **** Prognosis (Prognose Erfolg/Verlust) Budget ********************************* *}
{$prognosis_budget_prev='--'}
{$prognosis_budget='--'}
{if isset($data_item->completion_level_prev) && $data_item->completion_level_prev>0}
    {$prognosis_budget_prev=$data_item->budget_plan_costs_prev-($data_item->total_cost_prev*(1/$data_item->completion_level_prev))}
{/if}
{if $prognosis_budget_prev eq 0}{$prognosis_budget_prev='--'}{/if}
{if isset($data_item->completion_level) && $data_item->completion_level>0}
    {$prognosis_budget=$data_item->budget_plan_costs-($data_item->total_cost*(1/$data_item->completion_level))}
{/if}
{if $prognosis_budget_prev!=='--'}
    {assign var='prognosis_budget_prev_sum' value=$prognosis_budget_prev_sum+$prognosis_budget_prev scope='global'}
{/if}
{if $prognosis_budget eq 0}{$prognosis_budget='--'}{/if}
{if $prognosis_budget!=='--'}
    {assign var='prognosis_budget_sum' value=$prognosis_budget_sum+$prognosis_budget scope='global'}
{/if}

{* **** Calcexp done (Abgerechnet) *************************************** *}
{$calcexp_done_prev = 0}
{$calcexp_done = 0}
{if !$show_calcexp_woa}
    {if isset($data_item->calcexp_done_proj_prev)}
        {$calcexp_done_prev = $data_item->calcexp_done_proj_prev}
    {/if}
    {if isset($data_item->calcexp_done_proj)}
        {$calcexp_done = $data_item->calcexp_done_proj}
    {/if}
{else}
    {if isset($data_item->calcexp_done_woa_prev)}
        {$calcexp_done_prev = $data_item->calcexp_done_woa_prev}
    {/if}
    {if isset($data_item->calcexp_done_woa)}
        {$calcexp_done = $data_item->calcexp_done_woa}
    {/if}
{/if}

{if isset($data_item->calcexp_loc_prev)}
    {$calcexp_done_prev = $calcexp_done_prev + $data_item->calcexp_loc_prev}
{/if}
{if isset($data_item->calcexp_loc)}
    {$calcexp_done = $calcexp_done + $data_item->calcexp_loc}
{/if}

{/strip}