From 65395c0cae3b99d10bf6ba296f0731e2473e18fa Mon Sep 17 00:00:00 2001 From: Kerim Atilgan Date: Fri, 15 May 2026 18:22:39 +0200 Subject: [PATCH] Fix Gesamt-Provision: shop minus employee share Gesamt-Provision represents what the shop keeps after paying the employee, not the sum of both. Update both the frontend KPI card calculation and the /api/provisionen total_gesamt_provision field so they agree. Co-Authored-By: Claude Opus 4.7 (1M context) --- public/script.js | 3 ++- routes/provisionen.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/public/script.js b/public/script.js index 3db4440..76e5afc 100644 --- a/public/script.js +++ b/public/script.js @@ -2338,7 +2338,8 @@ function updateProvisionenTable(schaltungen, totalShopProvision, totalMitarbeite tbody.appendChild(tr); }); - const totalGesamt = (totalShopProvision || 0) + (totalMitarbeiterProvision || 0); + // Gesamt-Provision = what the shop keeps after paying out the employee share. + const totalGesamt = (totalShopProvision || 0) - (totalMitarbeiterProvision || 0); if (totalShopSpan) totalShopSpan.textContent = formatEuro(totalShopProvision); if (totalMitarbeiterSpan) totalMitarbeiterSpan.textContent = formatEuro(totalMitarbeiterProvision); if (totalGesamtSpan) totalGesamtSpan.textContent = formatEuro(totalGesamt); diff --git a/routes/provisionen.js b/routes/provisionen.js index 64f5867..efe93c0 100644 --- a/routes/provisionen.js +++ b/routes/provisionen.js @@ -138,7 +138,7 @@ router.get('/provisionen', asyncHandler(async (req, res) => { total_provision: totalShop.toFixed(2), total_shop_provision: totalShop.toFixed(2), total_mitarbeiter_provision: totalMitarbeiter.toFixed(2), - total_gesamt_provision: (totalShop + totalMitarbeiter).toFixed(2), + total_gesamt_provision: (totalShop - totalMitarbeiter).toFixed(2), }); }));