/**
 * Refund domain effects.
 *
 * Effect ordering in apply-effects.ts:
 *   1. set-refunded (order status recompute + voucher cancel on full refund)
 *   2. enqueue-outbox (DB insert + queue send)
 *   3. referral-clawback (outbox)
 */

export type RefundEffect =
  | {
      kind: 'set-refunded';
      purchaseId: string;
      cancelledAt: Date;
      cancellationReason: string;
      /** true = full-line refund → platform voucher CANCELLED. Partial keeps voucher live. */
      cancelVoucher: boolean;
    }
  | {
      kind: 'enqueue-outbox';
      aggregateType: 'refund';
      aggregateId: string;
      eventType: string;
      dedupeKey: string;
      payload: Record<string, unknown>;
    }
  | {
      kind: 'referral-clawback';
      purchaseId: string;
      refundEventId: string;
      refundFraction: number;
      refundAmountAgorot: number;
    };
