April 2026 waren Wirtschaft Feedback

This commit is contained in:
Kevin Adametz 2026-04-10 17:14:38 +02:00
parent 02f2a4c23e
commit 9ce711d6b2
167 changed files with 25278 additions and 8518 deletions

View file

@ -9,6 +9,7 @@ namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* Class Ingredient
@ -25,10 +26,10 @@ use Illuminate\Database\Eloquent\Model;
* @property Carbon $created_at
* @property Carbon $updated_at
* @property Collection|Product[] $products
* @package App\Models
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProductIngredient[] $product_ingredients
* @property-read Collection|ProductIngredient[] $product_ingredients
* @property-read int|null $product_ingredients_count
* @property-read int|null $products_count
*
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient query()
@ -43,38 +44,52 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient whereTransInci($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient whereTransName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient whereUpdatedAt($value)
*
* @mixin \Eloquent
*/
class Ingredient extends Model
{
protected $table = 'ingredients';
protected $table = 'ingredients';
protected $casts = [
'active' => 'bool',
'pos' => 'int'
];
protected $casts = [
'active' => 'bool',
'pos' => 'int',
'default_factor' => 'decimal:2',
'min_stock_alert' => 'decimal:2',
];
protected $fillable = [
'name',
'trans_name',
'inci',
'trans_inci',
'effect',
'trans_effect',
'active',
'pos'
];
protected $fillable = [
'name',
'trans_name',
'inci',
'trans_inci',
'effect',
'trans_effect',
'active',
'pos',
'default_factor',
'min_stock_alert',
'material_quality_id',
];
public function products()
{
return $this->belongsToMany(Product::class, 'product_ingredients')
->withPivot('id')
->withTimestamps();
}
/**
* @return BelongsTo<MaterialQuality, $this>
*/
public function materialQuality(): BelongsTo
{
return $this->belongsTo(MaterialQuality::class);
}
public function products()
{
return $this->belongsToMany(Product::class, 'product_ingredients')
->withPivot('id', 'pos', 'gram', 'factor')
->withTimestamps()
->orderByPivot('pos');
}
public function product_ingredients()
{
return $this->hasMany(ProductIngredient::class, 'product_ingredients', 'id');
return $this->hasMany(ProductIngredient::class, 'ingredient_id');
}
}

28
app/Models/Location.php Normal file
View file

@ -0,0 +1,28 @@
<?php
namespace App\Models;
use Database\Factories\LocationFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Location extends Model
{
/** @use HasFactory<LocationFactory> */
use HasFactory;
protected $fillable = [
'name',
'active',
];
/**
* @return array<string, string>
*/
protected function casts(): array
{
return [
'active' => 'boolean',
];
}
}

View file

@ -0,0 +1,18 @@
<?php
namespace App\Models;
use Database\Factories\MaterialQualityFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class MaterialQuality extends Model
{
/** @use HasFactory<MaterialQualityFactory> */
use HasFactory;
protected $fillable = [
'name',
'pos',
];
}

View file

@ -0,0 +1,75 @@
<?php
namespace App\Models;
use Database\Factories\PackagingItemFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\SoftDeletes;
class PackagingItem extends Model
{
/** @use HasFactory<PackagingItemFactory> */
use HasFactory, SoftDeletes;
protected $fillable = [
'packaging_material_id',
'supplier_id',
'name',
'category',
'weight_grams',
'min_stock_alert',
'url',
'product_id',
'active',
];
/**
* @return array<string, string>
*/
protected function casts(): array
{
return [
'active' => 'boolean',
'weight_grams' => 'decimal:2',
];
}
/**
* @return BelongsTo<PackagingMaterial, $this>
*/
public function packagingMaterial(): BelongsTo
{
return $this->belongsTo(PackagingMaterial::class);
}
/**
* @return BelongsTo<Supplier, $this>
*/
public function supplier(): BelongsTo
{
return $this->belongsTo(Supplier::class);
}
/**
* @return BelongsTo<Product, $this>
*/
public function product(): BelongsTo
{
return $this->belongsTo(Product::class);
}
/**
* Produkte, die diesen Verpackungsartikel in der Stückliste führen (BOM).
*
* @return BelongsToMany<Product, $this>
*/
public function products(): BelongsToMany
{
return $this->belongsToMany(Product::class, 'product_packagings')
->withPivot('quantity', 'pos')
->withTimestamps();
}
}

View file

@ -0,0 +1,27 @@
<?php
namespace App\Models;
use Database\Factories\PackagingMaterialFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
class PackagingMaterial extends Model
{
/** @use HasFactory<PackagingMaterialFactory> */
use HasFactory;
protected $fillable = [
'name',
'pos',
];
/**
* @return HasMany<PackagingItem, $this>
*/
public function packagingItems(): HasMany
{
return $this->hasMany(PackagingItem::class);
}
}

View file

@ -11,7 +11,7 @@ use Illuminate\Database\Eloquent\Model;
/**
* Class PaymentReminder
*
*
* @property int $id
* @property string|null $title
* @property int|null $interval
@ -20,38 +20,56 @@ use Illuminate\Database\Eloquent\Model;
* @property bool $active
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property string|null $subject
* @property string|null $clearingtype
*
* @package App\Models
* @method static \Illuminate\Database\Eloquent\Builder<static>|PaymentReminder newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder<static>|PaymentReminder newQuery()
* @method static \Illuminate\Database\Eloquent\Builder<static>|PaymentReminder query()
* @method static \Illuminate\Database\Eloquent\Builder<static>|PaymentReminder whereAction($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|PaymentReminder whereActive($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|PaymentReminder whereClearingtype($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|PaymentReminder whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|PaymentReminder whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|PaymentReminder whereInterval($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|PaymentReminder whereMessage($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|PaymentReminder whereSubject($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|PaymentReminder whereTitle($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|PaymentReminder whereUpdatedAt($value)
*
* @mixin \Eloquent
*/
class PaymentReminder extends Model
{
protected $table = 'payment_reminders';
protected $table = 'payment_reminders';
protected $casts = [
'interval' => 'int',
'active' => 'bool'
];
protected $casts = [
'interval' => 'int',
'active' => 'bool',
];
protected $fillable = [
'title',
'subject',
'interval',
'message',
'action',
'clearingtype',
'active'
];
protected $fillable = [
'title',
'subject',
'interval',
'message',
'action',
'clearingtype',
'active',
];
protected static $clearingtypes = [
protected static $clearingtypes = [
'fnc' => 'Rechnung',
'vor' => 'Vorkasse',
];
public function getClearingtype(){
return isset(self::$clearingtypes[$this->clearingtype]) ? self::$clearingtypes[$this->clearingtype] : 'Kein Typ';
}
public function getClearingtype()
{
return isset(self::$clearingtypes[$this->clearingtype]) ? self::$clearingtypes[$this->clearingtype] : 'Kein Typ';
}
public static function returnClearingtypes(){
return self::$clearingtypes;
}
public static function returnClearingtypes()
{
return self::$clearingtypes;
}
}

View file

@ -5,8 +5,12 @@ namespace App\Models;
use App\Services\Type;
use App\Services\Util;
use Cviebrock\EloquentSluggable\Sluggable;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Carbon;
/**
* App\Models\Product
@ -34,13 +38,14 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @property int|null $pos
* @property int $active
* @property int|null $amount
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property \Illuminate\Support\Carbon|null $deleted_at
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProductAttribute[] $attributes
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProductCategory[] $categories
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProductImage[] $images
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
* @property-read Collection|ProductAttribute[] $attributes
* @property-read Collection|ProductCategory[] $categories
* @property-read Collection|ProductImage[] $images
* @property-write mixed $price_vk
*
* @method static bool|null forceDelete()
* @method static \Illuminate\Database\Query\Builder|\App\Models\Product onlyTrashed()
* @method static bool|null restore()
@ -72,78 +77,102 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereUsage($value)
* @method static \Illuminate\Database\Query\Builder|\App\Models\Product withTrashed()
* @method static \Illuminate\Database\Query\Builder|\App\Models\Product withoutTrashed()
*
* @property string|null $slug
*
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product findSimilarSlugs($attribute, $config, $slug)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereSlug($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product query()
*
* @property int|null $weight
* @property int|null $show_at
* @property array|null $action
* @property-read int|null $attributes_count
* @property-read int|null $categories_count
* @property-read int|null $images_count
*
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereAction($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereShowAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereWeight($value)
*
* @property int|null $points
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProductImage[] $imagesActive
* @property-read Collection|ProductImage[] $imagesActive
* @property-read int|null $images_active_count
*
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product wherePoints($value)
*
* @property string|null $identifier
*
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereIdentifier($value)
*
* @property int|null $upgrade_to_id
*
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereUpgradeToId($value)
*
* @property int|null $contents_total
* @property int|null $unit
*
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereContentsTotal($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereUnit($value)
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\CountryPrice[] $country_prices
*
* @property-read Collection|CountryPrice[] $country_prices
* @property-read int|null $country_prices_count
* @property int|null $wp_number
*
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereWpNumber($value)
*
* @property bool|null $single_commission
*
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereShippingAddon($value)
*
* @property-read int|null $ingredients_count
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProductIngredient[] $product_ingredients
* @property-read Collection|ProductIngredient[] $product_ingredients
* @property-read int|null $product_ingredients_count
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Ingredient[] $p_ingredients
* @property-read Collection|Ingredient[] $p_ingredients
* @property-read int|null $p_ingredients_count
* @property bool $amount_commission
* @property string|null $value_commission
* @property string|null $partner_commission
*
* @method static \Illuminate\Database\Eloquent\Builder|Product whereAmountCommission($value)
* @method static \Illuminate\Database\Eloquent\Builder|Product wherePartnerCommission($value)
* @method static \Illuminate\Database\Eloquent\Builder|Product whereSingleCommission($value)
* @method static \Illuminate\Database\Eloquent\Builder|Product whereValueCommission($value)
*
* @property bool|null $shipping_addon
* @property bool|null $max_buy
* @property int|null $max_buy_num
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProductBuy[] $product_buys
* @property-read Collection|ProductBuy[] $product_buys
* @property-read int|null $product_buys_count
*
* @method static \Illuminate\Database\Eloquent\Builder|Product whereMaxBuy($value)
* @method static \Illuminate\Database\Eloquent\Builder|Product whereMaxBuyNum($value)
* @method static \Illuminate\Database\Eloquent\Builder|Product withUniqueSlugConstraints(\Illuminate\Database\Eloquent\Model $model, string $attribute, array $config, string $slug)
*
* @property string|null $short_copy
* @property array|null $show_on
*
* @method static \Illuminate\Database\Eloquent\Builder|Product whereShortCopy($value)
* @method static \Illuminate\Database\Eloquent\Builder|Product whereShowOn($value)
*
* @property bool $exclude_stats_sales
* @property bool|null $whitelabel
* @property string|null $whitelabel_name
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\ProductAttribute> $attribute_variants
* @property-read Collection<int, ProductAttribute> $attribute_variants
* @property-read int|null $attribute_variants_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\ProductImage> $whitelabel_images
* @property-read Collection<int, ProductImage> $whitelabel_images
* @property-read int|null $whitelabel_images_count
*
* @method static \Illuminate\Database\Eloquent\Builder|Product whereExcludeStatsSales($value)
* @method static \Illuminate\Database\Eloquent\Builder|Product whereWhitelabel($value)
* @method static \Illuminate\Database\Eloquent\Builder|Product whereWhitelabelName($value)
*
* @mixin \Eloquent
*/
class Product extends Model
{
/*identifiers
show_upgrade # in membership payment can upgrade this package to show order
show_order # in membership payment show always
@ -172,8 +201,8 @@ class Product extends Model
'max_buy_num' => 'int',
'whitelabel' => 'bool',
];
use Sluggable;
use Sluggable;
use SoftDeletes;
protected $dates = ['deleted_at'];
@ -215,7 +244,9 @@ class Product extends Model
'upgrade_to_id',
'shipping_addon',
'max_buy',
'max_buy_num'
'max_buy_num',
'shelf_life_type',
'shelf_life_months',
];
@ -225,8 +256,9 @@ class Product extends Model
'show_order' => 'Wird immer als Option angezeigt',
'upgrade' => 'Produktupgrade zur Produkt ID',
'upgrade_member' => 'Vertriebspartnerupgrade zur Karriere ID',
//'proportional_voucher' => 'Anteiliger Gutschein Vertriebspartner',
// 'proportional_voucher' => 'Anteiliger Gutschein Vertriebspartner',
];
public $unitTypes = [
0 => '',
1 => 'ml',
@ -238,9 +270,9 @@ class Product extends Model
public $actions = [
0 => 'payment_for_account',
1 => 'charging_credits',
// 1 => 'payment_for_shop',
// 2 => 'payment_for_shop_upgrade',
// 4 => 'payment_for_lead_upgrade',
// 1 => 'payment_for_shop',
// 2 => 'payment_for_shop_upgrade',
// 4 => 'payment_for_lead_upgrade',
];
@ -248,34 +280,39 @@ class Product extends Model
{
return [
'slug' => [
'source' => 'name'
]
'source' => 'name',
],
];
}
public function attributes(){
return $this->hasMany(ProductAttribute::class, 'product_id', 'id')->where('type_id','!=', 1);
public function attributes()
{
return $this->hasMany(ProductAttribute::class, 'product_id', 'id')->where('type_id', '!=', 1);
}
public function attribute_variants(){
return $this->hasMany(ProductAttribute::class, 'product_id', 'id')->where('type_id','=', 1);
public function attribute_variants()
{
return $this->hasMany(ProductAttribute::class, 'product_id', 'id')->where('type_id', '=', 1);
}
public function categories(){
public function categories()
{
return $this->hasMany('App\Models\ProductCategory', 'product_id', 'id');
}
public function images(){
return $this->hasMany(ProductImage::class, 'product_id', 'id')->where('type','=', 'product')->orderBy('pos');
public function images()
{
return $this->hasMany(ProductImage::class, 'product_id', 'id')->where('type', '=', 'product')->orderBy('pos');
}
public function imagesActive(){
return $this->hasMany(ProductImage::class, 'product_id', 'id')->where('type','=', 'product')->where('active', true)->orderBy('pos');
public function imagesActive()
{
return $this->hasMany(ProductImage::class, 'product_id', 'id')->where('type', '=', 'product')->where('active', true)->orderBy('pos');
}
public function whitelabel_images(){
return $this->hasMany(ProductImage::class, 'product_id', 'id')->where('type','=', 'wllogo')->orderBy('pos');
public function whitelabel_images()
{
return $this->hasMany(ProductImage::class, 'product_id', 'id')->where('type', '=', 'wllogo')->orderBy('pos');
}
public function country_prices()
@ -291,81 +328,130 @@ class Product extends Model
public function p_ingredients()
{
return $this->belongsToMany(Ingredient::class, 'product_ingredients')
->withPivot('id')
->withTimestamps();
->withPivot('id', 'pos', 'gram', 'factor', 'recipe_type')
->withTimestamps()
->wherePivot('recipe_type', 'product')
->orderByPivot('pos');
}
public function manufacturer_ingredients()
{
return $this->belongsToMany(Ingredient::class, 'product_ingredients')
->withPivot('id', 'pos', 'gram', 'factor', 'recipe_type')
->withTimestamps()
->wherePivot('recipe_type', 'manufacturer')
->orderByPivot('pos');
}
public function product_ingredients()
{
return $this->hasMany(ProductIngredient::class, 'product_ingredients', 'id');
return $this->hasMany(ProductIngredient::class, 'product_id');
}
public function getShortCopy($clean = false, $len = false){
/**
* Verpackungs-Stückliste (BOM) am Produkt mit Menge und Reihenfolge.
*
* @return BelongsToMany<PackagingItem, $this>
*/
public function packagings()
{
return $this->belongsToMany(PackagingItem::class, 'product_packagings')
->withPivot('quantity', 'pos')
->withTimestamps()
->orderByPivot('pos');
}
/**
* @return HasMany<Production, $this>
*/
public function productions(): HasMany
{
return $this->hasMany(Production::class);
}
public function getShortCopy($clean = false, $len = false)
{
$ret = $this->short_copy ? $this->short_copy : $this->description;
if($len && $clean){
if ($len && $clean) {
return substr_ellipsis($ret, $len, $clean);
}
return $ret;
}
public function getActionName($id = 0){
if(isset($this->actions[$id])){
public function getActionName($id = 0)
{
if (isset($this->actions[$id])) {
return $this->actions[$id];
}
return false;
}
public function getWhiteLableName($id = 0){
public function getWhiteLableName($id = 0)
{
return $this->whitelabel_name ? $this->whitelabel_name : $this->name;
}
public function _format_number($value){
return preg_replace("/[^0-9,]/", "", $value);
public function _format_number($value)
{
return preg_replace('/[^0-9,]/', '', $value);
}
public function setPriceAttribute( $value ) {
public function setPriceAttribute($value)
{
$this->attributes['price'] = $value ? Util::reFormatNumber($value) : null;
}
public function setPriceEkAttribute( $value ) {
public function setPriceEkAttribute($value)
{
$this->attributes['price_ek'] = $value ? Util::reFormatNumber($value) : null;
}
public function setTaxAttribute( $value ) {
$this->attributes['tax'] = $value != "" ? Util::reFormatNumber($value) : null;
public function setTaxAttribute($value)
{
$this->attributes['tax'] = $value != '' ? Util::reFormatNumber($value) : null;
}
public function setPriceOldAttribute( $value ) {
public function setPriceOldAttribute($value)
{
$this->attributes['price_old'] = $value ? Util::reFormatNumber($value) : null;
}
public function setValueCommissionAttribute( $value ) {
public function setValueCommissionAttribute($value)
{
$this->attributes['value_commission'] = $value ? Util::reFormatNumber($value) : 0;
}
public function setPartnerCommissionAttribute( $value ) {
public function setPartnerCommissionAttribute($value)
{
$this->attributes['partner_commission'] = $value ? Util::reFormatNumber($value) : 0;
}
public function getFormattedPrice()
{
return isset($this->attributes['price']) ? Util::formatNumber($this->attributes['price']) : "";
return isset($this->attributes['price']) ? Util::formatNumber($this->attributes['price']) : '';
}
public function getFormattedPriceEk()
{
return isset($this->attributes['price_ek']) ? Util::formatNumber($this->attributes['price_ek']) : "";
return isset($this->attributes['price_ek']) ? Util::formatNumber($this->attributes['price_ek']) : '';
}
public function getFormattedTax($country = null)
{
return isset($this->attributes['tax']) ? Util::formatNumber($this->getTaxWith($country), 0) : "";
return isset($this->attributes['tax']) ? Util::formatNumber($this->getTaxWith($country), 0) : '';
}
public function getFormattedPriceOld()
{
return isset($this->attributes['price_old']) ? Util::formatNumber($this->attributes['price_old']) : "";
return isset($this->attributes['price_old']) ? Util::formatNumber($this->attributes['price_old']) : '';
}
public function getFormattedValueCommission()
{
return isset($this->attributes['value_commission']) ? Util::formatNumber($this->attributes['value_commission']) : 0;
@ -376,9 +462,9 @@ class Product extends Model
return isset($this->attributes['partner_commission']) ? Util::formatNumber($this->attributes['partner_commission']) : 0;
}
/*price by user Factor*/
private function calcPriceUserFactor($price){
/* price by user Factor */
private function calcPriceUserFactor($price)
{
/*
Nicht in benutzung, die margin errechnet sich im Warenkorb, wegen der Staffelprovision
if(\Auth::user() && \Auth::user()->user_level){
@ -388,98 +474,116 @@ class Product extends Model
*/
return $price;
}
/*price net*/
private function calcPriceNet($price, $country=null){
/* price net */
private function calcPriceNet($price, $country = null)
{
$tax = $this->getTaxWith($country);
$tax_rate = ($tax + 100) / 100;
$tax_rate = ($tax + 100) / 100;
return $price / $tax_rate;
}
//price calu with
public function getPriceWith(Bool $net = true, Bool $ufactor = true, $country = null, $commission=false){
// price calu with
public function getPriceWith(bool $net = true, bool $ufactor = true, $country = null, $commission = false)
{
$price = isset($this->attributes['price']) ? $this->attributes['price'] : null;
/*$cprice = $country ? $this->getCPrice($country) : null; //eigener Preis für Land
$price = $cprice ? $cprice : $price; */
$price = $net ? $this->calcPriceNet($price, $country) : $price;
$price = $ufactor ? $this->calcPriceUserFactor($price) : $price;
$price = $commission ? $this->calcPriceUserCommission($price) : $price;
return round($price, 2);
}
/*out*/
public function getFormattedPriceWith(Bool $net = true, Bool $ufactor = true)
/* out */
public function getFormattedPriceWith(bool $net = true, bool $ufactor = true)
{
return isset($this->attributes['price']) ? Util::formatNumber($this->getPriceWith($net, $ufactor)) : "";
return isset($this->attributes['price']) ? Util::formatNumber($this->getPriceWith($net, $ufactor)) : '';
}
public function getTaxWith($country = null){
public function getTaxWith($country = null)
{
$tax = isset($this->attributes['tax']) ? $this->attributes['tax'] : null;
$ctax = $country ? $this->getCTax($country) : null;
return $ctax !== null ? $ctax : $tax;
}
public function getBasePriceFormattedFull(){
if($price = $this->getBasePrice()){
public function getBasePriceFormattedFull()
{
if ($price = $this->getBasePrice()) {
$unit = $this->attributes['unit'];
//ml g
if($unit === 1 || $unit === 2){
return Util::formatNumber($price) . ' € / 100 '.$this->getUnitType();
// ml g
if ($unit === 1 || $unit === 2) {
return Util::formatNumber($price).' € / 100 '.$this->getUnitType();
}
//l kg
if($unit === 3 || $unit === 4){
return Util::formatNumber($price) . ' € / 1 '.$this->getUnitType();
// l kg
if ($unit === 3 || $unit === 4) {
return Util::formatNumber($price).' € / 1 '.$this->getUnitType();
}
}
return "";
return '';
}
public function getBasePriceFormatted(){
if($price = $this->getBasePrice()){
public function getBasePriceFormatted()
{
if ($price = $this->getBasePrice()) {
return Util::formatNumber($price);
}
return "";
return '';
}
public function getBasePrice(){
if(isset($this->attributes['unit']) && isset($this->attributes['contents_total']) && $this->attributes['contents_total'] != 0){
public function getBasePrice()
{
if (isset($this->attributes['unit']) && isset($this->attributes['contents_total']) && $this->attributes['contents_total'] != 0) {
$unit = $this->attributes['unit'];
//ml g
if($unit === 1 || $unit === 2){
// ml g
if ($unit === 1 || $unit === 2) {
return $this->attributes['price'] * 100 / $this->attributes['contents_total'];
}
//l kg
if($unit === 3 || $unit === 4){
return $this->attributes['price'] * 1000 / $this->attributes['contents_total'];
// l kg
if ($unit === 3 || $unit === 4) {
return $this->attributes['price'] * 1000 / $this->attributes['contents_total'];
}
}
return "";
return '';
}
public function getUnitType(){
public function getUnitType()
{
return isset($this->unitTypes[$this->unit]) ? $this->unitTypes[$this->unit] : '-';
}
public function getShowAtType(){
public function getShowAtType()
{
return isset(Type::$showATs[$this->show_at]) ? Type::$showATs[$this->show_at] : '-';
}
public function getShowOnTypes($seperator = false){
public function getShowOnTypes($seperator = false)
{
$ret = [];
if($this->show_on && is_array($this->show_on)){
foreach($this->show_on as $show){
if ($this->show_on && is_array($this->show_on)) {
foreach ($this->show_on as $show) {
$ret[] = isset(Type::$showONs[$show]) ? Type::$showONs[$show] : '-';
}
}
return $seperator ? implode($seperator, $ret) : $ret;
}
public function setPosAttribute($value){
public function setPosAttribute($value)
{
$this->attributes['pos'] = is_numeric($value) ? $value : null;
}
public function getLang($key)
{
$lang = \App::getLocale();
@ -487,62 +591,75 @@ class Product extends Model
return $this->{$key};
}
$trans = $this->getTrans($key, $lang);
if (!$trans || $trans == '') {
if (! $trans || $trans == '') {
return $this->{$key};
}
return $trans;
}
public function getTrans($key, $lang)
{
$key = 'trans_' . $key;
if (!empty($this->{$key}[$lang])) {
$key = 'trans_'.$key;
if (! empty($this->{$key}[$lang])) {
return $this->{$key}[$lang];
}
}
public function getTranNames()
{
$ret = "";
foreach ((array) $this->trans_name as $value){
$ret = '';
foreach ((array) $this->trans_name as $value) {
$ret .= $value.', ';
}
return rtrim($ret, ', ');
}
public function getCountryPrice($country_id){
return $this->country_prices->where('country_id', '=', $country_id)->first() ?: new CountryPrice();
public function getCountryPrice($country_id)
{
return $this->country_prices->where('country_id', '=', $country_id)->first() ?: new CountryPrice;
}
public function getCPrice($country_id){
public function getCPrice($country_id)
{
return $this->getCountryPrice($country_id)->c_price;
}
public function getCTax($country_id){
public function getCTax($country_id)
{
return $this->getCountryPrice($country_id)->c_tax;
}
public function getCPriceOld($country_id){
public function getCPriceOld($country_id)
{
return $this->getCountryPrice($country_id)->c_price_old;
}
public function getCCurrency($country_id){
public function getCCurrency($country_id)
{
return $this->getCountryPrice($country_id)->c_currency;
}
public function getRealPrice(Country $country){
if($country->own_eur && $this->getCPrice($country->id)){
public function getRealPrice(Country $country)
{
if ($country->own_eur && $this->getCPrice($country->id)) {
return $this->getCPrice($country->id);
}
return $this->price;
}
public function getFormattedPriceCurrencyWith(Bool $net = true, Bool $ufactor = true, Country $country = null, $commission = false){
$ret = "";
if($country && isset($country->currency) && $country->currency){
$price = $this->getPriceWith($net, $ufactor, $country, $commission);
$ret = formatNumber($price * $country->currency_faktor)." ".$country->currency_unit;
public function getFormattedPriceCurrencyWith(bool $net = true, bool $ufactor = true, ?Country $country = null, $commission = false)
{
$ret = '';
if ($country && isset($country->currency) && $country->currency) {
$price = $this->getPriceWith($net, $ufactor, $country, $commission);
$ret = formatNumber($price * $country->currency_faktor).' '.$country->currency_unit;
return '<br><span class="small">~'.$ret.'<span>';
}
return "" ;
return '';
}
}

View file

@ -19,7 +19,7 @@ use Illuminate\Database\Eloquent\Model;
* @property Carbon $updated_at
* @property Ingredient $ingredient
* @property Product $product
* @package App\Models
*
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductIngredient newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductIngredient newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductIngredient query()
@ -28,29 +28,37 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductIngredient whereIngredientId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductIngredient whereProductId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductIngredient whereUpdatedAt($value)
*
* @mixin \Eloquent
*/
class ProductIngredient extends Model
{
protected $table = 'product_ingredients';
protected $table = 'product_ingredients';
protected $casts = [
'product_id' => 'int',
'ingredient_id' => 'int'
];
protected $casts = [
'product_id' => 'int',
'ingredient_id' => 'int',
'pos' => 'int',
'gram' => 'decimal:3',
'factor' => 'decimal:2',
];
protected $fillable = [
'product_id',
'ingredient_id'
];
protected $fillable = [
'product_id',
'ingredient_id',
'pos',
'gram',
'factor',
'recipe_type',
];
public function ingredient()
{
return $this->belongsTo(Ingredient::class, 'ingredient_id');
}
public function ingredient()
{
return $this->belongsTo(Ingredient::class, 'ingredient_id');
}
public function product()
{
return $this->belongsTo(Product::class, 'product_id');
}
public function product()
{
return $this->belongsTo(Product::class, 'product_id');
}
}

72
app/Models/Production.php Normal file
View file

@ -0,0 +1,72 @@
<?php
namespace App\Models;
use App\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
class Production extends Model
{
protected $fillable = [
'product_id',
'location_id',
'produced_by',
'produced_at',
'quantity',
'notes',
'mhd_warning',
];
/**
* @return array<string, string>
*/
protected function casts(): array
{
return [
'produced_at' => 'date',
'mhd_warning' => 'boolean',
];
}
/**
* @return BelongsTo<Product, $this>
*/
public function product(): BelongsTo
{
return $this->belongsTo(Product::class);
}
/**
* @return BelongsTo<Location, $this>
*/
public function location(): BelongsTo
{
return $this->belongsTo(Location::class);
}
/**
* @return BelongsTo<User, $this>
*/
public function producedByUser(): BelongsTo
{
return $this->belongsTo(User::class, 'produced_by');
}
/**
* @return HasMany<ProductionIngredient, $this>
*/
public function productionIngredients(): HasMany
{
return $this->hasMany(ProductionIngredient::class);
}
/**
* @return HasMany<ProductionPackaging, $this>
*/
public function productionPackagings(): HasMany
{
return $this->hasMany(ProductionPackaging::class);
}
}

View file

@ -0,0 +1,50 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class ProductionIngredient extends Model
{
protected $fillable = [
'production_id',
'ingredient_id',
'stock_entry_id',
'quantity_used',
];
/**
* @return array<string, string>
*/
protected function casts(): array
{
return [
'quantity_used' => 'decimal:2',
];
}
/**
* @return BelongsTo<Production, $this>
*/
public function production(): BelongsTo
{
return $this->belongsTo(Production::class);
}
/**
* @return BelongsTo<Ingredient, $this>
*/
public function ingredient(): BelongsTo
{
return $this->belongsTo(Ingredient::class);
}
/**
* @return BelongsTo<StockEntry, $this>
*/
public function stockEntry(): BelongsTo
{
return $this->belongsTo(StockEntry::class);
}
}

View file

@ -0,0 +1,41 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class ProductionPackaging extends Model
{
protected $fillable = [
'production_id',
'packaging_item_id',
'quantity_used',
];
/**
* @return array<string, string>
*/
protected function casts(): array
{
return [
'quantity_used' => 'integer',
];
}
/**
* @return BelongsTo<Production, $this>
*/
public function production(): BelongsTo
{
return $this->belongsTo(Production::class);
}
/**
* @return BelongsTo<PackagingItem, $this>
*/
public function packagingItem(): BelongsTo
{
return $this->belongsTo(PackagingItem::class);
}
}

View file

@ -2,8 +2,11 @@
namespace App\Models;
use App\User;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Carbon;
/**
* App\Models\ShoppingOrder
@ -22,16 +25,17 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @property int|null $weight
* @property int|null $paid
* @property string|null $txaction
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \App\User|null $auth_user
* @property-read \App\Models\Country $country
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ShoppingOrderItem[] $shopping_order_items
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property-read User|null $auth_user
* @property-read Country $country
* @property-read Collection|ShoppingOrderItem[] $shopping_order_items
* @property-read int|null $shopping_order_items_count
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ShoppingPayment[] $shopping_payments
* @property-read Collection|ShoppingPayment[] $shopping_payments
* @property-read int|null $shopping_payments_count
* @property-read \App\Models\ShoppingUser $shopping_user
* @property-read \App\Models\UserShop $user_shop
* @property-read ShoppingUser $shopping_user
* @property-read UserShop $user_shop
*
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder query()
@ -51,62 +55,93 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereUserShopId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereWeight($value)
*
* @property int|null $payment_for
*
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder wherePaymentFor($value)
*
* @property int|null $member_id
* @property string|null $mode
* @property-read \App\User|null $member
* @property-read \App\Models\UserHistory|null $user_history
* @property-read User|null $member
* @property-read UserHistory|null $user_history
*
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereMemberId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereMode($value)
* @property \Illuminate\Support\Carbon|null $deleted_at
*
* @property Carbon|null $deleted_at
* @property string|null $user_deleted_at
*
* @method static \Illuminate\Database\Query\Builder|\App\Models\ShoppingOrder onlyTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereDeletedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereUserDeletedAt($value)
* @method static \Illuminate\Database\Query\Builder|\App\Models\ShoppingOrder withTrashed()
* @method static \Illuminate\Database\Query\Builder|\App\Models\ShoppingOrder withoutTrashed()
* @property-read \App\Models\ShippingCountry $shipping_country
*
* @property-read ShippingCountry $shipping_country
* @property float|null $shipping_net
* @property float|null $subtotal_shipping
* @property int|null $points
* @property int|null $shipped
* @property string|null $tracking
* @property string|null $wp_invoice_path
*
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder wherePoints($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereShipped($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereShippingNet($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereSubtotalWs($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereTracking($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereWpInvoicePath($value)
*
* @property array|null $wp_notice
*
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereWpNotice($value)
*
* @property string|null $subtotal_full
* @property-read \App\Models\ShoppingOrderMargin|null $shopping_order_margin
* @property-read \App\Models\ShoppingPayment|null $shopping_payment_last
* @property-read ShoppingOrderMargin|null $shopping_order_margin
* @property-read ShoppingPayment|null $shopping_payment_last
*
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereSubtotalFull($value)
*
* @property string|null $discount
* @property string|null $payment_credit
*
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereDiscount($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder wherePaymentCredit($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereSubtotalShipping($value)
*
* @property string|null $total_without_credit
*
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereTotalWithoutCredit($value)
*
* @property array|null $invoice
* @property \Illuminate\Support\Carbon|null $shipped_at
* @property Carbon|null $shipped_at
*
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereInvoice($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereShippedAt($value)
*
* @property string|null $invoice_number
*
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereInvoiceNumber($value)
*
* @property int|null $promotion_user_id
* @property string|null $shipping_option
* @property-read \App\Models\PromotionUser|null $promotion_user
* @property-read PromotionUser|null $promotion_user
*
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder wherePromotionUserId($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereShippingOption($value)
*
* @property array|null $delivery
*
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereDelivery($value)
*
* @property bool $user_white_label
*
* @method static \Illuminate\Database\Eloquent\Builder<static>|ShoppingOrder whereUserWhiteLabel($value)
*
* @property array<array-key, mixed>|null $cancellation_invoice
*
* @method static \Illuminate\Database\Eloquent\Builder<static>|ShoppingOrder whereCancellationInvoice($value)
*
* @mixin \Eloquent
*/
class ShoppingOrder extends Model
@ -114,6 +149,7 @@ class ShoppingOrder extends Model
protected $table = 'shopping_orders';
use SoftDeletes;
protected $dates = ['deleted_at'];
protected $fillable = [
@ -139,6 +175,7 @@ class ShoppingOrder extends Model
'weight',
'paid',
'invoice',
'cancellation_invoice',
'delivery',
'user_white_label',
'invoice_number',
@ -155,6 +192,7 @@ class ShoppingOrder extends Model
protected $casts = [
'wp_notice' => 'array',
'invoice' => 'array',
'cancellation_invoice' => 'array',
'delivery' => 'array',
'shipped_at' => 'datetime',
'user_white_label' => 'boolean',
@ -167,14 +205,14 @@ class ShoppingOrder extends Model
3 => 'abgeschlossen',
5 => 'Wartestellung',
4 => 'Abholung',
10 => 'storniert'
10 => 'storniert',
];
public static $paymentForTypes = [
0 => '',
1 => 'Registrierung',
2 => 'Mitgliedschaft',
3 => 'Guthabenaufladung', //guthaben
3 => 'Guthabenaufladung', // guthaben
4 => 'VP.Bestellung Abholung',
5 => 'VP.Bestellung Lieferung',
6 => 'VP.Kundenbestellung',
@ -182,7 +220,7 @@ class ShoppingOrder extends Model
8 => 'Shop',
9 => '-',
10 => 'extern',
11 => ''
11 => '',
];
public static $paymentForColors = [
@ -198,18 +236,17 @@ class ShoppingOrder extends Model
8 => 'info',
9 => 'default',
10 => 'info',
11 => 'default'
11 => 'default',
];
public static $apiShippedTypes = [
0 => 'open', //(Fullfilment durch Händler)',
1 => 'process', //(Fullfilment: nicht Versand)
2 => 'sent', //(Fullfilment: Versand erfolgt)'
3 => 'close', //(Fullfilment: Versand erfolgt)',
4 => 'pick_up', //(Fullfilment: Versand erfolgt)',
10 => 'cancel'
0 => 'open', // (Fullfilment durch Händler)',
1 => 'process', // (Fullfilment: nicht Versand)
2 => 'sent', // (Fullfilment: Versand erfolgt)'
3 => 'close', // (Fullfilment: Versand erfolgt)',
4 => 'pick_up', // (Fullfilment: Versand erfolgt)',
10 => 'cancel',
];
public static $shippedColors = [
@ -224,101 +261,126 @@ class ShoppingOrder extends Model
public function shopping_user()
{
return $this->belongsTo('App\Models\ShoppingUser','shopping_user_id');
return $this->belongsTo('App\Models\ShoppingUser', 'shopping_user_id');
}
public function country()
{
return $this->belongsTo('App\Models\ShippingCountry','country_id');
return $this->belongsTo('App\Models\ShippingCountry', 'country_id');
}
public function shipping_country()
{
return $this->belongsTo('App\Models\ShippingCountry','country_id');
return $this->belongsTo('App\Models\ShippingCountry', 'country_id');
}
public function promotion_user()
{
return $this->belongsTo('App\Models\PromotionUser','promotion_user_id');
return $this->belongsTo('App\Models\PromotionUser', 'promotion_user_id');
}
public function user_shop()
{
return $this->belongsTo('App\Models\UserShop','user_shop_id');
return $this->belongsTo('App\Models\UserShop', 'user_shop_id');
}
//can null
// can null
public function member()
{
return $this->belongsTo('App\User','member_id');
return $this->belongsTo('App\User', 'member_id');
}
//can null
// can null
public function auth_user()
{
return $this->belongsTo('App\User','auth_user_id');
return $this->belongsTo('App\User', 'auth_user_id');
}
public function user_history()
{
return $this->hasOne('App\Models\UserHistory','shopping_order_id')->latest();
return $this->hasOne('App\Models\UserHistory', 'shopping_order_id')->latest();
}
public function shopping_order_margin()
{
return $this->hasOne('App\Models\ShoppingOrderMargin','shopping_order_id')->latest();
return $this->hasOne('App\Models\ShoppingOrderMargin', 'shopping_order_id')->latest();
}
public function shopping_order_items(){
public function shopping_order_items()
{
return $this->hasMany('App\Models\ShoppingOrderItem', 'shopping_order_id');
}
public function shopping_payments(){
/**
* Mindestens eine Bestellzeile mit White-Label-Produkt (Lieferschein mit Etikett-Infos).
*/
public function hasWhitelabelProducts(): bool
{
return $this->shopping_order_items()
->whereHas('product', function ($query): void {
$query->where('whitelabel', true);
})
->exists();
}
public function shopping_payments()
{
return $this->hasMany('App\Models\ShoppingPayment', 'shopping_order_id');
}
public function shopping_payment_last(){
public function shopping_payment_last()
{
return $this->hasOne('App\Models\ShoppingPayment', 'shopping_order_id')->latest();
}
public function setUserHistoryValue($values = []){
if($user_history = $this->user_history){
foreach ($values as $key=>$val){
public function setUserHistoryValue($values = [])
{
if ($user_history = $this->user_history) {
foreach ($values as $key => $val) {
$user_history->{$key} = $val;
}
$user_history->save();
}
}
public function getLastShoppingPayment($key=false){
public function getLastShoppingPayment($key = false)
{
$shopping_payment = $this->shopping_payments->last();
if($shopping_payment){
if($key === 'getPaymentType'){
if ($shopping_payment) {
if ($key === 'getPaymentType') {
return $shopping_payment->getPaymentType();
}
if($key === 'reference'){
if ($key === 'reference') {
return $shopping_payment->reference;
}
}
return "";
return '';
}
public function getShippedType(){
return isset(self::$shippedTypes[$this->shipped]) ? self::$shippedTypes[$this->shipped] : "";
public function getShippedType()
{
return isset(self::$shippedTypes[$this->shipped]) ? self::$shippedTypes[$this->shipped] : '';
}
public function getAPIShippedType(){
return isset(self::$apiShippedTypes[$this->shipped]) ? self::$apiShippedTypes[$this->shipped] : "free";
public function getAPIShippedType()
{
return isset(self::$apiShippedTypes[$this->shipped]) ? self::$apiShippedTypes[$this->shipped] : 'free';
}
public function getShippedColor(){
return isset(self::$shippedColors[$this->shipped]) ? self::$shippedColors[$this->shipped] : "default";
public function getShippedColor()
{
return isset(self::$shippedColors[$this->shipped]) ? self::$shippedColors[$this->shipped] : 'default';
}
public function getPaymentForType(){
return isset(self::$paymentForTypes[$this->payment_for]) ? self::$paymentForTypes[$this->payment_for] : "";
public function getPaymentForType()
{
return isset(self::$paymentForTypes[$this->payment_for]) ? self::$paymentForTypes[$this->payment_for] : '';
}
public function getPaymentForColor(){
return isset(self::$paymentForColors[$this->payment_for]) ? self::$paymentForColors[$this->payment_for] : "";
public function getPaymentForColor()
{
return isset(self::$paymentForColors[$this->payment_for]) ? self::$paymentForColors[$this->payment_for] : '';
}
public function getFormattedTotal()
@ -360,39 +422,46 @@ class ShoppingOrder extends Model
{
return formatNumber($this->attributes['tax']);
}
public function getFormattedTotalWithoutCredit()
{
return formatNumber($this->attributes['total_without_credit']);
}
public function getFormattedPaymentCredit()
{
return formatNumber($this->attributes['payment_credit']);
}
public function getFormattedTotalShipping()
{
return formatNumber($this->attributes['total_shipping']);
}
public function getItemsCount(){
public function getItemsCount()
{
$count = 0;
if($this->shopping_order_items){
foreach ($this->shopping_order_items as $shopping_order_item){
if ($this->shopping_order_items) {
foreach ($this->shopping_order_items as $shopping_order_item) {
$count += $shopping_order_item->qty;
}
}
return $count;
}
public function isInvoice(){
public function isInvoice()
{
return $this->user_invoice ? true : false;
}
public function isPickUp(){
public function isPickUp()
{
return $this->shipping_option === 'pick_up' ? true : false;
}
public function isTax(){
public function isTax()
{
return $this->tax > 0 ? true : false;
}
}

View file

@ -3,7 +3,9 @@
namespace App\Models;
use App\Services\Util;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Carbon;
/**
* App\Models\ShoppingPayment
@ -18,11 +20,12 @@ use Illuminate\Database\Eloquent\Model;
* @property string $currency
* @property string|null $status
* @property string|null $txaction
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\PaymentTransaction[] $payment_transactions
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property-read Collection|PaymentTransaction[] $payment_transactions
* @property-read int|null $payment_transactions_count
* @property-read \App\Models\ShoppingOrder $shopping_order
* @property-read ShoppingOrder $shopping_order
*
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment query()
@ -38,8 +41,17 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment whereTxaction($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment whereWallettype($value)
*
* @property string|null $mode
*
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment whereMode($value)
*
* @property int|null $reminder
* @property Carbon|null $reminder_date
*
* @method static \Illuminate\Database\Eloquent\Builder<static>|ShoppingPayment whereReminder($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|ShoppingPayment whereReminderDate($value)
*
* @mixin \Eloquent
*/
class ShoppingPayment extends Model
@ -58,7 +70,7 @@ class ShoppingPayment extends Model
'reminder',
'reminder_date',
'txaction',
'mode'
'mode',
];
protected $casts = [
@ -66,44 +78,46 @@ class ShoppingPayment extends Model
'reminder_date' => 'datetime',
];
public function shopping_order()
{
return $this->belongsTo('App\Models\ShoppingOrder','shopping_order_id');
return $this->belongsTo('App\Models\ShoppingOrder', 'shopping_order_id');
}
public function payment_transactions()
{
return $this->hasMany('App\Models\PaymentTransaction','shopping_payment_id');
return $this->hasMany('App\Models\PaymentTransaction', 'shopping_payment_id');
}
public function getPaymentType(){
public function getPaymentType()
{
if($this->clearingtype === 'pp') {
if ($this->clearingtype === 'pp') {
return 'PayPal';
}
if($this->clearingtype === 'cc') {
if ($this->clearingtype === 'cc') {
return 'Kreditkarte';
}
if($this->clearingtype === 'vor') {
if ($this->clearingtype === 'vor') {
return 'Vorkasse';
}
if($this->clearingtype === 'elv') {
if ($this->clearingtype === 'elv') {
return 'SEPA Lastschrift';
}
if($this->clearingtype === 'sb') {
if ($this->clearingtype === 'sb') {
return 'Sofort Überweisung';
}
if($this->clearingtype === 'fnc') {
if ($this->clearingtype === 'fnc') {
return 'Rechnung';
}
if($this->clearingtype === 'non') {
if ($this->clearingtype === 'non') {
return 'keine';
}
return 'keine';
}
public function getPaymentAmount(){
return Util::formatNumber($this->amount/100)." ".$this->currency;
public function getPaymentAmount()
{
return Util::formatNumber($this->amount / 100).' '.$this->currency;
}
}
}

118
app/Models/StockEntry.php Normal file
View file

@ -0,0 +1,118 @@
<?php
namespace App\Models;
use App\User;
use Database\Factories\StockEntryFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class StockEntry extends Model
{
/** @use HasFactory<StockEntryFactory> */
use HasFactory;
protected $fillable = [
'entry_type',
'ingredient_id',
'packaging_item_id',
'supplier_id',
'location_id',
'unit',
'ordered_by',
'ordered_at',
'ordered_quantity',
'price_per_kg',
'price_total',
'received_by',
'received_at',
'received_quantity',
'batch_number',
'best_before',
'quality_id',
'status',
];
/**
* @return array<string, string>
*/
protected function casts(): array
{
return [
'ordered_at' => 'date',
'received_at' => 'date',
'best_before' => 'date',
'ordered_quantity' => 'decimal:2',
'received_quantity' => 'decimal:2',
'price_per_kg' => 'decimal:4',
'price_total' => 'decimal:4',
];
}
/**
* @return BelongsTo<Ingredient, $this>
*/
public function ingredient(): BelongsTo
{
return $this->belongsTo(Ingredient::class);
}
/**
* @return BelongsTo<PackagingItem, $this>
*/
public function packagingItem(): BelongsTo
{
return $this->belongsTo(PackagingItem::class);
}
/**
* @return BelongsTo<Supplier, $this>
*/
public function supplier(): BelongsTo
{
return $this->belongsTo(Supplier::class);
}
/**
* @return BelongsTo<Location, $this>
*/
public function location(): BelongsTo
{
return $this->belongsTo(Location::class);
}
/**
* @return BelongsTo<MaterialQuality, $this>
*/
public function quality(): BelongsTo
{
return $this->belongsTo(MaterialQuality::class, 'quality_id');
}
/**
* @return BelongsTo<User, $this>
*/
public function orderedByUser(): BelongsTo
{
return $this->belongsTo(User::class, 'ordered_by');
}
/**
* @return BelongsTo<User, $this>
*/
public function receivedByUser(): BelongsTo
{
return $this->belongsTo(User::class, 'received_by');
}
public function isPending(): bool
{
return $this->status === 'pending';
}
public function isReceived(): bool
{
return $this->status === 'received';
}
}

67
app/Models/Supplier.php Normal file
View file

@ -0,0 +1,67 @@
<?php
namespace App\Models;
use Database\Factories\SupplierFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
class Supplier extends Model
{
/** @use HasFactory<SupplierFactory> */
use HasFactory, SoftDeletes;
protected $fillable = [
'name',
'url',
'contact_person',
'email',
'phone',
'country_id',
'notes',
'active',
];
/**
* @return array<string, string>
*/
protected function casts(): array
{
return [
'active' => 'boolean',
];
}
/**
* @return BelongsTo<Country, $this>
*/
public function country(): BelongsTo
{
return $this->belongsTo(Country::class);
}
/**
* @return BelongsToMany<SupplierCategory, $this>
*/
public function supplierCategories(): BelongsToMany
{
return $this->belongsToMany(
SupplierCategory::class,
'supplier_supplier_category',
'supplier_id',
'supplier_category_id'
)->withTimestamps();
}
/**
* @return HasMany<PackagingItem, $this>
*/
public function packagingItems(): HasMany
{
return $this->hasMany(PackagingItem::class);
}
}

View file

@ -0,0 +1,32 @@
<?php
namespace App\Models;
use Database\Factories\SupplierCategoryFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
class SupplierCategory extends Model
{
/** @use HasFactory<SupplierCategoryFactory> */
use HasFactory;
protected $fillable = [
'name',
'pos',
];
/**
* @return BelongsToMany<Supplier, $this>
*/
public function suppliers(): BelongsToMany
{
return $this->belongsToMany(
Supplier::class,
'supplier_supplier_category',
'supplier_category_id',
'supplier_id'
)->withTimestamps();
}
}