class CreatePDocuments < ActiveRecord::Migration[6.0]
  def change
    create_table :p_documents do |t|
      t.string       :element_type
      t.references   :element,   index: true
      t.references   :p_document_type,   index: true
      t.references   :particular_bill,   index: true
      t.references   :particular_send,   index: true
      t.string       :name
      t.string       :d_number
      t.integer      :d_index
      t.integer      :d_year
      t.string       :d_prefix
      t.string       :label
      t.text         :header
      t.text         :footer
      t.integer      :image_file_id
      t.integer      :data_file_id
      t.string       :token
      t.references   :p_sheet_line,   index: true
      t.string       :bl_type
      t.decimal      :cache_total_ht,   :precision => 14,   :scale => 2
      t.decimal      :cache_total_ttc,   :precision => 14,   :scale => 2
      t.decimal      :cache_tva,   :precision => 14,   :scale => 2
      t.integer      :payment_days
      t.datetime     :cache_exp_date
      t.references   :p_customer,   index: true
      t.boolean      :theo_paid,   :default => false
      t.datetime     :theo_paid_at
      t.boolean      :paid,   :default => false
      t.datetime     :paid_at
      t.decimal      :acompte_percent,   :precision => 14,   :scale => 2
      t.decimal      :acompte_value,   :precision => 14,   :scale => 2
      t.boolean      :imported,   :default => false
      t.decimal      :cache_to_paid,   :precision => 14,   :scale => 2
      t.decimal      :cache_to_th_paid,   :precision => 14,   :scale => 2
      t.decimal      :cache_total_tva,   :precision => 14,   :scale => 2
      t.boolean      :comptant,   :default => true
      t.boolean      :acompte,   :default => false
      t.integer      :payment_delais
      t.boolean      :payment_fin_de_mois,   :default => false
      t.references   :p_payment_type,   index: true
      t.references   :p_ship_tour_truck,   index: true
      t.boolean      :canceled,   :default => false
      t.boolean      :i_archive,   :default => false
      t.string       :cust_ref
      t.integer      :doc_ref_id
      t.date         :echeance_date
      t.text         :avoir_text
      t.string       :doc_ref_number
      t.boolean      :i_ajust,   :default => false
      t.boolean      :i_ajust_result,   :default => false
      t.integer      :p_commercial_id
      t.integer      :p_compta_export_id
      t.boolean      :compta_locked,   :default => false

      t.timestamps
    end
  end
end
