class CreateShiftSales < ActiveRecord::Migration[5.1]
  def change
    create_table :shift_sales do |t|
      t.references :cashier_terminal, foreign_key: true, :null => false
      t.datetime :shift_started_at
      t.datetime :shift_closed_at
      t.references :employee, foreign_key: true #cashier
      t.decimal :opening_balance, :precision => 10, :scale => 2, :null => false, :default => 0.00
      t.decimal :closing_balance, :precision => 10, :scale => 2, :null => false, :default => 0.00
      t.decimal :total_revenue, :precision => 10, :scale => 2, :null => false, :default => 0.00
      t.decimal :total_discounts, :precision => 10, :scale => 2, :null => false, :default => 0.00
      t.decimal :total_taxes, :precision => 10, :scale => 2, :null => false, :default => 0.00
      t.decimal :grand_total, :precision => 10, :scale => 2, :null => false, :default => 0.00
      t.decimal :nett_sales, :precision => 10, :scale => 2, :null => false, :default => 0.00
      t.decimal :cash_sales, :precision => 10, :scale => 2, :null => false, :default => 0.00
      t.decimal :credit_sales, :precision => 10, :scale => 2, :null => false, :default => 0.00
      t.json :other_sales
      t.decimal :commercial_taxes, :precision => 10, :scale => 2, :null => false, :default => 0.00
      t.decimal :cash_in, :precision => 10, :scale => 2, :null => false, :default => 0.00
      t.decimal :cash_out, :precision => 10, :scale => 2, :null => false, :default => 0.00
      t.integer :dining_count, :default => 0
      t.integer :takeaway_count, :default => 0
      t.integer :member_count, :default => 0
      t.timestamps
    end
  end
end
