Einwand/Entscheidung 12.06.2026: Legacy fakturierte brutto (Steuer inkludiert, z. B. 199 Euro; steuerbefreite Kunden mit Netto-Ausweis 167,23). Alle neuen Preise sind netto; die Steuer wird zur Rechnungsstellung sauber validiert und ausgewiesen. - VatResolver + VatTreatment: DE grundsaetzlich immer mit Steuer, EU nur mit (formal plausibler) USt-ID befreit (Reverse Charge inkl. Pflichthinweis), Drittlaender grundsaetzlich befreit; EU-Laenderliste + vat_rate in config/billing.php - Schema: billing_addresses.vat_id + invoice_billing_addresses.vat_id (Snapshot pro Rechnung), invoices.tax_note; Profil-Formular schreibt die vorhandene USt-ID jetzt auch an die Rechnungsadresse - ManualInvoiceService: rechnet auf Netto-Vertragsbasis (legacy_conditions.net_cents bzw. Netto-Katalogpreis) und bestimmt Steuer/is_netto/tax_note pro Rechnung ueber den VatResolver - legacy:grandfather-subscriptions: leitet net_cents aus der letzten Legacy-Rechnung ab (brutto / 1,19 bzw. is_netto-Betrag direkt); fuer DE-Bestandskunden bleibt der Bruttobetrag unveraendert (199 brutto -> 167,23 netto + 31,77 USt = 199,00) - Doku: Decision-Update 2.1 (Netto-Klarstellung), Phase-9-Plan, Checkliste, 05-DATABASE-MERGE 5.6; offen: VIES-Validierung der USt-ID Tests: VatResolverTest (Datasets fuer alle Faelle), Reverse-Charge/ EU-/Drittland-Rechnungen, Netto-Ableitung; Suite 490 passed, 4 skipped. Pint clean. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
63 lines
1.5 KiB
PHP
63 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Enums\InvoiceStatus;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class Invoice extends Model
|
|
{
|
|
use HasFactory, SoftDeletes;
|
|
|
|
protected $fillable = [
|
|
'user_id',
|
|
'user_payment_id',
|
|
'invoice_billing_address_id',
|
|
'number',
|
|
'status',
|
|
'amount_cents',
|
|
'tax_cents',
|
|
'total_cents',
|
|
'currency',
|
|
'is_netto',
|
|
'tax_note',
|
|
'invoice_date',
|
|
'due_date',
|
|
'paid_at',
|
|
'stripe_invoice_id',
|
|
'pdf_path',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'status' => InvoiceStatus::class,
|
|
'amount_cents' => 'integer',
|
|
'tax_cents' => 'integer',
|
|
'total_cents' => 'integer',
|
|
'is_netto' => 'boolean',
|
|
'invoice_date' => 'date',
|
|
'due_date' => 'date',
|
|
'paid_at' => 'datetime',
|
|
'deleted_at' => 'datetime',
|
|
];
|
|
}
|
|
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
public function userPayment(): BelongsTo
|
|
{
|
|
return $this->belongsTo(UserPayment::class, 'user_payment_id');
|
|
}
|
|
|
|
public function invoiceBillingAddress(): BelongsTo
|
|
{
|
|
return $this->belongsTo(InvoiceBillingAddress::class);
|
|
}
|
|
}
|