class CreatePriceDocuments < ActiveRecord::Migration[6.0]
  def change
    create_table :price_documents do |t|
      
      t.boolean :archived
      
      t.references :p_customer
      t.integer :p_commercial_id
      t.string :movement_type
      t.boolean :accounting, :default => false
      t.boolean :soldable, :default => false
      t.datetime :date
      
      t.integer :ac_accounting_zone_id
      t.integer :cc_accounting_zone_id
      
      t.string :ac_accounting_zone_name
      t.string :cc_accounting_zone_name
      
      t.decimal :ac_tot_amount_ht,   :precision => 14,   :scale => 2
      t.decimal :cc_tot_amount_ht,   :precision => 14,   :scale => 2
      t.decimal :ac_tot_amount_ttc,   :precision => 14,   :scale => 2
      t.decimal :cc_tot_amount_ttc,   :precision => 14,   :scale => 2
      t.decimal :ac_tot_amount_tva,   :precision => 14,   :scale => 2
      t.decimal :cc_tot_amount_tva,   :precision => 14,   :scale => 2
      t.string :d_number
      t.integer :d_index
      t.integer :d_year
      t.integer :d_month
      t.integer :d_day
      t.string :d_prefix
      t.boolean :solded, :default => false
      t.boolean :imported, :default => false
      t.string :ref_element_type
      t.integer :ref_element_id
      t.integer :price_document_type_id
      t.string :ac_label
      t.string :cc_label
      t.string :token
      t.text :ct_header
      t.text :ac_header
      t.text :cc_header
      t.text :ct_footer
      t.text :ac_footer
      t.text :cc_footer
      t.integer :ac_payment_days
      t.integer :cc_payment_days
      t.datetime :paid_at
      t.integer :ct_payment_delais
      t.integer :ac_payment_delais
      t.integer :cc_payment_delais
      t.boolean :ct_payment_month_end
      t.boolean :ac_payment_month_end
      t.boolean :cc_payment_month_end
      t.date :ac_payment_end_at
      t.date :cc_payment_end_at
      t.integer :doc_ref_id
      t.boolean :accounting_locked, :default => false
      t.integer :particular_bill_id
      t.integer :particular_send_id
      t.integer :ac_particular_bill_id
      t.integer :ac_particular_send_id
      t.decimal :ac_to_paid_ht,   :precision => 14,   :scale => 2
      t.decimal :cc_to_paid_ht,   :precision => 14,   :scale => 2
      t.decimal :ac_to_paid_ttc,   :precision => 14,   :scale => 2
      t.decimal :cc_to_paid_ttc,   :precision => 14,   :scale => 2
      t.decimal :ac_to_paid_tva,   :precision => 14,   :scale => 2
      t.decimal :cc_to_paid_tva,   :precision => 14,   :scale => 2

      t.timestamps
    end
  end
end
