# Generated by Django 4.2.24 on 2025-09-30 08:47

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


class Migration(migrations.Migration):

    dependencies = [
        ('orgs', '0008_userprofile_address_line1_userprofile_address_line2_and_more'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('recycle_core', '0002_alter_pickuporder_options_alter_scraplisting_options_and_more'),
    ]

    operations = [
        migrations.CreateModel(
            name='MaterialEmissionFactor',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('unit', models.CharField(choices=[('kg', 'Kilogram'), ('lb', 'Pound'), ('pcs', 'Pieces')], default='kg', max_length=8)),
                ('kgco2e_per_unit', models.DecimalField(decimal_places=6, max_digits=16)),
                ('source', models.CharField(blank=True, max_length=255)),
                ('effective_from', models.DateField(blank=True, null=True)),
                ('effective_to', models.DateField(blank=True, null=True)),
                ('material', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='emission_factors', to='recycle_core.material')),
                ('organization', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='material_factors', to='orgs.organization')),
            ],
            options={
                'indexes': [models.Index(fields=['organization', 'material', 'unit'], name='recycle_cor_organiz_71d624_idx')],
            },
        ),
        migrations.CreateModel(
            name='CarbonEvent',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('quantity', models.DecimalField(decimal_places=3, max_digits=14)),
                ('unit', models.CharField(choices=[('kg', 'Kilogram'), ('lb', 'Pound'), ('pcs', 'Pieces')], default='kg', max_length=8)),
                ('kgco2e', models.DecimalField(decimal_places=6, max_digits=18)),
                ('event_date', models.DateTimeField(db_index=True, default=django.utils.timezone.now)),
                ('status', models.CharField(choices=[('pending', 'Pending'), ('approved', 'Approved'), ('rejected', 'Rejected')], db_index=True, default='pending', max_length=16)),
                ('approved_at', models.DateTimeField(blank=True, null=True)),
                ('notes', models.TextField(blank=True)),
                ('approved_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='approved_carbon_events', to=settings.AUTH_USER_MODEL)),
                ('material', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='recycle_core.material')),
                ('organization', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='carbon_events', to='orgs.organization')),
                ('weigh_line', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='carbon_events', to='recycle_core.weighline')),
                ('weigh_ticket', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='carbon_events', to='recycle_core.weighticket')),
            ],
            options={
                'indexes': [models.Index(fields=['organization', 'status'], name='recycle_cor_organiz_fad901_idx'), models.Index(fields=['organization', 'event_date'], name='recycle_cor_organiz_3206eb_idx')],
                'unique_together': {('weigh_line',)},
            },
        ),
        migrations.CreateModel(
            name='CarbonBalance',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('year', models.PositiveSmallIntegerField()),
                ('month', models.PositiveSmallIntegerField()),
                ('events_count', models.PositiveIntegerField(default=0)),
                ('approved_kgco2e', models.DecimalField(decimal_places=6, default=0, max_digits=18)),
                ('organization', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='carbon_balances', to='orgs.organization')),
            ],
            options={
                'indexes': [models.Index(fields=['organization', 'year', 'month'], name='recycle_cor_organiz_1160f2_idx')],
                'unique_together': {('organization', 'year', 'month')},
            },
        ),
    ]
