diff --git a/app/Invoice/Actions/HasValidation.php b/app/Invoice/Actions/HasValidation.php index 165c49be..652ed662 100644 --- a/app/Invoice/Actions/HasValidation.php +++ b/app/Invoice/Actions/HasValidation.php @@ -17,7 +17,6 @@ trait HasValidation 'status' => ['required', 'string', 'max:255', Rule::in(InvoiceStatus::values())], 'via' => ['required', 'string', 'max:255', Rule::in(BillKind::values())], 'usage' => 'required|max:255|string', - 'mail_name' => 'nullable|string|max:255', 'mail_email' => 'nullable|string|max:255|email', 'to' => 'array', 'to.address' => 'required|string|max:255', diff --git a/app/Invoice/Models/Invoice.php b/app/Invoice/Models/Invoice.php index b5336cbc..30208ff8 100644 --- a/app/Invoice/Models/Invoice.php +++ b/app/Invoice/Models/Invoice.php @@ -51,8 +51,7 @@ class Invoice extends Model 'status' => InvoiceStatus::NEW, 'via' => $member->bill_kind, 'usage' => 'Mitgliedsbeitrag für ' . $member->lastname, - 'mail_email' => $member->email, - 'mail_name' => 'Familie ' . $member->lastname, + 'mail_email' => $member->email_parents ?: $member->email, ]); } @@ -87,7 +86,7 @@ class Invoice extends Model { return (object) [ 'email' => $this->mail_email, - 'name' => $this->mail_name, + 'name' => $this->to['name'] ]; } diff --git a/app/Invoice/Resources/InvoiceResource.php b/app/Invoice/Resources/InvoiceResource.php index 77aa6969..d4c7ffc5 100644 --- a/app/Invoice/Resources/InvoiceResource.php +++ b/app/Invoice/Resources/InvoiceResource.php @@ -35,7 +35,6 @@ class InvoiceResource extends JsonResource 'positions' => InvoicePositionResource::collection($this->whenLoaded('positions')), 'greeting' => $this->greeting, 'usage' => $this->usage, - 'mail_name' => $this->mail_name, 'mail_email' => $this->mail_email, 'links' => [ 'pdf' => route('invoice.pdf', ['invoice' => $this->getModel()]), @@ -71,7 +70,6 @@ class InvoiceResource extends JsonResource 'status' => InvoiceStatus::NEW->value, 'via' => null, 'usage' => '', - 'mail_name' => '', 'mail_email' => '', ], 'default_position' => [ diff --git a/database/migrations/2023_12_12_015320_create_invoices_table.php b/database/migrations/2023_12_12_015320_create_invoices_table.php index c763c13e..586d013a 100644 --- a/database/migrations/2023_12_12_015320_create_invoices_table.php +++ b/database/migrations/2023_12_12_015320_create_invoices_table.php @@ -21,7 +21,6 @@ return new class extends Migration $table->date('sent_at')->nullable(); $table->string('via'); $table->string('usage'); - $table->string('mail_name')->nullable(); $table->string('mail_email')->nullable(); $table->timestamps(); }); diff --git a/resources/js/views/invoice/Index.vue b/resources/js/views/invoice/Index.vue index c23551d6..91369350 100644 --- a/resources/js/views/invoice/Index.vue +++ b/resources/js/views/invoice/Index.vue @@ -31,11 +31,15 @@
- - - + + + + sentAt(now()->subDay()) ->via(BillKind::POST) ->status(InvoiceStatus::SENT) - ->create(['usage' => 'Usa', 'mail_name' => 'lala', 'mail_email' => 'a@b.de']); + ->create(['usage' => 'Usa', 'mail_email' => 'a@b.de']); $this->get(route('invoice.index')) ->assertInertiaPath('data.data.0.to.name', 'Familie Blabla') @@ -35,7 +35,6 @@ 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.mail_name', 'lala') ->assertInertiaPath('data.data.0.mail_email', 'a@b.de') ->assertInertiaPath('data.data.0.usage', 'Usa') ->assertInertiaPath('data.data.0.greeting', $invoice->greeting) @@ -64,7 +63,6 @@ class InvoiceIndexActionTest extends TestCase 'status' => InvoiceStatus::NEW->value, 'via' => null, 'usage' => '', - 'mail_name' => '', 'mail_email' => '', ]) ->assertInertiaPath('data.meta.default_position', [ diff --git a/tests/Feature/Invoice/InvoiceSendActionTest.php b/tests/Feature/Invoice/InvoiceSendActionTest.php index 5fc5d5a5..58b5bdb7 100644 --- a/tests/Feature/Invoice/InvoiceSendActionTest.php +++ b/tests/Feature/Invoice/InvoiceSendActionTest.php @@ -29,11 +29,11 @@ class InvoiceSendActionTest extends TestCase ->to(ReceiverRequestFactory::new()->name('Familie Muster')) ->has(InvoicePosition::factory()->description('lalab')->withMember(), 'positions') ->via(BillKind::EMAIL) - ->create(['mail_name' => 'Muster', 'mail_email' => 'max@muster.de']); + ->create(['mail_email' => 'max@muster.de']); InvoiceSendAction::run(); - Mail::assertSent(BillMail::class, fn ($mail) => $mail->build() && $mail->hasTo('max@muster.de', 'Muster') && Storage::disk('temp')->path('rechnung-fur-familie-muster.pdf') === $mail->filename && Storage::disk('temp')->exists('rechnung-fur-familie-muster.pdf')); + Mail::assertSent(BillMail::class, fn ($mail) => $mail->build() && $mail->hasTo('max@muster.de', 'Familie Muster') && Storage::disk('temp')->path('rechnung-fur-familie-muster.pdf') === $mail->filename && Storage::disk('temp')->exists('rechnung-fur-familie-muster.pdf')); Tex::assertCompiled(BillDocument::class, fn ($document) => 'Familie Muster' === $document->toName); $this->assertEquals(InvoiceStatus::SENT, $invoice->fresh()->status); $this->assertEquals(now()->format('Y-m-d'), $invoice->fresh()->sent_at->format('Y-m-d')); diff --git a/tests/Feature/Invoice/InvoiceStoreActionTest.php b/tests/Feature/Invoice/InvoiceStoreActionTest.php index 368ff21a..13e936fe 100644 --- a/tests/Feature/Invoice/InvoiceStoreActionTest.php +++ b/tests/Feature/Invoice/InvoiceStoreActionTest.php @@ -30,7 +30,7 @@ class InvoiceStoreActionTest extends TestCase 'greeting' => 'Hallo Familie', ]) ->position(InvoicePositionRequestFactory::new()->description('Beitrag Abc')->price(3250)->member($member)) - ->create(['mail_email' => 'a@b.de', 'mail_name' => 'lala']) + ->create(['mail_email' => 'a@b.de']) ); $response->assertOk(); @@ -39,7 +39,6 @@ class InvoiceStoreActionTest extends TestCase 'via' => BillKind::POST->value, 'status' => InvoiceStatus::PAID->value, 'mail_email' => 'a@b.de', - 'mail_name' => 'lala' ]); $invoice = Invoice::firstWhere('greeting', 'Hallo Familie'); $this->assertDatabaseHas('invoice_positions', [ diff --git a/tests/Feature/Invoice/MassStoreActionTest.php b/tests/Feature/Invoice/MassStoreActionTest.php index 5eab81d5..c3e2bdc3 100644 --- a/tests/Feature/Invoice/MassStoreActionTest.php +++ b/tests/Feature/Invoice/MassStoreActionTest.php @@ -65,7 +65,6 @@ class MassStoreActionTest extends TestCase ], $invoice->to); $this->assertEquals('Mitgliedsbeitrag für Muster', $invoice->usage); $this->assertEquals('lala@b.de', $invoice->mail_email); - $this->assertEquals('Familie Muster', $invoice->mail_name); $this->assertEquals(BillKind::EMAIL, $invoice->via); $this->assertDatabaseHas('invoice_positions', [ 'invoice_id' => $invoice->id,