# Generated by Django 4.2.28 on 2026-02-22 17:55

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('finance', '0001_initial'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('inventory', '0001_initial'),
    ]

    operations = [
        migrations.CreateModel(
            name='Sale',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('reference', models.CharField(max_length=50, unique=True)),
                ('customer_name', models.CharField(blank=True, max_length=255)),
                ('payment_method', models.CharField(choices=[('cash', 'Cash'), ('mobile', 'Mobile Money'), ('bank', 'Bank Transfer'), ('credit', 'Credit')], default='cash', max_length=20)),
                ('status', models.CharField(choices=[('completed', 'Completed'), ('cancelled', 'Cancelled')], default='completed', max_length=20)),
                ('discount', models.DecimalField(decimal_places=2, default=0, max_digits=15)),
                ('note', models.TextField(blank=True)),
                ('date', models.DateField(default=django.utils.timezone.now)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('account', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='sales', to='finance.account')),
                ('created_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='SaleItem',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('quantity', models.DecimalField(decimal_places=2, max_digits=15)),
                ('unit_price', models.DecimalField(decimal_places=2, max_digits=15)),
                ('unit_cost', models.DecimalField(decimal_places=2, max_digits=15)),
                ('product', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='inventory.product')),
                ('sale', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='items', to='sales.sale')),
            ],
        ),
    ]
