From 11d72eca1095df53c8b6141c14fd9f90c4e1565b Mon Sep 17 00:00:00 2001 From: DanielHaefliger Date: Thu, 19 Mar 2026 17:16:50 +0100 Subject: [PATCH] no message --- Abrechnung/module.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Abrechnung/module.php b/Abrechnung/module.php index 6266c25..f7c9c24 100644 --- a/Abrechnung/module.php +++ b/Abrechnung/module.php @@ -399,20 +399,21 @@ private function BuildQRBill($pdf, $user, $amount) $pdf->SetX(118); $pdf->Cell(80, 4, $user['city'] ?? '', 0, 1); } - private function GenerateQRString($iban, $amount, $user) +private function GenerateQRString($iban, $amount, $user) { // Daten nach SIX Swiss Payment Standard beschneiden (max 70 Zeichen pro Zeile) $creditorName = mb_substr($this->ReadPropertyString('CreditorName'), 0, 70); $creditorStr = mb_substr($this->ReadPropertyString('CreditorAddress'), 0, 70); $creditorCity = mb_substr($this->ReadPropertyString('CreditorCity'), 0, 70); - $debtorName = mb_substr($user['name'] ?? '', 0, 70); + // Fallback falls ein Mieter keinen Namen oder Ort hinterlegt hat (Banken verlangen das zwingend) + $debtorName = mb_substr(empty($user['name']) ? 'Unbekannt' : $user['name'], 0, 70); $debtorStr = mb_substr($user['address'] ?? '', 0, 70); - $debtorCity = mb_substr($user['city'] ?? '', 0, 70); + $debtorCity = mb_substr(empty($user['city']) ? 'Unbekannt' : $user['city'], 0, 70); $amountStr = number_format($amount, 2, '.', ''); - // EPC / Swiss QR Code String Format + // EPC / Swiss QR Code String Format (Exakte Reihenfolge ist kritisch!) $lines = [ 'SPC', '0200', '1', $iban, 'K', $creditorName, $creditorStr, $creditorCity, '', '', 'CH', @@ -420,12 +421,12 @@ private function BuildQRBill($pdf, $user, $amount) $amountStr, 'CHF', 'K', $debtorName, $debtorStr, $debtorCity, '', '', 'CH', 'NON', '', // Reference Type (NON = Ohne Referenz) - 'EPD', 'Abrechnung Liegenschaft' + 'Abrechnung Liegenschaft', // 30. Unstrukturierte Mitteilung + 'EPD' // 31. Trailer (Zwingend exakt 'EPD' am Schluss!) ]; return implode("\r\n", $lines); } - // ====================== Stromkosten (15-Minuten, alle User) ====================== private function CalculateAllPowerCosts($powerMeters, $tariffs, $from, $to)