Remove mail_name

This commit is contained in:
Philipp Lang 2023-12-18 01:56:58 +01:00
parent be29a284d5
commit afbfdf7ca2
9 changed files with 13 additions and 18 deletions

View File

@ -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',

View File

@ -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']
];
}

View File

@ -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' => [

View File

@ -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();
});

View File

@ -31,11 +31,15 @@
<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 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>
<ui-box heading="Empfänger" container-class="grid grid-cols-2 gap-3 col-span-full">
<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" label="Adresse"
class="col-span-full" 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>
<f-text id="mail_email" v-model="single.mail_email" name="mail_email" label="E-Mail-Adresse"
class="col-span-full"></f-text>
</ui-box>
<ui-box heading="Status" container-class="grid gap-3">
<f-select id="status" v-model="single.status" :options="meta.statuses" name="status" label="Status"

View File

@ -26,7 +26,7 @@ class InvoiceIndexActionTest extends TestCase
->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', [

View File

@ -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'));

View File

@ -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', [

View File

@ -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,