Kundenwunsch 06.10.2026: Ein Kunde kam über die Stripe-Rechnungsseite nicht an seine Rechnung und fragte nach Belegen und einer Rechnungs-E-Mail. - Profil ▸ Rechnungsadresse ▸ Rechnungsversand: Schalter „Rechnungs-PDF an die Konto-E-Mail" (Standard an), optionale „E-Mail für Rechnungen" mit Schalter „Rechnungen als PDF an diese Adresse senden" (Standard an). Neue Spalten an billing_addresses (klein, ohne FULLTEXT). - InvoiceDelivery entscheidet Empfänger und Anhang; gleiche Adresse wie das Konto ergibt eine Mail mit PDF. - Zahlungsbestätigung (STR) und Bestandskunden-Rechnung/-Erinnerung (MAN) folgen der Einstellung; die Fassung an die Rechnungs-E-Mail nennt das Konto, ohne Blindkopie und ohne Login-Button. - StripeInvoicePdf holt das Stripe-PDF einmal und legt es lokal ab (storage/app/private/invoices/stripe); Mailversand wiederholt bei Stripe-Ausfall (5 Versuche). - Rechnungsseite: „PDF öffnen" aus pressekonto, „Beleg bei Stripe" für den Zahlungsbeleg auf der Stripe-Seite. Suite 2.340 grün, einer übersprungen; Larastan und Pint ohne Meldung. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
77 lines
1.9 KiB
PHP
77 lines
1.9 KiB
PHP
<?php
|
||
|
||
namespace App\Models;
|
||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||
use Illuminate\Database\Eloquent\Model;
|
||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||
|
||
class BillingAddress extends Model
|
||
{
|
||
use HasFactory;
|
||
|
||
protected $fillable = [
|
||
'user_id',
|
||
'salutation_key',
|
||
'title',
|
||
'company',
|
||
'first_name',
|
||
'last_name',
|
||
'name',
|
||
'address1',
|
||
'address2',
|
||
'postal_code',
|
||
'city',
|
||
'country_code',
|
||
'vat_id',
|
||
'invoice_email',
|
||
'invoice_pdf_to_account',
|
||
'invoice_pdf_to_invoice_email',
|
||
];
|
||
|
||
/**
|
||
* @return array<string, string>
|
||
*/
|
||
protected function casts(): array
|
||
{
|
||
return [
|
||
'invoice_pdf_to_account' => 'boolean',
|
||
'invoice_pdf_to_invoice_email' => 'boolean',
|
||
];
|
||
}
|
||
|
||
/**
|
||
* @return BelongsTo<User, $this>
|
||
*/
|
||
public function user(): BelongsTo
|
||
{
|
||
return $this->belongsTo(User::class);
|
||
}
|
||
|
||
/**
|
||
* Ist die Adresse vollständig genug für eine Rechnung bzw. Buchung?
|
||
* Maßgeblich: Empfänger (Name), Straße, PLZ, Ort und Land.
|
||
*
|
||
* @var list<string>
|
||
*/
|
||
public const REQUIRED_FIELDS = ['name', 'address1', 'postal_code', 'city', 'country_code'];
|
||
|
||
public function isComplete(): bool
|
||
{
|
||
return collect(self::REQUIRED_FIELDS)
|
||
->every(fn (string $field): bool => filled($this->{$field}));
|
||
}
|
||
|
||
/**
|
||
* Anteil der ausgefüllten Pflichtfelder in Prozent (0–100) — für die
|
||
* Fortschritts-Anzeige im Dashboard.
|
||
*/
|
||
public function completenessPercent(): int
|
||
{
|
||
$filled = collect(self::REQUIRED_FIELDS)
|
||
->filter(fn (string $field): bool => filled($this->{$field}))
|
||
->count();
|
||
|
||
return (int) round(($filled / count(self::REQUIRED_FIELDS)) * 100);
|
||
}
|
||
}
|