# Generated by Django 4.2.28 on 2026-07-27 22:20

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('products', '0001_initial'),
        ('businesses', '0001_initial'),
        ('payments', '0001_initial'),
    ]

    operations = [
        migrations.CreateModel(
            name='Sale',
            fields=[
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('title', models.CharField(blank=True, max_length=300)),
                ('slug', models.SlugField(max_length=320, unique=True)),
                ('start_at', models.DateTimeField(help_text='Server-authoritative start time (UTC).')),
                ('end_at', models.DateTimeField(help_text='Server-authoritative end time (UTC).')),
                ('status', models.CharField(choices=[('draft', 'Draft'), ('upcoming', 'Upcoming'), ('live', 'Live'), ('ended', 'Ended')], default='draft', max_length=20)),
                ('pricing_model', models.CharField(choices=[('daily_rate', 'Daily Rate'), ('commission', 'Commission (5% After Sale)')], default='daily_rate', help_text='How the booking fee was calculated.', max_length=20)),
                ('booking_fee_amount', models.DecimalField(decimal_places=2, default=0, help_text='Snapshot of price paid at booking time.', max_digits=10)),
                ('view_count', models.PositiveIntegerField(default=0)),
                ('booking_payment', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='booked_sale', to='payments.payment')),
                ('business', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='sales', to='businesses.business')),
            ],
            options={
                'ordering': ['-start_at'],
            },
        ),
        migrations.CreateModel(
            name='SaleItem',
            fields=[
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('price', models.DecimalField(decimal_places=2, help_text='Actual selling price for this sale, independent of product.base_price.', max_digits=10)),
                ('discount_percent', models.DecimalField(blank=True, decimal_places=2, help_text='Displayed as strikethrough vs price. No coupon code layer.', max_digits=5, null=True)),
                ('stock_total', models.PositiveIntegerField(help_text='Set by seller at sale-creation time.')),
                ('stock_remaining', models.PositiveIntegerField(help_text='Decremented atomically on order confirmation.')),
                ('product', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='sale_items', to='products.product')),
                ('sale', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='items', to='sales.sale')),
            ],
            options={
                'ordering': ['created_at'],
                'unique_together': {('sale', 'product')},
            },
        ),
    ]
