{$vat_total = 0}{$gross_total = 0}{$gross_total_rounded = 0}
{foreach item="offer_component" from=$offer_components}
{if !empty($offer_component->offer->title)}
    <h2>{$offer_component->offer->title}</h2>
{else}
    <h2>{$i.calcexp_level_of_completion}</h2>
{/if}
<table style="width: 100%; max-width: 95vw;">
    <thead>
    <tr>
        <th style="min-width:200px" rowspan="2">{$i.projectadmin_work_package}</th>
        <th style="min-width:100px" rowspan="2">
            {$i.offers_management_costs_view}
            {if !$project_use_currency}
                {$project_global_currency}
            {else}
                {$offer_component->offer->currency_name}
            {/if}
        </th>
        <th style="min-width:100px; background: rgba(220, 220, 255, 0.4);" rowspan="2">{$i.offers_management_fee_supplement}</th>
        <th style="min-width:60px; background: rgba(255, 255, 200, 0.4);" colspan="2">{$i.offers_management_extras_in_currency}</th>
        <th style="min-width:60px; background: rgba(255, 200, 200, 0.4);" colspan="2">{$i.offers_management_rebate_in_currency}</th>
        <th style="min-width:110px" colspan="3">{$i.calcexp_already_invoiced}</th>
        <th style="min-width:60px" rowspan="2">{$i.calcexp_billable}</th>
        <th style="min-width:140px" {if $project_use_currency && !$offer_component->ontop->with_old_hoai}colspan="{if $transfer_mode}4{else}3{/if}"{else}colspan="2"{/if}>
            {if $payment->object_is_editable}
                {$i.calcexp_billable_value_curr}
            {else}
                {$i.calcexp_billable_value}
            {/if}
        </th>
    </tr>
    <tr>
        <th style="background: rgba(255, 255, 200, 0.4);">%</th>{* ## Nebenkosten % ## *}
        <th style="background: rgba(255, 255, 200, 0.4);">€</th>{* ## Nebenkosten % ## *}
        <th style="background: rgba(255, 200, 200, 0.4);">%</th>{* ## Rabatt % ## *}
        <th style="background: rgba(255, 200, 200, 0.4);">€</th>{* ## Rabatt % ## *}
        <th>{* ## Bereits verrechnet € ## *}
            {if !$project_use_currency}
                {$project_global_currency}
            {else}
                {$offer_component->offer->currency_name}
            {/if}
        </th>
        <th>{* ## Bereits verrechnet inkl. USt. ## *}
            {$i.calcexp_value_pre_tax}
        </th>
        <th>%</th>{* ## Bereits verrechnet % ## *}
        {if $project_use_currency && !$offer_component->ontop->with_old_hoai}
            <th class="global_currency">{$project_global_currency} {$i.calcexp_from_offer}</th>
            {if $transfer_mode}
                <th class="global_currency">{$project_global_currency} {$i.calcexp_current_exch}</th>
            {/if}
            <th>{$offer_component->offer->currency_name}</th>
        {else}
            <th>{$project_global_currency}</th>
        {/if}
        <th>
            {if !$offer_component->ontop->with_old_hoai}
                {$i.offers_management_totalall}{* ** Gesamt ** *}
            {else}
                {$i.offers_management_totalhoai}{* ** Controlling Honorar ** *}
            {/if}
            {if !$project_use_currency}
                {$project_global_currency}
            {else}
                {$offer_component->offer->currency_name}
            {/if}
        </th>
    </tr>
    </thead>
    <tbody>
    {$sum_billable_value=0}{$sum_billable_value_otcurr=0}{$sum_costs=0}{$sum_costs_otcurr=0}{$sum_already_invoiced=0}{$sum_already_invoiced_otcurr=0}
    {foreach item="allocation" from=$offer_component->allocations}
        {$sum_billable_value=$sum_billable_value+$allocation->currently_billable_value}
        {$sum_billable_value_otcurr=$sum_billable_value_otcurr+$allocation->currently_billable_value_otcurr}
        {$sum_costs=$sum_costs+$allocation->costs_view}
        {$sum_costs_otcurr=$sum_costs_otcurr+$allocation->costs_otcurr}
        {$sum_already_invoiced=$sum_already_invoiced+$allocation->already_invoiced}
        {$sum_already_invoiced_otcurr=$sum_already_invoiced_otcurr+$allocation->already_invoiced_otcurr}
        <tr {if $allocation->subs_active<=0 || !$allocation->is_to_print}class="inactive_state"{/if}>
            <td>
                {$allocation->work_package_name}
            </td>
            <td style="text-align:right;" title="costs_view {isfloat value=$allocation->costs_view} {$project_global_currency}">{* ## Rechn. Honorar ## *}
                {if !$project_use_currency}
                    {isfloat value=$allocation->costs_view}
                {else}
                    {isfloat value=$allocation->costs_otcurr}
                {/if}
            </td>
            <td style="text-align:right; background: rgba(220, 220, 255, 0.4);" title="costs_supplement_view {isfloat value=$allocation->costs_supplement_view} {$project_global_currency}">{* ## Leistungsphasenzuschlag ## *}
                {if !$project_use_currency}
                    {isfloat value=$allocation->costs_supplement_view}
                {else}
                    {isfloat value=$allocation->costs_supplement_otcurr}
                {/if}
            </td>
            <td style="text-align:right; background: rgba(255, 255, 200, 0.4);">{* ## Nebenkosten in % ## *}
                {isfloat value=$allocation->costs_extras_percentage}%
            </td>
            <td style="text-align:right; background: rgba(255, 255, 200, 0.4);">{* ## Nebenkosten in € ## *}
                {if $allocation->costs_extras_amount_otcurr}
                    {isfloat value=$allocation->costs_extras_amount_otcurr}
                {else}
                    {isfloat value=$allocation->costs_extras_amount}
                {/if}
            </td>
            <td style="text-align:right; background: rgba(255, 200, 200, 0.4);">{* ## Rabatt in % ## *}
                {isfloat value=$allocation->costs_rebate_percentage}%
            </td>
            <td style="text-align:right; background: rgba(255, 200, 200, 0.4);">{* ## Rabatt in € ## *}
                {if $allocation->costs_rebate_amount_otcurr}
                    {isfloat value=$allocation->costs_rebate_amount_otcurr}
                {else}
                    {isfloat value=$allocation->costs_rebate_amount}
                {/if}
            </td>
            <td style="text-align:right;" title="already_invoiced {isfloat value=$allocation->already_invoiced} {$project_global_currency}">{* ## Bereits verrechnet ## *}
                {if !$project_use_currency}
                    {isfloat value=$allocation->already_invoiced}
                {else}
                    {isfloat value=$allocation->already_invoiced_otcurr}
                {/if}
            </td>
            <td style="text-align:right;">{* ## Bereits verrechnet Gesamt inkl. USt. ## *}
                {if !$project_use_currency}
                    {isfloat value=$allocation->already_invoiced_total_gross}
                {else if isset($allocation->already_invoiced_total_otcurr_gross)}
                    {isfloat value=$allocation->already_invoiced_total_otcurr_gross}
                {else}
                    {isfloat value=0}
                {/if}
            </td>
            <td style="text-align:right;">{* ## Bereits verrechnet % ## *}
                {isfloat value=$allocation->percentage_max_invoiced*100}%
            </td>
            <td style="text-align:right;">{* ## Abrechenbar % ## *}
                {islongfloat value=$allocation->payment_percentage*100}%
            </td>
            <td {if $project_use_currency}class="global_currency"{/if} style="text-align:right;" title="currently_billable_value" id="work_package_alloc_{$allocation->work_package_id}">{* ## Abzurechnender Betrag ## *}
                {isfloat value=$allocation->currently_billable_value}
            </td>
            {if $project_use_currency && !$offer_component->ontop->with_old_hoai}
                {if $transfer_mode}
                    <td class="global_currency" style="text-align:right;">{* ## Abzurechnender Betrag Andere Währung aktueller Kurs ## *}
                        {include file='r/view-only.tpl' name="calcexp_level_of_completion_transfer_value_otcurr_`$allocation->work_package_id`" class='calcexp_level_of_completion_transfer_value_otcurr'
                            filter_extra="data-value_otcurr='`$allocation->currently_billable_value_otcurr`'"
                            default={isfloat value=$allocation->currently_billable_value}}
                    </td>
                {/if}
                <td style="text-align:right;" title="currently_billable_value_otcurr">{* ## Abzurechnender Betrag Andere Währung lt. Angebot ## *}
                    {isfloat value=$allocation->currently_billable_value_otcurr}
                </td>
            {/if}
            {if !$offer_component->ontop->with_old_hoai}
                <td style="text-align:right;" title="currently_billable_value_overall {isfloat value=$allocation->currently_billable_value_overall} {$project_global_currency}">{* ## Abzurechnender Betrag Gesamt ## *}
                    {if !$project_use_currency}
                        {isfloat value=$allocation->currently_billable_value_overall}
                    {else}
                        {isfloat value=$allocation->currently_billable_value_overall_otcurr}
                    {/if}
                </td>
            {else}
                <td style="text-align:right;" title="old_hoai_currently_billable_value">
                    {isfloat value=$allocation->old_hoai_currently_billable_value}
                </td>
            {/if}
        </tr>
    {/foreach}
    </tbody>
    <tfoot>
        <tr>
            <th>
                {$i.basic_total}
            </th>
            <th style="text-align:right;" title="sum_costs">{* ## Honorar Summe ## *}
                {if !$project_use_currency}
                    {isfloat value=$sum_costs}
                {else}
                    {isfloat value=$sum_costs_otcurr}
                {/if}
            </th>
            <th></th>
            <th></th>
            <th></th>
            <th></th>
            <th></th>
            <th colspan="3" style="text-align:right;" title="sum_already_invoiced">{* ## Bereits verrechnet ## *}
                {if !$project_use_currency}
                    {isfloat value=$sum_already_invoiced}
                {else}
                    {isfloat value=$sum_already_invoiced_otcurr}
                {/if}
            </th>
            <th></th>
            <th {if $project_use_currency}class="global_currency"{/if} style="text-align:right; font-size: 1.1em;" title="sum_billable_value">{* ## Abzurechnender Betrag Summe ## *}
                {isfloat value=$sum_billable_value}
            </th>
            {if $project_use_currency && !$offer_component->ontop->with_old_hoai}
                {if $transfer_mode}
                    <th class="global_currency" style="text-align:right;" title="sum_billable_value">{* ## Abzurechnender Betrag Summe Andere Währung aktueller Kurs ## *}
                        {include file='r/view-only.tpl' name='calcexp_level_of_completion_transfer_sum_billable_value' default={isfloat value=$sum_billable_value}}
                    </th>
                {/if}
                <th style="text-align:right; font-size: 1.1em;" title="sum_billable_value_otcurr">{* ## Abzurechnender Betrag Summe Andere Währung lt. Angebot ## *}
                    {isfloat value=$sum_billable_value_otcurr}
                </th>
            {/if}
            <th class="stripes"></th>
        </tr> <!-- --------------------------------------------------------- -->
        {if $sum_billable_value<($offer_component->ontop->total-0.001) || $sum_billable_value>($offer_component->ontop->total+0.001)}
            {if $offer_component->ontop->with_old_hoai || $offer_component->ontop->with_hoai}
                <tr>
                    <td colspan="11"><small>&nbsp;</small></td>
                </tr>
                <tr>
                    <th colspan="2" style="text-align:center;">
                        {$i.calcexp_billable}
                        {if $offer_component->ontop->with_old_hoai}
                            %
                        {/if}
                    </th>
                    <th colspan="5">
                    </th>
                    <th style="text-align:right;" title="currently_total_supplement_val">
                        {if $offer_component->ontop->with_old_hoai}
                            {isfloat value=$offer_component->ontop->currently_proportion*100}%
                        {/if}
                    </th>
                    <th>
                    </th>
                    <th></th>
                </tr>
                <tr>
                    <td style="text-align:center;">
                        {$i.calcexp_hoai_supplement} 
                        {if $offer_component->ontop->with_old_hoai}
                            ({isfloat value=$offer_component->ontop->supplement}%)
                        {/if}
                    </td>
                    <td style="text-align:right;" title="full_supplement_val">
                        {if $offer_component->ontop->with_old_hoai}
                            {isfloat value=$offer_component->ontop->full_supplement_val}
                        {else}
                            <span title="Aus X2 HOAI Angebot. Das neue Angebot basiert auf einem X3 HOAI Angebot">n.a.</span>
                        {/if}
                    </td>
                    <td colspan="3" style="text-align:right;">
                    </td>
                    <td colspan="3" style="text-align:right;" title="already_supplement_val">
                        {isfloat value=$offer_component->ontop->already_supplement_val}
                    </td>
                    <td style="text-align:right;" title="currently_total_supplement_val">
                        {if $offer_component->ontop->with_old_hoai}
                            {isfloat value=$offer_component->ontop->currently_total_supplement_val}
                        {else}
                            <span title="Aus X2 HOAI Angebot. Das neue Angebot basiert auf einem X3 HOAI Angebot">n.a.</span>
                        {/if}
                    </td>
                    <td style="text-align:right;" title="supplement_val">
                        {isfloat value=$offer_component->ontop->supplement_val}
                    </td>
                    <td class="stripes"></td>
                </tr>
                <tr>
                    <td style="text-align:center;">
                        {$i.calcexp_hoai_specserv}
                    </td>
                    <td style="text-align:right;" title="full_specserv">
                        {if $offer_component->ontop->with_old_hoai}
                            {isfloat value=$offer_component->ontop->full_specserv}
                        {else}
                            <span title="Aus X2 HOAI Angebot. Das neue Angebot basiert auf einem X3 HOAI Angebot">n.a.</span>
                        {/if}
                    </td>
                    <td colspan="3" style="text-align:right;">
                    </td>
                    <td colspan="3" style="text-align:right;" title="already_specserv">
                        {isfloat value=$offer_component->ontop->already_specserv}
                    </td>
                    <td style="text-align:right;" title="currently_total_specserv">
                        {if $offer_component->ontop->with_old_hoai}
                            {isfloat value=$offer_component->ontop->currently_total_specserv}
                        {else}
                            <span title="Aus X2 HOAI Angebot. Das neue Angebot basiert auf einem X3 HOAI Angebot">n.a.</span>
                        {/if}
                    </td>
                    <td style="text-align:right;" title="specserv">
                        {isfloat value=$offer_component->ontop->specserv}
                    </td>
                    <td class="stripes"></td>
                </tr>
                <tr>
                    <th colspan="2">
                        {$i.calcexp_hoai_sum_mid}
                    </th>
                    <th colspan="3" style="text-align:right;">
                    </th>
                    <th colspan="3" style="text-align:right;" title="already_sum_mid">
                        {isfloat value=$offer_component->ontop->already_sum_mid}
                    </th>
                    <th style="text-align:right;" title="currently_total_sum_mid">
                        {isfloat value=$offer_component->ontop->currently_total_sum_mid}
                    </th>
                    <th style="text-align:right;" title="sum_mid">
                        {isfloat value=$offer_component->ontop->sum_mid}
                    </th>
                    <th class="stripes"></th>
                </tr> <!-- --------------------------------------------------------- -->
            {/if}
            
            {* ## Zuschläge ## *}
            <tr>
                <td colspan="2" style="text-align:center; background: rgba(220, 220, 255, 0.4);">
                    {$i.offers_management_supplement}
                </td>
                <td style="text-align:right; background: rgba(220, 220, 255, 0.4);" title="supplement">
                    {isfloat value=$offer_component->ontop->supplement}%
                </td>
                <td style="background: rgba(220, 220, 255, 0.4);">
                </td>
                <td style="background: rgba(220, 220, 255, 0.4);">
                </td>
                <td colspan="3" style="text-align:right; background: rgba(220, 220, 255, 0.4);" title="already_supplement_val {isfloat value=$offer_component->ontop->already_supplement_val} {$project_global_currency}">
                    {if !$project_use_currency}
                        {isfloat value=$offer_component->ontop->already_costs_supplement_val}
                    {else}
                        {isfloat value=$offer_component->ontop->already_costs_supplement_otcurr}
                    {/if}
                </td>
                <td style="text-align:right; background: rgba(220, 220, 255, 0.4);" title="currently_total_supplement_val {isfloat value=$offer_component->ontop->currently_total_costs_supplement_val} {$project_global_currency}">
                    {if !$project_use_currency}
                        {isfloat value=$offer_component->ontop->currently_total_costs_supplement_val}
                    {else}
                        {isfloat value=$offer_component->ontop->currently_total_costs_supplement_otcurr}
                    {/if}
                </td>
                {if $project_use_currency && !$offer_component->ontop->with_old_hoai}
                    {if $transfer_mode}
                        <td colspan="2" rowspan="5"></td>
                    {else}
                        <td rowspan="5"></td>
                    {/if}
                {/if}
                <td style="text-align:right; background: rgba(220, 220, 255, 0.4);" title="supplement_val {isfloat value=$offer_component->ontop->costs_supplement_val} {$project_global_currency}">
                    {if !$project_use_currency}
                        {isfloat value=$offer_component->ontop->costs_supplement_val}
                    {else}
                        {isfloat value=$offer_component->ontop->costs_supplement_otcurr}
                    {/if}
                </td>
                <td rowspan="5" class="stripes">
                </td>
            </tr>
            
            {* ## Zwischensumme mit Zuschlägen ## *}
            <tr>
                <th colspan="2" style="text-align:center;">
                    {$i.calcexp_hoai_sum_midext}
                </th>
                <th colspan="3" style="text-align:right;">
                </th>
                <th colspan="3" style="text-align:right;" title="already_sum_mid+already_supplement_val {isfloat value=$offer_component->ontop->already_sum_mid+$offer_component->ontop->already_costs_supplement_val} {$project_global_currency}">
                    {if !$project_use_currency}
                        {isfloat value=$offer_component->ontop->already_sum_mid+$offer_component->ontop->already_costs_supplement_val}
                    {else}
                        {isfloat value=$offer_component->ontop->already_sum_mid_otcurr+$offer_component->ontop->already_costs_supplement_otcurr}
                    {/if}
                </th>
                <th style="text-align:right;" title="currently_total_sum_mid+currently_total_supplement_val {isfloat value=$offer_component->ontop->currently_total_sum_mid+$offer_component->ontop->currently_total_costs_supplement_val} {$project_global_currency}">
                    {if !$project_use_currency}
                        {isfloat value=$offer_component->ontop->currently_total_sum_mid+$offer_component->ontop->currently_total_costs_supplement_val}
                    {else}
                        {isfloat value=$offer_component->ontop->currently_total_sum_mid_otcurr+$offer_component->ontop->currently_total_costs_supplement_otcurr}
                    {/if}
                </th>
                <th style="text-align:right;" title="sum_mid+supplement_val {isfloat value=$offer_component->ontop->sum_mid+$offer_component->ontop->costs_supplement_val} {$project_global_currency}">
                    {if !$project_use_currency}
                        {isfloat value=$offer_component->ontop->sum_mid+$offer_component->ontop->costs_supplement_val}
                    {else}
                        {isfloat value=$offer_component->ontop->sum_mid_otcurr+$offer_component->ontop->costs_supplement_otcurr}
                    {/if}
                </th>
            </tr>
            
            {* ## Nebenkosten ## *}
            <tr>
                <td colspan="2" style="text-align:center; background: rgba(255, 255, 200, 0.4);">
                    {$i.offers_management_extras}
                </td>
                <td style="background: rgba(255, 255, 200, 0.4);">
                </td>
                <td style="text-align:right; background: rgba(255, 255, 200, 0.4);" title="extras">
                    {isfloat value=$offer_component->ontop->extras}%
                </td>
                <td style="background: rgba(255, 255, 200, 0.4);">
                </td>
                <td colspan="3" style="text-align:right; background: rgba(255, 255, 200, 0.4);" title="already_extras_val {isfloat value=$offer_component->ontop->already_extras_val} {$project_global_currency}">
                    {if !$project_use_currency}
                        {isfloat value=$offer_component->ontop->already_extras_val}
                    {else}
                        {isfloat value=$offer_component->ontop->already_extras_otcurr}
                    {/if}
                </td>
                <td style="text-align:right; background: rgba(255, 255, 200, 0.4);" title="currently_total_extras_val {isfloat value=$offer_component->ontop->currently_total_extras_val} {$project_global_currency}">
                    {if !$project_use_currency}
                        {isfloat value=$offer_component->ontop->currently_total_extras_val}
                    {else}
                        {isfloat value=$offer_component->ontop->currently_total_extras_otcurr}
                    {/if}
                </td>
                <td style="text-align:right; background: rgba(255, 255, 200, 0.4);" title="extras_val {isfloat value=$offer_component->ontop->extras_val} {$project_global_currency}">
                    {if !$project_use_currency}
                        {isfloat value=$offer_component->ontop->extras_val}
                    {else}
                        {isfloat value=$offer_component->ontop->extras_otcurr}
                    {/if}
                </td>
            </tr>

            {* ## Zwischensumme ## *}
            <tr>
                <th colspan="2" style="text-align:center;">
                    {$i.calcexp_hoai_sum_midext}
                </th>
                <th colspan="3" style="text-align:right;">
                </th>
                <th colspan="3" style="text-align:right;" title="already_sum_mid+already_supplement_val+already_extras_val {isfloat value=$offer_component->ontop->already_sum_mid+$offer_component->ontop->already_costs_supplement_val+$offer_component->ontop->already_extras_val} {$project_global_currency}">
                    {if !$project_use_currency}
                        {isfloat value=$offer_component->ontop->already_sum_mid+$offer_component->ontop->already_costs_supplement_val+$offer_component->ontop->already_extras_val}
                    {else}
                        {isfloat value=$offer_component->ontop->already_sum_mid_otcurr+$offer_component->ontop->already_costs_supplement_otcurr+$offer_component->ontop->already_extras_otcurr}
                    {/if}
                </th>
                <th style="text-align:right;" title="currently_total_sum_mid+currently_total_supplement_val+currently_total_extras_val {isfloat value=$offer_component->ontop->currently_total_sum_mid+$offer_component->ontop->currently_total_costs_supplement_val+$offer_component->ontop->currently_total_extras_val} {$project_global_currency}">
                    {if !$project_use_currency}
                        {isfloat value=$offer_component->ontop->currently_total_sum_mid+$offer_component->ontop->currently_total_costs_supplement_val+$offer_component->ontop->currently_total_extras_val}
                    {else}
                        {isfloat value=$offer_component->ontop->currently_total_sum_mid_otcurr+$offer_component->ontop->currently_total_costs_supplement_otcurr+$offer_component->ontop->currently_total_extras_otcurr}
                    {/if}
                </th>
                <th style="text-align:right;" title="sum_mid+supplement_val+extras_val {isfloat value=$offer_component->ontop->sum_mid+$offer_component->ontop->costs_supplement_val+$offer_component->ontop->extras_val} {$project_global_currency}">
                    {if !$project_use_currency}
                        {isfloat value=$offer_component->ontop->sum_mid+$offer_component->ontop->costs_supplement_val+$offer_component->ontop->extras_val}
                    {else}
                        {isfloat value=$offer_component->ontop->sum_mid_otcurr+$offer_component->ontop->costs_supplement_otcurr+$offer_component->ontop->extras_otcurr}
                    {/if}
                </th>
            </tr>

            {* ## Rabatt ## *}
            <tr>
                <td colspan="2" style="text-align:center; background: rgba(255, 200, 200, 0.4);">
                    {$i.calcexp_hoai_rebate}
                </td>
                <td style="background: rgba(255, 200, 200, 0.4);">
                </td>
                <td style="background: rgba(255, 200, 200, 0.4);">
                </td>
                <td style="text-align:right; background: rgba(255, 200, 200, 0.4);" title="rebate">
                    {if $rebate_type}
                        -{isfloat value=$offer_component->ontop->rebate}%
                    {else}
                        -{isfloat value=$offer_component->ontop->rebate}
                    {/if}
                </td>
                <td colspan="3" style="text-align:right; background: rgba(255, 200, 200, 0.4);" title="already_rebate_val {isfloat value=$offer_component->ontop->already_rebate_val} {$project_global_currency}">
                    {if !$project_use_currency}
                        -{isfloat value=$offer_component->ontop->already_rebate_val}
                    {else}
                        -{isfloat value=$offer_component->ontop->already_rebate_otcurr}
                    {/if}
                </td>
                <td style="text-align:right; background: rgba(255, 200, 200, 0.4);" title="currently_total_rebate_val {isfloat value=$offer_component->ontop->currently_total_rebate_val} {$project_global_currency}">
                    {if !$project_use_currency}
                        -{isfloat value=$offer_component->ontop->currently_total_rebate_val}
                    {else}
                        -{isfloat value=$offer_component->ontop->currently_total_rebate_otcurr}
                    {/if}
                </td>
                <td style="text-align:right; background: rgba(255, 200, 200, 0.4);" title="rebate_val {isfloat value=$offer_component->ontop->rebate_val} {$project_global_currency}">
                    {if !$project_use_currency}
                        -{isfloat value=$offer_component->ontop->rebate_val}
                    {else}
                        -{isfloat value=$offer_component->ontop->rebate_otcurr}
                    {/if}
                </td>
            </tr> <!-- --------------------------------------------------------- -->
        {/if}
        
        {* ## Summe ## *}
        <tr>
            <th colspan="2" style="text-align:center; font-size: 1.1em;">
                {if $has_repetition}
                    {$i.basic_total_without_rep}
                {else}
                    {$i.basic_total}
                {/if}
            </th>
            <th colspan="3" style="text-align:right;">
            </th>
            <th colspan="3" style="text-align:right;" title="already_total {isfloat value=$offer_component->ontop->already_total} {$project_global_currency}">
                {if !$project_use_currency}
                    {isfloat value=$offer_component->ontop->already_total}
                {else}
                    {isfloat value=$offer_component->ontop->already_total_otcurr}
                {/if}
            </th>
            <th style="text-align:right;" title="currently_total_total {isfloat value=$offer_component->ontop->currently_total_total} {$project_global_currency}">
                {if !$project_use_currency}
                    {isfloat value=$offer_component->ontop->currently_total_total}
                {else}
                    {isfloat value=$offer_component->ontop->currently_total_total_otcurr}
                {/if}
            </th>
            <th {if !$project_use_currency}colspan="2"{else}class="global_currency"{/if} style="text-align:right; font-size: 1.1em;" title="total">
                {isfloat value=$offer_component->ontop->total}
            </th>
            {if $offer_component->ontop->with_old_hoai}
                <th></th>
            {elseif $project_use_currency && !$offer_component->ontop->with_old_hoai}
                {if $transfer_mode}
                    <th class="global_currency" style="text-align:right;">
                        {include file='r/view-only.tpl' name='calcexp_level_of_completion_transfer_total' 
                            filter_extra="data-total_otcurr='`$offer_component->ontop->total_otcurr`'"
                            default={isfloat value=$offer_component->ontop->total}}
                    </th>
                {/if}
                <th colspan="2" style="text-align:right; font-size: 1.1em;">
                    {isfloat value=$offer_component->ontop->total_otcurr}
                </th>
            {/if}
        </tr> <!-- --------------------------------------------------------- -->
    </tfoot>
</table>

{* ## Wiederholungen ## *}
{if $has_repetition}
    <table style="width: 100%; max-width: 95vw;">
        <thead>
        <tr>
            <th style="min-width:200px" colspan="3">Wiederholungen</th>
            <th style="min-width:100px"></th>
            <th style="min-width:60px"></th>
            <th style="min-width:100px"></th>
            <th style="min-width:100px"></th>
            <th style="min-width:100px">Einzelsumme</th>
            <th style="min-width:100px">Gruppierte Summe</th>
        </tr>
        </thead>
        <tbody>
            {foreach item="repetition_item" from=$offer_component->repetitions->repetitions}
                <tr>
                    <td style="text-align:center;">{$repetition_item->name}</td>
                    {if !$project_use_currency}
                        <td colspan="5" style="text-align:right;">{isfloat value=$repetition_item->already_amount}</td>
                        <td style="text-align:right;">{isfloat value=$repetition_item->current_total_amount}</td>
                        <td style="text-align:right;">{isfloat value=$repetition_item->current_amount}</td>
                        <td style="text-align:right;">{isfloat value=$repetition_item->current_sum_amount}</td>
                    {else}
                        <td colspan="5" style="text-align:right;">{isfloat value=$repetition_item->already_amount_otcurr}</td>
                        <td style="text-align:right;">{isfloat value=$repetition_item->current_total_amount_otcurr}</td>
                        <td style="text-align:right;">{isfloat value=$repetition_item->current_amount_otcurr}</td>
                        <td style="text-align:right;">{isfloat value=$repetition_item->current_sum_amount_otcurr}</td>
                    {/if}
                </tr>
            {/foreach}
            <tr>
                <th style="text-align:center;">{$i.basic_total_rep}</th>
                {if !$project_use_currency}
                    <th colspan="8" style="text-align:right;">{isfloat value=$offer_component->repetitions->rep_sum}</th>
                {else}
                    <th colspan="8" style="text-align:right;">{isfloat value=$offer_component->repetitions->rep_sum_otcurr}</th>
                {/if}
            </tr>
            <tr>
                <th style="text-align:center;">{$i.basic_total_with_rep}</th>

                {if !$project_use_currency}
                    {$rep_total_sum = $offer_component->ontop->total+$offer_component->repetitions->rep_sum}
                {else}
                    {$rep_total_sum = $offer_component->ontop->total_otcurr+$offer_component->repetitions->rep_sum_otcurr}
                {/if}
                <th colspan="10" style="text-align:right;">{isfloat value=$rep_total_sum}</th>
            </tr>
        </tbody>
    </table>
{/if}

{* if $payment->fee_type eq Payments_model::T_FINAL && $offer_component->ontop->total_need_final_vat_mode}
    <h4 style="padding-top: 20px;">{$i.calcexp_vat_simple}</h4>
{/if *}

<br />

{if !$project_use_currency}
    {$vat_total = $vat_total+$offer_component->ontop->total_vat_simple}
{else}
    {$vat_total = $vat_total+$offer_component->ontop->total_vat_simple_otcurr}
{/if}
{if !$project_use_currency}
    {$gross_total = $gross_total+$offer_component->ontop->total_rep+$offer_component->ontop->total_vat_simple}
{else}
    {$gross_total = $gross_total+$offer_component->ontop->total_rep_otcurr+$offer_component->ontop->total_vat_simple_otcurr}
{/if}
{if $offer_component->ontop->round_gross && $offer_component->ontop->round_info && $offer_component->ontop->round_info[0]>0 && $offer_component->ontop->round_info[2]>0}
    {$gross_total_rounded = round($gross_total/$offer_component->ontop->round_info[2], $offer_component->ontop->round_info[1])*$offer_component->ontop->round_info[2]}
{else}
    {$gross_total_rounded = round($gross_total, 2)}
{/if}
{/foreach}

<table style="width: 100%; max-width: 95vw; margin-top: 10px;">
    <tr>
        <th colspan="2" style="text-align:center;">{$i.calcexp_sum_vat}</th>
        <th colspan="2" style="text-align:right;">{isfloat value=$payment->vat*100}%</th>
        <th colspan="2" style="text-align:right;">
            {isfloat value=$vat_total}
        </th>
    </tr>
    <tr>
        <th colspan="2" style="text-align:center;">{$i.calcexp_sum_gross}</th>
        <th colspan="2">
            {if $offer_component->ontop->round_gross && $offer_component->ontop->round_info && $offer_component->ontop->round_info[0]>0 && $offer_component->ontop->round_info[2]>0}
                <small style="font-weight: lighter;">({$i.calcexp_round_gross}: {isfloat value=$gross_total_rounded-$gross_total})</small>
            {/if}
        </th>
        <th colspan="2" style="text-align:right;">{isfloat value=$gross_total_rounded}</th>
    </tr>
</table>

{* if $payment->fee_type eq Payments_model::T_FINAL && $offer_component->ontop->total_need_final_vat_mode}
    <h4 style="padding-top: 20px;">{$i.calcexp_vat_final}</h4>
    
    <table style="width: 100%; max-width: 95vw; margin-top: 10px;">
        <tr>
            <th colspan="2" style="text-align:center;">{$i.calcexp_sum_vat_curr_total}</th>
            <th colspan="2" style="text-align:right;">{isfloat value=$payment->vat*100}%</th>
            <th colspan="2" style="text-align:right;">
                {if !$project_use_currency}
                    {isfloat value=$offer_component->ontop->currently_total_vat}
                {else}
                    {isfloat value=$offer_component->ontop->currently_total_vat_otcurr}
                {/if}
            </th>
        </tr>
        <tr>
            <th colspan="2" style="text-align:center;">{$i.calcexp_sum_vat_already}</th>
            <th colspan="2" style="text-align:right;"></th>
            <th colspan="2" style="text-align:right;">
                {if !$project_use_currency}
                    {isfloat value=$offer_component->ontop->already_vat}
                {else}
                    {isfloat value=$offer_component->ontop->already_vat_otcurr}
                {/if}
            </th>
        </tr>
        <tr>
            <th colspan="2" style="text-align:center;">{$i.calcexp_sum_vat_currently}</th>
            <th colspan="2" style="text-align:right;"></th>
            <th colspan="2" style="text-align:right;">
                {if !$project_use_currency}
                    {isfloat value=$offer_component->ontop->total_vat_final}
                {else}
                    {isfloat value=$offer_component->ontop->total_vat_final_otcurr}
                {/if}
            </th>
        </tr>
        <tr>
            <th colspan="2" style="text-align:center;">{$i.calcexp_sum_gross}</th>
            <th colspan="2">
                {if !$project_use_currency}
                    {$gross_total = $offer_component->ontop->total+$offer_component->ontop->total_vat_final}
                {else}
                    {$gross_total = $offer_component->ontop->total_otcurr+$offer_component->ontop->total_vat_final_otcurr}
                {/if}
                {if $offer_component->ontop->round_gross && $offer_component->ontop->round_info && $offer_component->ontop->round_info[0]>0 && $offer_component->ontop->round_info[2]>0}
                    {$gross_total_rounded = round($gross_total/$offer_component->ontop->round_info[2], $offer_component->ontop->round_info[1])*$offer_component->ontop->round_info[2]}
                    <small style="font-weight: lighter;">({$i.calcexp_round_gross}: {isfloat value=$gross_total_rounded-$gross_total})</small>
                {else}
                    {$gross_total_rounded = round($gross_total, 2)}
                {/if}
            </th>
            <th colspan="2" style="text-align:right;">{isfloat value=$gross_total_rounded}</th>
        </tr>
    </table>
{/if *}

<br />
<br />
