# Generated by Django 5.0 on 2026-03-17 08:49

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


class Migration(migrations.Migration):

    dependencies = [
        ('fertilizer', '0007_delivery_models'),
        ('fields', '0006_e1c_chusankan_17_fields'),
    ]

    operations = [
        migrations.CreateModel(
            name='SpreadingSession',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('year', models.IntegerField(verbose_name='年度')),
                ('date', models.DateField(verbose_name='散布日')),
                ('name', models.CharField(blank=True, max_length=100, verbose_name='名前')),
                ('notes', models.TextField(blank=True, default='', verbose_name='備考')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
            ],
            options={
                'verbose_name': '散布実績',
                'verbose_name_plural': '散布実績',
                'ordering': ['-date', '-id'],
            },
        ),
        migrations.AddField(
            model_name='fertilizationentry',
            name='actual_bags',
            field=models.DecimalField(blank=True, decimal_places=4, max_digits=10, null=True, verbose_name='実績袋数'),
        ),
        migrations.CreateModel(
            name='SpreadingSessionItem',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('actual_bags', models.DecimalField(decimal_places=4, max_digits=10, verbose_name='実散布袋数')),
                ('planned_bags_snapshot', models.DecimalField(decimal_places=4, max_digits=10, verbose_name='計画袋数スナップショット')),
                ('delivered_bags_snapshot', models.DecimalField(decimal_places=4, max_digits=10, verbose_name='運搬済み袋数スナップショット')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('fertilizer', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='fertilizer.fertilizer', verbose_name='肥料')),
                ('field', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='fields.field', verbose_name='圃場')),
                ('session', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='items', to='fertilizer.spreadingsession', verbose_name='散布実績')),
            ],
            options={
                'verbose_name': '散布実績明細',
                'verbose_name_plural': '散布実績明細',
                'ordering': ['field__display_order', 'field__id', 'fertilizer__name'],
                'unique_together': {('session', 'field', 'fertilizer')},
            },
        ),
    ]
