53 lines
1.9 KiB
PHP
53 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
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('invoices', function (Blueprint $table): void {
|
|
$table->id();
|
|
$table->foreignId('client_id')->nullable()->constrained()->nullOnDelete();
|
|
$table->string('invoice_number')->unique();
|
|
$table->string('title');
|
|
$table->text('description')->nullable();
|
|
$table->decimal('subtotal', 15, 2)->default(0);
|
|
$table->decimal('tax_rate', 5, 2)->default(11); // PPN Indonesia 11%
|
|
$table->decimal('tax_amount', 15, 2)->default(0);
|
|
$table->decimal('total', 15, 2)->default(0);
|
|
$table->string('currency')->default('IDR');
|
|
$table->string('status')->default('draft'); // draft, sent, paid, overdue, cancelled
|
|
$table->date('issue_date');
|
|
$table->date('due_date');
|
|
$table->date('paid_date')->nullable();
|
|
$table->text('notes')->nullable();
|
|
$table->string('bank_name')->nullable();
|
|
$table->string('bank_account')->nullable();
|
|
$table->string('bank_holder')->nullable();
|
|
$table->timestamps();
|
|
$table->softDeletes();
|
|
});
|
|
|
|
Schema::create('invoice_items', function (Blueprint $table): void {
|
|
$table->id();
|
|
$table->foreignId('invoice_id')->constrained()->cascadeOnDelete();
|
|
$table->string('description');
|
|
$table->integer('quantity')->default(1);
|
|
$table->decimal('unit_price', 15, 2);
|
|
$table->decimal('total', 15, 2);
|
|
$table->timestamps();
|
|
});
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('invoice_items');
|
|
Schema::dropIfExists('invoices');
|
|
}
|
|
};
|