Zahlungsparser
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Enumerations\EatingHabit;
|
||||
use App\Models\Event;
|
||||
use App\Models\EventParticipant;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class EventParticipantRepository {
|
||||
public function getForList(Event $event, Request $request, bool $signedOffParticipants = false) : array {
|
||||
@@ -39,6 +40,39 @@ class EventParticipantRepository {
|
||||
return $participant;
|
||||
}
|
||||
|
||||
/**
|
||||
* Anmeldungen, gegen die ein Zahlungseingang zugeordnet werden kann.
|
||||
*
|
||||
* Abgemeldete sind ausdrücklich dabei: Wer den Beitrag überwiesen und sich danach abgemeldet hat,
|
||||
* steht trotzdem im Kontoauszug. Die Zahlung muss erfasst werden -- erst dann gibt es überhaupt
|
||||
* etwas zu erstatten. Ließe man sie hier weg, bliebe der Eingang unzuordenbar und das Geld läge
|
||||
* unbemerkt auf dem Konto.
|
||||
*
|
||||
* `event.paymentMethods` wird mitgeladen, weil die Zuordnung je Anmeldung das Zahlungsmodul
|
||||
* auflöst und das sonst pro Zeile eine Abfrage wäre.
|
||||
*
|
||||
* @return \Illuminate\Support\Collection<int, EventParticipant>
|
||||
*/
|
||||
public function getForPaymentMatching(Event $event) : Collection {
|
||||
return $event->participants()
|
||||
->with('event.paymentMethods')
|
||||
->orderBy('lastname')
|
||||
->orderBy('firstname')
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Eine Anmeldung dieser Veranstaltung -- der Identifier kommt beim Zahlungsimport aus dem Browser
|
||||
* und wird deshalb hier gegen die Aktion geprüft. Der Tenant-Filter kommt vom SiteScope.
|
||||
*
|
||||
* Abgemeldete eingeschlossen, aus demselben Grund wie in {@see getForPaymentMatching()}.
|
||||
*/
|
||||
public function findInEventByIdentifier(Event $event, string $identifier) : ?EventParticipant {
|
||||
return EventParticipant::where('identifier', $identifier)
|
||||
->where('event_id', $event->id)
|
||||
->first();
|
||||
}
|
||||
|
||||
public function groupByLocalGroup(Event $event, Request $request, ?string $filter = null) : array {
|
||||
$allParticipants = $this->getForList($event, $request);
|
||||
$participants = [];
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Models\AvailablePaymentMethod;
|
||||
|
||||
/**
|
||||
* Zugriff auf die Zahlungsmethoden-Instanzen des Mandanten.
|
||||
*
|
||||
* Existiert, damit die Zahlungsmodule DB-frei bleiben können: Sie bekommen ihre Konfiguration als
|
||||
* Array hereingereicht ({@see \App\EventPaymentModules\ProvidesStatementRuleset}) und holen sie sich
|
||||
* nicht selbst -- sonst bräuchte jeder Modul-Unit-Test eine Datenbank.
|
||||
*/
|
||||
class PaymentMethodRepository
|
||||
{
|
||||
/**
|
||||
* Konfiguration einer Zahlungsart beim aktuellen Mandanten. Der Tenant-Filter kommt vom SiteScope.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function tenantConfiguration(string $slug): array
|
||||
{
|
||||
return (array) (AvailablePaymentMethod::where('slug', $slug)->first()?->configuration ?? []);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user