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

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('clients', '0001_initial'),
        ('core', '0001_initial'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='HistoricalService',
            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')),
                ('service_type', models.CharField(choices=[('domain', 'Domínio'), ('hosting', 'Alojamento web'), ('email', 'Email profissional'), ('ssl', 'Certificado SSL'), ('maintenance', 'Manutenção'), ('website', 'Website / projeto'), ('backup', 'Backup'), ('server', 'Servidor'), ('other', 'Outro')], db_index=True, max_length=20, verbose_name='Tipo de serviço')),
                ('name', models.CharField(max_length=180, verbose_name='Designação')),
                ('description', models.TextField(blank=True, verbose_name='Descrição')),
                ('status', models.CharField(choices=[('active', 'Ativo'), ('pending', 'Pendente'), ('overdue', 'Vencido'), ('cancelled', 'Cancelado'), ('suspended', 'Suspenso'), ('complimentary', 'Oferta'), ('transferred', 'Transferido'), ('client_direct', 'Pago diretamente pelo cliente'), ('archived', 'Arquivado')], db_index=True, default='active', max_length=25, verbose_name='Estado')),
                ('start_date', models.DateField(blank=True, null=True, verbose_name='Data de início')),
                ('next_renewal_date', models.DateField(blank=True, db_index=True, null=True, verbose_name='Próxima renovação')),
                ('billing_cycle', models.CharField(choices=[('none', 'Sem recorrência'), ('monthly', 'Mensal'), ('quarterly', 'Trimestral'), ('semiannual', 'Semestral'), ('annual', 'Anual'), ('biennial', 'Bianual'), ('custom', 'Outro')], default='annual', max_length=20, verbose_name='Periodicidade')),
                ('notice_days', models.PositiveSmallIntegerField(default=30, verbose_name='Avisar com antecedência (dias)')),
                ('cost_price', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=10, verbose_name='Preço de custo')),
                ('sale_price', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=10, verbose_name='Valor a cobrar')),
                ('tax_rate', models.DecimalField(decimal_places=2, default=Decimal('23.00'), max_digits=5, verbose_name='IVA (%)')),
                ('auto_renew', models.BooleanField(default=False, verbose_name='Renovação automática')),
                ('is_recurring', models.BooleanField(default=True, verbose_name='Serviço recorrente')),
                ('customer_pays_provider_directly', models.BooleanField(default=False, verbose_name='Pago diretamente pelo cliente')),
                ('is_complimentary', models.BooleanField(default=False, verbose_name='Oferta')),
                ('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)),
                ('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)),
                ('provider', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='core.provider', verbose_name='Fornecedor')),
            ],
            options={
                'verbose_name': 'historical Serviço',
                'verbose_name_plural': 'historical Serviços',
                'ordering': ('-history_date', '-history_id'),
                'get_latest_by': ('history_date', 'history_id'),
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
        migrations.CreateModel(
            name='Service',
            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')),
                ('service_type', models.CharField(choices=[('domain', 'Domínio'), ('hosting', 'Alojamento web'), ('email', 'Email profissional'), ('ssl', 'Certificado SSL'), ('maintenance', 'Manutenção'), ('website', 'Website / projeto'), ('backup', 'Backup'), ('server', 'Servidor'), ('other', 'Outro')], db_index=True, max_length=20, verbose_name='Tipo de serviço')),
                ('name', models.CharField(max_length=180, verbose_name='Designação')),
                ('description', models.TextField(blank=True, verbose_name='Descrição')),
                ('status', models.CharField(choices=[('active', 'Ativo'), ('pending', 'Pendente'), ('overdue', 'Vencido'), ('cancelled', 'Cancelado'), ('suspended', 'Suspenso'), ('complimentary', 'Oferta'), ('transferred', 'Transferido'), ('client_direct', 'Pago diretamente pelo cliente'), ('archived', 'Arquivado')], db_index=True, default='active', max_length=25, verbose_name='Estado')),
                ('start_date', models.DateField(blank=True, null=True, verbose_name='Data de início')),
                ('next_renewal_date', models.DateField(blank=True, db_index=True, null=True, verbose_name='Próxima renovação')),
                ('billing_cycle', models.CharField(choices=[('none', 'Sem recorrência'), ('monthly', 'Mensal'), ('quarterly', 'Trimestral'), ('semiannual', 'Semestral'), ('annual', 'Anual'), ('biennial', 'Bianual'), ('custom', 'Outro')], default='annual', max_length=20, verbose_name='Periodicidade')),
                ('notice_days', models.PositiveSmallIntegerField(default=30, verbose_name='Avisar com antecedência (dias)')),
                ('cost_price', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=10, verbose_name='Preço de custo')),
                ('sale_price', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=10, verbose_name='Valor a cobrar')),
                ('tax_rate', models.DecimalField(decimal_places=2, default=Decimal('23.00'), max_digits=5, verbose_name='IVA (%)')),
                ('auto_renew', models.BooleanField(default=False, verbose_name='Renovação automática')),
                ('is_recurring', models.BooleanField(default=True, verbose_name='Serviço recorrente')),
                ('customer_pays_provider_directly', models.BooleanField(default=False, verbose_name='Pago diretamente pelo cliente')),
                ('is_complimentary', models.BooleanField(default=False, verbose_name='Oferta')),
                ('internal_notes', models.TextField(blank=True, verbose_name='Observações internas')),
                ('client', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='services', to='clients.client', verbose_name='Cliente')),
                ('provider', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='services', to='core.provider', verbose_name='Fornecedor')),
            ],
            options={
                'verbose_name': 'Serviço',
                'verbose_name_plural': 'Serviços',
                'ordering': ['next_renewal_date', 'client__name', 'name'],
                'indexes': [models.Index(fields=['status', 'next_renewal_date'], name='services_se_status_6e5913_idx'), models.Index(fields=['client', 'service_type'], name='services_se_client__185e65_idx')],
            },
        ),
    ]
