Invoice PAIN & CSV can be uploaded

This commit is contained in:
2026-02-13 22:37:27 +01:00
parent cd526231ed
commit 4f4dff2edd
29 changed files with 1635 additions and 193 deletions

View File

@@ -0,0 +1,49 @@
<?php
namespace App\Providers;
use App\Models\Invoice;
use App\Resources\InvoiceResource;
class InvoiceCsvFileProvider {
/* @var Invoice[] */
private array $invoices;
public function __construct(array $invoices) {
$this->invoices = $invoices;
}
public function createCsvFileContent() : string
{
$csvArray[] = implode(
',', [
'"Rechnungsnummer"',
'"Zahlungsgrund"',
'"Name"',
'"IBAN"',
'"Kontoinhaber*in"',
'"Betrag"',
'"Spende"',
'"Beleg ohne Auszahlung"',
]);
foreach ($this->invoices as $invoice) {
$invoiceReadable = new InvoiceResource($invoice)->toArray();
$csvLine = implode(',', [
'"' . $invoiceReadable['invoiceNumber'] . '"',
'"' . $invoiceReadable['invoiceType'] . '"',
'"' . $invoiceReadable['contactName'] . '"',
'"' . $invoiceReadable['accountIban'] . '"',
'"' . $invoiceReadable['accountOwner'] . '"',
'"' . $invoiceReadable['amountPlain'] . '"',
'"' . $invoiceReadable['donation'] . '"',
'"' . $invoiceReadable['alreadyPaid'] . '"'
]);
$csvArray[] = $csvLine;
}
return implode(PHP_EOL, $csvArray);
}
}