# Generated by Django 5.1.1 on 2024-10-05 02:15

import apps.transactions.validators
import django.core.validators
import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("accounts", "0002_account_exchange_currency"),
        ("transactions", "0009_alter_transaction_tags"),
    ]

    operations = [
        migrations.CreateModel(
            name="InstallmentPlan",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("start_date", models.DateField(verbose_name="Start Date")),
                (
                    "description",
                    models.CharField(max_length=500, verbose_name="Description"),
                ),
                (
                    "number_of_installments",
                    models.PositiveIntegerField(
                        validators=[django.core.validators.MinValueValidator(1)],
                        verbose_name="Number of Installments",
                    ),
                ),
                (
                    "total_amount",
                    models.DecimalField(
                        decimal_places=30,
                        max_digits=42,
                        validators=[
                            apps.transactions.validators.validate_non_negative,
                            apps.transactions.validators.validate_decimal_places,
                        ],
                        verbose_name="Total Amount",
                    ),
                ),
                (
                    "account",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="accounts.account",
                        verbose_name="Account",
                    ),
                ),
            ],
            options={
                "verbose_name": "Installment Plan",
                "verbose_name_plural": "Installment Plans",
            },
        ),
        migrations.AddField(
            model_name="transaction",
            name="installment_plan",
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name="transactions",
                to="transactions.installmentplan",
                verbose_name="Installment Plan",
            ),
        ),
    ]
