<div data-reload="price">
   {if $module.ORDER_DISCOUNT && ($body->getPurchaseState()->getDiscounts() || $body->getPurchaseState()->getCharges())}
      {$cartDiscountActive = true}
   {/if}

   {$totalPrice = $body->getPurchaseState()->getTotalPrice()}
   {$productsTotalPrice = $body->getPurchaseState()->getProductsTotalPrice()}

   <div class="price-box">
      {block "products-price"}
         {if $transport==1 or $cartDiscountActive}
            <div class="price-box-row">
               <p>{t}Cena zboží{/t}</p>
               <p>
                  {$discountsProductsTotalPrice = $body->getPurchaseState()->discountsProductsTotalPrice}
                  {* discountsProducts - napr. darky, jsou vetsinou zdarma, ale mohou byt i za nejakou cenu *}
                  {* cena darku neni zapoctena v totalPrice *}
                  {$productsTotalPriceIncrement = 0}
                  {if $discountsProductsTotalPrice}
                     {if $noVat}
                        {$productsTotalPriceIncrement = $discountsProductsTotalPrice->getPriceWithoutVat()}
                     {else}
                        {$productsTotalPriceIncrement = $discountsProductsTotalPrice->getPriceWithVat()}
                     {/if}
                  {/if}

                  {if $noVat}
                     {$productsTotalPrice->getPriceWithoutVat()->add($productsTotalPriceIncrement)|format_price:"ceil=no;decimal=dynamic"}
                  {else}
                     {$productsTotalPrice->getPriceWithVat()->add($productsTotalPriceIncrement)|format_price:"ceil=no;decimal=dynamic"}
                  {/if}
               </p>
            </div>
         {/if}
      {/block}

      {block "pricebox-discounts"}
         {* Render order discounts (new) *}
         {if $body->getPurchaseState()->getDiscounts()|count && findModule('order_discount')}
            {foreach $body->getPurchaseState()->getDiscounts() as $discount}
               {if is_a($discount, 'KupShop\OrderingBundle\Entity\Purchase\DiscountPurchaseItem')}
                  {block "pricebox-order-discount"}
                     <div class="price-box-row discount">
                        <p>{$discount->getName()}</p>
                        <p>{if $noVat}{$discount->getPriceWithoutVat()|format_price:"ceil=no;decimal=dynamic"}
                           {else}{$discount->getPriceWithVat()|format_price:"ceil=no;decimal=dynamic"}{/if}</p>
                     </div>
                  {/block}
               {/if}
            {/foreach}
         {/if}
      {/block}

      {block "pricebox-charges"}
         {if $body->getPurchaseState()->getCharges()}
            {foreach $body->getPurchaseState()->getCharges() as $charge}
               {if is_a($charge, 'KupShop\OrderingBundle\Entity\Purchase\ChargePurchaseItem')}
               <div class="price-box-row charge">
                  <p>{$charge->getName()}</p>
                  <p>{$charge->getPrice()|format_price:"ceil=no;decimal=dynamic"}</p>
               </div>
               {/if}
            {/foreach}
         {/if}
      {/block}

      {block "pricebox-transport"}
         {if $transport==1}
            <div class="price-box-row">
               {if !$body.transport}
                  <p>
                     {if !$body.delivery_id}{t}Vyberte dopravu{/t}{else}{t}Vyberte platbu{/t}{/if}
                  </p>
               {else}
                  <p>{t}Doprava a platba{/t}</p>
                  <p>
                     {$delivery = $body->getDeliveryType()}
                     {if $noVat}{$delivery.price.value_without_vat|format_price:"ceil=no;decimal=dynamic"}{else}{$delivery.price.value_with_vat|format_price:"ceil=no;decimal=dynamic"}{/if}
                  </p>
               {/if}
            </div>
         {/if}
      {/block}

       {if ($body->getPurchaseState()->getCustomData('rounding_balance') && $dbcfg.invoice_rounding_balance == 'Y')}
         <div class="price-box-row">
            <p>{t}Zaokrouhlení{/t}</p>
            <p>{$body->getPurchaseState()->getCustomData('rounding_balance')|format_price:"ceil=no;decimal=dynamic"}</p>
         </div>
      {/if}

      {block "pricebox-cartsaving"}
         {if $tpl_vars.pricebox_cartsaving}
            {get_cart_savings assign='cartSavings'}
            {if $cartSavings->isPositive()}
               <div class="price-box-row price-box-row-cartsaving">
                  <p>{t}Ušetříte{/t}</p>
                  <p>{$cartSavings|format_price:"ceil=no;decimal=dynamic"}</p>
               </div>
            {/if}
         {/if}
      {/block}

      {block "pricebox-without-vat"}
         {if $dbcfg.shop_vat_payer == "Y" or $isB2BUser}
            <div class="price-box-row">
               <p>{t}Celková částka bez DPH{/t}</p>
               <p>{$totalPrice->getPriceWithoutVat()|format_price:"ceil=no;decimal=dynamic"}</p>
            </div>
         {/if}
      {/block}

      {block "pricebox-total"}
         <div class="price-box-row total-price">
            <p>{if $dbcfg.shop_vat_payer == "Y"}{t}Celková částka s DPH{/t}{else}{t}Celková částka{/t}{/if}</p>
            <p>{$totalPrice->getPriceWithVat()|format_price:"ceil=no;decimal=dynamic"}</p>
         </div>
      {/block}
   </div>
</div>
