1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Fixes for base repo. (#3464)

* Fixes for designs

* remove logs

* Minor fixes for Invoice Item

* Fixes for company defaults
This commit is contained in:
David Bomba 2020-03-10 17:45:24 +11:00 committed by GitHub
parent 6ffea888b0
commit 25e29ed54c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 8 deletions

View File

@ -51,10 +51,10 @@ class InvoiceItem
public $custom_value4 = '';
public $line_item_type_id = 1; //1 = product, 2 = service, 3 unpaid gateway fee, 4 paid gateway fee
public $type_id = 1; //1 = product, 2 = service, 3 unpaid gateway fee, 4 paid gateway fee
public static $casts = [
'line_item_type_id' => 'string',
'type_id' => 'string',
'quantity' => 'float',
'cost' => 'float',
'product_key' => 'string',

View File

@ -464,19 +464,24 @@ class Client extends BaseModel implements HasLocalePreference
return $this->company->company_key . '/';
}
public function setCompanyDefaults($data, $entity_name)
public function setCompanyDefaults($data, $entity_name) :array
{
$defaults = [];
if(!(array_key_exists('terms', $data) && strlen($data['terms']) > 1))
$data['terms'] = $this->getSetting($entity_name.'_terms');
$defaults['terms'] = $this->getSetting($entity_name.'_terms');
elseif(array_key_exists('terms', $data))
$defaults['terms'] = $data['terms'];
if(!(array_key_exists('footer', $data) && strlen($data['footer']) > 1))
$data['footer'] = $this->getSetting($entity_name.'_footer');
$defaults['footer'] = $this->getSetting($entity_name.'_footer');
elseif(array_key_exists('footer', $data))
$defaults['footer'] = $data['footer'];
if(strlen($this->public_notes) >=1)
$data['public_notes'] = $this->public_notes;
$defaults['public_notes'] = $this->public_notes;
return $data;
return $defaults;
}
}

View File

@ -201,8 +201,10 @@ class BaseRepository
$state['starting_amount'] = $model->amount;
if (!$model->id) {
$data = $client->setCompanyDefaults($data,lcfirst($resource));
$company_defaults = $client->setCompanyDefaults($data,lcfirst($resource));
$model->uses_inclusive_taxes = $client->getSetting('inclusive_taxes');
$data = array_merge($company_defaults, $data);
}
$model->fill($data);