feat:고객/매출/매입/정산 등 재무 관련 8개 테이블 마이그레이션 추가

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
김보곤
2026-02-04 22:43:46 +09:00
parent a6fc537a02
commit 343d7f6256
8 changed files with 265 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void
{
Schema::create('customers', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('tenant_id');
$table->string('name', 100);
$table->string('biz_no', 20)->nullable();
$table->string('ceo', 50)->nullable();
$table->string('industry', 50)->nullable();
$table->string('grade', 20)->default('Silver');
$table->string('contact', 50)->nullable();
$table->string('email', 100)->nullable();
$table->string('address', 200)->nullable();
$table->string('manager', 50)->nullable();
$table->string('manager_phone', 20)->nullable();
$table->string('status', 20)->default('active');
$table->text('memo')->nullable();
$table->timestamps();
$table->softDeletes();
$table->index(['tenant_id', 'status']);
$table->index(['tenant_id', 'grade']);
});
}
public function down(): void
{
Schema::dropIfExists('customers');
}
};

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void
{
Schema::create('incomes', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('tenant_id');
$table->date('date');
$table->string('customer', 100);
$table->string('description', 200)->nullable();
$table->string('category', 50)->default('기타수입');
$table->bigInteger('amount')->default(0);
$table->string('status', 20)->default('pending');
$table->string('invoice_no', 50)->nullable();
$table->text('memo')->nullable();
$table->timestamps();
$table->softDeletes();
$table->index(['tenant_id', 'status']);
$table->index(['tenant_id', 'date']);
});
}
public function down(): void
{
Schema::dropIfExists('incomes');
}
};

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void
{
Schema::create('expenses', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('tenant_id');
$table->date('date');
$table->string('vendor', 100);
$table->string('description', 200)->nullable();
$table->string('category', 50)->default('운영비');
$table->bigInteger('amount')->default(0);
$table->string('status', 20)->default('pending');
$table->string('payment_method', 30)->default('계좌이체');
$table->string('invoice_no', 50)->nullable();
$table->text('memo')->nullable();
$table->timestamps();
$table->softDeletes();
$table->index(['tenant_id', 'status']);
$table->index(['tenant_id', 'date']);
});
}
public function down(): void
{
Schema::dropIfExists('expenses');
}
};

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void
{
Schema::create('sales_records', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('tenant_id');
$table->date('date');
$table->string('customer', 100);
$table->string('project', 200)->nullable();
$table->string('type', 50)->default('프로젝트');
$table->bigInteger('amount')->default(0);
$table->bigInteger('vat')->default(0);
$table->string('status', 20)->default('negotiating');
$table->string('invoice_no', 50)->nullable();
$table->text('memo')->nullable();
$table->timestamps();
$table->softDeletes();
$table->index(['tenant_id', 'status']);
$table->index(['tenant_id', 'date']);
});
}
public function down(): void
{
Schema::dropIfExists('sales_records');
}
};

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void
{
Schema::create('purchases', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('tenant_id');
$table->date('date');
$table->string('vendor', 100);
$table->string('item', 200)->nullable();
$table->string('category', 50)->default('운영비');
$table->bigInteger('amount')->default(0);
$table->bigInteger('vat')->default(0);
$table->string('status', 20)->default('pending');
$table->string('invoice_no', 50)->nullable();
$table->text('memo')->nullable();
$table->timestamps();
$table->softDeletes();
$table->index(['tenant_id', 'status']);
$table->index(['tenant_id', 'date']);
});
}
public function down(): void
{
Schema::dropIfExists('purchases');
}
};

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void
{
Schema::create('consulting_fees', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('tenant_id');
$table->date('date');
$table->string('consultant', 50);
$table->string('customer', 100);
$table->string('service', 50)->default('기술 컨설팅');
$table->integer('hours')->default(0);
$table->integer('hourly_rate')->default(0);
$table->bigInteger('amount')->default(0);
$table->string('status', 20)->default('pending');
$table->text('memo')->nullable();
$table->timestamps();
$table->softDeletes();
$table->index(['tenant_id', 'status']);
$table->index(['tenant_id', 'date']);
});
}
public function down(): void
{
Schema::dropIfExists('consulting_fees');
}
};

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void
{
Schema::create('customer_settlements', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('tenant_id');
$table->string('period', 7);
$table->string('customer', 100);
$table->bigInteger('total_sales')->default(0);
$table->bigInteger('commission')->default(0);
$table->bigInteger('expense')->default(0);
$table->bigInteger('net_amount')->default(0);
$table->string('status', 20)->default('pending');
$table->date('settled_date')->nullable();
$table->text('memo')->nullable();
$table->timestamps();
$table->softDeletes();
$table->index(['tenant_id', 'status']);
$table->index(['tenant_id', 'period']);
});
}
public function down(): void
{
Schema::dropIfExists('customer_settlements');
}
};

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void
{
Schema::create('subscriptions', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('tenant_id');
$table->string('customer', 100);
$table->string('plan', 50)->default('Business');
$table->bigInteger('monthly_fee')->default(0);
$table->string('billing_cycle', 20)->default('monthly');
$table->date('start_date')->nullable();
$table->date('next_billing')->nullable();
$table->string('status', 20)->default('active');
$table->integer('users')->default(0);
$table->text('memo')->nullable();
$table->timestamps();
$table->softDeletes();
$table->index(['tenant_id', 'status']);
});
}
public function down(): void
{
Schema::dropIfExists('subscriptions');
}
};