# Generated manually for CustomerDebtor (debtors / lend to customer)

from decimal import Decimal
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone


class Migration(migrations.Migration):

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ("shop_management", "0067_stocktransfer_wholesale_retail_price"),
    ]

    operations = [
        migrations.CreateModel(
            name="CustomerDebtor",
            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, blank=True)),
                ("updated_at", models.DateTimeField(auto_now=True, null=True, blank=True)),
                ("amount", models.DecimalField(decimal_places=2, max_digits=14)),
                (
                    "settled_amount",
                    models.DecimalField(
                        decimal_places=2,
                        default=Decimal("0"),
                        help_text="Amount already repaid via customer payments",
                        max_digits=14,
                    ),
                ),
                (
                    "exchange_rate",
                    models.DecimalField(decimal_places=6, default=1, max_digits=20),
                ),
                (
                    "converted_amount",
                    models.DecimalField(decimal_places=2, default=0, max_digits=18),
                ),
                (
                    "loan_date",
                    models.DateTimeField(default=django.utils.timezone.now),
                ),
                ("notes", models.TextField(blank=True, null=True)),
                (
                    "account",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="customer_debtors",
                        to="shop_management.account",
                    ),
                ),
                (
                    "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="customer_debtors",
                        to="shop_management.currency",
                    ),
                ),
                (
                    "customer",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="debtor_loans",
                        to="shop_management.customer",
                    ),
                ),
            ],
            options={
                "ordering": ["-loan_date", "-id"],
            },
        ),
    ]
