changes
This commit is contained in:
parent
54c43fd052
commit
8f68ed02c5
|
|
@ -677,7 +677,7 @@ async function openInvoiceModal(invoiceId = null) {
|
||||||
document.getElementById('invoice-terms').value = data.invoice.terms;
|
document.getElementById('invoice-terms').value = data.invoice.terms;
|
||||||
document.getElementById('invoice-authorization').value = data.invoice.auth_code || '';
|
document.getElementById('invoice-authorization').value = data.invoice.auth_code || '';
|
||||||
document.getElementById('invoice-tax-exempt').checked = data.invoice.tax_exempt;
|
document.getElementById('invoice-tax-exempt').checked = data.invoice.tax_exempt;
|
||||||
|
document.getElementById('invoice-bill-to-name').value = data.invoice.bill_to_name || '';
|
||||||
// Scheduled Send Date
|
// Scheduled Send Date
|
||||||
const sendDateEl = document.getElementById('invoice-send-date');
|
const sendDateEl = document.getElementById('invoice-send-date');
|
||||||
if (sendDateEl) {
|
if (sendDateEl) {
|
||||||
|
|
@ -951,6 +951,7 @@ async function handleInvoiceSubmit(e) {
|
||||||
auth_code: document.getElementById('invoice-authorization').value,
|
auth_code: document.getElementById('invoice-authorization').value,
|
||||||
tax_exempt: document.getElementById('invoice-tax-exempt').checked,
|
tax_exempt: document.getElementById('invoice-tax-exempt').checked,
|
||||||
scheduled_send_date: document.getElementById('invoice-send-date')?.value || null,
|
scheduled_send_date: document.getElementById('invoice-send-date')?.value || null,
|
||||||
|
bill_to_name: document.getElementById('invoice-bill-to-name')?.value || null,
|
||||||
items: getInvoiceItems() // Deine bestehende Funktion
|
items: getInvoiceItems() // Deine bestehende Funktion
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -430,6 +430,11 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm font-medium text-gray-700 mb-1">Bill To Name (optional)</label>
|
||||||
|
<input type="text" id="invoice-bill-to-name" placeholder="Default: Company name"
|
||||||
|
class="w-full px-4 py-2 border border-gray-300 rounded-md">
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-sm font-medium text-gray-700 mb-1">Date</label>
|
<label class="block text-sm font-medium text-gray-700 mb-1">Date</label>
|
||||||
<input type="date" id="invoice-date" required
|
<input type="date" id="invoice-date" required
|
||||||
|
|
|
||||||
36
server.js
36
server.js
|
|
@ -1308,6 +1308,7 @@ app.get('/api/invoices/:id/pdf', async (req, res) => {
|
||||||
// KORRIGIERT: Abfrage von line1-4
|
// KORRIGIERT: Abfrage von line1-4
|
||||||
const invoiceResult = await pool.query(`
|
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
|
FROM invoices i
|
||||||
LEFT JOIN customers c ON i.customer_id = c.id
|
LEFT JOIN customers c ON i.customer_id = c.id
|
||||||
WHERE i.id = $1
|
WHERE i.id = $1
|
||||||
|
|
@ -1361,11 +1362,28 @@ app.get('/api/invoices/:id/pdf', async (req, res) => {
|
||||||
<td class="total-amount">$${parseFloat(invoice.tax_amount).toFixed(2)}</td>
|
<td class="total-amount">$${parseFloat(invoice.tax_amount).toFixed(2)}</td>
|
||||||
</tr>`;
|
</tr>`;
|
||||||
}
|
}
|
||||||
|
const amountPaid = parseFloat(invoice.amount_paid) || 0;
|
||||||
|
const balanceDue = parseFloat(invoice.total) - amountPaid;
|
||||||
|
|
||||||
itemsHTML += `
|
itemsHTML += `
|
||||||
<tr class="footer-row">
|
<tr class="footer-row">
|
||||||
<td colspan="3" class="total-label">TOTAL:</td>
|
<td colspan="3" class="total-label">TOTAL:</td>
|
||||||
<td class="total-amount">$${parseFloat(invoice.total).toFixed(2)}</td>
|
<td class="total-amount">$${parseFloat(invoice.total).toFixed(2)}</td>
|
||||||
|
</tr>`;
|
||||||
|
|
||||||
|
if (amountPaid > 0) {
|
||||||
|
itemsHTML += `
|
||||||
|
<tr class="footer-row">
|
||||||
|
<td colspan="3" class="total-label" style="font-size: 12px; color: #059669;">Less: Payment received:</td>
|
||||||
|
<td class="total-amount" style="font-size: 12px; color: #059669;">-$${amountPaid.toFixed(2)}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr class="footer-row">
|
||||||
|
<td colspan="3" class="total-label" style="font-weight: bold; font-size: 14px; border-top: 2px solid #333; padding-top: 8px;">BALANCE DUE:</td>
|
||||||
|
<td class="total-amount" style="font-weight: bold; font-size: 14px; border-top: 2px solid #333; padding-top: 8px;">$${balanceDue.toFixed(2)}</td>
|
||||||
|
</tr>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
itemsHTML += `
|
||||||
<tr class="footer-row">
|
<tr class="footer-row">
|
||||||
<td colspan="4" class="thank-you">Thank you for your business!</td>
|
<td colspan="4" class="thank-you">Thank you for your business!</td>
|
||||||
</tr>`;
|
</tr>`;
|
||||||
|
|
@ -1533,6 +1551,7 @@ app.get('/api/invoices/:id/html', async (req, res) => {
|
||||||
// KORREKTUR: Line 1-4 abfragen
|
// KORREKTUR: Line 1-4 abfragen
|
||||||
const invoiceResult = await pool.query(`
|
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
|
FROM invoices i
|
||||||
LEFT JOIN customers c ON i.customer_id = c.id
|
LEFT JOIN customers c ON i.customer_id = c.id
|
||||||
WHERE i.id = $1
|
WHERE i.id = $1
|
||||||
|
|
@ -1586,11 +1605,28 @@ app.get('/api/invoices/:id/html', async (req, res) => {
|
||||||
<td class="total-amount">$${parseFloat(invoice.tax_amount).toFixed(2)}</td>
|
<td class="total-amount">$${parseFloat(invoice.tax_amount).toFixed(2)}</td>
|
||||||
</tr>`;
|
</tr>`;
|
||||||
}
|
}
|
||||||
|
const amountPaid = parseFloat(invoice.amount_paid) || 0;
|
||||||
|
const balanceDue = parseFloat(invoice.total) - amountPaid;
|
||||||
|
|
||||||
itemsHTML += `
|
itemsHTML += `
|
||||||
<tr class="footer-row">
|
<tr class="footer-row">
|
||||||
<td colspan="3" class="total-label">TOTAL:</td>
|
<td colspan="3" class="total-label">TOTAL:</td>
|
||||||
<td class="total-amount">$${parseFloat(invoice.total).toFixed(2)}</td>
|
<td class="total-amount">$${parseFloat(invoice.total).toFixed(2)}</td>
|
||||||
|
</tr>`;
|
||||||
|
|
||||||
|
if (amountPaid > 0) {
|
||||||
|
itemsHTML += `
|
||||||
|
<tr class="footer-row">
|
||||||
|
<td colspan="3" class="total-label" style="font-size: 12px; color: #059669;">Less: Payment received:</td>
|
||||||
|
<td class="total-amount" style="font-size: 12px; color: #059669;">-$${amountPaid.toFixed(2)}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr class="footer-row">
|
||||||
|
<td colspan="3" class="total-label" style="font-weight: bold; font-size: 14px; border-top: 2px solid #333; padding-top: 8px;">BALANCE DUE:</td>
|
||||||
|
<td class="total-amount" style="font-weight: bold; font-size: 14px; border-top: 2px solid #333; padding-top: 8px;">$${balanceDue.toFixed(2)}</td>
|
||||||
|
</tr>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
itemsHTML += `
|
||||||
<tr class="footer-row">
|
<tr class="footer-row">
|
||||||
<td colspan="4" class="thank-you">Thank you for your business!</td>
|
<td colspan="4" class="thank-you">Thank you for your business!</td>
|
||||||
</tr>`;
|
</tr>`;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue