Add refund system and meet link management

Refund System:
- Add refund processing with amount and reason tracking
- Auto-revoke product access on refund
- Support full and partial refunds
- Add database fields for refund tracking

Meet Link Management:
- Show meet link status badge (Ready/Not Ready)
- Add manual meet link creation/update form
- Allow admin to create meet links if auto-creation fails

Database Migration:
- Add refund_amount, refund_reason, refunded_at, refunded_by to orders
- Add cancellation_reason to orders and consulting_slots

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
dwindown
2025-12-26 17:05:25 +07:00
parent b955445dea
commit 81bbafcff0
2 changed files with 305 additions and 17 deletions

View File

@@ -0,0 +1,28 @@
-- Add refund and cancellation tracking fields
-- This migration adds support for refund processing and cancellation reasons
-- Add cancellation reason to orders
ALTER TABLE orders
ADD COLUMN IF NOT EXISTS cancellation_reason TEXT;
-- Add refund tracking to orders
ALTER TABLE orders
ADD COLUMN IF NOT EXISTS refunded_amount INTEGER DEFAULT 0,
ADD COLUMN IF NOT EXISTS refund_reason TEXT,
ADD COLUMN IF NOT EXISTS refunded_at TIMESTAMPTZ,
ADD COLUMN IF NOT EXISTS refunded_by UUID REFERENCES auth.users(id);
-- Add cancellation reason to consulting_slots
ALTER TABLE consulting_slots
ADD COLUMN IF NOT EXISTS cancellation_reason TEXT;
-- Add index for refund queries
CREATE INDEX IF NOT EXISTS idx_orders_refunded_at ON orders(refunded_at) WHERE refunded_at IS NOT NULL;
-- Add comment for documentation
COMMENT ON COLUMN orders.cancellation_reason IS 'Reason why order was cancelled (by user or admin)';
COMMENT ON COLUMN orders.refunded_amount IS 'Amount refunded to customer (in cents/minor units)';
COMMENT ON COLUMN orders.refund_reason IS 'Reason for refund';
COMMENT ON COLUMN orders.refunded_at IS 'Timestamp when refund was processed';
COMMENT ON COLUMN orders.refunded_by IS 'Admin user ID who processed the refund';
COMMENT ON COLUMN consulting_slots.cancellation_reason IS 'Reason why consulting slot was cancelled';