SELECT 
    je.id,
    je.entry_number,
    je.entry_date,
    je.description,
    je.name,
    je.department,
    je.location,
    je.status,
    COALESCE((SELECT SUM(debit) FROM journal_entry_lines WHERE entry_id = je.id), 0) as amount,
    je.created_at
FROM journal_entries je