Rechnungsseite: neue STR/MAN-Rechnungen gelistet, STR bei Stripe verlinkt
Die Kundenseite /admin/me/invoices zeigte bisher nur das Legacy-Archiv. Neue Sektion "Aktuelle Rechnungen" mit Netto/USt/Gesamt und Status; STR-Rechnungen oeffnen die gehostete Stripe-Rechnungsansicht ueber einen Redirect-Endpunkt (URL wird je Aufruf frisch geholt, Zugriff nur fuer den Eigentuemer). KPIs zaehlen neu + Archiv zusammen. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
4cda4d3bda
commit
7e571eed94
4 changed files with 226 additions and 25 deletions
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
use App\Enums\InvoiceStatus;
|
||||
use App\Enums\UserPaymentOptionStatus;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\LegacyInvoice;
|
||||
use App\Models\User;
|
||||
use App\Models\UserPaymentOption;
|
||||
|
|
@ -96,6 +98,73 @@ test('customer sees only own legacy invoices', function () {
|
|||
->assertSee('99,00 €');
|
||||
});
|
||||
|
||||
test('current STR and MAN invoices are listed with a stripe link where available', function () {
|
||||
/** @var TestCase $this */
|
||||
$customer = User::factory()->create(['is_active' => true]);
|
||||
|
||||
$strInvoice = Invoice::factory()->create([
|
||||
'user_id' => $customer->id,
|
||||
'user_payment_id' => null,
|
||||
'number' => 'STR-00042',
|
||||
'status' => InvoiceStatus::Paid->value,
|
||||
'amount_cents' => 2900,
|
||||
'tax_cents' => 551,
|
||||
'total_cents' => 3451,
|
||||
'stripe_invoice_id' => 'in_test_42',
|
||||
]);
|
||||
Invoice::factory()->create([
|
||||
'user_id' => $customer->id,
|
||||
'user_payment_id' => null,
|
||||
'number' => 'MAN-00007',
|
||||
'status' => InvoiceStatus::Paid->value,
|
||||
'stripe_invoice_id' => null,
|
||||
]);
|
||||
Invoice::factory()->create([
|
||||
'user_payment_id' => null,
|
||||
'number' => 'STR-99999',
|
||||
'stripe_invoice_id' => 'in_test_other',
|
||||
]);
|
||||
|
||||
$this->actingAs($customer);
|
||||
|
||||
LivewireVolt::test('customer.invoices')
|
||||
->assertSee('Aktuelle Rechnungen')
|
||||
->assertSee('STR-00042')
|
||||
->assertSee('MAN-00007')
|
||||
->assertDontSee('STR-99999')
|
||||
->assertSee('Bei Stripe öffnen')
|
||||
->assertSee(route('me.invoices.stripe', $strInvoice));
|
||||
});
|
||||
|
||||
test('the stripe invoice redirect rejects foreign invoices and ones without stripe id', function () {
|
||||
/** @var TestCase $this */
|
||||
$this->seed(RolesAndPermissionsSeeder::class);
|
||||
|
||||
$customer = User::factory()->create(['is_active' => true]);
|
||||
$customer->assignRole('customer');
|
||||
$intruder = User::factory()->create(['is_active' => true]);
|
||||
$intruder->assignRole('customer');
|
||||
|
||||
$strInvoice = Invoice::factory()->create([
|
||||
'user_id' => $customer->id,
|
||||
'user_payment_id' => null,
|
||||
'stripe_invoice_id' => 'in_test_43',
|
||||
]);
|
||||
$manInvoice = Invoice::factory()->create([
|
||||
'user_id' => $customer->id,
|
||||
'user_payment_id' => null,
|
||||
'stripe_invoice_id' => null,
|
||||
]);
|
||||
|
||||
$this->actingAs($intruder)
|
||||
->get(route('me.invoices.stripe', $strInvoice))
|
||||
->assertNotFound();
|
||||
|
||||
$this->actingAs($customer)
|
||||
->get(route('me.invoices.stripe', $manInvoice))
|
||||
->assertNotFound();
|
||||
});
|
||||
|
||||
test('customer can open generated legacy invoice pdf inline from archive data', function () {
|
||||
/** @var TestCase $this */
|
||||
$this->seed(RolesAndPermissionsSeeder::class);
|
||||
|
|
@ -136,7 +205,7 @@ test('customer can open generated legacy invoice pdf inline from archive data',
|
|||
$this->actingAs($customer);
|
||||
|
||||
LivewireVolt::test('customer.invoices')
|
||||
->assertSee('Hinweis zu Rechnungen')
|
||||
->assertSee('Rechnungsarchiv (Altsystem)')
|
||||
->assertSee('Rechnungsadresse im Profil pflegen')
|
||||
->assertSee('Öffnen');
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue