<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;

class CreateBixoAccountInvoicesTable extends Migration
{
    /*
     * Run the migrations.
     *
     * @return void
     */

    public function up()
    {

        /*
         * Table: bixo_account_invoices
         */
        Schema::create('bixo_account_invoices', function ($table) {
            $table->increments('id');
            $table->integer('related_id')->nullable();
            $table->integer('team_id')->nullable();
            $table->integer('agent_id')->nullable();
            $table->integer('deal_id')->nullable();
            $table->string('ref', 30)->nullable();
            $table->integer('customer_id')->nullable();
            $table->integer('supplier_id')->nullable();
            $table->string('purchase_invoice_number', 50)->nullable();
            $table->string('purchase_order_number', 60)->nullable();
            $table->integer('company_id')->nullable();
            $table->integer('branch_id')->nullable();
            $table->string('unit', 60)->nullable();
            $table->string('location', 300)->nullable();
            $table->integer('location_id')->nullable();
            $table->integer('sublocation_id')->nullable();
            $table->integer('property_id')->nullable();
            $table->string('department', 50)->nullable();
            $table->string('billing_address', 150)->nullable();
            $table->string('mobile', 50)->nullable();
            $table->string('email', 100)->nullable();
            $table->string('serial_no', 20)->nullable();
            $table->dateTime('invoice_date')->nullable();
            $table->dateTime('due_date')->nullable();
            $table->integer('bank_account_id')->nullable();
            $table->string('customer_note', 200)->nullable();
            $table->enum('status', ['Yes', 'No'])->nullable();
            $table->decimal('sub_total', 12,2)->nullable();
            $table->string('tax_type', 20)->nullable();
            $table->decimal('tax_rate', 5,2)->nullable();
            $table->decimal('tax_amount', 12,2)->nullable();
            $table->decimal('discount', 12,2)->nullable();
            $table->enum('discount_type', ['Yes', 'No'])->nullable();
            $table->decimal('discount_value', 12,2)->nullable();
            $table->decimal('total', 12,2)->nullable();
            $table->decimal('total_usd', 12,3)->nullable();
            $table->decimal('payment_total', 12,2)->nullable();
            $table->decimal('balance_due', 12,2)->nullable();
            $table->text('message_invoice')->nullable();
            $table->text('message_statement')->nullable();
            $table->text('notes')->nullable();
            $table->text('documents')->nullable();
            $table->tinyInteger('show_footer')->nullable();
            $table->tinyInteger('amount_inwords')->nullable();
            $table->text('customer_address')->nullable();
            $table->integer('payment_terms')->nullable();
            $table->enum('payment_status', ['Yes', 'No'])->nullable();
            $table->integer('pro_forma_id')->nullable();
            $table->integer('offplan_payment_id')->nullable();
            $table->enum('type', ['Yes', 'No'])->nullable();
            $table->string('currency', 10)->nullable();
            $table->string('deal_customer_type', 30)->nullable();
            $table->text('ref_client')->nullable();
            $table->integer('user_id')->nullable();
            $table->string('user_type', 20)->nullable();
            $table->text('marking', 200)->nullable();
            $table->softDeletes();
            $table->nullableTimestamps();
        });
    }

    /*
    * Reverse the migrations.
    *
    * @return void
    */

    public function down()
    {
        Schema::drop('bixo_account_invoices');
    }
}