"""Event definitions for the invoices domain."""

from typing import List, Dict

INVOICE_EVENTS: List[Dict] = [
    {
        "event_id": "invoice.prepared",
        "event_name": "Invoice Prepared",
        "description": (
            "Emitted after an Invoice record is created from a completed "
            "PaymentRequest.  Consumed by the invoices listener to dispatch "
            "an invoice delivery notification to the customer."
        ),
        "topic": "payment_events_invoices",
        "emitted_by": "invoices/listener.py",
        "consumed_by": ["invoices/listener.py"],
        "data_contract": {
            "invoice_id": "int — internal PK of the Invoice",
            "invoice_literal": "str — human-readable INVxxxxxx identifier",
            "payment_request_id": "int",
            "merchant_id": "int",
            "customer_id": "int",
            "amount": "float",
            "currency": "str",
            "due_date": "ISO8601 date string | None",
        },
    },
    {
        "event_id": "invoice.sent",
        "event_name": "Invoice Sent",
        "description": (
            "Emitted after an invoice is dispatched to the customer via "
            "email or SMS.  Consumed by the invoices listener to write an "
            "activity record."
        ),
        "topic": "payment_events_invoices",
        "emitted_by": "invoices/router.py",
        "consumed_by": ["invoices/listener.py"],
        "data_contract": {
            "invoice_id": "int",
            "merchant_id": "int",
            "recipient_email": "str | None",
        },
    },
    {
        "event_id": "invoice.paid",
        "event_name": "Invoice Paid",
        "description": (
            "Emitted when an invoice transitions to PAID status.  Consumed "
            "by the invoices listener to write an activity record."
        ),
        "topic": "payment_events_invoices",
        "emitted_by": "invoices/services.py",
        "consumed_by": ["invoices/listener.py"],
        "data_contract": {
            "invoice_id": "int",
            "payment_request_id": "int",
            "merchant_id": "int",
            "paid_amount": "float",
            "currency": "str",
        },
    },
    {
        "event_id": "invoice.overdue",
        "event_name": "Invoice Overdue",
        "description": (
            "Emitted by a scheduled Celery task when an unpaid invoice "
            "passes its due date.  Consumed by the invoices listener to "
            "update status and write an activity record."
        ),
        "topic": "payment_events_invoices",
        "emitted_by": "worker/tasks.py",
        "consumed_by": ["invoices/listener.py"],
        "data_contract": {
            "invoice_id": "int",
            "merchant_id": "int",
            "due_date": "ISO8601 date string",
        },
    },
]
