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>
102 lines
2.5 KiB
PHP
102 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Services\Util;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Illuminate\Support\Carbon;
|
|
|
|
/**
|
|
* Class UserAboOneTimeItem
|
|
*
|
|
* Einmalig dem Abo hinzugefügte Produkte aus dem normalen Bestellsortiment.
|
|
* Bewusst getrennt von {@see UserAboItem}, damit diese Positionen nie in die
|
|
* dauerhafte Abo-Logik geraten und nach erfolgreicher Ausführung gelöscht werden.
|
|
*
|
|
* @property int $id
|
|
* @property int $user_abo_id
|
|
* @property int $product_id
|
|
* @property int|null $comp
|
|
* @property int $qty
|
|
* @property int|null $confirmed_qty
|
|
* @property Carbon|null $confirmed_at
|
|
* @property float|null $price
|
|
* @property float|null $price_net
|
|
* @property float|null $tax_rate
|
|
* @property float|null $tax
|
|
* @property float|null $price_vk_net
|
|
* @property float|null $discount
|
|
* @property float|null $points
|
|
* @property int $status
|
|
* @property-read Product $product
|
|
* @property-read UserAbo $user_abo
|
|
*/
|
|
class UserAboOneTimeItem extends Model
|
|
{
|
|
use HasFactory;
|
|
use SoftDeletes;
|
|
|
|
protected $table = 'user_abo_one_time_items';
|
|
|
|
protected $casts = [
|
|
'user_abo_id' => 'int',
|
|
'product_id' => 'int',
|
|
'comp' => 'int',
|
|
'qty' => 'int',
|
|
'confirmed_qty' => 'int',
|
|
'confirmed_at' => 'datetime',
|
|
'price' => 'float',
|
|
'price_net' => 'float',
|
|
'tax_rate' => 'float',
|
|
'tax' => 'float',
|
|
'price_vk_net' => 'float',
|
|
'discount' => 'float',
|
|
'points' => 'float',
|
|
'status' => 'int',
|
|
];
|
|
|
|
protected $fillable = [
|
|
'user_abo_id',
|
|
'product_id',
|
|
'comp',
|
|
'qty',
|
|
'confirmed_qty',
|
|
'confirmed_at',
|
|
'price',
|
|
'price_net',
|
|
'tax_rate',
|
|
'tax',
|
|
'price_vk_net',
|
|
'discount',
|
|
'points',
|
|
'status',
|
|
];
|
|
|
|
public function product(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Product::class);
|
|
}
|
|
|
|
public function user_abo(): BelongsTo
|
|
{
|
|
return $this->belongsTo(UserAbo::class);
|
|
}
|
|
|
|
public function isConfirmed(): bool
|
|
{
|
|
return $this->confirmed_at !== null && $this->confirmed_qty === $this->qty;
|
|
}
|
|
|
|
public function getFormattedPrice(): string
|
|
{
|
|
return Util::formatNumber($this->price);
|
|
}
|
|
|
|
public function getFormattedTotalPrice(): string
|
|
{
|
|
return Util::formatNumber($this->price * $this->qty);
|
|
}
|
|
}
|