# Generated by Django 5.2.9 on 2025-12-19 18:20

import django.core.validators
import django.db.models.deletion
from decimal import Decimal
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('billing', '0017_add_history_tracking'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.RemoveField(
            model_name='creditcostconfig',
            name='credits_cost',
        ),
        migrations.RemoveField(
            model_name='creditcostconfig',
            name='previous_cost',
        ),
        migrations.RemoveField(
            model_name='creditcostconfig',
            name='unit',
        ),
        migrations.RemoveField(
            model_name='historicalcreditcostconfig',
            name='credits_cost',
        ),
        migrations.RemoveField(
            model_name='historicalcreditcostconfig',
            name='previous_cost',
        ),
        migrations.RemoveField(
            model_name='historicalcreditcostconfig',
            name='unit',
        ),
        migrations.AddField(
            model_name='creditcostconfig',
            name='min_credits',
            field=models.IntegerField(default=1, help_text='Minimum credits to charge regardless of token usage', validators=[django.core.validators.MinValueValidator(0)]),
        ),
        migrations.AddField(
            model_name='creditcostconfig',
            name='previous_tokens_per_credit',
            field=models.IntegerField(blank=True, help_text='Tokens per credit before last update (for audit trail)', null=True),
        ),
        migrations.AddField(
            model_name='creditcostconfig',
            name='price_per_credit_usd',
            field=models.DecimalField(decimal_places=4, default=Decimal('0.01'), help_text='USD price per credit (for revenue reporting)', max_digits=10, validators=[django.core.validators.MinValueValidator(Decimal('0.0001'))]),
        ),
        migrations.AddField(
            model_name='creditcostconfig',
            name='tokens_per_credit',
            field=models.IntegerField(default=100, help_text='Number of tokens that equal 1 credit (e.g., 100 tokens = 1 credit)', validators=[django.core.validators.MinValueValidator(1)]),
        ),
        migrations.AddField(
            model_name='historicalcreditcostconfig',
            name='min_credits',
            field=models.IntegerField(default=1, help_text='Minimum credits to charge regardless of token usage', validators=[django.core.validators.MinValueValidator(0)]),
        ),
        migrations.AddField(
            model_name='historicalcreditcostconfig',
            name='previous_tokens_per_credit',
            field=models.IntegerField(blank=True, help_text='Tokens per credit before last update (for audit trail)', null=True),
        ),
        migrations.AddField(
            model_name='historicalcreditcostconfig',
            name='price_per_credit_usd',
            field=models.DecimalField(decimal_places=4, default=Decimal('0.01'), help_text='USD price per credit (for revenue reporting)', max_digits=10, validators=[django.core.validators.MinValueValidator(Decimal('0.0001'))]),
        ),
        migrations.AddField(
            model_name='historicalcreditcostconfig',
            name='tokens_per_credit',
            field=models.IntegerField(default=100, help_text='Number of tokens that equal 1 credit (e.g., 100 tokens = 1 credit)', validators=[django.core.validators.MinValueValidator(1)]),
        ),
        migrations.CreateModel(
            name='BillingConfiguration',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('default_tokens_per_credit', models.IntegerField(default=100, help_text='Default: How many tokens equal 1 credit (e.g., 100)', validators=[django.core.validators.MinValueValidator(1)])),
                ('default_credit_price_usd', models.DecimalField(decimal_places=4, default=Decimal('0.01'), help_text='Default price per credit in USD', max_digits=10, validators=[django.core.validators.MinValueValidator(Decimal('0.0001'))])),
                ('enable_token_based_reporting', models.BooleanField(default=True, help_text='Show token metrics in all reports')),
                ('credit_rounding_mode', models.CharField(choices=[('up', 'Round Up'), ('down', 'Round Down'), ('nearest', 'Round to Nearest')], default='up', help_text='How to round fractional credits', max_length=10)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('updated_by', models.ForeignKey(blank=True, help_text='Admin who last updated', null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'Billing Configuration',
                'verbose_name_plural': 'Billing Configuration',
                'db_table': 'igny8_billing_configuration',
            },
        ),
    ]
