Absatzstatistik: Summen aus Bestellpositionen, Kompensationsprodukte ausgewiesen, Extern-Bestellungen nachgefüllt

- Stats\Sales: alle Summenzeilen (Angezeigt/Ausgeblendet/Gesamt/Rabatte/Netto)
  aus price_net × qty der Positionen statt aus subtotal_full/discount des
  Bestellkopfs; WooCommerce-Importe (txaction extern) hatten dort NULL und
  zählten seit 06/2026 mit 0 € (Aug 2026: 449 € statt 3.318 € angezeigt)
- Kompensationsprodukte (comp > 0) bleiben in der Menge, neue Spalten
  „davon Kompensation“ (aktuell + Vorjahr) und Summenzeile 9993
- Gelöschte Produkte bleiben im Umsatz sichtbar (withTrashed, „(gelöscht)“)
- WP-Import setzt subtotal_full und discount jetzt wie der Checkout
- Migration füllt subtotal_full/discount bestehender Extern-Bestellungen nach
- Excel-Export um die beiden Kompensationsspalten erweitert
- Test tests/Feature/StatsSalesVolumeTest.php (Konsistenz, Filter, Jahr)

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Kevin Adametz 2026-09-14 08:15:30 +00:00
parent 2482d073a1
commit ef19dc2ced
6 changed files with 433 additions and 255 deletions

View file

@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
/**
* WooCommerce-Bestellungen (txaction "extern") wurden bis 14.09.2026 ohne
* subtotal_full/discount angelegt (NULL). Die Absatzstatistik zählte sie
* dadurch mit 0 € Umsatz. Nachfüllen: Rabatt gibt es bei Extern-Bestellungen
* nicht, also subtotal_full = subtotal und discount = 0.
*/
return new class extends Migration
{
public function up(): void
{
DB::table('shopping_orders')
->where('txaction', 'extern')
->whereNull('subtotal_full')
->update([
'subtotal_full' => DB::raw('COALESCE(subtotal, 0)'),
'discount' => 0,
]);
DB::table('shopping_orders')
->where('txaction', 'extern')
->whereNull('discount')
->update(['discount' => 0]);
}
public function down(): void
{
// Nachgefüllte Werte sind fachlich korrekt und bleiben erhalten.
}
};