Punkte: Dezimalpunkte in Einmalprodukten, Homeparty und Shop-API nicht mehr abschneiden
Produkte mit 7,5 Punkten wurden an drei Stellen zu ganzen Zahlen: user_abo_one_time_items (PHP-Cast int, 7,5 -> 7), homeparty_user_order_items (MySQL rundete auf 8) und shopping_collect_orders (Summe der Shop-API). Die Migration zieht die drei Spalten auf DECIMAL(10,2) nach (Nachtrag zu 2026_01_22), Cast und Abo-Snapshot rechnen mit float. points:report-decimal-diff wertet die Differenzen je Berater und Monat aus (nur lesend), points:repair-decimal korrigiert den laufenden Monat und zieht die Monatssummen nach. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
e009b11259
commit
a21bebc932
15 changed files with 1539 additions and 9 deletions
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Migration: Verbliebene Points-Spalten von INT auf DECIMAL(10,2) umstellen
|
||||
*
|
||||
* Nachzug zu 2026_01_22_154524_change_points_columns_to_decimal, dort wurden
|
||||
* diese drei Tabellen übersehen:
|
||||
* - user_abo_one_time_items: points (PHP-Cast schnitt zusätzlich ab: 7,5 -> 7)
|
||||
* - homeparty_user_order_items: points (MySQL rundete auf: 7,5 -> 8)
|
||||
* - shopping_collect_orders: points (Summe des Shop-API-Pfads wurde gerundet)
|
||||
*
|
||||
* Grund: Produkte können Dezimal-Punkte haben (z.B. 7,5 Punkte). Die Punkte
|
||||
* fließen über shopping_orders.points in user_sales_volumes und damit in die
|
||||
* Provisionsberechnung ein.
|
||||
*
|
||||
* Hinweis: `homeparty_user_order_items` hat keine eigene Migration und existiert
|
||||
* daher nicht in jedem Schema (z.B. nicht in der SQLite-Testdatenbank). Alle
|
||||
* Änderungen sind deshalb über hasColumn() abgesichert.
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* @var list<string>
|
||||
*/
|
||||
private array $tables = [
|
||||
'user_abo_one_time_items',
|
||||
'homeparty_user_order_items',
|
||||
'shopping_collect_orders',
|
||||
];
|
||||
|
||||
public function up(): void
|
||||
{
|
||||
foreach ($this->tables as $table) {
|
||||
if (! Schema::hasColumn($table, 'points')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Schema::table($table, function (Blueprint $blueprint) {
|
||||
$blueprint->decimal('points', 10, 2)->unsigned()->nullable()->change();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
foreach ($this->tables as $table) {
|
||||
if (! Schema::hasColumn($table, 'points')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Schema::table($table, function (Blueprint $blueprint) {
|
||||
$blueprint->unsignedInteger('points')->nullable()->change();
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue