# Generated by Django 4.2.7 on 2026-05-04 08:47

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


class Migration(migrations.Migration):

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('tenancy', '0004_tenantlicense'),
        ('customers', '0003_supportticket_supportticketmessage_and_more'),
    ]

    operations = [
        migrations.CreateModel(
            name='Creditor',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=200)),
                ('code', models.CharField(blank=True, max_length=60, null=True)),
                ('type', models.CharField(choices=[('company', 'Entreprise'), ('individual', 'Particulier')], default='company', max_length=12)),
                ('email', models.EmailField(blank=True, max_length=254, null=True)),
                ('phone', models.CharField(blank=True, max_length=40, null=True)),
                ('country', models.CharField(blank=True, max_length=2, null=True)),
                ('city', models.CharField(blank=True, max_length=120, null=True)),
                ('address', models.CharField(blank=True, max_length=255, null=True)),
                ('tax_id', models.CharField(blank=True, max_length=80, null=True)),
                ('is_active', models.BooleanField(default=True)),
                ('notes', models.TextField(blank=True, default='')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('client', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='creditors', to='customers.customer')),
                ('created_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='created_creditors', to=settings.AUTH_USER_MODEL)),
                ('tenant', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='creditors', to='tenancy.tenant')),
            ],
            options={
                'ordering': ['name'],
            },
        ),
        migrations.AddConstraint(
            model_name='creditor',
            constraint=models.UniqueConstraint(fields=('tenant', 'name'), name='uniq_creditor_tenant_name'),
        ),
    ]
