#main
  
  %div{:style => "position:absolute;top:4.4cm;right:1cm;text-align:right;"}
    =@product_order_document.label
    n°
    =@product_order_document.d_number
    %br
    =l @product_order.created_at, :format => :date #@product_order_document.created_at




  %div{:style => "height:350px;"}
  


  %table.table{:style => "position:absolute;right:1cm;top:220px"}
    %tr
      %td{:style => "width:8cm;border:0"}
        %h3 Adresse de facturation
      
        %strong=@product_order.particular_bill.organisation
        %br
        =@product_order.particular_bill.firstname

        =@product_order.particular_bill.name
        %br
        =@product_order.particular_bill.address_2

        -if @product_order.particular_bill.address_3?
          %br
          =@product_order.particular_bill.address_3
        %br
        =@product_order.particular_bill.cp

        =@product_order.particular_bill.city
        %br
        =@product_order.particular_bill.country
        %br
        %br
        =@product_order.particular_bill.tel
      
    

  -@fournisseur = @product_order_document.product_order_document_type.fournisseur
  -fournisseur = @fournisseur
  
  %br
  %br
      
  %table.table{:style => "width:100%;margin:1cm 0;"}
    %tr
      %th Référence
      %th Nom
      %th Nbr
      -if true
        %th Prix U. HT
        %th Prix HT

   
    -@product_order.sub_products.group(:reference).where(:fournisseur_id => @fournisseur.id).each do |sub_product_group|
      %tr
        %td= sub_product_group.reference
        %td= sub_product_group.name
      
        -sub_products = @product_order.sub_products.where(:reference => sub_product_group.reference)

        
        %td
          -i = 0.0
          -sub_products.each do |sub_product|
            -i += sub_product.qte_tot
          =i
        -if true
          %td
        
            =number_to_currency sub_products[0].price_ht
            
        %td{:style => "text-align:right;"}
          =number_to_currency sub_products[0].price_ht * i
    
    %tr
      %td{:colspan => 4, :style => "text-align:right;"}
        Total HT :
      %td{:style => "text-align:right;"}
        -i = 0.0
        -@product_order.sub_products.where(:fournisseur_id => fournisseur.id).each do |sub_product|
          -i += sub_product.price_tot_with_qte
        =number_to_currency i
    -if @fournisseur.id == 5
      %tr
        %td{:colspan => 4, :style => "text-align:right;"}
          Taux de TVA :
        %td{:style => "text-align:right;"}
          20%
      %tr
        %td{:colspan => 4, :style => "text-align:right;"}
          TVA :
        %td{:style => "text-align:right;"}
          =number_to_currency i*0.20
      %tr
        %td{:colspan => 4, :style => "text-align:right;"}
          Total TTC
        %td{:style => "text-align:right;"}
          =number_to_currency i*1.2
      
  

 