diff --git a/app/Invoice/Data/ReceiverData.php b/app/Invoice/Data/ReceiverData.php index f360c3bd..552a65d8 100644 --- a/app/Invoice/Data/ReceiverData.php +++ b/app/Invoice/Data/ReceiverData.php @@ -15,7 +15,15 @@ class ReceiverData extends Data public string $greeting, ) {} - public static function default(): self { - // return new self('', '', '', '', null, ''); + public static function default(): self + { + return new self( + name: '', + address: '', + zip: '', + location: '', + email: null, + greeting: '' + ); } } diff --git a/app/Invoice/Models/Invoice.php b/app/Invoice/Models/Invoice.php index 3fd26ffd..a1e8848a 100644 --- a/app/Invoice/Models/Invoice.php +++ b/app/Invoice/Models/Invoice.php @@ -152,7 +152,7 @@ class Invoice extends Model public function toSearchableArray(): array { return [ - 'to' => implode(', ', $this->to), + 'to' => implode(', ', $this->to->toArray()), 'usage' => $this->usage, 'status' => $this->status->value, ]; diff --git a/tests/EndToEnd/Invoice/InvoiceIndexActionTest.php b/tests/EndToEnd/Invoice/InvoiceIndexActionTest.php index e769d859..96928e38 100644 --- a/tests/EndToEnd/Invoice/InvoiceIndexActionTest.php +++ b/tests/EndToEnd/Invoice/InvoiceIndexActionTest.php @@ -22,7 +22,7 @@ it('testItDisplaysInvoices', function () { $invoice = Invoice::factory() ->has(InvoicePosition::factory()->price(1100)->for($member)->state(['description' => 'lala']), 'positions') ->has(InvoicePosition::factory()->price(2200)->withMember(), 'positions') - ->to(ReceiverRequestFactory::new()->name('Familie Blabla')) + ->to(ReceiverRequestFactory::new()->name('Familie Blabla')->email('a@b.de')->greeting('Liebe Fam')) ->sentAt(now()->subDay()) ->via(BillKind::POST) ->status(InvoiceStatus::SENT) @@ -36,9 +36,9 @@ it('testItDisplaysInvoices', function () { ->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.mail_email', 'a@b.de') + ->assertInertiaPath('data.data.0.to.email', 'a@b.de') ->assertInertiaPath('data.data.0.usage', 'Usa') - ->assertInertiaPath('data.data.0.greeting', $invoice->greeting) + ->assertInertiaPath('data.data.0.to.greeting', 'Liebe Fam') ->assertInertiaPath('data.data.0.positions.0.price', 1100) ->assertInertiaPath('data.data.0.positions.0.member_id', $member->id) ->assertInertiaPath('data.data.0.positions.0.description', 'lala') @@ -62,13 +62,13 @@ it('testItDisplaysInvoices', function () { 'address' => '', 'zip' => '', 'location' => '', + 'email' => null, + 'greeting' => '', ], 'positions' => [], - 'greeting' => '', 'status' => InvoiceStatus::NEW->value, 'via' => null, 'usage' => '', - 'mail_email' => '', ]) ->assertInertiaPath('data.meta.default_position', [ 'id' => null,