Fix services with no model, showing future invoice items
This commit is contained in:
parent
57f24c9315
commit
10c8e43f7c
@ -493,7 +493,7 @@ class Service extends Model
|
||||
*/
|
||||
public function getNameShortAttribute()
|
||||
{
|
||||
return $this->type->service_name;
|
||||
return $this->type ? $this->type->service_name : $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -831,7 +831,7 @@ class Service extends Model
|
||||
// If the service is active, there will be service charges
|
||||
if ((! $this->invoice_items->filter(function($item) { return $item->item_type==0 AND ! $item->exists; })->count())
|
||||
AND ($this->active OR $this->isPending())
|
||||
AND ($future == FALSE AND ($this->invoice_to < Carbon::now()->addDays(30))))
|
||||
AND ($future == TRUE OR ($future == FALSE AND ($this->invoice_to < Carbon::now()->addDays(30)))))
|
||||
{
|
||||
do {
|
||||
$o = new InvoiceItem;
|
||||
@ -854,7 +854,9 @@ class Service extends Model
|
||||
}
|
||||
|
||||
// Add additional charges
|
||||
if (! $this->invoice_items->filter(function($item) { return $item->module_id == 30 AND ! $item->exists; })->count())
|
||||
if (($future = TRUE OR ($future == FALSE AND ($this->invoice_to < Carbon::now()->addDays(30))))
|
||||
AND ! $this->invoice_items->filter(function($item) { return $item->module_id == 30 AND ! $item->exists; })->count())
|
||||
{
|
||||
foreach ($this->charges->filter(function($item) { return ! $item->processed; }) as $oo) {
|
||||
$o = new InvoiceItem;
|
||||
$o->active = TRUE;
|
||||
@ -872,6 +874,7 @@ class Service extends Model
|
||||
$o->addTaxes($this->account->country->taxes);
|
||||
$this->invoice_items->push($o);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->invoice_items->filter(function($item) { return ! $item->exists; });
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user