# Generated by Django 5.0.7 on 2026-08-31 12:17

import django.db.models.deletion
import django.utils.timezone
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('shop_management', '0077_daily_diary_entry'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='DailyDiaryLog',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_at', models.DateTimeField(auto_now_add=True, null=True)),
                ('updated_at', models.DateTimeField(auto_now=True, null=True)),
                ('entry_date', models.DateField(default=django.utils.timezone.localdate)),
                ('entry_datetime', models.DateTimeField(default=django.utils.timezone.now)),
                ('activity_type', models.CharField(choices=[('manual', 'Manual'), ('purchase', 'Purchase'), ('sale', 'Sale'), ('quotation', 'Quotation'), ('sale_payment', 'Sale Payment'), ('purchase_payment', 'Purchase Payment'), ('customer_payment', 'Customer Payment'), ('supplier_payment', 'Supplier Payment'), ('stock_transfer', 'Stock Transfer'), ('expense', 'Expense'), ('sale_return', 'Sale Return'), ('purchase_return', 'Purchase Return'), ('payroll', 'Payroll'), ('advance', 'Advance'), ('passive_income', 'Passive Income')], default='manual', max_length=32)),
                ('source_model', models.CharField(blank=True, default='', max_length=64)),
                ('source_id', models.PositiveIntegerField(blank=True, null=True)),
                ('title', models.CharField(max_length=255)),
                ('party', models.CharField(blank=True, default='', max_length=255)),
                ('amount', models.DecimalField(blank=True, decimal_places=2, max_digits=18, null=True)),
                ('description', models.TextField(blank=True, default='')),
                ('is_auto', models.BooleanField(default=False)),
                ('is_deleted', models.BooleanField(default=False)),
                ('created_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(class)s_created', to=settings.AUTH_USER_MODEL)),
                ('currency', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='daily_diary_logs', to='shop_management.currency')),
                ('shop', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='daily_diary_logs', to='shop_management.shop')),
            ],
            options={
                'ordering': ['-entry_datetime', '-id'],
                'indexes': [models.Index(fields=['shop', 'entry_date'], name='shop_manage_shop_id_717499_idx'), models.Index(fields=['activity_type'], name='shop_manage_activit_a503c4_idx'), models.Index(fields=['source_model', 'source_id'], name='shop_manage_source__52d636_idx')],
            },
        ),
        migrations.AddConstraint(
            model_name='dailydiarylog',
            constraint=models.UniqueConstraint(condition=models.Q(('is_auto', True), ('is_deleted', False)), fields=('source_model', 'source_id'), name='unique_auto_diary_log_source'),
        ),
    ]
