CREATE TABLE agent_transactions (
id INTEGER PRIMARY KEY AUTOINCREMENT,
agent_id INTEGER NOT NULL,
transaction_type TEXT NOT NULL CHECK (transaction_type IN ('deposit', 'withdrawal', 'voucher_sale', 'monthly_payment', 'commission', 'balance_request')),
amount DECIMAL(15,2) NOT NULL,
description TEXT,
reference_id TEXT,
status TEXT DEFAULT 'completed' CHECK (status IN ('pending', 'completed', 'failed', 'cancelled')),
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (agent_id) REFERENCES agents(id) ON DELETE CASCADE
)