# Generated by Django 5.0.7 on 2026-01-17 07:25

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("shop_management", "0017_remove_payroll_paid_amount"),
    ]

    operations = [
        migrations.CreateModel(
            name="PurchaseReturn",
            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)),
                (
                    "return_date",
                    models.DateTimeField(
                        auto_now_add=True,
                        help_text="The date and time when the return was processed.",
                    ),
                ),
                (
                    "reason",
                    models.TextField(
                        blank=True,
                        help_text="Optional reason for the return.",
                        null=True,
                    ),
                ),
                (
                    "total_refund_amount",
                    models.DecimalField(
                        decimal_places=2,
                        default=0,
                        help_text="Total refund amount calculated from all return items.",
                        max_digits=12,
                    ),
                ),
                (
                    "purchase",
                    models.ForeignKey(
                        help_text="The original purchase for which products are being returned.",
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="purchase_returns",
                        to="shop_management.purchase",
                    ),
                ),
                (
                    "shop",
                    models.ForeignKey(
                        help_text="The shop processing the return.",
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="purchase_returns",
                        to="shop_management.shop",
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="PurchaseReturnItem",
            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)),
                (
                    "return_quantity",
                    models.PositiveIntegerField(
                        help_text="The quantity of the item being returned."
                    ),
                ),
                (
                    "refund_amount",
                    models.DecimalField(
                        blank=True,
                        decimal_places=2,
                        help_text="Optional refund amount for this return item. If not provided, it can be auto-calculated.",
                        max_digits=10,
                        null=True,
                    ),
                ),
                (
                    "purchase_item",
                    models.ForeignKey(
                        blank=True,
                        help_text="The original purchase item being returned.",
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="return_items",
                        to="shop_management.purchaseitem",
                    ),
                ),
                (
                    "purchase_return",
                    models.ForeignKey(
                        help_text="The parent return record.",
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="return_items",
                        to="shop_management.purchasereturn",
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
    ]
