Files
MoneyFlix/crm/Core/Database/Migrations/CreateInvoicesTable.php
T
1sonhador 9d43854277 feat: Initial MoneyFlix project setup
- Created separate MoneyFlix project directory
- Copied Node.js redirector from production server
- Added CRM PHP code (Redirects module, Core classes, Config, Routes, Views)
- Created comprehensive documentation (README_MONEYFLIX.md)
- Added sync script to keep CRM code updated (sync-from-crm.sh)
- Configured .gitignore for Node.js and PHP
- Set up proper project structure for multi-client isolation

This separates MoneyFlix from the main CRM to avoid confusion
between different client systems and provides a dedicated
environment for MoneyFlix-specific development and maintenance.
2025-10-03 12:09:41 +01:00

49 lines
2.0 KiB
PHP

<?php
namespace App\Core\Database\Migrations;
use App\Core\Database\Migration;
class CreateInvoicesTable extends Migration
{
/**
* The name of the database connection to use.
* Uses default CRM database for invoices
*/
protected ?string $connection = null; // CRM database (default)
public function up(): void
{
$this->createTable('invoices', function($table) {
$table->bigInteger('id')->autoIncrement()->notNull();
$table->string('invoice_number', 50)->notNull()->unique();
$table->string('customer_name', 255)->notNull();
$table->string('customer_email', 255)->nullable();
$table->decimal('amount', 10, 2)->notNull();
$table->decimal('tax_amount', 10, 2)->default(0.00)->notNull();
$table->decimal('total_amount', 10, 2)->notNull();
$table->enum('status', ['draft', 'pending', 'paid', 'cancelled', 'refunded'])->default('draft')->notNull();
$table->enum('currency', ['EUR', 'USD', 'GBP'])->default('EUR')->notNull();
$table->date('due_date')->nullable();
$table->date('paid_date')->nullable();
$table->text('notes')->nullable();
$table->json('items')->nullable(); // Array de itens da fatura
$table->string('payment_method', 100)->nullable();
$table->string('payment_reference', 255)->nullable();
$table->bigInteger('created_by')->nullable();
$table->timestamp('created_at')->default('CURRENT_TIMESTAMP')->notNull();
$table->timestamp('updated_at')->default('CURRENT_TIMESTAMP')->notNull();
$table->timestamp('deleted_at')->nullable();
$table->primaryKey('id');
$table->index(['status', 'due_date']);
$table->index(['customer_email']);
$table->index(['created_by']);
});
}
public function down(): void
{
$this->dropTable('invoices');
}
}