Verbessere Mitgliederfilter und Zahlungszuordnung

This commit is contained in:
2026-08-13 15:40:43 +02:00
parent 0f263c3a19
commit a93e067e04
6 changed files with 892 additions and 29 deletions
+64
View File
@@ -43,6 +43,12 @@ function payment_matching_insert_participant(PDO $pdo, int $tenantId, string $di
function payment_matching_cleanup(PDO $pdo, array $tenantIds): void
{
foreach ($tenantIds as $tenantId) {
$pdo->prepare(
'DELETE r FROM payment_import_rows r
JOIN payment_import_batches b ON b.id = r.batch_id
WHERE b.tenant_id = ?'
)->execute([$tenantId]);
$pdo->prepare('DELETE FROM payment_import_batches WHERE tenant_id = ?')->execute([$tenantId]);
$pdo->prepare('DELETE FROM participants WHERE tenant_id = ?')->execute([$tenantId]);
$pdo->prepare('DELETE FROM tenants WHERE id = ?')->execute([$tenantId]);
}
@@ -139,6 +145,64 @@ try {
$failures,
$passes
);
$suggestions = imports_suggest_participants($pdo, $tenantId, "paypal unique {$suffix}", null, 3);
payment_matching_assert(
'Vorschlaege enthalten den passenden Teilnehmer',
$suggestions !== [] && $suggestions[0]['participant_id'] === $uniqueId,
$failures,
$passes
);
$batchId = imports_create_batch($pdo, $tenantId, 'matching-test.csv', hash('sha256', $suffix), null);
$unmatchedRowId = imports_store_row(
$pdo,
$batchId,
1,
null,
"PayPal Unique {$suffix}",
500,
date('Y-m-d H:i:s'),
'unmatched',
['row' => 1]
);
$invalidRowId = imports_store_row(
$pdo,
$batchId,
2,
null,
"Kaputt {$suffix}",
0,
date('Y-m-d H:i:s'),
'invalid',
['row' => 2]
);
$assignResult = imports_assign_row($pdo, $tenantId, $batchId, $unmatchedRowId, $uniqueId);
$stmt = $pdo->prepare('SELECT participant_id, status FROM payment_import_rows WHERE id = ?');
$stmt->execute([$unmatchedRowId]);
$assignedRow = $stmt->fetch();
payment_matching_assert(
'unmatched CSV-Zeile kann manuell zugeordnet werden',
$assignResult['ok'] === true
&& (int)$assignedRow['participant_id'] === $uniqueId
&& (string)$assignedRow['status'] === 'matched',
$failures,
$passes
);
$ignoreResult = imports_ignore_row($pdo, $tenantId, $batchId, $invalidRowId);
$stmt = $pdo->prepare('SELECT participant_id, status FROM payment_import_rows WHERE id = ?');
$stmt->execute([$invalidRowId]);
$ignoredRow = $stmt->fetch();
payment_matching_assert(
'ungueltige CSV-Zeile kann ignoriert werden',
$ignoreResult['ok'] === true
&& $ignoredRow['participant_id'] === null
&& (string)$ignoredRow['status'] === 'ignored',
$failures,
$passes
);
} catch (Throwable $e) {
if ($pdo->inTransaction()) {
$pdo->rollBack();