# Generated by Django 5.2.11 on 2026-05-17 15:18

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


class Migration(migrations.Migration):

    dependencies = [
        ('property_manager_app', '0004_managedproperty_estimate_generated_at_and_more'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='PropertyCarePlan',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('plan_status', models.CharField(choices=[('draft', 'Draft'), ('finalized', 'Finalized'), ('superseded', 'Superseded')], default='draft', max_length=30)),
                ('provisional_estimate_snapshot_usd', models.DecimalField(blank=True, decimal_places=2, help_text='Snapshot of the calculator estimate available when the care plan was prepared.', max_digits=12, null=True)),
                ('final_monthly_fee_usd', models.DecimalField(blank=True, decimal_places=2, help_text='Final approved recurring monthly care fee calculated from included plan service lines.', max_digits=12, null=True)),
                ('start_date', models.DateField(blank=True, help_text='Approved service start date.', null=True)),
                ('general_exclusions', models.TextField(blank=True, help_text='General exclusions that apply to the finalized care plan.')),
                ('plan_notes', models.TextField(blank=True, help_text='Final plan notes, internal operational guidance, or owner-facing plan remarks.')),
                ('finalized_at', models.DateTimeField(blank=True, null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('created_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='created_property_care_plans', to=settings.AUTH_USER_MODEL)),
                ('finalized_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='finalized_property_care_plans', to=settings.AUTH_USER_MODEL)),
                ('property', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='care_plan', to='property_manager_app.managedproperty')),
                ('updated_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='updated_property_care_plans', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'Property Care Plan',
                'verbose_name_plural': 'Property Care Plans',
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='PropertyCarePlanServiceLine',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('is_included', models.BooleanField(default=True)),
                ('final_frequency', models.CharField(choices=[('one_time', 'One-Time / As Needed'), ('monthly_once', 'Once per Month'), ('monthly_twice', 'Twice per Month'), ('weekly_once', 'Once per Week'), ('weekly_twice', 'Twice per Week'), ('custom', 'Custom Frequency')], default='monthly_once', max_length=30)),
                ('final_visits_per_month', models.PositiveIntegerField(default=1)),
                ('final_monthly_amount_usd', models.DecimalField(decimal_places=2, default=0, max_digits=12)),
                ('line_note', models.TextField(blank=True, help_text='Staff note explaining how this service is included or handled.')),
                ('exclusion_reason', models.TextField(blank=True, help_text='Reason this owner-requested service was excluded, if not included.')),
                ('display_order', models.PositiveIntegerField(default=0)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('plan', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='service_lines', to='property_manager_app.propertycareplan')),
                ('service_type', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='care_plan_service_lines', to='property_manager_app.maintenanceservicetype')),
                ('source_selection', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='care_plan_lines', to='property_manager_app.propertyserviceselection')),
            ],
            options={
                'verbose_name': 'Property Care Plan Service Line',
                'verbose_name_plural': 'Property Care Plan Service Lines',
                'ordering': ['display_order', 'service_type__name'],
                'constraints': [models.UniqueConstraint(fields=('plan', 'service_type'), name='unique_service_type_per_property_care_plan')],
            },
        ),
    ]
