Rechnungen + Gutschriften
This commit is contained in:
parent
39ef16686a
commit
35ae3da244
33 changed files with 2834 additions and 34 deletions
|
|
@ -93,6 +93,10 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @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
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereInvoice($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereShippedAt($value)
|
||||
*/
|
||||
class ShoppingOrder extends Model
|
||||
{
|
||||
|
|
@ -127,12 +131,14 @@ class ShoppingOrder extends Model
|
|||
'wp_notice',
|
||||
'mode',
|
||||
'shipped',
|
||||
'shipped_at',
|
||||
'tracking'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'wp_notice' => 'array',
|
||||
'invoice' => 'array',
|
||||
'shipped_at' => 'datetime',
|
||||
];
|
||||
|
||||
public static $shippedTypes = [
|
||||
|
|
@ -159,9 +165,6 @@ class ShoppingOrder extends Model
|
|||
10 => 'danger',
|
||||
];
|
||||
|
||||
|
||||
|
||||
|
||||
public function shopping_user()
|
||||
{
|
||||
return $this->belongsTo('App\Models\ShoppingUser','shopping_user_id');
|
||||
|
|
@ -298,9 +301,6 @@ class ShoppingOrder extends Model
|
|||
return formatNumber($this->attributes['total_shipping']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function getItemsCount(){
|
||||
$count = 0;
|
||||
if($this->shopping_order_items){
|
||||
|
|
|
|||
|
|
@ -52,6 +52,11 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderMargin whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderMargin whereUserId($value)
|
||||
* @mixin \Eloquent
|
||||
* @property \Illuminate\Support\Carbon|null $partner_commission_pending_to
|
||||
* @property bool|null $partner_commission_paid
|
||||
* @property-read User|null $m_sponsor
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderMargin wherePartnerCommissionPaid($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderMargin wherePartnerCommissionPendingTo($value)
|
||||
*/
|
||||
class ShoppingOrderMargin extends Model
|
||||
{
|
||||
|
|
@ -68,7 +73,9 @@ class ShoppingOrderMargin extends Model
|
|||
'net_partner_commission' => 'float',
|
||||
'paid' => 'bool',
|
||||
'cancellation' => 'bool',
|
||||
'status' => 'int'
|
||||
'status' => 'int',
|
||||
'partner_commission_pending_to' => 'datetime',
|
||||
'partner_commission_paid' => 'bool',
|
||||
];
|
||||
|
||||
protected $dates = [
|
||||
|
|
@ -88,6 +95,8 @@ class ShoppingOrderMargin extends Model
|
|||
'paid',
|
||||
'cancellation',
|
||||
'status',
|
||||
'partner_commission_pending_to',
|
||||
'partner_commission_paid',
|
||||
'content'
|
||||
];
|
||||
|
||||
|
|
@ -105,4 +114,17 @@ class ShoppingOrderMargin extends Model
|
|||
{
|
||||
return $this->belongsTo(User::class, 'm_sponsor_id');
|
||||
}
|
||||
|
||||
|
||||
public function m_sponsor()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'm_sponsor_id');
|
||||
}
|
||||
|
||||
public function hasPartnerCommission(){
|
||||
if($this->m_sponsor_id || $this->net_partner_commission > 0){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
116
app/Models/UserCredit.php
Normal file
116
app/Models/UserCredit.php
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
|
||||
/**
|
||||
* Class UserCredit
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $auth_user_id
|
||||
* @property float|null $net
|
||||
* @property float|null $tax_rate
|
||||
* @property float|null $tax
|
||||
* @property float|null $total
|
||||
* @property string|null $credit
|
||||
* @property string|null $user_margins
|
||||
* @property bool $paid_out
|
||||
* @property bool $cancellation
|
||||
* @property int $status
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property User $user
|
||||
* @package App\Models
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereAuthUserId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereCancellation($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereCredit($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereNet($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit wherePaidOut($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereStatus($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereTax($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereTaxRate($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereTotal($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereUserMargins($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class UserCredit extends Model
|
||||
{
|
||||
protected $table = 'user_credits';
|
||||
|
||||
protected $casts = [
|
||||
'auth_user_id' => 'int',
|
||||
'net' => 'float',
|
||||
'tax_rate' => 'float',
|
||||
'tax' => 'float',
|
||||
'total' => 'float',
|
||||
'paid_out' => 'bool',
|
||||
'cancellation' => 'bool',
|
||||
'status' => 'int',
|
||||
'credit' => 'array',
|
||||
'user_margins' => 'object'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'auth_user_id',
|
||||
'net',
|
||||
'tax_rate',
|
||||
'tax',
|
||||
'total',
|
||||
'date',
|
||||
'credit',
|
||||
'user_margins',
|
||||
'paid_out',
|
||||
'cancellation',
|
||||
'status'
|
||||
];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(\App\User::class, 'auth_user_id');
|
||||
}
|
||||
|
||||
public function getDateAttribute($value)
|
||||
{
|
||||
if(!$value){
|
||||
return "";
|
||||
}
|
||||
return Carbon::parse($value)->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 getFormattedTax()
|
||||
{
|
||||
return formatNumber($this->attributes['tax']);
|
||||
}
|
||||
|
||||
public function getFormattedNet()
|
||||
{
|
||||
return formatNumber($this->attributes['net']);
|
||||
}
|
||||
|
||||
public function getFormattedTotal()
|
||||
{
|
||||
return formatNumber($this->attributes['total']);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue