Changed account search to user search, show connection charges on invoice for pending services
This commit is contained in:
@@ -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