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

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


class Migration(migrations.Migration):

    dependencies = [
        ('billing', '0001_initial'),
        ('clients', '0001_initial'),
        ('core', '0001_initial'),
        ('services', '0001_initial'),
    ]

    operations = [
        migrations.CreateModel(
            name='HistoricalDocument',
            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=220, verbose_name='Título')),
                ('category', models.CharField(choices=[('contract', 'Contrato'), ('invoice', 'Fatura'), ('receipt', 'Recibo'), ('payment_proof', 'Comprovativo'), ('domain', 'Documento de domínio'), ('technical', 'Documento técnico'), ('report', 'Relatório'), ('other', 'Outro')], db_index=True, default='other', max_length=25, verbose_name='Categoria')),
                ('file', models.TextField(blank=True, max_length=100, verbose_name='Ficheiro')),
                ('issued_on', models.DateField(blank=True, null=True, verbose_name='Data do documento')),
                ('expires_on', models.DateField(blank=True, db_index=True, null=True, verbose_name='Válido até')),
                ('reference', models.CharField(blank=True, max_length=150, verbose_name='Referência')),
                ('visible_to_client', models.BooleanField(default=False, verbose_name='Visível na futura área do cliente')),
                ('notes', models.TextField(blank=True, verbose_name='Notas')),
                ('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)),
            ],
            options={
                'verbose_name': 'historical Documento',
                'verbose_name_plural': 'historical Documentos',
                'ordering': ('-history_date', '-history_id'),
                'get_latest_by': ('history_date', 'history_id'),
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
        migrations.CreateModel(
            name='Document',
            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=220, verbose_name='Título')),
                ('category', models.CharField(choices=[('contract', 'Contrato'), ('invoice', 'Fatura'), ('receipt', 'Recibo'), ('payment_proof', 'Comprovativo'), ('domain', 'Documento de domínio'), ('technical', 'Documento técnico'), ('report', 'Relatório'), ('other', 'Outro')], db_index=True, default='other', max_length=25, verbose_name='Categoria')),
                ('file', models.FileField(blank=True, upload_to='documents/%Y/%m/', verbose_name='Ficheiro')),
                ('issued_on', models.DateField(blank=True, null=True, verbose_name='Data do documento')),
                ('expires_on', models.DateField(blank=True, db_index=True, null=True, verbose_name='Válido até')),
                ('reference', models.CharField(blank=True, max_length=150, verbose_name='Referência')),
                ('visible_to_client', models.BooleanField(default=False, verbose_name='Visível na futura área do cliente')),
                ('notes', models.TextField(blank=True, verbose_name='Notas')),
                ('client', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='documents', to='clients.client', verbose_name='Cliente')),
                ('payment', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='documents', to='billing.payment', verbose_name='Pagamento')),
                ('service', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='documents', to='services.service', verbose_name='Serviço')),
            ],
            options={
                'verbose_name': 'Documento',
                'verbose_name_plural': 'Documentos',
                'ordering': ['-issued_on', '-created_at'],
            },
        ),
    ]
