# Generated by Django 5.2.16 on 2026-07-31 12:51

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('agreements', '0001_initial'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='AgreementPageTemplate',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=255)),
                ('html_template', models.TextField()),
                ('css_template', models.TextField(blank=True, null=True)),
                ('is_default', models.BooleanField(default=False)),
            ],
        ),
        migrations.RenameField(
            model_name='paymentsection',
            old_name='total_amount',
            new_name='subtotal',
        ),
        migrations.RemoveField(
            model_name='agreementtemplate',
            name='structure',
        ),
        migrations.RemoveField(
            model_name='timelinephase',
            name='duration_days',
        ),
        migrations.AddField(
            model_name='paymentsection',
            name='discount_amount',
            field=models.DecimalField(decimal_places=2, default=0, max_digits=12),
        ),
        migrations.AddField(
            model_name='paymentsection',
            name='final_payable',
            field=models.DecimalField(decimal_places=2, default=0, max_digits=12),
        ),
        migrations.AddField(
            model_name='paymentsection',
            name='finalized',
            field=models.BooleanField(default=False),
        ),
        migrations.AddField(
            model_name='paymentsection',
            name='grand_total',
            field=models.DecimalField(decimal_places=2, default=0, max_digits=12),
        ),
        migrations.AddField(
            model_name='paymentsection',
            name='gst_amount',
            field=models.DecimalField(decimal_places=2, default=0, max_digits=12),
        ),
        migrations.AddField(
            model_name='paymentsection',
            name='tds_amount',
            field=models.DecimalField(decimal_places=2, default=0, max_digits=12),
        ),
        migrations.AddField(
            model_name='responsibilitynode',
            name='node_type',
            field=models.CharField(choices=[('SECTION', 'Section'), ('SUBSECTION', 'Sub Section'), ('ITEM', 'Item')], default='SECTION', max_length=20),
        ),
        migrations.AddField(
            model_name='scopenode',
            name='node_type',
            field=models.CharField(choices=[('SECTION', 'Section'), ('SUBSECTION', 'Sub Section'), ('FEATURE', 'Feature')], default='SECTION', max_length=20),
        ),
        migrations.AddField(
            model_name='signature',
            name='browser_info',
            field=models.CharField(blank=True, max_length=255, null=True),
        ),
        migrations.AddField(
            model_name='signature',
            name='device_info',
            field=models.CharField(blank=True, max_length=255, null=True),
        ),
        migrations.AddField(
            model_name='signature',
            name='ip_address',
            field=models.GenericIPAddressField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name='signature',
            name='location',
            field=models.CharField(blank=True, max_length=255, null=True),
        ),
        migrations.AddField(
            model_name='signature',
            name='signed_time',
            field=models.DateTimeField(blank=True, null=True),
        ),
        migrations.AlterField(
            model_name='agreement',
            name='status',
            field=models.CharField(choices=[('DRAFT', 'Draft'), ('REVIEW', 'Review'), ('SENT', 'Sent'), ('VIEWED', 'Viewed'), ('REVISION_REQUESTED', 'Revision Requested'), ('APPROVED', 'Approved'), ('SIGNED', 'Signed'), ('ARCHIVED', 'Archived')], default='DRAFT', max_length=20),
        ),
        migrations.CreateModel(
            name='AgreementAttachment',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('file', models.FileField(upload_to='agreement_attachments/')),
                ('description', models.CharField(blank=True, max_length=255, null=True)),
                ('uploaded_at', models.DateTimeField(auto_now_add=True)),
                ('agreement', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='attachments', to='agreements.agreement')),
            ],
        ),
        migrations.CreateModel(
            name='AgreementHistory',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('action', models.CharField(choices=[('CREATED', 'Created'), ('EDITED', 'Edited'), ('STATUS_CHANGED', 'Status Changed'), ('VIEWED', 'Viewed'), ('DOWNLOADED', 'Downloaded'), ('SIGNED', 'Signed'), ('APPROVED', 'Approved')], max_length=20)),
                ('timestamp', models.DateTimeField(auto_now_add=True)),
                ('details', models.JSONField(blank=True, default=dict)),
                ('agreement', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='history', to='agreements.agreement')),
                ('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='AgreementPage',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('rendered_html', models.TextField(blank=True, null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('agreement', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='pages', to='agreements.agreement')),
                ('page_template', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='agreements.agreementpagetemplate')),
            ],
        ),
        migrations.CreateModel(
            name='TemplateSection',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('section_type', models.CharField(max_length=50)),
                ('data', models.JSONField(default=dict)),
                ('order', models.PositiveIntegerField()),
                ('template', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='sections', to='agreements.agreementtemplate')),
            ],
            options={
                'ordering': ['order'],
            },
        ),
    ]
