Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

2024_11_27_221657_create_bills_table.php 1.8KB

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('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('unpaid');
  22. $table->string('currency_code')->nullable();
  23. $table->string('discount_method')->default('per_line_item');
  24. $table->string('discount_computation')->default('percentage');
  25. $table->integer('discount_rate')->default(0);
  26. $table->integer('subtotal')->default(0);
  27. $table->integer('tax_total')->default(0);
  28. $table->integer('discount_total')->default(0);
  29. $table->integer('total')->default(0);
  30. $table->integer('amount_paid')->default(0);
  31. $table->integer('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. };