# Generated by Django 5.2.8 on 2025-11-07 07:39

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


class Migration(migrations.Migration):

    initial = True

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

    operations = [
        migrations.CreateModel(
            name='Invoice',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('period_start', models.DateField()),
                ('period_end', models.DateField()),
                ('amount_plan_total', models.DecimalField(decimal_places=2, default=0, max_digits=12)),
                ('amount_overage_total', models.DecimalField(decimal_places=2, default=0, max_digits=12)),
                ('amount_adjustment', models.DecimalField(decimal_places=2, default=0, max_digits=12)),
                ('amount_total', models.DecimalField(decimal_places=2, default=0, max_digits=12)),
                ('status', models.CharField(choices=[('unpaid', '未支付'), ('paid', '已支付'), ('cancelled', '已取消')], default='unpaid', max_length=20)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('paid_at', models.DateTimeField(blank=True, null=True)),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='invoices', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': '账单',
                'verbose_name_plural': '账单',
                'ordering': ['-period_end'],
            },
        ),
        migrations.CreateModel(
            name='InvoiceItem',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('description', models.CharField(max_length=200)),
                ('quantity', models.DecimalField(decimal_places=3, default=0, max_digits=12)),
                ('unit_price', models.DecimalField(decimal_places=2, default=0, max_digits=12)),
                ('amount', models.DecimalField(decimal_places=2, default=0, max_digits=12)),
                ('domain', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='domains.domain')),
                ('invoice', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='items', to='billing.invoice')),
            ],
            options={
                'verbose_name': '账单项',
                'verbose_name_plural': '账单项',
            },
        ),
    ]
