選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

2024_11_27_221657_create_bills_table.php 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. use Illuminate\Database\Migrations\Migration;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Support\Facades\Schema;
  5. return new class extends Migration
  6. {
  7. /**
  8. * Run the migrations.
  9. */
  10. public function up(): void
  11. {
  12. Schema::create('bills', function (Blueprint $table) {
  13. $table->id();
  14. $table->foreignId('company_id')->constrained()->cascadeOnDelete();
  15. $table->foreignId('vendor_id')->nullable()->constrained('vendors')->nullOnDelete();
  16. $table->string('bill_number')->nullable();
  17. $table->string('order_number')->nullable(); // PO, SO, etc.
  18. $table->date('date')->nullable();
  19. $table->date('due_date')->nullable();
  20. $table->timestamp('paid_at')->nullable();
  21. $table->string('status')->default('open');
  22. $table->string('currency_code')->nullable();
  23. $table->string('discount_method')->default('per_line_item');
  24. $table->string('discount_computation')->default('percentage');
  25. $table->bigInteger('discount_rate')->default(0);
  26. $table->bigInteger('subtotal')->default(0);
  27. $table->bigInteger('tax_total')->default(0);
  28. $table->bigInteger('discount_total')->default(0);
  29. $table->bigInteger('total')->default(0);
  30. $table->bigInteger('amount_paid')->default(0);
  31. $table->bigInteger('amount_due')->storedAs('total - amount_paid');
  32. $table->text('notes')->nullable();
  33. $table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete();
  34. $table->foreignId('updated_by')->nullable()->constrained('users')->nullOnDelete();
  35. $table->timestamps();
  36. });
  37. }
  38. /**
  39. * Reverse the migrations.
  40. */
  41. public function down(): void
  42. {
  43. Schema::dropIfExists('bills');
  44. }
  45. };