# Generated by Django 5.2.13 on 2026-05-03 14:22

import apps.core.storage.paths
import django.core.validators
import django.db.models.deletion
import django.utils.timezone
from decimal import Decimal
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("smehub_marketplace", "0002_alter_buyerregistryentry_verification_status"),
        ("smehub_onboarding", "0003_innovation_evaluatorassignment_vettingrecord_and_more"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="MarketValidation",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "validator_name",
                    models.CharField(
                        blank=True,
                        help_text="Free-form: 'Acme Foods Procurement Lead' or 'Anonymous interview #3'.",
                        max_length=255,
                    ),
                ),
                ("validator_email", models.EmailField(blank=True, max_length=254)),
                (
                    "method",
                    models.CharField(
                        choices=[
                            ("interview", "Customer interview"),
                            ("survey", "Survey"),
                            ("pilot", "Pilot / trial"),
                            ("loi", "Letter of intent"),
                            ("focus_group", "Focus group"),
                            ("demo_feedback", "Demo feedback"),
                        ],
                        db_index=True,
                        max_length=24,
                    ),
                ),
                ("conducted_at", models.DateTimeField(default=django.utils.timezone.now)),
                (
                    "problem_fit_score",
                    models.PositiveSmallIntegerField(
                        help_text="1 (no fit) – 5 (strong fit).",
                        validators=[
                            django.core.validators.MinValueValidator(1),
                            django.core.validators.MaxValueValidator(5),
                        ],
                    ),
                ),
                (
                    "solution_fit_score",
                    models.PositiveSmallIntegerField(
                        help_text="1 (poor solution) – 5 (great solution).",
                        validators=[
                            django.core.validators.MinValueValidator(1),
                            django.core.validators.MaxValueValidator(5),
                        ],
                    ),
                ),
                (
                    "willingness_to_pay_score",
                    models.PositiveSmallIntegerField(
                        help_text="1 (won't pay) – 5 (will pay readily).",
                        validators=[
                            django.core.validators.MinValueValidator(1),
                            django.core.validators.MaxValueValidator(5),
                        ],
                    ),
                ),
                (
                    "willingness_to_pay_amount",
                    models.DecimalField(
                        blank=True,
                        decimal_places=2,
                        help_text="Optional indicative amount the validator would pay.",
                        max_digits=14,
                        null=True,
                    ),
                ),
                (
                    "currency",
                    models.CharField(
                        blank=True,
                        choices=[
                            ("AED", "AED — UAE dirham"),
                            ("AFN", "AFN — Afghani"),
                            ("ALL", "ALL — Albanian lek"),
                            ("AMD", "AMD — Armenian dram"),
                            ("ANG", "ANG — Netherlands Antillean guilder"),
                            ("AOA", "AOA — Kwanza"),
                            ("ARS", "ARS — Argentine peso"),
                            ("AUD", "AUD — Australian dollar"),
                            ("AWG", "AWG — Aruban florin"),
                            ("AZN", "AZN — Azerbaijanian manat"),
                            ("BAM", "BAM — Convertible mark"),
                            ("BBD", "BBD — Barbados dollar"),
                            ("BDT", "BDT — Taka"),
                            ("BGN", "BGN — Bulgarian lev"),
                            ("BHD", "BHD — Bahraini dinar"),
                            ("BIF", "BIF — Burundi franc"),
                            ("BMD", "BMD — Bermudian dollar"),
                            ("BND", "BND — Brunei dollar"),
                            ("BOB", "BOB — Boliviano"),
                            ("BOV", "BOV — Mvdol"),
                            ("BRL", "BRL — Brazilian real"),
                            ("BSD", "BSD — Bahamian dollar"),
                            ("BTN", "BTN — Ngultrum"),
                            ("BWP", "BWP — Pula"),
                            ("BYN", "BYN — Belarusian ruble"),
                            ("BZD", "BZD — Belize dollar"),
                            ("CAD", "CAD — Canadian dollar"),
                            ("CDF", "CDF — Congolese franc"),
                            ("CHE", "CHE — WIR euro"),
                            ("CHF", "CHF — Swiss franc"),
                            ("CHW", "CHW — WIR franc"),
                            ("CLF", "CLF — Unidad de fomento"),
                            ("CLP", "CLP — Chilean peso"),
                            ("CNY", "CNY — Yuan renminbi"),
                            ("COP", "COP — Colombian peso"),
                            ("COU", "COU — Unidad de valor real"),
                            ("CRC", "CRC — Costa Rican colon"),
                            ("CUC", "CUC — Peso convertible"),
                            ("CUP", "CUP — Cuban peso"),
                            ("CVE", "CVE — Cabo Verde escudo"),
                            ("CZK", "CZK — Czech koruna"),
                            ("DJF", "DJF — Djibouti franc"),
                            ("DKK", "DKK — Danish krone"),
                            ("DOP", "DOP — Dominican peso"),
                            ("DZD", "DZD — Algerian dinar"),
                            ("EGP", "EGP — Egyptian pound"),
                            ("ERN", "ERN — Nakfa"),
                            ("ETB", "ETB — Ethiopian birr"),
                            ("EUR", "EUR — Euro"),
                            ("FJD", "FJD — Fiji dollar"),
                            ("FKP", "FKP — Falkland Islands pound"),
                            ("GBP", "GBP — Pound sterling"),
                            ("GEL", "GEL — Lari"),
                            ("GHS", "GHS — Ghana cedi"),
                            ("GIP", "GIP — Gibraltar pound"),
                            ("GMD", "GMD — Dalasi"),
                            ("GNF", "GNF — Guinean franc"),
                            ("GTQ", "GTQ — Quetzal"),
                            ("GYD", "GYD — Guyana dollar"),
                            ("HKD", "HKD — Hong Kong dollar"),
                            ("HNL", "HNL — Lempira"),
                            ("HTG", "HTG — Gourde"),
                            ("HUF", "HUF — Forint"),
                            ("IDR", "IDR — Rupiah"),
                            ("ILS", "ILS — New Israeli sheqel"),
                            ("INR", "INR — Indian rupee"),
                            ("IQD", "IQD — Iraqi dinar"),
                            ("IRR", "IRR — Iranian rial"),
                            ("ISK", "ISK — Icelandic krona"),
                            ("JMD", "JMD — Jamaican dollar"),
                            ("JOD", "JOD — Jordanian dinar"),
                            ("JPY", "JPY — Yen"),
                            ("KES", "KES — Kenyan shilling"),
                            ("KGS", "KGS — Som"),
                            ("KHR", "KHR — Riel"),
                            ("KMF", "KMF — Comorian franc"),
                            ("KPW", "KPW — North Korean won"),
                            ("KRW", "KRW — Won"),
                            ("KWD", "KWD — Kuwaiti dinar"),
                            ("KYD", "KYD — Cayman Islands dollar"),
                            ("KZT", "KZT — Tenge"),
                            ("LAK", "LAK — Kip"),
                            ("LBP", "LBP — Lebanese pound"),
                            ("LKR", "LKR — Sri Lanka rupee"),
                            ("LRD", "LRD — Liberian dollar"),
                            ("LSL", "LSL — Loti"),
                            ("LYD", "LYD — Libyan dinar"),
                            ("MAD", "MAD — Moroccan dirham"),
                            ("MDL", "MDL — Moldovan leu"),
                            ("MGA", "MGA — Malagasy ariary"),
                            ("MKD", "MKD — Denar"),
                            ("MMK", "MMK — Kyat"),
                            ("MNT", "MNT — Tugrik"),
                            ("MOP", "MOP — Pataca"),
                            ("MRU", "MRU — Ouguiya"),
                            ("MUR", "MUR — Mauritius rupee"),
                            ("MVR", "MVR — Rufiyaa"),
                            ("MWK", "MWK — Kwacha"),
                            ("MXN", "MXN — Mexican peso"),
                            ("MXV", "MXV — Mexican unidad de inversion"),
                            ("MYR", "MYR — Malaysian ringgit"),
                            ("MZN", "MZN — Mozambique metical"),
                            ("NAD", "NAD — Namibia dollar"),
                            ("NGN", "NGN — Naira"),
                            ("NIO", "NIO — Cordoba oro"),
                            ("NOK", "NOK — Norwegian krone"),
                            ("NPR", "NPR — Nepalese rupee"),
                            ("NZD", "NZD — New Zealand dollar"),
                            ("OMR", "OMR — Rial Omani"),
                            ("PAB", "PAB — Balboa"),
                            ("PEN", "PEN — Sol"),
                            ("PGK", "PGK — Kina"),
                            ("PHP", "PHP — Philippine peso"),
                            ("PKR", "PKR — Pakistan rupee"),
                            ("PLN", "PLN — Zloty"),
                            ("PYG", "PYG — Guarani"),
                            ("QAR", "QAR — Qatari riyal"),
                            ("RON", "RON — Romanian leu"),
                            ("RSD", "RSD — Serbian dinar"),
                            ("RUB", "RUB — Russian ruble"),
                            ("RWF", "RWF — Rwanda franc"),
                            ("SAR", "SAR — Saudi riyal"),
                            ("SBD", "SBD — Solomon Islands dollar"),
                            ("SCR", "SCR — Seychelles rupee"),
                            ("SDG", "SDG — Sudanese pound"),
                            ("SEK", "SEK — Swedish krona"),
                            ("SGD", "SGD — Singapore dollar"),
                            ("SHP", "SHP — Saint Helena pound"),
                            ("SLE", "SLE — Sierra Leonean leone"),
                            ("SOS", "SOS — Somali shilling"),
                            ("SRD", "SRD — Surinam dollar"),
                            ("SSP", "SSP — South Sudanese pound"),
                            ("STN", "STN — Dobra"),
                            ("SVC", "SVC — El Salvador colon"),
                            ("SYP", "SYP — Syrian pound"),
                            ("SZL", "SZL — Lilangeni"),
                            ("THB", "THB — Baht"),
                            ("TJS", "TJS — Somoni"),
                            ("TMT", "TMT — Turkmenistan new manat"),
                            ("TND", "TND — Tunisian dinar"),
                            ("TOP", "TOP — Pa'anga"),
                            ("TRY", "TRY — Turkish lira"),
                            ("TTD", "TTD — Trinidad and Tobago dollar"),
                            ("TWD", "TWD — New Taiwan dollar"),
                            ("TZS", "TZS — Tanzanian shilling"),
                            ("UAH", "UAH — Hryvnia"),
                            ("UGX", "UGX — Uganda shilling"),
                            ("USD", "USD — US dollar"),
                            ("USN", "USN — US dollar (next day)"),
                            ("UYI", "UYI — Uruguay peso en unidades indexadas"),
                            ("UYU", "UYU — Peso uruguayo"),
                            ("UYW", "UYW — Unidad previsional"),
                            ("UZS", "UZS — Uzbekistan sum"),
                            ("VES", "VES — Bolívar soberano"),
                            ("VND", "VND — Dong"),
                            ("VUV", "VUV — Vatu"),
                            ("WST", "WST — Tala"),
                            ("XAF", "XAF — CFA franc BEAC"),
                            ("XAG", "XAG — Silver"),
                            ("XAU", "XAU — Gold"),
                            ("XBA", "XBA — European Composite Unit"),
                            ("XBB", "XBB — European Monetary Unit"),
                            ("XBC", "XBC — European Unit of Account 9"),
                            ("XBD", "XBD — European Unit of Account 17"),
                            ("XCD", "XCD — East Caribbean dollar"),
                            ("XCG", "XCG — Caribbean guilder"),
                            ("XDR", "XDR — Special drawing rights"),
                            ("XOF", "XOF — CFA franc BCEAO"),
                            ("XPD", "XPD — Palladium"),
                            ("XPF", "XPF — CFP franc"),
                            ("XPT", "XPT — Platinum"),
                            ("XSU", "XSU — Sucre"),
                            ("XUA", "XUA — ADB Unit of Account"),
                            ("XXX", "XXX — No currency"),
                            ("YER", "YER — Yemeni rial"),
                            ("ZAR", "ZAR — South African rand"),
                            ("ZMW", "ZMW — Zambian kwacha"),
                            ("ZWL", "ZWL — Zimbabwe dollar"),
                        ],
                        help_text="Required iff willingness_to_pay_amount is set.",
                        max_length=8,
                    ),
                ),
                ("notes", models.TextField(blank=True)),
                (
                    "evidence_file",
                    models.FileField(
                        blank=True,
                        help_text="Optional supporting artefact (transcript, signed LOI, survey export).",
                        null=True,
                        upload_to=apps.core.storage.paths.upload_to_smehub_marketplace,
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "business",
                    models.ForeignKey(
                        help_text="Denormalised from product_listing.business; auto-set in save().",
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="market_validations",
                        to="smehub_onboarding.business",
                    ),
                ),
                (
                    "product_listing",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="validations",
                        to="smehub_marketplace.productlisting",
                    ),
                ),
                (
                    "recorded_by",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="smehub_market_validations_recorded",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "validator_buyer_entry",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="market_validations",
                        to="smehub_marketplace.buyerregistryentry",
                    ),
                ),
                (
                    "validator_user",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="smehub_market_validations_given",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ["-conducted_at"],
                "indexes": [
                    models.Index(
                        fields=["product_listing", "-conducted_at"],
                        name="smehub_mark_product_7f3362_idx",
                    ),
                    models.Index(
                        fields=["business", "method"], name="smehub_mark_busines_0f1d04_idx"
                    ),
                ],
            },
        ),
        migrations.CreateModel(
            name="SalesRecord",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "customer_name",
                    models.CharField(
                        blank=True,
                        help_text="Required when buyer_entry is null (validated in clean()).",
                        max_length=255,
                    ),
                ),
                (
                    "channel",
                    models.CharField(
                        choices=[
                            ("marketplace_award", "Marketplace award"),
                            ("direct_listing", "Direct listing"),
                            ("offline", "Offline / walk-in"),
                            ("repeat_customer", "Repeat customer"),
                            ("referral", "Referral"),
                            ("export", "Export"),
                        ],
                        db_index=True,
                        max_length=24,
                    ),
                ),
                (
                    "quantity",
                    models.DecimalField(decimal_places=2, default=Decimal("1.00"), max_digits=12),
                ),
                ("unit", models.CharField(blank=True, default="units", max_length=32)),
                (
                    "unit_price",
                    models.DecimalField(
                        blank=True,
                        decimal_places=2,
                        help_text="Auto-derived from gross_amount / quantity in save() if omitted.",
                        max_digits=14,
                        null=True,
                    ),
                ),
                (
                    "gross_amount",
                    models.DecimalField(decimal_places=2, default=Decimal("0.00"), max_digits=14),
                ),
                (
                    "currency",
                    models.CharField(
                        choices=[
                            ("AED", "AED — UAE dirham"),
                            ("AFN", "AFN — Afghani"),
                            ("ALL", "ALL — Albanian lek"),
                            ("AMD", "AMD — Armenian dram"),
                            ("ANG", "ANG — Netherlands Antillean guilder"),
                            ("AOA", "AOA — Kwanza"),
                            ("ARS", "ARS — Argentine peso"),
                            ("AUD", "AUD — Australian dollar"),
                            ("AWG", "AWG — Aruban florin"),
                            ("AZN", "AZN — Azerbaijanian manat"),
                            ("BAM", "BAM — Convertible mark"),
                            ("BBD", "BBD — Barbados dollar"),
                            ("BDT", "BDT — Taka"),
                            ("BGN", "BGN — Bulgarian lev"),
                            ("BHD", "BHD — Bahraini dinar"),
                            ("BIF", "BIF — Burundi franc"),
                            ("BMD", "BMD — Bermudian dollar"),
                            ("BND", "BND — Brunei dollar"),
                            ("BOB", "BOB — Boliviano"),
                            ("BOV", "BOV — Mvdol"),
                            ("BRL", "BRL — Brazilian real"),
                            ("BSD", "BSD — Bahamian dollar"),
                            ("BTN", "BTN — Ngultrum"),
                            ("BWP", "BWP — Pula"),
                            ("BYN", "BYN — Belarusian ruble"),
                            ("BZD", "BZD — Belize dollar"),
                            ("CAD", "CAD — Canadian dollar"),
                            ("CDF", "CDF — Congolese franc"),
                            ("CHE", "CHE — WIR euro"),
                            ("CHF", "CHF — Swiss franc"),
                            ("CHW", "CHW — WIR franc"),
                            ("CLF", "CLF — Unidad de fomento"),
                            ("CLP", "CLP — Chilean peso"),
                            ("CNY", "CNY — Yuan renminbi"),
                            ("COP", "COP — Colombian peso"),
                            ("COU", "COU — Unidad de valor real"),
                            ("CRC", "CRC — Costa Rican colon"),
                            ("CUC", "CUC — Peso convertible"),
                            ("CUP", "CUP — Cuban peso"),
                            ("CVE", "CVE — Cabo Verde escudo"),
                            ("CZK", "CZK — Czech koruna"),
                            ("DJF", "DJF — Djibouti franc"),
                            ("DKK", "DKK — Danish krone"),
                            ("DOP", "DOP — Dominican peso"),
                            ("DZD", "DZD — Algerian dinar"),
                            ("EGP", "EGP — Egyptian pound"),
                            ("ERN", "ERN — Nakfa"),
                            ("ETB", "ETB — Ethiopian birr"),
                            ("EUR", "EUR — Euro"),
                            ("FJD", "FJD — Fiji dollar"),
                            ("FKP", "FKP — Falkland Islands pound"),
                            ("GBP", "GBP — Pound sterling"),
                            ("GEL", "GEL — Lari"),
                            ("GHS", "GHS — Ghana cedi"),
                            ("GIP", "GIP — Gibraltar pound"),
                            ("GMD", "GMD — Dalasi"),
                            ("GNF", "GNF — Guinean franc"),
                            ("GTQ", "GTQ — Quetzal"),
                            ("GYD", "GYD — Guyana dollar"),
                            ("HKD", "HKD — Hong Kong dollar"),
                            ("HNL", "HNL — Lempira"),
                            ("HTG", "HTG — Gourde"),
                            ("HUF", "HUF — Forint"),
                            ("IDR", "IDR — Rupiah"),
                            ("ILS", "ILS — New Israeli sheqel"),
                            ("INR", "INR — Indian rupee"),
                            ("IQD", "IQD — Iraqi dinar"),
                            ("IRR", "IRR — Iranian rial"),
                            ("ISK", "ISK — Icelandic krona"),
                            ("JMD", "JMD — Jamaican dollar"),
                            ("JOD", "JOD — Jordanian dinar"),
                            ("JPY", "JPY — Yen"),
                            ("KES", "KES — Kenyan shilling"),
                            ("KGS", "KGS — Som"),
                            ("KHR", "KHR — Riel"),
                            ("KMF", "KMF — Comorian franc"),
                            ("KPW", "KPW — North Korean won"),
                            ("KRW", "KRW — Won"),
                            ("KWD", "KWD — Kuwaiti dinar"),
                            ("KYD", "KYD — Cayman Islands dollar"),
                            ("KZT", "KZT — Tenge"),
                            ("LAK", "LAK — Kip"),
                            ("LBP", "LBP — Lebanese pound"),
                            ("LKR", "LKR — Sri Lanka rupee"),
                            ("LRD", "LRD — Liberian dollar"),
                            ("LSL", "LSL — Loti"),
                            ("LYD", "LYD — Libyan dinar"),
                            ("MAD", "MAD — Moroccan dirham"),
                            ("MDL", "MDL — Moldovan leu"),
                            ("MGA", "MGA — Malagasy ariary"),
                            ("MKD", "MKD — Denar"),
                            ("MMK", "MMK — Kyat"),
                            ("MNT", "MNT — Tugrik"),
                            ("MOP", "MOP — Pataca"),
                            ("MRU", "MRU — Ouguiya"),
                            ("MUR", "MUR — Mauritius rupee"),
                            ("MVR", "MVR — Rufiyaa"),
                            ("MWK", "MWK — Kwacha"),
                            ("MXN", "MXN — Mexican peso"),
                            ("MXV", "MXV — Mexican unidad de inversion"),
                            ("MYR", "MYR — Malaysian ringgit"),
                            ("MZN", "MZN — Mozambique metical"),
                            ("NAD", "NAD — Namibia dollar"),
                            ("NGN", "NGN — Naira"),
                            ("NIO", "NIO — Cordoba oro"),
                            ("NOK", "NOK — Norwegian krone"),
                            ("NPR", "NPR — Nepalese rupee"),
                            ("NZD", "NZD — New Zealand dollar"),
                            ("OMR", "OMR — Rial Omani"),
                            ("PAB", "PAB — Balboa"),
                            ("PEN", "PEN — Sol"),
                            ("PGK", "PGK — Kina"),
                            ("PHP", "PHP — Philippine peso"),
                            ("PKR", "PKR — Pakistan rupee"),
                            ("PLN", "PLN — Zloty"),
                            ("PYG", "PYG — Guarani"),
                            ("QAR", "QAR — Qatari riyal"),
                            ("RON", "RON — Romanian leu"),
                            ("RSD", "RSD — Serbian dinar"),
                            ("RUB", "RUB — Russian ruble"),
                            ("RWF", "RWF — Rwanda franc"),
                            ("SAR", "SAR — Saudi riyal"),
                            ("SBD", "SBD — Solomon Islands dollar"),
                            ("SCR", "SCR — Seychelles rupee"),
                            ("SDG", "SDG — Sudanese pound"),
                            ("SEK", "SEK — Swedish krona"),
                            ("SGD", "SGD — Singapore dollar"),
                            ("SHP", "SHP — Saint Helena pound"),
                            ("SLE", "SLE — Sierra Leonean leone"),
                            ("SOS", "SOS — Somali shilling"),
                            ("SRD", "SRD — Surinam dollar"),
                            ("SSP", "SSP — South Sudanese pound"),
                            ("STN", "STN — Dobra"),
                            ("SVC", "SVC — El Salvador colon"),
                            ("SYP", "SYP — Syrian pound"),
                            ("SZL", "SZL — Lilangeni"),
                            ("THB", "THB — Baht"),
                            ("TJS", "TJS — Somoni"),
                            ("TMT", "TMT — Turkmenistan new manat"),
                            ("TND", "TND — Tunisian dinar"),
                            ("TOP", "TOP — Pa'anga"),
                            ("TRY", "TRY — Turkish lira"),
                            ("TTD", "TTD — Trinidad and Tobago dollar"),
                            ("TWD", "TWD — New Taiwan dollar"),
                            ("TZS", "TZS — Tanzanian shilling"),
                            ("UAH", "UAH — Hryvnia"),
                            ("UGX", "UGX — Uganda shilling"),
                            ("USD", "USD — US dollar"),
                            ("USN", "USN — US dollar (next day)"),
                            ("UYI", "UYI — Uruguay peso en unidades indexadas"),
                            ("UYU", "UYU — Peso uruguayo"),
                            ("UYW", "UYW — Unidad previsional"),
                            ("UZS", "UZS — Uzbekistan sum"),
                            ("VES", "VES — Bolívar soberano"),
                            ("VND", "VND — Dong"),
                            ("VUV", "VUV — Vatu"),
                            ("WST", "WST — Tala"),
                            ("XAF", "XAF — CFA franc BEAC"),
                            ("XAG", "XAG — Silver"),
                            ("XAU", "XAU — Gold"),
                            ("XBA", "XBA — European Composite Unit"),
                            ("XBB", "XBB — European Monetary Unit"),
                            ("XBC", "XBC — European Unit of Account 9"),
                            ("XBD", "XBD — European Unit of Account 17"),
                            ("XCD", "XCD — East Caribbean dollar"),
                            ("XCG", "XCG — Caribbean guilder"),
                            ("XDR", "XDR — Special drawing rights"),
                            ("XOF", "XOF — CFA franc BCEAO"),
                            ("XPD", "XPD — Palladium"),
                            ("XPF", "XPF — CFP franc"),
                            ("XPT", "XPT — Platinum"),
                            ("XSU", "XSU — Sucre"),
                            ("XUA", "XUA — ADB Unit of Account"),
                            ("XXX", "XXX — No currency"),
                            ("YER", "YER — Yemeni rial"),
                            ("ZAR", "ZAR — South African rand"),
                            ("ZMW", "ZMW — Zambian kwacha"),
                            ("ZWL", "ZWL — Zimbabwe dollar"),
                        ],
                        default="USD",
                        max_length=8,
                    ),
                ),
                ("sale_date", models.DateField(blank=True, null=True)),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("pending_details", "Pending details"),
                            ("recorded", "Recorded"),
                            ("verified", "Verified"),
                            ("disputed", "Disputed"),
                            ("cancelled", "Cancelled"),
                        ],
                        db_index=True,
                        default="recorded",
                        max_length=24,
                    ),
                ),
                ("notes", models.TextField(blank=True)),
                (
                    "evidence_file",
                    models.FileField(
                        blank=True,
                        help_text="Invoice / receipt / contract.",
                        null=True,
                        upload_to=apps.core.storage.paths.upload_to_smehub_marketplace,
                    ),
                ),
                ("verified_at", models.DateTimeField(blank=True, null=True)),
                ("dispute_reason", models.TextField(blank=True)),
                ("cancel_reason", models.TextField(blank=True)),
                ("recorded_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "business",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="sales",
                        to="smehub_onboarding.business",
                    ),
                ),
                (
                    "buyer_entry",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="sales_purchased",
                        to="smehub_marketplace.buyerregistryentry",
                    ),
                ),
                (
                    "demand_response",
                    models.ForeignKey(
                        blank=True,
                        help_text="Set by the auto-stub when a DemandResponse is awarded.",
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="sales",
                        to="smehub_marketplace.demandresponse",
                    ),
                ),
                (
                    "entrepreneur",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="smehub_sales_recorded",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "product_listing",
                    models.ForeignKey(
                        blank=True,
                        help_text="Nullable so off-catalogue sales can still be logged.",
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="sales",
                        to="smehub_marketplace.productlisting",
                    ),
                ),
                (
                    "verified_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="smehub_sales_verified",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ["-sale_date", "-recorded_at"],
                "indexes": [
                    models.Index(
                        fields=["business", "-sale_date"], name="smehub_mark_busines_aad9e7_idx"
                    ),
                    models.Index(
                        fields=["product_listing", "-sale_date"],
                        name="smehub_mark_product_2dcb75_idx",
                    ),
                    models.Index(
                        fields=["channel", "status"], name="smehub_mark_channel_e4b4b5_idx"
                    ),
                ],
                "constraints": [
                    models.UniqueConstraint(
                        condition=models.Q(("demand_response__isnull", False)),
                        fields=("demand_response",),
                        name="uniq_smehub_sale_per_demand_response",
                    )
                ],
            },
        ),
    ]
