# Generated by Django 5.0.12 on 2025-11-11 10:16

import django_fsm
import django.db.models.deletion
from decimal import Decimal
from django.db import migrations, models
import django_fsm
from django.db import migrations

def migrate_status(apps, schema_editor):
    OrderProposal = apps.get_model("wbportfolio", "OrderProposal")
    OrderProposal.objects.filter(status="APPLIED").update(status="CONFIRMED")


class Migration(migrations.Migration):

    dependencies = [
        ('wbportfolio', '0091_remove_order_execution_confirmed_and_more'),
    ]

    operations = [
        migrations.AddField(
            model_name='order',
            name='quantization_error',
            field=models.DecimalField(decimal_places=8, default=Decimal('0'), max_digits=9, verbose_name='Quantization Error'),
        ),
        migrations.AlterField(
            model_name='orderproposal',
            name='status',
            field=django_fsm.FSMField(choices=[('DRAFT', 'Draft'), ('PENDING', 'Pending'), ('APPROVED', 'Approved'), ('DENIED', 'Denied'), ('EXECUTION', 'Execution'), ('APPLIED', 'Applied'), ('FAILED', 'Failed')], default='DRAFT', max_length=50, verbose_name='Status'),
        ),
        migrations.AlterField(
            model_name='orderproposal',
            name='status',
            field=django_fsm.FSMField(
                choices=[('DRAFT', 'Draft'), ('PENDING', 'Pending'), ('APPROVED', 'Approved'), ('DENIED', 'Denied'),
                         ('EXECUTION', 'Execution'), ('CONFIRMED', 'Confirmed'), ('FAILED', 'Failed')], default='DRAFT',
                max_length=50, verbose_name='Status'),
        ),
        migrations.AddField(
            model_name='order',
            name='execution_trade',
            field=models.OneToOneField(blank=True, help_text='The executed Trade', null=True,
                                       on_delete=django.db.models.deletion.SET_NULL, related_name='order',
                                       to='wbportfolio.trade'),
        ),
        migrations.RunPython(migrate_status),

    ]
