.effective-order-items
  %table.table
    %thead
      %tr
        %th.quantity Qty
        %th.item= order.order_items.length > 1 ? 'Items' : 'Item'
        %th.price Price

    %tbody
      - order.order_items.each do |item|
        %tr
          %td.quantity= item.quantity

          %td.item
            = item.name.html_safe

            - if order.purchased? && item.purchased_download_url.present?
              = link_to 'Download', item.purchased_download_url

          %td.price= price_to_currency(item.subtotal)

  %table.table
    %tfoot
      %tr
        %th
        %td.subtotal Subtotal
        %td.price.subtotal-price= price_to_currency(order.subtotal)

      - if order.tax_rate.blank?
        -# Nothing to do. We can't display Tax, Total or Credit Card Surcharge (which is taxed) yet.

      - elsif order.tax_rate.present? && order.surcharge_percent.to_f > 0.0
        %tr
          %th
          %td.tax Tax (#{rate_to_percentage(order.tax_rate)})
          %td.price.tax-price= price_to_currency(order.tax)

        %tr.single-line
          %th
          %td.amount-owing Amount owing before Credit Card Processing Fee
          %td.price.amount-owing-price= price_to_currency(order.amount_owing)

        %tr
          %th
          %td
          %td

        %tr
          %th
          %td.surcharge Credit Card Processing Fee (#{rate_to_percentage(order.surcharge_percent)}) on #{price_to_currency(order.amount_owing)}
          %td.price.surcharge-price= price_to_currency(order.surcharge)

        %tr
          %th
          %td.surcharge-tax Tax (#{rate_to_percentage(order.tax_rate)}) on Credit Card Processing Fee
          %td.price.surcharge-tax-price= price_to_currency(order.surcharge_tax)

        %tr.double-line
          %th
          %td.total Total amount charged to credit card
          %td.price.total-price= price_to_currency(order.total)

      - elsif order.tax_rate.present? && !(order.surcharge_percent.to_f > 0.0)
        %tr
          %th
          %td.tax Tax (#{rate_to_percentage(order.tax_rate)})
          %td.price.tax-price= price_to_currency(order.tax)

        %tr.single-line
          %th
          %td.total= order.total_label
          %td.price.total-price= price_to_currency(order.total)