Files
exchange-2.0/database/migrations/2020_12_01_102314_create_transaction_table.php
T
weiken.intex 9ed67e74e2 create Transaction & Transaction Detail
- Supplier (AP)
	- PO
	- DO
	- INV

- Customer (AR)
	- PO
	- DO
	- INV
2020-12-07 14:00:24 +08:00

64 lines
2.3 KiB
PHP

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateTransactionTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('transaction', function (Blueprint $table) {
$table->id();
$table->string('trans_type1');
$table->string('trans_type2');
$table->bigInteger('bill_no')->unsigned();
$table->decimal('amount', 14, 5)->default(0.00);
$table->decimal('original_amount', 14, 5)->default(0.00);
$table->bigInteger('currency_id')->unsigned();
$table->bigInteger('original_currency_id')->unsigned();
$table->decimal('currency_rate', 14, 5)->default(0.00);
$table->date('dt_transaction');
$table->integer('status');
$table->bigInteger('booking_id')->unsigned();
$table->bigInteger('company_id')->unsigned();
$table->timestamps();
$table->foreign('company_id')->references('id')->on('companies')->onDelete('cascade');
$table->foreign('currency_id')->references('id')->on('currencies')->onDelete('cascade');
$table->foreign('original_currency_id')->references('id')->on('currencies')->onDelete('cascade');
});
Schema::create('transaction_detail', function (Blueprint $table) {
$table->id();
$table->string('trans_type1');
$table->string('trans_type2');
$table->bigInteger('transaction_id')->unsigned();
$table->string('product_code');
$table->string('product_name');
$table->integer('qty')->default(0);
$table->decimal('price', 14, 5)->default(0.00);
$table->decimal('amount', 14, 5)->default(0.00);
$table->timestamps();
$table->foreign('transaction_id')->references('id')->on('transaction')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('transaction');
Schema::dropIfExists('transaction_detail');
}
}