# Generated by Django 4.0.5 on 2023-03-09 22:14

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


class Migration(migrations.Migration):

    dependencies = [
        ('metering_billing', '0224_remove_planversion_unique_plan_version_and_more'),
    ]

    operations = [
        migrations.RemoveField(
            model_name='recurringcharge',
            name='plan_component',
        ),
        migrations.AlterField(
            model_name='invoicelineitem',
            name='chargeable_item_type',
            field=models.CharField(blank=True, choices=[('usage_charge', 'Usage Charge'), ('prepaid_usage_charge', 'Prepaid Usage Charge'), ('recurring_charge', 'Recurring Charge'), ('one_time_charge', 'One Time Charge'), ('plan_adjustment', 'Plan Adjustment'), ('customer_adjustment', 'Customer Adjustment'), ('tax', 'Tax')], max_length=40, null=True),
        ),
        migrations.CreateModel(
            name='ComponentFixedCharge',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('units', models.DecimalField(blank=True, decimal_places=10, max_digits=20, null=True, validators=[django.core.validators.MinValueValidator(0)])),
                ('charge_behavior', models.PositiveSmallIntegerField(choices=[(1, 'prorate'), (2, 'full')], default=1)),
                ('organization', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='component_charges', to='metering_billing.organization')),
            ],
        ),
        migrations.CreateModel(
            name='ComponentChargeRecord',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('start_date', models.DateTimeField()),
                ('end_date', models.DateTimeField()),
                ('units', models.DecimalField(decimal_places=10, max_digits=20, validators=[django.core.validators.MinValueValidator(Decimal('0'))])),
                ('fully_billed', models.BooleanField(default=False)),
                ('billing_record', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='component_charge_records', to='metering_billing.billingrecord')),
                ('component', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='component_charge_records', to='metering_billing.plancomponent')),
                ('component_charge', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='component_charge_records', to='metering_billing.componentfixedcharge')),
                ('organization', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='component_charge_records', to='metering_billing.organization')),
            ],
        ),
        migrations.AddField(
            model_name='plancomponent',
            name='fixed_charge',
            field=models.OneToOneField(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='component', to='metering_billing.componentfixedcharge'),
        ),
    ]
