# Generated by Django 5.2.12 on 2026-06-13 13:26

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


class Migration(migrations.Migration):

    dependencies = [
        ('invest', '0003_benchmarkprice'),
    ]

    operations = [
        migrations.AlterField(
            model_name='benchmarkprice',
            name='ticker',
            field=models.CharField(max_length=20),
        ),
        migrations.AlterField(
            model_name='benchmarkprice',
            name='close',
            field=models.DecimalField(decimal_places=6, max_digits=20),
        ),
        migrations.CreateModel(
            name='CashFlow',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('flow_type', models.CharField(choices=[('DEPOSIT', 'Deposit'), ('WITHDRAWAL', 'Withdrawal'), ('DIVIDEND', 'Dividend'), ('FEE', 'Fee'), ('INTEREST', 'Interest'), ('TRANSFER_IN', 'Transfer In'), ('TRANSFER_OUT', 'Transfer Out')], max_length=20)),
                ('amount', models.DecimalField(decimal_places=2, max_digits=20, validators=[django.core.validators.MinValueValidator(Decimal('0.01'))])),
                ('currency', models.CharField(default='USD', max_length=3)),
                ('date', models.DateField()),
                ('source', models.CharField(blank=True, default='', max_length=50)),
                ('note', models.TextField(blank=True, default='')),
                ('confidence', models.DecimalField(blank=True, decimal_places=4, max_digits=5, null=True, validators=[django.core.validators.MinValueValidator(Decimal('0')), django.core.validators.MaxValueValidator(Decimal('1'))])),
                ('created_at', models.DateTimeField(auto_now_add=True)),
            ],
            options={
                'ordering': ['-date', '-created_at'],
            },
        ),
        migrations.AddField(
            model_name='transaction',
            name='broker_trade_id',
            field=models.CharField(blank=True, default='', max_length=128),
        ),
        migrations.AddField(
            model_name='transaction',
            name='confidence',
            field=models.DecimalField(blank=True, decimal_places=4, max_digits=5, null=True, validators=[django.core.validators.MinValueValidator(Decimal('0')), django.core.validators.MaxValueValidator(Decimal('1'))]),
        ),
        migrations.AddField(
            model_name='transaction',
            name='currency',
            field=models.CharField(default='USD', max_length=3),
        ),
        migrations.AddField(
            model_name='transaction',
            name='fee',
            field=models.DecimalField(blank=True, decimal_places=6, help_text='Optional broker fee/commission in transaction currency.', max_digits=20, null=True, validators=[django.core.validators.MinValueValidator(Decimal('0'))]),
        ),
        migrations.AddField(
            model_name='transaction',
            name='price_per_share',
            field=models.DecimalField(blank=True, decimal_places=6, help_text='Optional execution price per share.', max_digits=20, null=True, validators=[django.core.validators.MinValueValidator(Decimal('0'))]),
        ),
        migrations.AddField(
            model_name='transaction',
            name='source',
            field=models.CharField(blank=True, default='', max_length=50),
        ),
        migrations.AddIndex(
            model_name='transaction',
            index=models.Index(fields=['portfolio', 'date'], name='invest_tran_portfol_962776_idx'),
        ),
        migrations.AddIndex(
            model_name='transaction',
            index=models.Index(fields=['stock_code', 'date'], name='invest_tran_stock_c_90351a_idx'),
        ),
        migrations.AddField(
            model_name='cashflow',
            name='portfolio',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='cashflows', to='invest.portfolio'),
        ),
        migrations.AddIndex(
            model_name='cashflow',
            index=models.Index(fields=['portfolio', 'date'], name='invest_cash_portfol_74c6cf_idx'),
        ),
        migrations.AddIndex(
            model_name='cashflow',
            index=models.Index(fields=['flow_type', 'date'], name='invest_cash_flow_ty_53c969_idx'),
        ),
    ]
