'int', 'shopping_order_id' => 'int', 'user_invoice_id' => 'int', 'month' => 'int', 'year' => 'int', 'points' => 'int', 'month_KP_points' => 'int', 'month_TP_points' => 'int', 'month_shop_points' => 'int', 'status_points' => 'int', 'status_turnover' => 'int', 'total_net' => 'float', 'month_total_net' => 'float', 'month_shop_total_net' => 'float', 'status' => 'int', 'syslog' => 'array' ]; protected $dates = [ 'date' ]; protected $fillable = [ 'user_id', 'shopping_order_id', 'user_invoice_id', 'month', 'year', 'date', 'points', 'month_KP_points', 'month_TP_points', 'month_shop_points', 'status_points', 'status_turnover', 'total_net', 'month_total_net', 'month_shop_total_net', 'message', 'info', 'status', 'syslog' ]; public static $statusPointsTypes = [ 1 => 'KU + TP', //Eigene + Team 2 => 'KU', //nur Eigene nicht Team ]; public static $statusTurnoverTypes = [ 1 => 'advisor_order', //hinzugefügt aus 2 => 'shoporder', //hinzugefügt aus ]; public static $statusTypes = [ 0 => 'not_assigned', 1 => 'advisor_order', //hinzugefügt aus 2 => 'shoporder', //hinzugefügt aus 3 => 'shoporder_pending', //hinzugefügt aus 4 => 'credit', //hinzugefügt aus 5 => 'registration', //hinzugefügt aus // 10 => '' ]; public static $statusColors = [ 0 => 'warning', 1 => 'success', 2 => 'secondary', 3 => 'warning', 4 => 'info', 5 => 'info', 10 => 'danger', ]; 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 getPointsKPSum(){ return $this->month_KP_points + $this->month_shop_points; //only KP für SUM - KP is for User } public function getPointsTPSum(){ return $this->month_TP_points + $this->month_shop_points; //only TP für SUM - TP is only for Payline } public function getTotalNetSum(){ return $this->month_total_net + $this->month_shop_total_net; } public function getStatusType(){ return isset(self::$statusTypes[$this->status]) ? __('payment.'.self::$statusTypes[$this->status]) : ""; } public static function getTransStatusType(){ $ret = []; foreach(self::$statusTypes as $key=>$val){ $ret[$key] = trans('payment.'.$val); } return $ret; } public static function getTransTurnoverTypes(){ $ret = []; foreach(self::$statusTurnoverTypes as $key=>$val){ $ret[$key] = trans('payment.'.$val); } return $ret; } public function getStatusColor(){ return isset(self::$statusColors[$this->status]) ? self::$statusColors[$this->status] : "default"; } public function getStatusPointsType(){ return isset(self::$statusPointsTypes[$this->status_points]) ? self::$statusPointsTypes[$this->status_points] : ""; } public function getStatusPointsColor(){ return isset(self::$statusColors[$this->status_points]) ? self::$statusColors[$this->status_points] : "default"; } public function getStatusTurnoverType(){ switch ($this->status) { case 1: //Bestellung Berater return 'E'; case 2: //Shop return 'S'; case 4: //Gutschrift if($this->status_turnover === 2){ return 'S'; }else{ return 'E'; } case 5: //Registrierung return 'E'; } return ""; } public function getStatusTurnoverColor(){ switch ($this->status) { case 1: //Bestellung Berater return 'success'; case 2: //Shop return 'secondary'; case 4: //Gutschrift if($this->status_turnover === 2){ return 'secondary'; }else{ return 'success'; } case 5: //Registrierung return 'success'; } return "default"; } public function getFormatedMonthYear(){ return str_pad($this->month, 2, "0", STR_PAD_LEFT)."/".$this->year; } public function isCurrentMonthYear(){ if($this->month === intval(date('m')) && $this->year === intval(date('Y'))){ return true; } return false; } public function caluCommissonTotalNet($margin){ if($this->total_net > 0 && $margin > 0){ return $this->total_net / 100 * $margin; } return 0; } }