From 9dc4d15ea040dc4ea0b9770ff601baba98614674 Mon Sep 17 00:00:00 2001 From: mrothauer Date: Thu, 5 Dec 2024 20:03:54 +0100 Subject: [PATCH] csv --- .../src/Controller/FundingsController.php | 39 ++++++++----------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/plugins/Admin/src/Controller/FundingsController.php b/plugins/Admin/src/Controller/FundingsController.php index c3a40f920..a70d5dad4 100644 --- a/plugins/Admin/src/Controller/FundingsController.php +++ b/plugins/Admin/src/Controller/FundingsController.php @@ -41,10 +41,13 @@ public function foerderantragPdf($fundingUid) { public function bankExport() { + $this->disableAutoRender(); $fundingsTable = $this->getTableLocator()->get('Fundings'); $fundings = $fundingsTable->find('all', - conditions: $this->conditions, + conditions: [ + $fundingsTable->aliasField('submit_date IS NOT NULL'), + ], contain: [ 'OwnerUsers', 'Fundingsupporters', @@ -53,20 +56,12 @@ public function bankExport() { $validFundings = []; foreach($fundings as $funding) { - - if (!$funding->is_submitted) { - continue; - } - - if ($funding->owner_user) { - $funding->owner_user->revertPrivatizeData(); - } - + $funding->owner_user->revertPrivatizeData(); $validFundings[] = $funding; - } $writer = Writer::createFromString(); + $writer->setDelimiter(';'); $writer->insertOne($this->getCsvHeader()); $records = []; @@ -74,7 +69,7 @@ public function bankExport() { $record = []; $record = [ 'EUR', // Währung - $funding->budgetplan_total_with_limit, // VorzBetrag + number_format($funding->budgetplan_total_with_limit, 2, ',', ''), // VorzBetrag 'Antrag-' . $funding->uid, // RechNr date('d.m.Y'), // Belegdatum '', // InterneRechNr @@ -85,7 +80,7 @@ public function bankExport() { '5010', // Konto '', // Kontobezeichnung 'Reparaturförderung', // Ware/Leistung - date('Y.m.d'), // Fällig_am + date('d.m.Y'), // Fällig_am '', // gezahlt_am '', // UStSatz '', // USt-IdNr.Kunde @@ -97,24 +92,23 @@ public function bankExport() { '', // Skonto '', // Nachricht '', // Skto_Fällig_am + '', // BankKonto + '', // BankBlz $funding->fundingsupporter->bank_institute, // Bankname - $funding->fundingsupporter->iban, // BankKonto - $funding->fundingsupporter->bic, // BankBlz + $funding->fundingsupporter->iban, // BankIban + $funding->fundingsupporter->bic, // BankBic '', // Skto_Proz + '', // Leistungsdatum ]; $records[] = $record; } $writer->insertAll($records); - $this->disableAutoRender(); - - pr($writer->toString()); - exit; - $response = $this->response; $response = $response->withStringBody($writer->toString()); $response = $response->withCharset('UTF-8'); - $response = $response->withDownload('bankexport' . DateTime::now()->i18nFormat('yyyyMMdd_HHmmss') . '.csv'); + $response = $response->withDownload('bankexport-' . DateTime::now()->i18nFormat('yyyyMMdd_HHmmss') . '.csv'); + return $response; } @@ -135,7 +129,7 @@ private function getCsvHeader() { 'Fällig_am', 'gezahlt_am', 'UStSatz', - 'USt-IdNr.Kunde', + 'USt-IdNr.Lieferant', 'Kunden-Nr.', 'KOST1', 'KOST2', @@ -150,6 +144,7 @@ private function getCsvHeader() { 'BankIban', 'BankBic', 'Skto_Proz', + 'Leistungsdatum', ]; }