Fix rendering of future charge items

This commit is contained in:
Deon George 2020-03-31 14:39:39 +11:00
parent 9ab30086fc
commit fb9ccd927d
2 changed files with 17 additions and 16 deletions

View File

@ -107,7 +107,7 @@ class InvoiceItem extends Model
); );
default: default:
return Arr::get($types,$this->item_type,'Unknown'); return ($this->module_id == 30 ? 'Additional Charge: ' : '').Arr::get($types,$this->item_type,'Unknown');
} }
} }

View File

@ -840,22 +840,23 @@ class Service extends Model
} }
// Add additional charges // Add additional charges
foreach ($this->charges->filter(function($item) { return ! $item->processed; }) as $oo) { if (! $this->invoice_items->filter(function($item) { return $item->module_id == 30 AND ! $item->exists; })->count())
$o = new InvoiceItem; foreach ($this->charges->filter(function($item) { return ! $item->processed; }) as $oo) {
$o->active = TRUE; $o = new InvoiceItem;
$o->service_id = $oo->service_id; $o->active = TRUE;
$o->product_id = $this->product_id; $o->service_id = $oo->service_id;
$o->quantity = $oo->quantity; $o->product_id = $this->product_id;
$o->item_type = $oo->type; $o->quantity = $oo->quantity;
$o->price_base = $oo->amount; $o->item_type = $oo->type;
$o->date_start = $oo->date_charge; $o->price_base = $oo->amount;
$o->date_stop = $oo->date_charge; $o->date_start = $oo->date_charge;
$o->module_id = 30; // @todo This shouldnt be hard coded $o->date_stop = $oo->date_charge;
$o->module_ref = $oo->id; $o->module_id = 30; // @todo This shouldnt be hard coded
$o->module_ref = $oo->id;
$o->addTaxes($this->account->country->taxes); $o->addTaxes($this->account->country->taxes);
$this->invoice_items->push($o); $this->invoice_items->push($o);
} }
return $this->invoice_items->filter(function($item) { return ! $item->exists; }); return $this->invoice_items->filter(function($item) { return ! $item->exists; });
} }