This commit is contained in:
2026-02-19 22:02:22 -06:00
parent 49aeff8cb6
commit 410faee6d1
4 changed files with 142 additions and 149 deletions

View File

@@ -216,8 +216,10 @@ async function loadCustomers() {
}
}
// --- 1. renderCustomers() — ERSETZE komplett ---
// Zeigt QBO-Status, Credit-Betrag und Downpayment-Button
// =====================================================
// 1. renderCustomers() — ERSETZE komplett
// Zeigt QBO-Status und Export-Button in der Kundenliste
// =====================================================
function renderCustomers() {
const tbody = document.getElementById('customers-list');
@@ -228,41 +230,25 @@ function renderCustomers() {
if (cityStateZip) fullAddress += (fullAddress ? ', ' : '') + cityStateZip;
// QBO Status
let qboCol;
if (customer.qbo_id) {
qboCol = `<span class="inline-block px-2 py-0.5 text-xs font-semibold rounded-full bg-green-100 text-green-800" title="QBO ID: ${customer.qbo_id}">QBO ✓</span>`;
} else {
qboCol = `<button onclick="exportCustomerToQbo(${customer.id})" class="inline-block px-2 py-0.5 text-xs font-semibold rounded-full bg-orange-100 text-orange-800 hover:bg-orange-200 cursor-pointer">QBO Export</button>`;
}
// Downpayment button (only if in QBO)
const downpayBtn = customer.qbo_id
? `<button onclick="openDownpaymentModal(${customer.id}, '${customer.qbo_id}', '${customer.name.replace(/'/g, "\\'")}')" class="text-emerald-600 hover:text-emerald-800">Downpayment</button>`
: '';
// Credit placeholder (loaded async)
const creditSpan = customer.qbo_id
? `<span id="customer-credit-${customer.id}" class="text-xs text-gray-400">...</span>`
: '';
const qboStatus = customer.qbo_id
? `<span class="inline-block px-2 py-0.5 text-xs font-semibold rounded-full bg-green-100 text-green-800" title="QBO ID: ${customer.qbo_id}">QBO ✓</span>`
: `<button onclick="exportCustomerToQbo(${customer.id})" class="inline-block px-2 py-0.5 text-xs font-semibold rounded-full bg-orange-100 text-orange-800 hover:bg-orange-200 cursor-pointer" title="Kunde nach QBO exportieren">QBO Export</button>`;
return `
<tr>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">
${customer.name} ${qboCol} ${creditSpan}
${customer.name} ${qboStatus}
</td>
<td class="px-6 py-4 text-sm text-gray-500">${fullAddress || '-'}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${customer.account_number || '-'}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium space-x-2">
<button onclick="editCustomer(${customer.id})" class="text-blue-600 hover:text-blue-900">Edit</button>
${downpayBtn}
<button onclick="deleteCustomer(${customer.id})" class="text-red-600 hover:text-red-900">Delete</button>
</td>
</tr>`;
}).join('');
// Load credits async for QBO customers
loadCustomerCredits();
}
// --- 2. Credits async laden ---
async function loadCustomerCredits() {
const qboCustomers = customers.filter(c => c.qbo_id);