%tr
  
  
  %td
    =l p_document.created_at, :format => :date
  
  -if @p_documents
    %td
      =link_to "##{p_document.element.id}", admin_p_customer_sheet_path(p_document.element)
    %td
      =p_document.element.p_customer.show_name if p_document.element and p_document.element.p_customer
    
    
  
  %td
    =p_document.label
  %td
    =link_to p_document.d_number, admin_p_document_path(p_document.token)
    
  -totals = PSheetLine.totals(p_document.p_sheet_lines)
  %td
    -if p_document.label == "Facture"
      = number_to_currency totals[:ok_total]
    -else
      = number_to_currency totals[:total]
    HT
  
  %td
    -if p_document.label == "Facture"
      = number_to_currency totals[:ok_total_ttc]
    -else
      = number_to_currency totals[:total_ttc]
    TTC
  
  -if params[:p_document_type_id].to_i == 4
    %th
      ="oui" if p_document.theo_paid
    %th
      ="oui" if p_document.paid
      
      
  -if false
    %table
      %tr 
        %td
          Paid
        %td
          =p_document.paid
      %tr 
        %td
          TH Paid
        %td
          =p_document.theo_paid
      -p_document.p_payment_documents.each do |pp|
        %tr
          %td
            =pp.amount
          %td
            =pp.paid
            =pp.p_payment.paid
      
    
      
  %td
    