1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 16:31:33 +02:00

Set defaults and cast invoice items if they are blank (#3030)

This commit is contained in:
David Bomba 2019-10-30 08:42:42 +11:00 committed by GitHub
parent aad22f607e
commit e7a6a8c403
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -52,8 +52,10 @@ class InvoiceItem
public $custom_value4 = '';
public $invoice_item_type_id = 1;
public static $casts = [
'invoice_item_type_id' => 'string',
'quantity' => 'float',
'cost' => 'float',
'product_key' => 'string',

View File

@ -282,8 +282,12 @@ class InvoiceItemSum
foreach($invoice_item as $key => $value)
{
if(!property_exists($this->item, $key))
if(!property_exists($this->item, $key) || !isset($this->item->{$key})){
$this->item->{$key} = $value;
$this->item->{$key} = BaseSettings::castAttribute(InvoiceItem::$casts[$key], $value);
}
}