diff --git a/server.js b/server.js index 47afe17..1f5ef83 100644 --- a/server.js +++ b/server.js @@ -1307,7 +1307,7 @@ app.get('/api/invoices/:id/pdf', async (req, res) => { try { // KORRIGIERT: Abfrage von line1-4 const invoiceResult = await pool.query(` - SELECT i.*, c.name as customer_name, c.line1, c.line2, c.line3, c.line4, c.city, c.state, c.zip_code, c.account_number + SELECT i.*, c.name as customer_name, c.line1, c.line2, c.line3, c.line4, c.city, c.state, c.zip_code, c.account_number, COALESCE((SELECT SUM(pi.amount) FROM payment_invoices pi WHERE pi.invoice_id = i.id), 0) as amount_paid FROM invoices i LEFT JOIN customers c ON i.customer_id = c.id @@ -1550,7 +1550,7 @@ app.get('/api/invoices/:id/html', async (req, res) => { try { // KORREKTUR: Line 1-4 abfragen const invoiceResult = await pool.query(` - SELECT i.*, c.name as customer_name, c.line1, c.line2, c.line3, c.line4, c.city, c.state, c.zip_code, c.account_number + SELECT i.*, c.name as customer_name, c.line1, c.line2, c.line3, c.line4, c.city, c.state, c.zip_code, c.account_number, COALESCE((SELECT SUM(pi.amount) FROM payment_invoices pi WHERE pi.invoice_id = i.id), 0) as amount_paid FROM invoices i LEFT JOIN customers c ON i.customer_id = c.id