= wicked_pdf_stylesheet_link_tag "mail"

%table{:width => "100%"}
  %tbody
    %tr{ valign: "top" }
      %td{ :align => "left", colspan: 3 }
        %h6
          = "#{t('.issued_on')}: "
          = l Time.zone.now.to_date
    %tr{ valign: "top" }
      %td{ :align => "left" }
        %h4
          = "#{t('.tax_invoice')}: "
          = "#{@order.number}"
      %td{width: "10%" }
        &nbsp;
      %td{ :align => "right" }
        %h4= @order.order_cycle&.name
    %tr{ valign: "top" }
      %td{ align: "left", colspan: 3 }
        - if @order.distributor.business_address.blank?
          %strong= "#{t('.from')}: #{@order.distributor.name}"
        - else 
          %strong= "#{t('.from')}: #{@order.distributor.business_address.company}"
        - if @order.distributor.abn.present?
          %br
          = "#{t(:abn)} #{@order.distributor.abn}"
        %br
        - if @order.distributor.business_address.blank?
          = @order.distributor.address.full_address
        - else
          = @order.distributor.business_address.full_address
        %br
        = @order.distributor.contact.email
    %tr{ valign: "top" }
      %td{ colspan: 3 }
        &nbsp;
    %tr{ valign: "top" }
      %td{ align: "left" }
        %strong= "#{t('.to')}:"
        %br
        - if @order.bill_address
          = @order.bill_address.full_name
        - if @order&.customer&.code.present?
          %br
          = "#{t('.code')}: #{@order.customer.code}"
        %br
        - if @order.bill_address
          = @order.bill_address.full_address
        %br
        - if @order&.customer&.email.present?
          = "#{@order.customer.email},"
        - if @order.bill_address
          = "#{@order.bill_address.phone}"
      %td
        &nbsp;
      %td{ align: "left", style: "border-left: .1em solid black; padding-left: 1em" }
        %strong= "#{t('.shipping')}: #{@order.shipping_method&.name}"
        - if @order.shipping_method&.require_ship_address
          %br
          = @order.ship_address.full_name
          %br
          = @order.ship_address.full_address
          %br
          = @order.ship_address.phone
        - if @order.special_instructions.present?
          %br
          %br
            %strong= t :customer_instructions
          = @order.special_instructions


= render 'spree/admin/orders/invoice_table'

- if @order.distributor.invoice_text.present?
  %p
    = @order.distributor.invoice_text

= render 'spree/shared/payment'

- if @order.note.present?
  = render partial: 'spree/shared/order_note'
