Add usage to invoice

This commit is contained in:
Philipp Lang 2023-12-17 23:00:52 +01:00
parent b0534279b6
commit f4dc8b24bc
8 changed files with 20 additions and 7 deletions

View File

@ -16,6 +16,7 @@ trait HasValidation
return [
'status' => ['required', 'string', 'max:255', Rule::in(InvoiceStatus::values())],
'via' => ['required', 'string', 'max:255', Rule::in(BillKind::values())],
'usage' => 'required|max:255|string',
'to' => 'array',
'to.address' => 'required|string|max:255',
'to.location' => 'required|string|max:255',
@ -42,6 +43,7 @@ trait HasValidation
'to.location' => 'Ort',
'status' => 'Status',
'via' => 'Rechnungsweg',
'usage' => 'Verwendungszweck',
];
}
}

View File

@ -47,6 +47,7 @@ class Invoice extends Model
'greeting' => 'Liebe Familie ' . $member->lastname,
'status' => InvoiceStatus::NEW,
'via' => $member->bill_kind,
'usage' => 'Mitgliedsbeitrag für Familie ' . $member->lastname,
]);
}

View File

@ -34,6 +34,7 @@ class InvoiceResource extends JsonResource
'via' => $this->via->value,
'positions' => InvoicePositionResource::collection($this->whenLoaded('positions')),
'greeting' => $this->greeting,
'usage' => $this->usage,
'links' => [
'update' => route('invoice.update', ['invoice' => $this->getModel()]),
'destroy' => route('invoice.destroy', ['invoice' => $this->getModel()]),
@ -65,6 +66,7 @@ class InvoiceResource extends JsonResource
'greeting' => '',
'status' => InvoiceStatus::NEW->value,
'via' => null,
'usage' => '',
],
'default_position' => [
'id' => null,

View File

@ -31,11 +31,9 @@
<ui-popup v-if="single !== null" :heading="`Rechnung ${single.id ? 'bearbeiten' : 'erstellen'}`"
inner-width="max-w-4xl" @close="cancel">
<form class="grid grid-cols-2 gap-3 mt-4" @submit.prevent="submit">
<ui-box heading="Empfänger" container-class="grid grid-cols-2 gap-3">
<f-text id="to_name" v-model="single.to.name" name="to_name" label="Name" class="col-span-full"
required></f-text>
<f-text id="to_address" v-model="single.to.address" name="to_address" class="col-span-full"
label="Adresse" required></f-text>
<ui-box heading="Empfänger" container-class="grid gap-3">
<f-text id="to_name" v-model="single.to.name" name="to_name" label="Name" required></f-text>
<f-text id="to_address" v-model="single.to.address" name="to_address" label="Adresse" required></f-text>
<f-text id="to_zip" v-model="single.to.zip" name="to_zip" label="PLZ" required></f-text>
<f-text id="to_location" v-model="single.to.location" name="to_location" label="Ort" required></f-text>
</ui-box>
@ -45,6 +43,7 @@
<f-select id="via" v-model="single.via" :options="meta.vias" name="via" label="Rechnungsweg"
required></f-select>
<f-text id="greeting" v-model="single.greeting" name="greeting" label="Anrede" required></f-text>
<f-text id="usage" v-model="single.usage" name="usage" label="Verwendungszweck" required></f-text>
</ui-box>
<ui-box heading="Positionen" class="col-span-full" container-class="grid gap-3">
<template #in-title>

View File

@ -26,7 +26,7 @@ class InvoiceIndexActionTest extends TestCase
->sentAt(now()->subDay())
->via(BillKind::POST)
->status(InvoiceStatus::SENT)
->create();
->create(['usage' => 'Usa']);
$this->get(route('invoice.index'))
->assertInertiaPath('data.data.0.to.name', 'Familie Blabla')
@ -35,6 +35,7 @@ class InvoiceIndexActionTest extends TestCase
->assertInertiaPath('data.data.0.sent_at_human', now()->subDay()->format('d.m.Y'))
->assertInertiaPath('data.data.0.status', 'Rechnung gestellt')
->assertInertiaPath('data.data.0.via', 'Post')
->assertInertiaPath('data.data.0.usage', 'Usa')
->assertInertiaPath('data.data.0.greeting', $invoice->greeting)
->assertInertiaPath('data.data.0.positions.0.price', 1100)
->assertInertiaPath('data.data.0.positions.0.member_id', $member->id)
@ -58,6 +59,7 @@ class InvoiceIndexActionTest extends TestCase
'greeting' => '',
'status' => InvoiceStatus::NEW->value,
'via' => null,
'usage' => '',
])
->assertInertiaPath('data.meta.default_position', [
'id' => null,

View File

@ -18,7 +18,8 @@ class InvoiceRequestFactory extends RequestFactory
'greeting' => 'Hallo Familie',
'status' => InvoiceStatus::NEW->value,
'via' => BillKind::EMAIL->value,
'positions' => []
'positions' => [],
'usage' => $this->faker->words(4, true),
];
}

View File

@ -95,6 +95,11 @@ class InvoiceStoreActionTest extends TestCase
['via' => 'lala'],
['via' => 'Der gewählte Wert für Rechnungsweg ist ungültig.']
];
yield [
['usage' => ''],
['usage' => 'Verwendungszweck ist erforderlich.']
];
}
/**

View File

@ -63,6 +63,7 @@ class MassStoreActionTest extends TestCase
'zip' => '33445',
'location' => 'Solingen',
], $invoice->to);
$this->assertEquals('Mitgliedsbeitrag für Familie Muster', $invoice->usage);
$this->assertEquals(BillKind::EMAIL, $invoice->via);
$this->assertDatabaseHas('invoice_positions', [
'invoice_id' => $invoice->id,