Move charge to under service
This commit is contained in:
@@ -4,29 +4,24 @@ namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Leenooks\Traits\ScopeActive;
|
||||
|
||||
use App\Casts\CollectionOrNull;
|
||||
use App\Traits\SiteID;
|
||||
|
||||
/**
|
||||
* CLEANUP NOTES:
|
||||
* + Charge Date should not be null
|
||||
* + Attributes should be a collection array
|
||||
* + type should not be null
|
||||
* + It would be useful, given an array of Charges to call a function that renders them into invoice format. This may provide consistence and be the single view of how charges do look on an invoice.
|
||||
*/
|
||||
class Charge extends Model
|
||||
{
|
||||
use SiteID;
|
||||
use ScopeActive;
|
||||
|
||||
protected $casts = [
|
||||
'attributes' => CollectionOrNull::class,
|
||||
];
|
||||
|
||||
protected $dates = [
|
||||
'start_at',
|
||||
'stop_at',
|
||||
'charge_at', // The date the charge applies - since it can be different to created_at
|
||||
'start_at' => 'datetime:Y-m-d',
|
||||
'stop_at' => 'datetime:Y-m-d',
|
||||
'charge_at' => 'datetime:Y-m-d', // The date the charge applies - since it can be different to created_at
|
||||
];
|
||||
|
||||
public const sweep = [
|
||||
@@ -61,6 +56,7 @@ class Charge extends Model
|
||||
/** @deprecated use pending */
|
||||
public function scopeUnprocessed($query)
|
||||
{
|
||||
Log::alert('UMO:! Deprecated function scopeUnprocessed()');
|
||||
return $this->scopePending();
|
||||
}
|
||||
|
||||
@@ -76,7 +72,21 @@ class Charge extends Model
|
||||
|
||||
public function getNameAttribute()
|
||||
{
|
||||
return sprintf('%s %s',$this->description,$this->getAttribute('attributes') ? join('|',unserialize($this->getAttribute('attributes'))) : '');
|
||||
return sprintf('%s %s',
|
||||
$this->description,
|
||||
$this->getAttribute('attributes')
|
||||
? join('|',unserialize($this->getAttribute('attributes')))
|
||||
: '');
|
||||
}
|
||||
|
||||
public function getSubTotalAttribute(): float
|
||||
{
|
||||
return $this->quantity*$this->amount;
|
||||
}
|
||||
|
||||
public function getTotalAttribute(): float
|
||||
{
|
||||
return $this->account->taxed($this->getSubTotalAttribute());
|
||||
}
|
||||
|
||||
public function getTypeNameAttribute(): string
|
||||
|
Reference in New Issue
Block a user