23-01-2026

This commit is contained in:
Kevin Adametz 2026-01-23 17:35:23 +01:00
parent a939cd51ef
commit a8b395e20d
248 changed files with 29342 additions and 4805 deletions

View file

@ -6,6 +6,7 @@
namespace App\Models;
use App\Services\Util;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
@ -29,7 +30,7 @@ use Illuminate\Database\Eloquent\Model;
* @property Homeparty $homeparty
* @property HomepartyUser $homeparty_user
* @property Product $product
* @package App\Models
*
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem query()
@ -47,58 +48,66 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem whereSlug($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem whereTaxRate($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem whereUpdatedAt($value)
*
* @property float|null $ek_price_net
*
* @method static \Illuminate\Database\Eloquent\Builder|HomepartyUserOrderItem whereEkPriceNet($value)
*
* @mixin \Eloquent
*/
class HomepartyUserOrderItem extends Model
{
protected $table = 'homeparty_user_order_items';
protected $table = 'homeparty_user_order_items';
protected $casts = [
'homeparty_id' => 'int',
'homeparty_user_id' => 'int',
'product_id' => 'int',
'qty' => 'int',
'price' => 'float',
'price_net' => 'float',
'tax_rate' => 'float',
'points' => 'int',
'margin' => 'float',
'ek_price' => 'float',
'ek_price_net' => 'float'
protected $casts = [
'homeparty_id' => 'int',
'homeparty_user_id' => 'int',
'product_id' => 'int',
'qty' => 'int',
'price' => 'float',
'price_net' => 'float',
'tax_rate' => 'float',
'points' => 'float',
'margin' => 'float',
'ek_price' => 'float',
'ek_price_net' => 'float',
];
];
protected $fillable = [
'homeparty_id',
'homeparty_user_id',
'product_id',
'qty',
'price',
'price_net',
'tax_rate',
'points',
'margin',
'ek_price',
protected $fillable = [
'homeparty_id',
'homeparty_user_id',
'product_id',
'qty',
'price',
'price_net',
'tax_rate',
'points',
'margin',
'ek_price',
'ek_price_net',
'slug'
];
'slug',
];
public function homeparty()
{
return $this->belongsTo(Homeparty::class);
}
public function homeparty()
{
return $this->belongsTo(Homeparty::class);
}
public function homeparty_user()
{
return $this->belongsTo(HomepartyUser::class);
}
public function homeparty_user()
{
return $this->belongsTo(HomepartyUser::class);
}
public function product()
{
return $this->belongsTo(Product::class);
}
public function product()
{
return $this->belongsTo(Product::class);
}
public function setPointsAttribute($value)
{
$this->attributes['points'] = $value !== null ? Util::reFormatNumber($value) : null;
}
public function getFormattedPrice()
{
@ -117,7 +126,7 @@ class HomepartyUserOrderItem extends Model
public function getFormattedTotalPriceNet()
{
return formatNumber($this->attributes['price_net'] * $this->attributes['qty']);
return formatNumber($this->attributes['price_net'] * $this->attributes['qty']);
}
public function getFormattedEKPrice()
@ -127,7 +136,7 @@ class HomepartyUserOrderItem extends Model
public function getFormattedTotalEKPrice()
{
return formatNumber($this->attributes['ek_price'] * $this->attributes['qty']);
return formatNumber($this->attributes['ek_price'] * $this->attributes['qty']);
}
public function getFormattedEKPriceNet()
@ -137,7 +146,7 @@ class HomepartyUserOrderItem extends Model
public function getFormattedTotalEKPriceNet()
{
return formatNumber($this->attributes['ek_price_net'] * $this->attributes['qty']);
return formatNumber($this->attributes['ek_price_net'] * $this->attributes['qty']);
}
public function getFormattedIncomePrice()
@ -147,12 +156,12 @@ class HomepartyUserOrderItem extends Model
public function getFormattedTotalIncomePrice()
{
return formatNumber(($this->attributes['price'] - $this->attributes['ek_price']) * $this->attributes['qty']);
return formatNumber(($this->attributes['price'] - $this->attributes['ek_price']) * $this->attributes['qty']);
}
public function getFormattedTotalPoints()
{
return formatNumber($this->attributes['points'] * $this->attributes['qty'], 0);
return formatNumber($this->attributes['points'] * $this->attributes['qty'], 2);
}
public function getTotalPrice()
@ -160,25 +169,24 @@ class HomepartyUserOrderItem extends Model
return (float) ($this->attributes['price'] * $this->attributes['qty']);
}
public function getTotalPoints()
{
return ($this->attributes['points'] * $this->attributes['qty']);
return $this->attributes['points'] * $this->attributes['qty'];
}
public function geTotalPriceNet()
{
return (float) ($this->attributes['price_net'] * $this->attributes['qty']);
return (float) ($this->attributes['price_net'] * $this->attributes['qty']);
}
public function geTotalEKPrice()
{
return (float) ($this->attributes['ek_price'] * $this->attributes['qty']);
return (float) ($this->attributes['ek_price'] * $this->attributes['qty']);
}
public function geTotalEKPriceNet()
{
return (float) ($this->attributes['ek_price_net'] * $this->attributes['qty']);
return (float) ($this->attributes['ek_price_net'] * $this->attributes['qty']);
}
public function getIncomePrice()
@ -188,14 +196,13 @@ class HomepartyUserOrderItem extends Model
public function geTotalIncomePrice()
{
return (float) (($this->attributes['price'] - $this->attributes['ek_price']) * $this->attributes['qty']);
return (float) (($this->attributes['price'] - $this->attributes['ek_price']) * $this->attributes['qty']);
}
public function getCurrencyByKey($key)
{
$rNumber = 0;
if($this->homeparty && $this->homeparty->isPriceCurrency()){
if ($this->homeparty && $this->homeparty->isPriceCurrency()) {
$user_country = $this->homeparty->getUserCountry();
$faktor = isset($user_country->currency_faktor) ? $user_country->currency_faktor : 1;
switch ($key) {
@ -204,15 +211,13 @@ class HomepartyUserOrderItem extends Model
break;
case 'TotalPrice':
$rNumber = $this->getTotalPrice() * $faktor;
break;
break;
case 'TotalEKPrice':
$rNumber = $this->geTotalEKPrice() * $faktor;
break;
break;
}
}
return formatNumber($rNumber);
}
}