better handling payment purpose

This commit is contained in:
2026-09-07 12:10:12 +02:00
parent d07980dd1f
commit 350c8dd0d0
7 changed files with 202 additions and 14 deletions
@@ -263,6 +263,32 @@ class EventIncomeSurplusStatementTest extends TestCase
$this->assertSame('Bastelmaterial — Materialkauf', $this->group('Programmkosten')['rows'][0]['purpose']);
}
public function test_travel_costs_name_the_reason_and_who_travelled(): void
{
// Bei Fahrtkosten bleibt `type_other` leer -- die Strecke landet in `travel_direction`. Der Zweck
// wird deshalb wie in der Beleg-Übersicht ermittelt, über Invoice::purposeText().
$this->makeEvent();
// Der Typ nur hier, nicht im setUp(): dort stehen bewusst drei Typen, deren Gliederung ein
// anderer Test wörtlich prüft.
DB::table('invoice_types')->insert([
'slug' => InvoiceType::INVOICE_TYPE_TRAVELLING,
'name' => 'Fahrtkosten',
'sort_order' => 1,
'selectable' => true,
'counts_as_expense' => true,
]);
$this->makeInvoice(
InvoiceType::INVOICE_TYPE_TRAVELLING,
88.0,
InvoiceStatus::INVOICE_STATUS_EXPORTED,
travelReason: 'Landeslager'
);
$this->assertSame('Landeslager — Mika Muster — Materialkauf', $this->group('Fahrtkosten')['rows'][0]['purpose']);
}
public function test_an_older_receipt_without_the_purchase_note_falls_back_to_the_comment(): void
{
// Belege von vor der Pflichtangabe haben `type_other` leer.
@@ -471,7 +497,8 @@ class EventIncomeSurplusStatementTest extends TestCase
float $amount,
string $status,
bool $donation = false,
?string $typeOther = null
?string $typeOther = null,
?string $travelReason = null
): Invoice {
return Invoice::create([
'tenant' => $this->tenant->slug,
@@ -480,6 +507,7 @@ class EventIncomeSurplusStatementTest extends TestCase
'status' => $status,
'type' => $type,
'type_other' => $typeOther,
'travel_reason' => $travelReason,
'donation' => $donation,
'contact_name' => 'Mika Muster',
'comment' => 'Materialkauf',