# Generated by Django 3.0.5 on 2020-04-12 19:28

import uuid

import django.db.models.deletion
import swapper
from django.db import migrations, models


class Migration(migrations.Migration):
    initial = True

    dependencies = [swapper.dependency("getpaid", "Order")]

    operations = [
        migrations.CreateModel(
            name="Payment",
            fields=[
                (
                    "id",
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                (
                    "amount_required",
                    models.DecimalField(
                        decimal_places=2,
                        help_text="Amount required to fulfill the payment; in selected currency, normal notation",
                        max_digits=20,
                        verbose_name="amount required",
                    ),
                ),
                ("currency", models.CharField(max_length=3, verbose_name="currency")),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("new", "new"),
                            ("in_progress", "in progress"),
                            ("accepted_for_proc", "accepted for processing"),
                            ("partially_paid", "partially paid"),
                            ("paid", "paid"),
                            ("cancelled", "cancelled"),
                            ("failed", "failed"),
                            ("refund_started", "refund started"),
                            ("refunded", "refunded"),
                        ],
                        db_index=True,
                        default="new",
                        max_length=20,
                        verbose_name="status",
                    ),
                ),
                (
                    "backend",
                    models.CharField(
                        db_index=True, max_length=100, verbose_name="backend"
                    ),
                ),
                (
                    "created_on",
                    models.DateTimeField(
                        auto_now_add=True, db_index=True, verbose_name="created on"
                    ),
                ),
                (
                    "last_payment_on",
                    models.DateTimeField(
                        blank=True,
                        db_index=True,
                        default=None,
                        null=True,
                        verbose_name="paid on",
                    ),
                ),
                (
                    "amount_locked",
                    models.DecimalField(
                        decimal_places=2,
                        default=0,
                        help_text="Amount locked with this payment, ready to charge.",
                        max_digits=20,
                        verbose_name="amount paid",
                    ),
                ),
                (
                    "amount_paid",
                    models.DecimalField(
                        decimal_places=2,
                        default=0,
                        help_text="Amount actually paid.",
                        max_digits=20,
                        verbose_name="amount paid",
                    ),
                ),
                (
                    "refunded_on",
                    models.DateTimeField(
                        blank=True,
                        db_index=True,
                        default=None,
                        null=True,
                        verbose_name="refunded on",
                    ),
                ),
                (
                    "amount_refunded",
                    models.DecimalField(
                        decimal_places=4,
                        default=0,
                        max_digits=20,
                        verbose_name="amount refunded",
                    ),
                ),
                (
                    "external_id",
                    models.CharField(
                        blank=True,
                        db_index=True,
                        default="",
                        max_length=64,
                        verbose_name="external id",
                    ),
                ),
                (
                    "description",
                    models.CharField(
                        blank=True,
                        default="",
                        max_length=128,
                        verbose_name="description",
                    ),
                ),
                (
                    "fraud_status",
                    models.CharField(
                        choices=[
                            ("unknown", "unknown"),
                            ("accepted", "accepted"),
                            ("rejected", "rejected"),
                            ("check", "check"),
                        ],
                        db_index=True,
                        default="unknown",
                        max_length=20,
                        verbose_name="fraud status",
                    ),
                ),
                (
                    "fraud_message",
                    models.TextField(blank=True, verbose_name="fraud message"),
                ),
                (
                    "order",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="payments",
                        to=swapper.get_model_name("getpaid", "Order"),
                        verbose_name="order",
                    ),
                ),
            ],
            options={
                "verbose_name": "Payment",
                "verbose_name_plural": "Payments",
                "ordering": ["-created_on"],
                "abstract": False,
                "swappable": swapper.swappable_setting("getpaid", "Payment"),
            },
        ),
    ]
