Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

2024_11_27_221657_create_bills_table.php 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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->string('status')->default('draft');
  21. $table->string('currency_code')->nullable();
  22. $table->integer('subtotal')->default(0);
  23. $table->integer('tax_total')->default(0);
  24. $table->integer('discount_total')->default(0);
  25. $table->integer('total')->default(0);
  26. $table->integer('amount_paid')->default(0);
  27. $table->integer('amount_due')->storedAs('total - amount_paid');
  28. $table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete();
  29. $table->foreignId('updated_by')->nullable()->constrained('users')->nullOnDelete();
  30. $table->timestamps();
  31. });
  32. }
  33. /**
  34. * Reverse the migrations.
  35. */
  36. public function down(): void
  37. {
  38. Schema::dropIfExists('bills');
  39. }
  40. };