Zahlungsparser
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\ValueObjects;
|
||||
|
||||
use Carbon\CarbonImmutable;
|
||||
|
||||
/**
|
||||
* Ein Umsatz aus dem Kontoauszug -- das Ergebnis einer geparsten CSV-Zeile, noch ohne jede Zuordnung.
|
||||
*
|
||||
* Zahlartneutral: ob der Umsatz überhaupt interessiert (Gutschrift bei der Überweisung, Belastung und
|
||||
* Rücklastschrift bei der SEPA-Lastschrift) entscheidet das jeweilige Zahlungsmodul, nicht der Parser.
|
||||
*
|
||||
* `amount` trägt das Vorzeichen der Bank: Gutschriften positiv, Belastungen negativ.
|
||||
*/
|
||||
final readonly class BankTransaction
|
||||
{
|
||||
public function __construct(
|
||||
public CarbonImmutable $paymentDate,
|
||||
public Amount $amount,
|
||||
public string $purpose,
|
||||
public string $payerName,
|
||||
public string $payerIban,
|
||||
/** Zeilennummer in der hochgeladenen Datei -- Schlüssel der Zeile in der Prüfansicht. */
|
||||
public int $rowNumber,
|
||||
) {
|
||||
}
|
||||
|
||||
public function isCredit(): bool
|
||||
{
|
||||
return $this->amount->getAmount() > 0;
|
||||
}
|
||||
|
||||
/** @return array<string, mixed> */
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'rowNumber' => $this->rowNumber,
|
||||
'paymentDate' => $this->paymentDate->format('Y-m-d'),
|
||||
'paymentDateFormatted' => $this->paymentDate->format('d.m.Y'),
|
||||
'amount' => $this->amount->getAmount(),
|
||||
'amountFormatted' => $this->amount->toString(),
|
||||
'purpose' => $this->purpose,
|
||||
'payerName' => $this->payerName,
|
||||
'payerIban' => $this->payerIban,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user