# Generated by Django 5.2.15 on 2026-06-15 08:28

import django.db.models.deletion
import simple_history.models
import uuid
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Client',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('public_id', models.UUIDField(default=uuid.uuid4, editable=False, unique=True)),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Criado em')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='Atualizado em')),
                ('client_type', models.CharField(choices=[('person', 'Particular'), ('company', 'Empresa / organização')], default='company', max_length=15, verbose_name='Tipo')),
                ('name', models.CharField(max_length=180, verbose_name='Nome / designação')),
                ('legal_name', models.CharField(blank=True, max_length=180, verbose_name='Nome fiscal')),
                ('nif', models.CharField(blank=True, db_index=True, max_length=20, verbose_name='NIF')),
                ('email', models.EmailField(blank=True, db_index=True, max_length=254, verbose_name='Email principal')),
                ('alternative_email', models.EmailField(blank=True, max_length=254, verbose_name='Email alternativo')),
                ('phone', models.CharField(blank=True, db_index=True, max_length=40, verbose_name='Telefone')),
                ('address', models.TextField(blank=True, verbose_name='Morada')),
                ('status', models.CharField(choices=[('active', 'Ativo'), ('inactive', 'Inativo'), ('debt', 'Com dívida'), ('former', 'Cliente antigo'), ('special', 'Cliente especial')], db_index=True, default='active', max_length=20, verbose_name='Estado')),
                ('preferred_payment_method', models.CharField(blank=True, choices=[('mbway', 'MB WAY'), ('bank_transfer', 'Transferência bancária'), ('cash', 'Dinheiro'), ('card', 'Cartão'), ('complimentary', 'Oferta'), ('client_direct', 'Pago diretamente pelo cliente'), ('other', 'Outro')], max_length=30, verbose_name='Pagamento preferido')),
                ('portal_access_enabled', models.BooleanField(default=False, verbose_name='Preparado para acesso ao portal')),
                ('internal_notes', models.TextField(blank=True, verbose_name='Observações internas')),
            ],
            options={
                'verbose_name': 'Cliente',
                'verbose_name_plural': 'Clientes',
                'ordering': ['name'],
                'indexes': [models.Index(fields=['status', 'name'], name='clients_cli_status_44bcec_idx')],
            },
        ),
        migrations.CreateModel(
            name='ClientContact',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('public_id', models.UUIDField(default=uuid.uuid4, editable=False, unique=True)),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Criado em')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='Atualizado em')),
                ('name', models.CharField(max_length=150, verbose_name='Nome')),
                ('role', models.CharField(blank=True, max_length=100, verbose_name='Função')),
                ('email', models.EmailField(blank=True, max_length=254, verbose_name='Email')),
                ('phone', models.CharField(blank=True, max_length=40, verbose_name='Telefone')),
                ('is_primary', models.BooleanField(default=False, verbose_name='Contacto principal')),
                ('receives_billing', models.BooleanField(default=True, verbose_name='Recebe avisos financeiros')),
                ('receives_technical', models.BooleanField(default=False, verbose_name='Recebe avisos técnicos')),
                ('client', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='contacts', to='clients.client', verbose_name='Cliente')),
            ],
            options={
                'verbose_name': 'Contacto',
                'verbose_name_plural': 'Contactos',
                'ordering': ['-is_primary', 'name'],
            },
        ),
        migrations.CreateModel(
            name='ClientNote',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('public_id', models.UUIDField(default=uuid.uuid4, editable=False, unique=True)),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Criado em')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='Atualizado em')),
                ('title', models.CharField(max_length=150, verbose_name='Título')),
                ('body', models.TextField(verbose_name='Nota')),
                ('is_important', models.BooleanField(default=False, verbose_name='Importante')),
                ('client', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='notes', to='clients.client', verbose_name='Cliente')),
                ('created_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='client_notes', to=settings.AUTH_USER_MODEL, verbose_name='Criado por')),
            ],
            options={
                'verbose_name': 'Nota do cliente',
                'verbose_name_plural': 'Notas dos clientes',
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='HistoricalClient',
            fields=[
                ('id', models.BigIntegerField(auto_created=True, blank=True, db_index=True, verbose_name='ID')),
                ('public_id', models.UUIDField(db_index=True, default=uuid.uuid4, editable=False)),
                ('created_at', models.DateTimeField(blank=True, editable=False, verbose_name='Criado em')),
                ('updated_at', models.DateTimeField(blank=True, editable=False, verbose_name='Atualizado em')),
                ('client_type', models.CharField(choices=[('person', 'Particular'), ('company', 'Empresa / organização')], default='company', max_length=15, verbose_name='Tipo')),
                ('name', models.CharField(max_length=180, verbose_name='Nome / designação')),
                ('legal_name', models.CharField(blank=True, max_length=180, verbose_name='Nome fiscal')),
                ('nif', models.CharField(blank=True, db_index=True, max_length=20, verbose_name='NIF')),
                ('email', models.EmailField(blank=True, db_index=True, max_length=254, verbose_name='Email principal')),
                ('alternative_email', models.EmailField(blank=True, max_length=254, verbose_name='Email alternativo')),
                ('phone', models.CharField(blank=True, db_index=True, max_length=40, verbose_name='Telefone')),
                ('address', models.TextField(blank=True, verbose_name='Morada')),
                ('status', models.CharField(choices=[('active', 'Ativo'), ('inactive', 'Inativo'), ('debt', 'Com dívida'), ('former', 'Cliente antigo'), ('special', 'Cliente especial')], db_index=True, default='active', max_length=20, verbose_name='Estado')),
                ('preferred_payment_method', models.CharField(blank=True, choices=[('mbway', 'MB WAY'), ('bank_transfer', 'Transferência bancária'), ('cash', 'Dinheiro'), ('card', 'Cartão'), ('complimentary', 'Oferta'), ('client_direct', 'Pago diretamente pelo cliente'), ('other', 'Outro')], max_length=30, verbose_name='Pagamento preferido')),
                ('portal_access_enabled', models.BooleanField(default=False, verbose_name='Preparado para acesso ao portal')),
                ('internal_notes', models.TextField(blank=True, verbose_name='Observações internas')),
                ('history_id', models.AutoField(primary_key=True, serialize=False)),
                ('history_date', models.DateTimeField(db_index=True)),
                ('history_change_reason', models.CharField(max_length=100, null=True)),
                ('history_type', models.CharField(choices=[('+', 'Created'), ('~', 'Changed'), ('-', 'Deleted')], max_length=1)),
                ('history_user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'historical Cliente',
                'verbose_name_plural': 'historical Clientes',
                'ordering': ('-history_date', '-history_id'),
                'get_latest_by': ('history_date', 'history_id'),
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
        migrations.CreateModel(
            name='HistoricalClientContact',
            fields=[
                ('id', models.BigIntegerField(auto_created=True, blank=True, db_index=True, verbose_name='ID')),
                ('public_id', models.UUIDField(db_index=True, default=uuid.uuid4, editable=False)),
                ('created_at', models.DateTimeField(blank=True, editable=False, verbose_name='Criado em')),
                ('updated_at', models.DateTimeField(blank=True, editable=False, verbose_name='Atualizado em')),
                ('name', models.CharField(max_length=150, verbose_name='Nome')),
                ('role', models.CharField(blank=True, max_length=100, verbose_name='Função')),
                ('email', models.EmailField(blank=True, max_length=254, verbose_name='Email')),
                ('phone', models.CharField(blank=True, max_length=40, verbose_name='Telefone')),
                ('is_primary', models.BooleanField(default=False, verbose_name='Contacto principal')),
                ('receives_billing', models.BooleanField(default=True, verbose_name='Recebe avisos financeiros')),
                ('receives_technical', models.BooleanField(default=False, verbose_name='Recebe avisos técnicos')),
                ('history_id', models.AutoField(primary_key=True, serialize=False)),
                ('history_date', models.DateTimeField(db_index=True)),
                ('history_change_reason', models.CharField(max_length=100, null=True)),
                ('history_type', models.CharField(choices=[('+', 'Created'), ('~', 'Changed'), ('-', 'Deleted')], max_length=1)),
                ('client', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='clients.client', verbose_name='Cliente')),
                ('history_user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'historical Contacto',
                'verbose_name_plural': 'historical Contactos',
                'ordering': ('-history_date', '-history_id'),
                'get_latest_by': ('history_date', 'history_id'),
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
        migrations.CreateModel(
            name='HistoricalClientNote',
            fields=[
                ('id', models.BigIntegerField(auto_created=True, blank=True, db_index=True, verbose_name='ID')),
                ('public_id', models.UUIDField(db_index=True, default=uuid.uuid4, editable=False)),
                ('created_at', models.DateTimeField(blank=True, editable=False, verbose_name='Criado em')),
                ('updated_at', models.DateTimeField(blank=True, editable=False, verbose_name='Atualizado em')),
                ('title', models.CharField(max_length=150, verbose_name='Título')),
                ('body', models.TextField(verbose_name='Nota')),
                ('is_important', models.BooleanField(default=False, verbose_name='Importante')),
                ('history_id', models.AutoField(primary_key=True, serialize=False)),
                ('history_date', models.DateTimeField(db_index=True)),
                ('history_change_reason', models.CharField(max_length=100, null=True)),
                ('history_type', models.CharField(choices=[('+', 'Created'), ('~', 'Changed'), ('-', 'Deleted')], max_length=1)),
                ('client', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='clients.client', verbose_name='Cliente')),
                ('created_by', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to=settings.AUTH_USER_MODEL, verbose_name='Criado por')),
                ('history_user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'historical Nota do cliente',
                'verbose_name_plural': 'historical Notas dos clientes',
                'ordering': ('-history_date', '-history_id'),
                'get_latest_by': ('history_date', 'history_id'),
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
    ]
