Update Framework, Invoices
This commit is contained in:
parent
cc5c147c27
commit
9b0b5feb7e
174 changed files with 28356 additions and 8093 deletions
|
|
@ -45,6 +45,7 @@ use Cviebrock\EloquentSluggable\Sluggable;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category whereTransHeadline($value)
|
||||
* @property-read \App\Models\IqImage|null $iq_image
|
||||
* @property-read int|null $product_categories_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Category withUniqueSlugConstraints(\Illuminate\Database\Eloquent\Model $model, string $attribute, array $config, string $slug)
|
||||
*/
|
||||
class Category extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -57,6 +57,10 @@ use PHPUnit\Framework\Constraint\Count;
|
|||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\CountryPrice[] $country_prices
|
||||
* @property-read int|null $country_prices_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereCurrencyUnit($value)
|
||||
* @property bool|null $eu_country
|
||||
* @property bool|null $supply_country
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Country whereEuCountry($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Country whereSupplyCountry($value)
|
||||
*/
|
||||
class Country extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -59,6 +59,19 @@ use Illuminate\Database\Eloquent\Collection;
|
|||
* @property-read int|null $homeparty_guests_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty whereToken($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty whereTokenActive($value)
|
||||
* @property int|null $country_id
|
||||
* @property int|null $step
|
||||
* @property array|null $settings
|
||||
* @property array|null $order
|
||||
* @property array|null $card_info
|
||||
* @property-read Country|null $country
|
||||
* @property-read Collection|\App\Models\HomepartyUserOrderItem[] $homeparty_order_items
|
||||
* @property-read int|null $homeparty_order_items_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Homeparty whereCardInfo($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Homeparty whereCountryId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Homeparty whereOrder($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Homeparty whereSettings($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Homeparty whereStep($value)
|
||||
*/
|
||||
class Homeparty extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -105,6 +105,10 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @mixin \Eloquent
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\HomepartyUserOrderItem[] $homeparty_user_order_items
|
||||
* @property-read int|null $homeparty_user_order_items_count
|
||||
* @property string|null $delivery
|
||||
* @property array|null $settings
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|HomepartyUser whereDelivery($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|HomepartyUser whereSettings($value)
|
||||
*/
|
||||
class HomepartyUser extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @property float $tax_rate
|
||||
* @property int $points
|
||||
* @property float $margin
|
||||
* @property float $ek-price
|
||||
* @property float $ek_price
|
||||
* @property string $slug
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
|
|
@ -48,6 +48,8 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem whereTaxRate($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property float|null $ek_price_net
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|HomepartyUserOrderItem whereEkPriceNet($value)
|
||||
*/
|
||||
class HomepartyUserOrderItem extends Model
|
||||
{
|
||||
|
|
@ -63,8 +65,8 @@ class HomepartyUserOrderItem extends Model
|
|||
'tax_rate' => 'float',
|
||||
'points' => 'int',
|
||||
'margin' => 'float',
|
||||
'ek-price' => 'float',
|
||||
'ek-price_net' => 'float'
|
||||
'ek_price' => 'float',
|
||||
'ek_price_net' => 'float'
|
||||
|
||||
];
|
||||
|
||||
|
|
@ -78,8 +80,8 @@ class HomepartyUserOrderItem extends Model
|
|||
'tax_rate',
|
||||
'points',
|
||||
'margin',
|
||||
'ek-price',
|
||||
'ek-price_net',
|
||||
'ek_price',
|
||||
'ek_price_net',
|
||||
'slug'
|
||||
];
|
||||
|
||||
|
|
@ -120,32 +122,32 @@ class HomepartyUserOrderItem extends Model
|
|||
|
||||
public function getFormattedEKPrice()
|
||||
{
|
||||
return formatNumber($this->attributes['ek-price']);
|
||||
return formatNumber($this->attributes['ek_price']);
|
||||
}
|
||||
|
||||
public function getFormattedTotalEKPrice()
|
||||
{
|
||||
return formatNumber($this->attributes['ek-price'] * $this->attributes['qty']);
|
||||
return formatNumber($this->attributes['ek_price'] * $this->attributes['qty']);
|
||||
}
|
||||
|
||||
public function getFormattedEKPriceNet()
|
||||
{
|
||||
return formatNumber($this->attributes['ek-price_net']);
|
||||
return formatNumber($this->attributes['ek_price_net']);
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
return formatNumber($this->attributes['price'] - $this->attributes['ek-price']);
|
||||
return formatNumber($this->attributes['price'] - $this->attributes['ek_price']);
|
||||
}
|
||||
|
||||
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()
|
||||
|
|
@ -171,22 +173,22 @@ class HomepartyUserOrderItem extends Model
|
|||
|
||||
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()
|
||||
{
|
||||
return (float) ($this->attributes['price'] - $this->attributes['ek-price']);
|
||||
return (float) ($this->attributes['price'] - $this->attributes['ek-ek_price']);
|
||||
}
|
||||
|
||||
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']);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage query()
|
||||
* @property int|null $pos
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IqImage wherePos($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|IqImage withUniqueSlugConstraints(\Illuminate\Database\Eloquent\Model $model, string $attribute, array $config, string $slug)
|
||||
*/
|
||||
class IqImage extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentMethod whereShowAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentMethod whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property array|null $show_on
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PaymentMethod whereShowOn($value)
|
||||
*/
|
||||
class PaymentMethod extends Model
|
||||
{
|
||||
|
|
@ -85,7 +87,7 @@ class PaymentMethod extends Model
|
|||
|
||||
public function getShowOnTypes(){
|
||||
$ret = [];
|
||||
if($this->show_on){
|
||||
if($this->show_on && is_array($this->show_on)){
|
||||
foreach($this->show_on as $show){
|
||||
$ret[] = isset(self::$showONs[$show]) ? self::$showONs[$show] : '-';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -108,6 +108,13 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @property-read int|null $ingredients_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProductIngredient[] $product_ingredients
|
||||
* @property-read int|null $product_ingredients_count
|
||||
* @property bool|null $no_commission
|
||||
* @property array|null $show_on
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Ingredient[] $p_ingredients
|
||||
* @property-read int|null $p_ingredients_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereNoCommission($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereShowOn($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product withUniqueSlugConstraints(\Illuminate\Database\Eloquent\Model $model, string $attribute, array $config, string $slug)
|
||||
*/
|
||||
class Product extends Model
|
||||
{
|
||||
|
|
@ -297,8 +304,7 @@ class Product extends Model
|
|||
{
|
||||
return isset($this->attributes['price_ek']) ? Util::formatNumber($this->attributes['price_ek']) : "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getFormattedPriceOld()
|
||||
{
|
||||
return isset($this->attributes['price_old']) ? Util::formatNumber($this->attributes['price_old']) : "";
|
||||
|
|
@ -437,17 +443,18 @@ class Product extends Model
|
|||
|
||||
public function getShowOnTypes(){
|
||||
$ret = [];
|
||||
foreach($this->show_on as $show){
|
||||
$ret[] = isset($this->showONs[$show]) ? $this->showONs[$show] : '-';
|
||||
if($this->show_on && is_array($this->show_on)){
|
||||
foreach($this->show_on as $show){
|
||||
$ret[] = isset($this->showONs[$show]) ? $this->showONs[$show] : '-';
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
public function setPosAttribute($value){
|
||||
$this->attributes['pos'] = is_numeric($value) ? $value : null;
|
||||
|
||||
}
|
||||
|
||||
public function getLang($key)
|
||||
{
|
||||
$lang = \App::getLocale();
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductCategory newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductCategory newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductCategory query()
|
||||
* @property int|null $pos
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ProductCategory wherePos($value)
|
||||
*/
|
||||
class ProductCategory extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage query()
|
||||
* @property int|null $pos
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage wherePos($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ProductImage withUniqueSlugConstraints(\Illuminate\Database\Eloquent\Model $model, string $attribute, array $config, string $slug)
|
||||
*/
|
||||
class ProductImage extends Model
|
||||
{
|
||||
|
|
|
|||
144
app/Models/Setting.php
Normal file
144
app/Models/Setting.php
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class Setting
|
||||
*
|
||||
* @property int $id
|
||||
* @property string|null $identifier
|
||||
* @property string $slug
|
||||
* @property int $referenz
|
||||
* @property string|null $action
|
||||
* @property string|null $object
|
||||
* @property string|null $full_text
|
||||
* @property string|null $text
|
||||
* @property int|null $int
|
||||
* @property int $status
|
||||
* @property string|null $type
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @package App\Models
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereAction($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereFullText($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereIdentifier($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereInt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereObject($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereReferenz($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereSlug($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereStatus($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereText($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereType($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Setting extends Model
|
||||
{
|
||||
protected $table = 'settings';
|
||||
|
||||
protected $casts = [
|
||||
'referenz' => 'int',
|
||||
'status' => 'int',
|
||||
'int' => 'int',
|
||||
'object' => 'array'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'identifier',
|
||||
'slug',
|
||||
'referenz',
|
||||
'action',
|
||||
'object',
|
||||
'full_text',
|
||||
'text',
|
||||
'int',
|
||||
'status',
|
||||
'type'
|
||||
];
|
||||
|
||||
protected static $types = [
|
||||
'object' => 'Object',
|
||||
'full_text' => 'Full Text',
|
||||
'text' => 'Text',
|
||||
'int' => 'Zahl',
|
||||
'bool' => 'Bool',
|
||||
|
||||
|
||||
];
|
||||
|
||||
public function sluggable()
|
||||
{
|
||||
return [
|
||||
'slug' => [
|
||||
'source' => 'name'
|
||||
]
|
||||
];
|
||||
}
|
||||
public static function getContentBySlug($slug){
|
||||
$content = self::whereSlug(trim($slug))->first();
|
||||
if($content){
|
||||
switch ($content->type){
|
||||
case 'object':
|
||||
return $content->object;
|
||||
break;
|
||||
case 'full_text':
|
||||
return $content->full_text;
|
||||
break;
|
||||
case 'text':
|
||||
return $content->text;
|
||||
break;
|
||||
case 'int':
|
||||
return $content->int;
|
||||
break;
|
||||
case 'bool':
|
||||
return $content->int === 1 ? true : false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function setContentBySlug($slug, $value, $type = "full_text"){
|
||||
|
||||
$content = self::whereSlug(trim($slug))->first();
|
||||
if(!$content) {
|
||||
$content = self::create([
|
||||
'slug' => $slug,
|
||||
'type' => $type,
|
||||
]);
|
||||
}
|
||||
$content->type = $type;
|
||||
switch ($content->type){
|
||||
case 'object':
|
||||
$content->object = $value ? $value : null;;
|
||||
break;
|
||||
case 'full_text':
|
||||
$content->full_text = $value ? $value : null;;
|
||||
break;
|
||||
case 'text':
|
||||
$content->text = $value ? $value : null;;
|
||||
break;
|
||||
case 'int':
|
||||
$content->int = (int) $value;
|
||||
break;
|
||||
case 'bool':
|
||||
$content->int = $value ? 1 : 0;
|
||||
break;
|
||||
}
|
||||
|
||||
$content->save();
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
|
@ -80,6 +80,11 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @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 int|null $homeparty_id
|
||||
* @property array|null $wp_notice
|
||||
* @property-read \App\Models\Homeparty|null $homeparty
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereHomepartyId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereWpNotice($value)
|
||||
*/
|
||||
class ShoppingOrder extends Model
|
||||
{
|
||||
|
|
@ -93,6 +98,7 @@ class ShoppingOrder extends Model
|
|||
'auth_user_id',
|
||||
'member_id',
|
||||
'homeparty_id',
|
||||
'payment_for',
|
||||
'country_id',
|
||||
'user_shop_id',
|
||||
'total',
|
||||
|
|
@ -101,6 +107,7 @@ class ShoppingOrder extends Model
|
|||
'shipping_net',
|
||||
'subtotal_ws',
|
||||
'tax',
|
||||
'tax_split',
|
||||
'total_shipping',
|
||||
'points',
|
||||
'weight',
|
||||
|
|
@ -115,6 +122,7 @@ class ShoppingOrder extends Model
|
|||
|
||||
protected $casts = [
|
||||
'wp_notice' => 'array',
|
||||
'tax_split' => 'array',
|
||||
];
|
||||
|
||||
public static $shippedTypes = [
|
||||
|
|
@ -141,6 +149,34 @@ class ShoppingOrder extends Model
|
|||
10 => 'danger',
|
||||
];
|
||||
|
||||
public static $paymentForTypes = [
|
||||
0 => '',
|
||||
1 => 'Registrierung',
|
||||
2 => 'Mitgliedschaft',
|
||||
3 => 'Bestellung',
|
||||
4 => 'Kundenbestellung',
|
||||
5 => 'Homeparty',
|
||||
6 => 'Shop',
|
||||
7 => 'extern',
|
||||
10 => '',
|
||||
];
|
||||
|
||||
public static $paymentForColors = [
|
||||
0 => 'default',
|
||||
1 => 'warning',
|
||||
2 => 'warning',
|
||||
3 => 'secondary',
|
||||
4 => 'info',
|
||||
5 => 'dark',
|
||||
6 => 'secondary',
|
||||
7 => 'dark',
|
||||
8 => 'info',
|
||||
9 => 'default',
|
||||
10 => 'info',
|
||||
11 => 'default'
|
||||
|
||||
];
|
||||
|
||||
|
||||
public function shopping_user()
|
||||
{
|
||||
|
|
@ -183,7 +219,10 @@ class ShoppingOrder extends Model
|
|||
return $this->hasOne('App\Models\UserHistory','shopping_order_id')->latest();
|
||||
}
|
||||
|
||||
|
||||
public function user_invoice(){
|
||||
return $this->hasOne('App\Models\UserInvoice', 'shopping_order_id', '');
|
||||
}
|
||||
|
||||
public function shopping_order_items(){
|
||||
return $this->hasMany('App\Models\ShoppingOrderItem', 'shopping_order_id');
|
||||
}
|
||||
|
|
@ -192,6 +231,18 @@ class ShoppingOrder extends Model
|
|||
return $this->hasMany('App\Models\ShoppingPayment', 'shopping_order_id');
|
||||
}
|
||||
|
||||
public function user_sales_volume(){
|
||||
return $this->hasMany('App\Models\UserSalesVolume', 'shopping_order_id');
|
||||
}
|
||||
|
||||
public function user_sales_volume_no_userid(){
|
||||
return $this->hasMany('App\Models\UserSalesVolume', 'shopping_order_id')->where('user_id', '=', NULL)->first();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function setUserHistoryValue($values = []){
|
||||
if($user_history = $this->user_history){
|
||||
foreach ($values as $key=>$val){
|
||||
|
|
@ -250,6 +301,11 @@ class ShoppingOrder extends Model
|
|||
{
|
||||
return formatNumber($this->attributes['subtotal_ws']);
|
||||
}
|
||||
|
||||
public function getFormattedSubtotalShipping()
|
||||
{
|
||||
return formatNumber($this->attributes['subtotal_shipping']);
|
||||
}
|
||||
|
||||
public function getFormattedTax()
|
||||
{
|
||||
|
|
@ -261,8 +317,33 @@ class ShoppingOrder extends Model
|
|||
return formatNumber($this->attributes['total_shipping']);
|
||||
}
|
||||
|
||||
public function getPriceVkNetBy($product_id)
|
||||
{
|
||||
if($product = Product::find($product_id)){
|
||||
if($this->shipping_country && $this->shipping_country->country){
|
||||
return $product->getPriceWith(true, false, $this->shipping_country->country);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
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 getUserDiscount()
|
||||
{
|
||||
if($this->auth_user && $this->auth_user->user_level){
|
||||
return $this->auth_user->user_level->getFormattedMargin();
|
||||
}
|
||||
if($this->member && $this->member->user_level){
|
||||
return $this->member->user_level->getFormattedMargin();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getItemsCount(){
|
||||
$count = 0;
|
||||
|
|
@ -271,9 +352,128 @@ class ShoppingOrder extends Model
|
|||
$count += $shopping_order_item->qty;
|
||||
}
|
||||
}
|
||||
|
||||
return $count;
|
||||
}
|
||||
public function isInvoice(){
|
||||
return $this->user_invoice ? true : false;
|
||||
}
|
||||
|
||||
public function getStatusByOrder(){
|
||||
if($this->payment_for){
|
||||
if($this->payment_for === 6){ //Kunde-Shop
|
||||
return 2;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function makeHomepartyTaxSplit()
|
||||
{
|
||||
$tax_split = [];
|
||||
if($this->homeparty){
|
||||
foreach($this->homeparty->homeparty_order_items as $item){
|
||||
$tax_rate = intval($item->tax_rate);
|
||||
if($tax_rate > 0){
|
||||
$vk_tax = round((($item->price - $item->price_net) * $item->qty), 2);
|
||||
$ek_tax = round((($item->ek_price - $item->ek_price_net) * $item->qty), 2);
|
||||
if(isset($tax_split[$tax_rate])){
|
||||
$tax_split[$tax_rate]['vk_tax'] = round($tax_split[$tax_rate]['vk_tax'] + $vk_tax, 2);
|
||||
$tax_split[$tax_rate]['ek_tax'] = round($tax_split[$tax_rate]['ek_tax'] + $ek_tax, 2);
|
||||
}else{
|
||||
$tax_split[$tax_rate] = ['vk_tax' => $vk_tax, 'ek_tax' => $ek_tax];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$order_vk_tax = 0;
|
||||
$order_ek_tax = 0;
|
||||
if($this->homeparty->order){
|
||||
if(isset($this->homeparty->order['ek_price_net'])){
|
||||
$order_vk_tax = round((($this->homeparty->order['price'] - $this->homeparty->order['price_net'])), 2);
|
||||
$order_ek_tax = round((($this->homeparty->order['ek_price'] - $this->homeparty->order['ek_price_net'])), 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(isset($tax_split[16])){
|
||||
$tax_split[16] = ['vk_tax' => $order_vk_tax, 'ek_tax' => $order_ek_tax];
|
||||
}
|
||||
if(isset($tax_split[19])){
|
||||
$tax_split[19] = ['vk_tax' => $order_vk_tax, 'ek_tax' => $order_ek_tax];
|
||||
}
|
||||
|
||||
if(isset($tax_split[5])){
|
||||
if(!isset($tax_split[16])){
|
||||
$tax_split[16] = ['vk_tax' => $order_vk_tax, 'ek_tax' => $order_ek_tax];
|
||||
}
|
||||
$tax_split[16]['vk_tax'] = round($tax_split[16]['vk_tax'] - $tax_split[5]['vk_tax'], 2);
|
||||
$tax_split[16]['ek_tax'] = round($tax_split[16]['ek_tax'] - $tax_split[5]['ek_tax'], 2);
|
||||
}
|
||||
if(isset($tax_split[7])){
|
||||
if(!isset($tax_split[19])){
|
||||
$tax_split[19] = ['vk_tax' => $order_vk_tax, 'ek_tax' => $order_ek_tax];
|
||||
}
|
||||
$tax_split[19]['vk_tax'] = round($tax_split[19]['vk_tax'] - $tax_split[7]['vk_tax'], 2);
|
||||
$tax_split[19]['ek_tax'] = round($tax_split[19]['ek_tax'] - $tax_split[7]['ek_tax'], 2);
|
||||
}
|
||||
|
||||
|
||||
foreach($tax_split as $key=>$value){
|
||||
$tax_split[$key]['vk_tax'] = number_format($value['vk_tax'], 2);
|
||||
$tax_split[$key]['ek_tax'] = number_format($value['ek_tax'], 2);
|
||||
|
||||
}
|
||||
}
|
||||
if(!isset($tax_split[16]) && !isset($tax_split[19])){
|
||||
$tax_split = NULL;
|
||||
}
|
||||
$this->tax_split = $tax_split;
|
||||
$this->save();
|
||||
}
|
||||
|
||||
public function makeTaxSplit()
|
||||
{
|
||||
$tax_split = NULL;
|
||||
|
||||
if($this->tax > 0){
|
||||
$tax_split = [];
|
||||
foreach($this->shopping_order_items as $item){
|
||||
$tax_rate = intval($item->tax_rate);
|
||||
if($tax_rate > 0){
|
||||
$tax_split[$tax_rate] = isset($tax_split[$tax_rate]) ?
|
||||
round($tax_split[$tax_rate] + ($item->tax * $item->qty), 2) :
|
||||
round(($item->tax * $item->qty), 2);
|
||||
}
|
||||
}
|
||||
if(isset($tax_split[16])){
|
||||
$tax_split[16] = $this->tax;
|
||||
}
|
||||
if(isset($tax_split[19])){
|
||||
$tax_split[19] = $this->tax;
|
||||
}
|
||||
|
||||
if(isset($tax_split[5])){
|
||||
if(!isset($tax_split[16])){
|
||||
$tax_split[16] = $this->tax;
|
||||
}
|
||||
$tax_split[16] = round($tax_split[16] - $tax_split[5], 2);
|
||||
}
|
||||
if(isset($tax_split[7])){
|
||||
if(!isset($tax_split[19])){
|
||||
$tax_split[19] = $this->tax;
|
||||
}
|
||||
$tax_split[19] = round($tax_split[19] - $tax_split[7], 2);
|
||||
|
||||
}
|
||||
|
||||
foreach($tax_split as $key=>$value){
|
||||
$tax_split[$key] = number_format($value, 2);
|
||||
}
|
||||
}
|
||||
$this->tax_split = $tax_split;
|
||||
$this->save();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -45,6 +45,9 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @property float|null $price_net
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrderItem whereComp($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrderItem wherePriceNet($value)
|
||||
* @property int|null $homeparty_id
|
||||
* @property-read \App\Models\Homeparty|null $homeparty
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderItem whereHomepartyId($value)
|
||||
*/
|
||||
class ShoppingOrderItem extends Model
|
||||
{
|
||||
|
|
@ -63,10 +66,13 @@ class ShoppingOrderItem extends Model
|
|||
'price',
|
||||
'price_net',
|
||||
'tax_rate',
|
||||
'tax',
|
||||
'price_vk_net',
|
||||
'discount',
|
||||
'points',
|
||||
'slug',
|
||||
];
|
||||
|
||||
|
||||
public function shopping_order()
|
||||
{
|
||||
return $this->belongsTo('App\Models\ShoppingOrder','shopping_order_id');
|
||||
|
|
@ -97,6 +103,27 @@ class ShoppingOrderItem extends Model
|
|||
return formatNumber($this->attributes['price_net']);
|
||||
}
|
||||
|
||||
public function getFormattedPriceVkNet()
|
||||
{
|
||||
return formatNumber($this->attributes['price_vk_net']);
|
||||
}
|
||||
|
||||
public function getFormattedTaxRate()
|
||||
{
|
||||
return cleanNumberFormat($this->attributes['tax_rate']);
|
||||
}
|
||||
|
||||
public function getTaxRate()
|
||||
{
|
||||
return formatNumber($this->attributes['tax']);
|
||||
}
|
||||
|
||||
|
||||
public function getFormattedDiscount()
|
||||
{
|
||||
return cleanNumberFormat($this->attributes['discount']);
|
||||
}
|
||||
|
||||
public function getFormattedTotalPriceNet()
|
||||
{
|
||||
return formatNumber($this->attributes['price_net'] * $this->attributes['qty']);
|
||||
|
|
|
|||
|
|
@ -113,6 +113,8 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereIsFrom($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereShippingEmail($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereShoppingUserId($value)
|
||||
* @property int|null $homeparty_id
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingUser whereHomepartyId($value)
|
||||
*/
|
||||
class ShoppingUser extends Model
|
||||
{
|
||||
|
|
@ -246,6 +248,26 @@ class ShoppingUser extends Model
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function getOrderPaymentFor() {
|
||||
|
||||
switch($this->is_from){
|
||||
case 'wizard':
|
||||
return 1;
|
||||
case 'membership':
|
||||
return 2;
|
||||
case 'user_order':
|
||||
return $this->is_for === 'me' ? 3 : 4;
|
||||
case 'homeparty':
|
||||
return 5;
|
||||
case 'shopping':
|
||||
return 6;
|
||||
case 'extern':
|
||||
return 7;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
public function getAPIShippedType() {
|
||||
if($this->shopping_order){
|
||||
return $this->shopping_order->getAPIShippedType();
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SySetting whereStatus($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SySetting whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|SySetting withUniqueSlugConstraints(\Illuminate\Database\Eloquent\Model $model, string $attribute, array $config, string $slug)
|
||||
*/
|
||||
class SySetting extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -119,6 +119,12 @@ use Carbon\Carbon;
|
|||
* @property array|null $notice
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereAcceptedContract($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereNotice($value)
|
||||
* @property int $reverse_charge
|
||||
* @property string|null $reverse_charge_code
|
||||
* @property string|null $reverse_charge_valid
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAccount whereReverseCharge($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAccount whereReverseChargeCode($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAccount whereReverseChargeValid($value)
|
||||
*/
|
||||
class UserAccount extends Model
|
||||
{
|
||||
|
|
|
|||
183
app/Models/UserInvoice.php
Normal file
183
app/Models/UserInvoice.php
Normal file
|
|
@ -0,0 +1,183 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
* Class UserInvoice
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $shopping_order_id
|
||||
* @property int|null $month
|
||||
* @property int|null $year
|
||||
* @property Carbon|null $date
|
||||
* @property string|null $full_number
|
||||
* @property int|null $number
|
||||
* @property string|null $file
|
||||
* @property string|null $infos
|
||||
* @property bool $paid
|
||||
* @property Carbon|null $paid_date
|
||||
* @property bool $cancellation
|
||||
* @property int|null $cancellation_id
|
||||
* @property Carbon|null $cancellation_date
|
||||
* @property int $status
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property string|null $deleted_at
|
||||
*
|
||||
* @property ShoppingOrder $shopping_order
|
||||
*
|
||||
* @package App\Models
|
||||
*/
|
||||
class UserInvoice extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
protected $table = 'user_invoices';
|
||||
|
||||
protected $casts = [
|
||||
'shopping_order_id' => 'int',
|
||||
'month' => 'int',
|
||||
'year' => 'int',
|
||||
'number' => 'int',
|
||||
'paid' => 'bool',
|
||||
'cancellation' => 'bool',
|
||||
'cancellation_id' => 'int',
|
||||
'status' => 'int',
|
||||
'infos' => 'array',
|
||||
];
|
||||
|
||||
protected $dates = [
|
||||
'date',
|
||||
'paid_date',
|
||||
'cancellation_date'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'shopping_order_id',
|
||||
'month',
|
||||
'year',
|
||||
'date',
|
||||
'full_number',
|
||||
'number',
|
||||
'filename',
|
||||
'dir',
|
||||
'delivery_filename',
|
||||
'delivery_dir',
|
||||
'disk',
|
||||
'infos',
|
||||
'paid',
|
||||
'paid_date',
|
||||
'cancellation',
|
||||
'cancellation_id',
|
||||
'cancellation_date',
|
||||
'status'
|
||||
];
|
||||
|
||||
public static $monthNames = [
|
||||
1 => 'Januar',
|
||||
2 => 'Februar',
|
||||
3 => 'März',
|
||||
4 => 'April',
|
||||
5 => 'Mai',
|
||||
6 => 'Juni',
|
||||
7 => 'Juli',
|
||||
8 => 'August',
|
||||
9 => 'September',
|
||||
10 => 'Oktober',
|
||||
11 => 'November',
|
||||
12 => 'Dezember'
|
||||
];
|
||||
|
||||
public static $statusTypes = [
|
||||
0 => '-',
|
||||
1 => 'Bestellung',
|
||||
2 => 'Shop',
|
||||
11 => 'storniert B.',
|
||||
12 => 'storniert Shop',
|
||||
|
||||
];
|
||||
|
||||
public static $statusColors = [
|
||||
0 => 'warning',
|
||||
1 => 'success',
|
||||
2 => 'secondary',
|
||||
11 => 'danger',
|
||||
12 => 'danger',
|
||||
|
||||
];
|
||||
|
||||
public function shopping_order(){
|
||||
return $this->belongsTo(ShoppingOrder::class);
|
||||
}
|
||||
|
||||
public function getDateAttribute($value){
|
||||
return $this->attributes['date'] ? Carbon::parse($this->attributes['date'])->format(\Util::formatDateDB()) : '';
|
||||
}
|
||||
public function setDateAttribute( $value ) {
|
||||
$this->attributes['date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
|
||||
}
|
||||
public function getDateRaw(){
|
||||
return isset($this->attributes['date']) ? $this->attributes['date'] : NULL;
|
||||
}
|
||||
|
||||
public function getPaidDateAttribute($value){
|
||||
return $this->attributes['paid_date'] ? Carbon::parse($this->attributes['paid_date'])->format(\Util::formatDateDB()) : '';
|
||||
}
|
||||
public function setPaidDateAttribute( $value ) {
|
||||
$this->attributes['paid_date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
|
||||
}
|
||||
public function getPaidDateRaw(){
|
||||
return isset($this->attributes['paid_date']) ? $this->attributes['paid_date'] : NULL;
|
||||
}
|
||||
|
||||
public function getCancellationDateAttribute($value){
|
||||
return $this->attributes['cancellation_date'] ? Carbon::parse($this->attributes['cancellation_date'])->format(\Util::formatDateDB()) : '';
|
||||
}
|
||||
public function setCancellationDateAttribute( $value ) {
|
||||
$this->attributes['cancellation_date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
|
||||
}
|
||||
public function getCancellationDateRaw(){
|
||||
return isset($this->attributes['cancellation_date']) ? $this->attributes['cancellation_date'] : NULL;
|
||||
}
|
||||
|
||||
public static function getYearRange()
|
||||
{
|
||||
$start = 2021;
|
||||
$end = date("Y");
|
||||
return array_reverse(range($start, $end));
|
||||
}
|
||||
|
||||
public static function getMonthName($month)
|
||||
{
|
||||
return isset(self::$monthNames[$month]) ? self::$monthNames[$month] : $month;
|
||||
}
|
||||
|
||||
public function getStatusType(){
|
||||
return isset(self::$statusTypes[$this->status]) ? self::$statusTypes[$this->status] : "";
|
||||
}
|
||||
|
||||
public function getStatusColor(){
|
||||
return isset(self::$statusColors[$this->status]) ? self::$statusColors[$this->status] : "default";
|
||||
}
|
||||
|
||||
public function getDownloadPath($full = false){
|
||||
if(!$full){
|
||||
return $this->dir.$this->filename;
|
||||
}
|
||||
return \Storage::disk($this->disk)->path($this->dir.$this->filename);
|
||||
}
|
||||
|
||||
public function getDownloadPathDelivery($full = false){
|
||||
if(!$full){
|
||||
return $this->delivery_dir.$this->delivery_filename;
|
||||
}
|
||||
return \Storage::disk($this->disk)->path($this->delivery_dir.$this->delivery_filename);
|
||||
}
|
||||
}
|
||||
229
app/Models/UserInvoiceCredit.php
Normal file
229
app/Models/UserInvoiceCredit.php
Normal file
|
|
@ -0,0 +1,229 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
* Class UserInvoiceCredit
|
||||
*
|
||||
* @property int $id
|
||||
* @property int|null $auth_user_id
|
||||
* @property int|null $shopping_order_id
|
||||
* @property int|null $shopping_user_id
|
||||
* @property string $type
|
||||
* @property string|null $full_number
|
||||
* @property int|null $number
|
||||
* @property float|null $net
|
||||
* @property float|null $tax_rate
|
||||
* @property float|null $tax
|
||||
* @property float|null $total
|
||||
* @property string|null $file
|
||||
* @property string|null $contents
|
||||
* @property string|null $infos
|
||||
* @property string|null $subject
|
||||
* @property string|null $address
|
||||
* @property bool $paid
|
||||
* @property Carbon|null $paid_date
|
||||
* @property int|null $cancellation_id
|
||||
* @property Carbon|null $cancellation_date
|
||||
* @property int $status
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property string|null $deleted_at
|
||||
* @property User|null $user
|
||||
* @property UserInvoiceCredit|null $user_invoice_credit
|
||||
* @property ShoppingOrder|null $shopping_order
|
||||
* @property ShoppingUser|null $shopping_user
|
||||
* @property Collection|UserInvoiceCredit[] $user_invoice_credits
|
||||
* @package App\Models
|
||||
* @property-read int|null $user_invoice_credits_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit newQuery()
|
||||
* @method static \Illuminate\Database\Query\Builder|UserInvoiceCredit onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereAddress($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereAuthUserId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereCancellationDate($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereCancellationId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereContents($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereFile($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereFullNumber($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereInfos($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereNet($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereNumber($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit wherePaid($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit wherePaidDate($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereShoppingOrderId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereShoppingUserId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereStatus($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereSubject($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereTax($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereTaxRate($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereTotal($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereType($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|UserInvoiceCredit withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|UserInvoiceCredit withoutTrashed()
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class UserInvoiceCredit extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
protected $table = 'user_invoice_credits';
|
||||
|
||||
protected $casts = [
|
||||
'auth_user_id' => 'int',
|
||||
'shopping_order_id' => 'int',
|
||||
'shopping_user_id' => 'int',
|
||||
'number' => 'int',
|
||||
'year' => 'int',
|
||||
'month' => 'int',
|
||||
'net' => 'float',
|
||||
'tax_rate' => 'float',
|
||||
'tax' => 'float',
|
||||
'total' => 'float',
|
||||
'paid' => 'bool',
|
||||
'cancellation_id' => 'int',
|
||||
'status' => 'int',
|
||||
'file' => 'array',
|
||||
'contents' => 'array',
|
||||
'infos' => 'array',
|
||||
|
||||
];
|
||||
|
||||
protected $dates = [
|
||||
'paid_date',
|
||||
'cancellation_date'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'auth_user_id',
|
||||
'shopping_order_id',
|
||||
'shopping_user_id',
|
||||
'type',
|
||||
'year',
|
||||
'month',
|
||||
'full_number',
|
||||
'number',
|
||||
'net',
|
||||
'tax_rate',
|
||||
'tax',
|
||||
'total',
|
||||
'file',
|
||||
'contents',
|
||||
'infos',
|
||||
'subject',
|
||||
'address',
|
||||
'paid',
|
||||
'paid_date',
|
||||
'cancellation_id',
|
||||
'cancellation_date',
|
||||
'status'
|
||||
];
|
||||
|
||||
public static $monthNames = [
|
||||
1 => 'Januar',
|
||||
2 => 'Februar',
|
||||
3 => 'März',
|
||||
4 => 'April',
|
||||
5 => 'Mai',
|
||||
6 => 'Juni',
|
||||
7 => 'Juli',
|
||||
8 => 'August',
|
||||
9 => 'September',
|
||||
10 => 'Oktober',
|
||||
11 => 'November',
|
||||
12 => 'Dezember'
|
||||
];
|
||||
|
||||
public static $statusTypes = [
|
||||
0 => 'offen',
|
||||
1 => 'bezahlt',
|
||||
2 => 'prüfen',
|
||||
10 => 'storniert'
|
||||
];
|
||||
|
||||
public static $statusColors = [
|
||||
0 => 'warning',
|
||||
1 => 'success',
|
||||
2 => 'secondary',
|
||||
10 => 'danger',
|
||||
];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(\App\User::class, 'auth_user_id');
|
||||
}
|
||||
|
||||
public function user_invoice_credit()
|
||||
{
|
||||
return $this->belongsTo(UserInvoiceCredit::class, 'cancellation_id');
|
||||
}
|
||||
|
||||
public function shopping_order()
|
||||
{
|
||||
return $this->belongsTo(ShoppingOrder::class);
|
||||
}
|
||||
|
||||
public function shopping_user()
|
||||
{
|
||||
return $this->belongsTo(ShoppingUser::class);
|
||||
}
|
||||
|
||||
public function user_invoice_credits()
|
||||
{
|
||||
return $this->hasMany(UserInvoiceCredit::class, 'cancellation_id');
|
||||
}
|
||||
|
||||
public function getPaidDateAttribute($value){
|
||||
return $this->attributes['paid_date'] ? Carbon::parse($this->attributes['paid_date'])->format(\Util::formatDateDB()) : '';
|
||||
}
|
||||
public function setPaidDateAttribute( $value ) {
|
||||
$this->attributes['paid_date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
|
||||
}
|
||||
public function getPaidDateRaw(){
|
||||
return isset($this->attributes['paid_date']) ? $this->attributes['paid_date'] : NULL;
|
||||
}
|
||||
|
||||
public function getCancellationDateAttribute($value){
|
||||
return $this->attributes['cancellation_date'] ? Carbon::parse($this->attributes['cancellation_date'])->format(\Util::formatDateDB()) : '';
|
||||
}
|
||||
public function setCancellationDateAttribute( $value ) {
|
||||
$this->attributes['cancellation_date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
|
||||
}
|
||||
public function getCancellationDateRaw(){
|
||||
return isset($this->attributes['cancellation_date']) ? $this->attributes['cancellation_date'] : NULL;
|
||||
}
|
||||
|
||||
public static function getYearRange()
|
||||
{
|
||||
$start = 2021;
|
||||
$end = date("Y");
|
||||
return array_reverse(range($start, $end));
|
||||
}
|
||||
|
||||
public static function getMonthName($month)
|
||||
{
|
||||
return isset(self::$monthNames[$month]) ? self::$monthNames[$month] : $month;
|
||||
}
|
||||
|
||||
public function getStatusType(){
|
||||
return isset(self::$statusTypes[$this->status]) ? self::$statusTypes[$this->status] : "";
|
||||
}
|
||||
|
||||
public function getStatusColor(){
|
||||
return isset(self::$statusColors[$this->status]) ? self::$statusColors[$this->status] : "default";
|
||||
}
|
||||
|
||||
}
|
||||
152
app/Models/UserSalesVolume.php
Normal file
152
app/Models/UserSalesVolume.php
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Models\ShoppingOrder;
|
||||
|
||||
/**
|
||||
* Class UserSalesVolume
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $user_id
|
||||
* @property int|null $shopping_order_id
|
||||
* @property int|null $month
|
||||
* @property int|null $year
|
||||
* @property Carbon|null $date
|
||||
* @property int|null $points
|
||||
* @property int|null $month_points
|
||||
* @property float|null $total_net
|
||||
* @property float|null $month_total_net
|
||||
* @property string|null $message
|
||||
* @property int $status
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
*
|
||||
* @property ShoppingOrder|null $shopping_order
|
||||
* @property User $user
|
||||
*
|
||||
* @package App\Models
|
||||
*/
|
||||
class UserSalesVolume extends Model
|
||||
{
|
||||
protected $table = 'user_sales_volumes';
|
||||
|
||||
protected $casts = [
|
||||
'user_id' => 'int',
|
||||
'shopping_order_id' => 'int',
|
||||
'user_invoice_id' => 'int',
|
||||
'month' => 'int',
|
||||
'year' => 'int',
|
||||
'points' => 'int',
|
||||
'month_points' => 'int',
|
||||
'month_shop_points' => 'int',
|
||||
'total_net' => 'float',
|
||||
'month_total_net' => 'float',
|
||||
'month_shop_total_net' => 'float',
|
||||
'status' => 'int'
|
||||
];
|
||||
|
||||
protected $dates = [
|
||||
'date'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'shopping_order_id',
|
||||
'user_invoice_id',
|
||||
'month',
|
||||
'year',
|
||||
'date',
|
||||
'points',
|
||||
'month_points',
|
||||
'month_shop_points',
|
||||
'total_net',
|
||||
'month_total_net',
|
||||
'month_shop_total_net',
|
||||
'message',
|
||||
'status'
|
||||
];
|
||||
|
||||
|
||||
public static $statusTypes = [
|
||||
0 => 'nicht zugewiesen',
|
||||
1 => 'hinzugefügt aus Bestellung',
|
||||
2 => 'hinzugefügt aus Shop',
|
||||
3 => 'hinzugefügt aus Shop / pending',
|
||||
10 => ''
|
||||
];
|
||||
|
||||
public function shopping_order()
|
||||
{
|
||||
return $this->belongsTo(ShoppingOrder::class);
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function user_invoice()
|
||||
{
|
||||
return $this->belongsTo(UserInvoice::class);
|
||||
}
|
||||
|
||||
public function getDateAttribute(){
|
||||
return $this->attributes['date'] ? Carbon::parse($this->attributes['date'])->format(\Util::formatDateDB()) : '';
|
||||
}
|
||||
public function setDateAttribute( $value ) {
|
||||
$this->attributes['date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
|
||||
}
|
||||
public function getDateRaw(){
|
||||
return isset($this->attributes['date']) ? $this->attributes['date'] : NULL;
|
||||
}
|
||||
|
||||
public function getStatusType(){
|
||||
return isset(self::$statusTypes[$this->status]) ? self::$statusTypes[$this->status] : "";
|
||||
}
|
||||
|
||||
public static function getStatusByOrder($ShoppingOrder){
|
||||
if($ShoppingOrder->payment_for){
|
||||
if($ShoppingOrder->payment_for === 6){ //Kunde-Shop
|
||||
if($ShoppingOrder->shopping_user && $ShoppingOrder->shopping_user->is_like){
|
||||
return 3; //shop Kunden, berater zuordnen
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getFormatedMonthYear(){
|
||||
return str_pad($this->month, 2, "0", STR_PAD_LEFT)."/".$this->year;
|
||||
}
|
||||
|
||||
public function setToUserAndCalculate($user_id){
|
||||
|
||||
$month = $this->month;
|
||||
$year = $this->year;
|
||||
$month_shop_points = UserSalesVolume::where('user_id', $user_id)->where('status', 2)->where('month', $month)->where('year', $year)->sum('points');
|
||||
$month_shop_total_net = UserSalesVolume::where('user_id', $user_id)->where('status', 2)->where('month', $month)->where('year', $year)->sum('total_net');
|
||||
$month_points = UserSalesVolume::where('user_id', $user_id)->where('status', 1)->where('month', $month)->where('year', $year)->sum('points');
|
||||
$month_total_net = UserSalesVolume::where('user_id', $user_id)->where('status', 1)->where('month', $month)->where('year', $year)->sum('total_net');
|
||||
|
||||
$month_shop_points += $this->points;
|
||||
$month_shop_total_net += $this->total_net;
|
||||
|
||||
$this->user_id = $user_id;
|
||||
$this->month_shop_points = $month_shop_points;
|
||||
$this->month_shop_total_net = $month_shop_total_net;
|
||||
$this->month_points = $month_points;
|
||||
$this->month_total_net = $month_total_net;
|
||||
$this->status = 2;
|
||||
$this->save();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -65,6 +65,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @method static \Illuminate\Database\Query\Builder|\App\Models\UserShop withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\UserShop withoutTrashed()
|
||||
* @mixin \Eloquent
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserShop withUniqueSlugConstraints(\Illuminate\Database\Eloquent\Model $model, string $attribute, array $config, string $slug)
|
||||
*/
|
||||
class UserShop extends Model
|
||||
{
|
||||
|
|
@ -83,8 +84,8 @@ class UserShop extends Model
|
|||
|
||||
use SoftDeletes;
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
use Sluggable;
|
||||
|
||||
public function sluggable()
|
||||
{
|
||||
return [
|
||||
|
|
@ -93,6 +94,7 @@ class UserShop extends Model
|
|||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('App\User', 'user_id');
|
||||
|
|
@ -135,6 +137,10 @@ class UserShop extends Model
|
|||
|
||||
//check if exisist
|
||||
$subdomain = $kas->action('get_subdomains', $pra);
|
||||
if(is_soap_fault($subdomain)){
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if(!empty($subdomain[0]['is_active']) && $subdomain[0]['is_active'] == 'Y'){
|
||||
$this->is_online = true;
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShopOnSite whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShopOnSite whereUserShopId($value)
|
||||
* @mixin \Eloquent
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserShopOnSite withUniqueSlugConstraints(\Illuminate\Database\Eloquent\Model $model, string $attribute, array $config, string $slug)
|
||||
*/
|
||||
class UserShopOnSite extends Model
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue