"""
Extend Book and Author with inventory / margin fields.

Book additions:
  selling_price_kes  – KES price used for physical-book sales (may differ from Book.price)
  my_keep_percent    – Tai AfroPress margin % for this book (overrides author default)
  reorder_level      – raise low-stock alert when stock falls to or below this
  track_inventory    – opt individual books in/out of inventory tracking

Author additions:
  default_my_keep_percent    – default company margin for this author's books
  default_author_pay_percent – always 100 - default_my_keep_percent; stored for clarity
"""

from decimal import Decimal
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("catalog_app", "0024_book_stock"),
    ]

    operations = [
        # ── Book fields ──────────────────────────────────────────────────────
        migrations.AddField(
            model_name="book",
            name="selling_price_kes",
            field=models.DecimalField(
                max_digits=10, decimal_places=2,
                null=True, blank=True,
                help_text="KES retail price for physical book sales. Defaults to Book.price when blank.",
            ),
        ),
        migrations.AddField(
            model_name="book",
            name="my_keep_percent",
            field=models.DecimalField(
                max_digits=5, decimal_places=2,
                default=Decimal("25.00"),
                help_text="Tai AfroPress margin percentage for this book. Must satisfy 0 ≤ x ≤ 100.",
            ),
        ),
        migrations.AddField(
            model_name="book",
            name="reorder_level",
            field=models.PositiveIntegerField(
                default=5,
                help_text="Trigger a low-stock alert when on-hand quantity reaches this level.",
            ),
        ),
        migrations.AddField(
            model_name="book",
            name="track_inventory",
            field=models.BooleanField(
                default=True,
                help_text="Include this book in inventory tracking and reporting.",
            ),
        ),
        # ── Author fields ─────────────────────────────────────────────────────
        migrations.AddField(
            model_name="author",
            name="default_my_keep_percent",
            field=models.DecimalField(
                max_digits=5, decimal_places=2,
                default=Decimal("25.00"),
                help_text="Default Tai AfroPress margin % applied to all books by this author.",
            ),
        ),
        migrations.AddField(
            model_name="author",
            name="default_author_pay_percent",
            field=models.DecimalField(
                max_digits=5, decimal_places=2,
                default=Decimal("75.00"),
                help_text="Default author pay % (always 100 − default_my_keep_percent).",
            ),
        ),
    ]
