Changed account search to user search, show connection charges on invoice for pending services
This commit is contained in:
@@ -14,8 +14,8 @@ class AccountPolicy
|
||||
/**
|
||||
* Determine whether the user can view the service.
|
||||
*
|
||||
* @param \App\User $user
|
||||
* @param Account $o
|
||||
* @param User $user
|
||||
* @param Account $o
|
||||
* @return mixed
|
||||
*/
|
||||
public function view(User $user, Account $o)
|
||||
@@ -33,7 +33,7 @@ class AccountPolicy
|
||||
/**
|
||||
* Determine whether the user can create services.
|
||||
*
|
||||
* @param \App\User $user
|
||||
* @param User $user
|
||||
* @return mixed
|
||||
*/
|
||||
public function create(User $user)
|
||||
@@ -44,8 +44,8 @@ class AccountPolicy
|
||||
/**
|
||||
* Determine whether the user can update the service.
|
||||
*
|
||||
* @param \App\User $user
|
||||
* @param Account $o
|
||||
* @param User $user
|
||||
* @param Account $o
|
||||
* @return mixed
|
||||
*/
|
||||
public function update(User $user, Account $o)
|
||||
@@ -56,8 +56,8 @@ class AccountPolicy
|
||||
/**
|
||||
* Determine whether the user can delete the service.
|
||||
*
|
||||
* @param \App\User $user
|
||||
* @param Account $o
|
||||
* @param User $user
|
||||
* @param Account $o
|
||||
* @return mixed
|
||||
*/
|
||||
public function delete(User $user, Account $o)
|
||||
@@ -68,8 +68,8 @@ class AccountPolicy
|
||||
/**
|
||||
* Determine whether the user can restore the service.
|
||||
*
|
||||
* @param \App\User $user
|
||||
* @param Account $o
|
||||
* @param User $user
|
||||
* @param Account $o
|
||||
* @return mixed
|
||||
*/
|
||||
public function restore(User $user, Account $o)
|
||||
@@ -80,8 +80,8 @@ class AccountPolicy
|
||||
/**
|
||||
* Determine whether the user can permanently delete the service.
|
||||
*
|
||||
* @param \App\User $user
|
||||
* @param Account $o
|
||||
* @param User $user
|
||||
* @param Account $o
|
||||
* @return mixed
|
||||
*/
|
||||
public function forceDelete(User $user, Account $o)
|
||||
|
@@ -186,12 +186,12 @@ class Product extends Model
|
||||
* @param int $period
|
||||
* @return mixed
|
||||
*/
|
||||
public function price(int $period)
|
||||
public function price(int $period,string $key='price_base')
|
||||
{
|
||||
return Arr::get(
|
||||
$this->price_array,
|
||||
sprintf('%s.1.price_base',$period),
|
||||
Arr::get($this->price_array,sprintf('%s.0.price_base',$period))
|
||||
sprintf('%s.1.%s',$period,$key),
|
||||
Arr::get($this->price_array,sprintf('%s.0.%s',$period,$key))
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -522,6 +522,12 @@ class Service extends Model
|
||||
return $this->product->name($this->account->language);
|
||||
}
|
||||
|
||||
public function getRecurScheduleAttribute($value): int
|
||||
{
|
||||
// If recur_schedule not set, default to 2
|
||||
return $value ?? 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated see getSIDAttribute()
|
||||
*/
|
||||
@@ -568,7 +574,7 @@ class Service extends Model
|
||||
*/
|
||||
public function getSDescAttribute(): string
|
||||
{
|
||||
return $this->type->service_description;
|
||||
return $this->type->service_description ?: 'Service Description NOT Defined for :'.$this->type->type;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -583,7 +589,7 @@ class Service extends Model
|
||||
*/
|
||||
public function getSNameAttribute(): string
|
||||
{
|
||||
return $this->type->service_name;
|
||||
return $this->type->service_name ?: 'Service Name NOT Defined for :'.$this->type->type;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -596,7 +602,7 @@ class Service extends Model
|
||||
{
|
||||
switch($this->product->model) {
|
||||
case 'App\Models\Product\Adsl': return 'broadband';
|
||||
default: abort(500,'Product type not configured',['product'=>$this->product]);
|
||||
default: return $this->type->type;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -770,6 +776,23 @@ class Service extends Model
|
||||
$result->push($o);
|
||||
}
|
||||
|
||||
// If pending, add any connection charges
|
||||
if ($this->isPending()) {
|
||||
$o = new InvoiceItem;
|
||||
$o->active = TRUE;
|
||||
$o->service_id = $this->id;
|
||||
$o->product_id = $this->product_id;
|
||||
$o->item_type = 4;
|
||||
$o->price_base = $this->price ?: $this->product->price($this->recur_schedule,'price_setup'); // @todo change to a method in this class
|
||||
//$o->recurring_schedule = $this->recur_schedule;
|
||||
$o->date_start = $this->invoice_next;
|
||||
$o->date_stop = $this->invoice_next;
|
||||
$o->quantity = 1;
|
||||
|
||||
$o->addTaxes();
|
||||
$result->push($o);
|
||||
}
|
||||
|
||||
// Add additional charges
|
||||
foreach ($this->charges->filter(function($item) { return ! $item->processed; }) as $oo) {
|
||||
$o = new InvoiceItem;
|
||||
|
Reference in New Issue
Block a user