1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 15:13:29 +01:00

vendor updates

This commit is contained in:
paulwer 2023-12-14 10:39:55 +01:00
parent d8064a9a35
commit 8bd9f34d98
2 changed files with 18 additions and 12 deletions

View File

@ -54,6 +54,8 @@ use Laracasts\Presenter\PresentableTrait;
* @property string|null $id_number * @property string|null $id_number
* @property string|null $language_id * @property string|null $language_id
* @property int|null $last_login * @property int|null $last_login
* @property string|null $expense_sender_email
* @property string|null $expense_sender_domain
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Activity> $activities * @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Activity> $activities
* @property-read int|null $activities_count * @property-read int|null $activities_count
* @property-read \App\Models\User|null $assigned_user * @property-read \App\Models\User|null $assigned_user
@ -115,6 +117,8 @@ class Vendor extends BaseModel
'number', 'number',
'language_id', 'language_id',
'classification', 'classification',
'expense_sender_email',
'expense_sender_domain',
]; ];
protected $casts = [ protected $casts = [
@ -169,11 +173,11 @@ class Vendor extends BaseModel
{ {
$currencies = Cache::get('currencies'); $currencies = Cache::get('currencies');
if (! $currencies) { if (!$currencies) {
$this->buildCache(true); $this->buildCache(true);
} }
if (! $this->currency_id) { if (!$this->currency_id) {
return $this->company->currency(); return $this->company->currency();
} }
@ -205,18 +209,18 @@ class Vendor extends BaseModel
return ctrans('texts.vendor'); return ctrans('texts.vendor');
} }
public function setCompanyDefaults($data, $entity_name) :array public function setCompanyDefaults($data, $entity_name): array
{ {
$defaults = []; $defaults = [];
if (! (array_key_exists('terms', $data) && strlen($data['terms']) > 1)) { if (!(array_key_exists('terms', $data) && strlen($data['terms']) > 1)) {
$defaults['terms'] = $this->getSetting($entity_name.'_terms'); $defaults['terms'] = $this->getSetting($entity_name . '_terms');
} elseif (array_key_exists('terms', $data)) { } elseif (array_key_exists('terms', $data)) {
$defaults['terms'] = $data['terms']; $defaults['terms'] = $data['terms'];
} }
if (! (array_key_exists('footer', $data) && strlen($data['footer']) > 1)) { if (!(array_key_exists('footer', $data) && strlen($data['footer']) > 1)) {
$defaults['footer'] = $this->getSetting($entity_name.'_footer'); $defaults['footer'] = $this->getSetting($entity_name . '_footer');
} elseif (array_key_exists('footer', $data)) { } elseif (array_key_exists('footer', $data)) {
$defaults['footer'] = $data['footer']; $defaults['footer'] = $data['footer'];
} }
@ -245,7 +249,7 @@ class Vendor extends BaseModel
return ''; return '';
} }
public function getMergedSettings() :object public function getMergedSettings(): object
{ {
return $this->company->settings; return $this->company->settings;
} }
@ -254,7 +258,7 @@ class Vendor extends BaseModel
{ {
$contact_key = $invitation->contact->contact_key; $contact_key = $invitation->contact->contact_key;
return $this->company->company_key.'/'.$this->vendor_hash.'/'.$contact_key.'/purchase_orders/'; return $this->company->company_key . '/' . $this->vendor_hash . '/' . $contact_key . '/purchase_orders/';
} }
public function locale(): string public function locale(): string
@ -277,9 +281,9 @@ class Vendor extends BaseModel
return $this->company->date_format(); return $this->company->date_format();
} }
public function backup_path() :string public function backup_path(): string
{ {
return $this->company->company_key.'/'.$this->vendor_hash.'/backups'; return $this->company->company_key . '/' . $this->vendor_hash . '/backups';
} }
public function service() public function service()

View File

@ -104,7 +104,9 @@ class VendorTransformer extends EntityTransformer
'number' => (string) $vendor->number ?: '', 'number' => (string) $vendor->number ?: '',
'language_id' => (string) $vendor->language_id ?: '', 'language_id' => (string) $vendor->language_id ?: '',
'classification' => (string) $vendor->classification ?: '', 'classification' => (string) $vendor->classification ?: '',
'display_name' => (string) $vendor->present()->name(), 'display_name' => (string) $vendor->present()->name(),
'expense_sender_email' => (string) $vendor->expense_sender_email ?: '',
'expense_sender_domain' => (string) $vendor->expense_sender_domain ?: '',
]; ];
} }
} }