diff --git a/database/migrations/2026_02_04_230001_create_customers_table.php b/database/migrations/2026_02_04_230001_create_customers_table.php new file mode 100644 index 0000000..b679dff --- /dev/null +++ b/database/migrations/2026_02_04_230001_create_customers_table.php @@ -0,0 +1,36 @@ +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'); + } +}; diff --git a/database/migrations/2026_02_04_230002_create_incomes_table.php b/database/migrations/2026_02_04_230002_create_incomes_table.php new file mode 100644 index 0000000..3f9c297 --- /dev/null +++ b/database/migrations/2026_02_04_230002_create_incomes_table.php @@ -0,0 +1,32 @@ +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'); + } +}; diff --git a/database/migrations/2026_02_04_230003_create_expenses_table.php b/database/migrations/2026_02_04_230003_create_expenses_table.php new file mode 100644 index 0000000..dcb3b72 --- /dev/null +++ b/database/migrations/2026_02_04_230003_create_expenses_table.php @@ -0,0 +1,33 @@ +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'); + } +}; diff --git a/database/migrations/2026_02_04_230004_create_sales_records_table.php b/database/migrations/2026_02_04_230004_create_sales_records_table.php new file mode 100644 index 0000000..a1cea1f --- /dev/null +++ b/database/migrations/2026_02_04_230004_create_sales_records_table.php @@ -0,0 +1,36 @@ +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'); + } +}; diff --git a/database/migrations/2026_02_04_230005_create_purchases_table.php b/database/migrations/2026_02_04_230005_create_purchases_table.php new file mode 100644 index 0000000..b767c99 --- /dev/null +++ b/database/migrations/2026_02_04_230005_create_purchases_table.php @@ -0,0 +1,36 @@ +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'); + } +}; diff --git a/database/migrations/2026_02_04_230006_create_consulting_fees_table.php b/database/migrations/2026_02_04_230006_create_consulting_fees_table.php new file mode 100644 index 0000000..01078de --- /dev/null +++ b/database/migrations/2026_02_04_230006_create_consulting_fees_table.php @@ -0,0 +1,33 @@ +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'); + } +}; diff --git a/database/migrations/2026_02_04_230007_create_customer_settlements_table.php b/database/migrations/2026_02_04_230007_create_customer_settlements_table.php new file mode 100644 index 0000000..91dd4a5 --- /dev/null +++ b/database/migrations/2026_02_04_230007_create_customer_settlements_table.php @@ -0,0 +1,33 @@ +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'); + } +}; diff --git a/database/migrations/2026_02_04_230008_create_subscriptions_table.php b/database/migrations/2026_02_04_230008_create_subscriptions_table.php new file mode 100644 index 0000000..6d37ef2 --- /dev/null +++ b/database/migrations/2026_02_04_230008_create_subscriptions_table.php @@ -0,0 +1,35 @@ +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'); + } +}; diff --git a/database/migrations/2026_02_05_093000_add_mng_columns_to_purchases_table.php b/database/migrations/2026_02_05_093000_add_mng_columns_to_purchases_table.php new file mode 100644 index 0000000..3b55e36 --- /dev/null +++ b/database/migrations/2026_02_05_093000_add_mng_columns_to_purchases_table.php @@ -0,0 +1,49 @@ +date('date')->nullable()->after('purchase_date')->comment('매입일(MNG용)'); + } + if (!Schema::hasColumn('purchases', 'vendor')) { + $table->string('vendor', 100)->nullable()->after('date')->comment('공급자명(MNG용)'); + } + if (!Schema::hasColumn('purchases', 'item')) { + $table->string('item', 200)->nullable()->after('vendor')->comment('품목명(MNG용)'); + } + if (!Schema::hasColumn('purchases', 'category')) { + $table->string('category', 50)->default('운영비')->after('item')->comment('분류(MNG용)'); + } + if (!Schema::hasColumn('purchases', 'amount')) { + $table->bigInteger('amount')->default(0)->after('category')->comment('금액(MNG용)'); + } + if (!Schema::hasColumn('purchases', 'vat')) { + $table->bigInteger('vat')->default(0)->after('amount')->comment('부가세(MNG용)'); + } + if (!Schema::hasColumn('purchases', 'invoice_no')) { + $table->string('invoice_no', 50)->nullable()->after('vat')->comment('인보이스번호(MNG용)'); + } + if (!Schema::hasColumn('purchases', 'memo')) { + $table->text('memo')->nullable()->after('invoice_no')->comment('메모(MNG용)'); + } + }); + } + + public function down(): void + { + Schema::table('purchases', function (Blueprint $table) { + $columns = ['date', 'vendor', 'item', 'category', 'amount', 'vat', 'invoice_no', 'memo']; + foreach ($columns as $col) { + if (Schema::hasColumn('purchases', $col)) { + $table->dropColumn($col); + } + } + }); + } +}; diff --git a/database/migrations/2026_02_05_100000_create_vat_records_table.php b/database/migrations/2026_02_05_100000_create_vat_records_table.php new file mode 100644 index 0000000..a7a065d --- /dev/null +++ b/database/migrations/2026_02_05_100000_create_vat_records_table.php @@ -0,0 +1,37 @@ +id(); + $table->unsignedBigInteger('tenant_id'); + $table->string('period', 20); // 2026-1H, 2025-2H + $table->string('type', 20)->default('sales'); // sales, purchase + $table->string('partner_name', 100); // 거래처명 + $table->string('invoice_no', 50); // 세금계산서번호 + $table->date('invoice_date')->nullable(); // 발행일 + $table->bigInteger('supply_amount')->default(0); // 공급가액 + $table->bigInteger('vat_amount')->default(0); // 부가세 + $table->bigInteger('total_amount')->default(0); // 합계 + $table->string('status', 20)->default('pending');// pending, filed, paid + $table->text('memo')->nullable(); + $table->timestamps(); + $table->softDeletes(); + $table->index(['tenant_id', 'period']); + $table->index(['tenant_id', 'type']); + }); + } + + public function down(): void + { + Schema::dropIfExists('vat_records'); + } +}; diff --git a/database/migrations/2026_02_05_100001_create_daily_fund_transactions_table.php b/database/migrations/2026_02_05_100001_create_daily_fund_transactions_table.php new file mode 100644 index 0000000..5182169 --- /dev/null +++ b/database/migrations/2026_02_05_100001_create_daily_fund_transactions_table.php @@ -0,0 +1,36 @@ +id(); + $table->unsignedBigInteger('tenant_id'); + $table->date('transaction_date'); // 거래일 + $table->string('type', 20); // income, expense + $table->string('time', 10)->nullable(); // 시간 (HH:MM) + $table->unsignedBigInteger('account_id')->nullable(); // 계좌ID (corporate_cards 등과 연동 가능) + $table->string('account_name', 50)->nullable(); // 계좌/은행명 (간편 저장용) + $table->string('description', 200); // 적요 + $table->bigInteger('amount')->default(0); // 금액 + $table->string('category', 50)->nullable(); // 카테고리 + $table->string('note', 200)->nullable(); // 비고 + $table->timestamps(); + $table->softDeletes(); + $table->index(['tenant_id', 'transaction_date']); + $table->index(['tenant_id', 'type']); + }); + } + + public function down(): void + { + Schema::dropIfExists('daily_fund_transactions'); + } +}; diff --git a/database/migrations/2026_02_05_100002_create_daily_fund_memos_table.php b/database/migrations/2026_02_05_100002_create_daily_fund_memos_table.php new file mode 100644 index 0000000..36cf021 --- /dev/null +++ b/database/migrations/2026_02_05_100002_create_daily_fund_memos_table.php @@ -0,0 +1,28 @@ +id(); + $table->unsignedBigInteger('tenant_id'); + $table->date('memo_date')->comment('해당 날짜'); + $table->text('memo')->nullable(); + $table->string('author', 50)->nullable(); + $table->timestamps(); + $table->unique(['tenant_id', 'memo_date']); + }); + } + + public function down(): void + { + Schema::dropIfExists('daily_fund_memos'); + } +}; diff --git a/database/migrations/2026_02_05_100003_create_card_transactions_table.php b/database/migrations/2026_02_05_100003_create_card_transactions_table.php new file mode 100644 index 0000000..9a55734 --- /dev/null +++ b/database/migrations/2026_02_05_100003_create_card_transactions_table.php @@ -0,0 +1,36 @@ +id(); + $table->unsignedBigInteger('tenant_id'); + $table->unsignedBigInteger('card_id')->nullable(); // corporate_cards.id + $table->date('transaction_date'); // 거래일 + $table->string('time', 10)->nullable(); // 시간 (HH:MM) + $table->string('merchant', 200); // 가맹점명 + $table->string('category', 50)->nullable(); // 카테고리 + $table->bigInteger('amount')->default(0); // 금액 (음수=취소) + $table->string('approval_no', 50)->nullable(); // 승인번호 + $table->string('status', 20)->default('approved'); // approved, cancelled + $table->text('memo')->nullable(); + $table->timestamps(); + $table->softDeletes(); + $table->index(['tenant_id', 'transaction_date']); + $table->index(['tenant_id', 'card_id']); + }); + } + + public function down(): void + { + Schema::dropIfExists('card_transactions'); + } +};