1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Fixes for tests

This commit is contained in:
David Bomba 2023-08-11 17:58:43 +10:00
parent d465fd3f2e
commit b08d805728
14 changed files with 83 additions and 53 deletions

View File

@ -17,6 +17,11 @@ use App\Models\Company;
use App\Models\User; use App\Models\User;
use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Cache;
/**
* @class \App\Http\Requests\Yodlee\YodleeAuthRequest
* @property string $token
* @property string $state
*/
class YodleeAuthRequest extends Request class YodleeAuthRequest extends Request
{ {
/** /**
@ -39,7 +44,6 @@ class YodleeAuthRequest extends Request
return []; return [];
} }
/** @var Request $token */
public function getTokenContent() public function getTokenContent()
{ {
if ($this->state) { if ($this->state) {

View File

@ -66,9 +66,6 @@ class ZipDocuments implements ShouldQueue
* Execute the job. * Execute the job.
* *
* @return void * @return void
* @throws \ZipStream\Exception\FileNotFoundException
* @throws \ZipStream\Exception\FileNotReadableException
* @throws \ZipStream\Exception\OverflowException
*/ */
public function handle() public function handle()
{ {

View File

@ -62,9 +62,6 @@ class ZipQuotes implements ShouldQueue
* Execute the job. * Execute the job.
* *
* @return void * @return void
* @throws \ZipStream\Exception\FileNotFoundException
* @throws \ZipStream\Exception\FileNotReadableException
* @throws \ZipStream\Exception\OverflowException
*/ */
public function handle() public function handle()
{ {

View File

@ -124,7 +124,6 @@ class BaseModel extends Model
/** /**
* @param \Illuminate\Database\Eloquent\Builder $query * @param \Illuminate\Database\Eloquent\Builder $query
* @extends \Illuminate\Database\Eloquent\Builder
* @return \Illuminate\Database\Eloquent\Builder * @return \Illuminate\Database\Eloquent\Builder
*/ */
public function scopeCompany($query): \Illuminate\Database\Eloquent\Builder public function scopeCompany($query): \Illuminate\Database\Eloquent\Builder

View File

@ -238,7 +238,10 @@ class Client extends BaseModel implements HasLocalePreference
return $this->hasMany(CompanyLedger::class)->orderBy('id', 'desc'); return $this->hasMany(CompanyLedger::class)->orderBy('id', 'desc');
} }
public function company_ledger() /**
* @return \Illuminate\Database\Eloquent\Relations\MorphMany<CompanyLedger>
*/
public function company_ledger(): \Illuminate\Database\Eloquent\Relations\MorphMany
{ {
return $this->morphMany(CompanyLedger::class, 'company_ledgerable'); return $this->morphMany(CompanyLedger::class, 'company_ledgerable');
} }
@ -516,7 +519,10 @@ class Client extends BaseModel implements HasLocalePreference
throw new \Exception('Could not find a settings object', 1); throw new \Exception('Could not find a settings object', 1);
} }
public function documents() :MorphMany /**
* @return \Illuminate\Database\Eloquent\Relations\MorphMany<Document>
*/
public function documents() :\Illuminate\Database\Eloquent\Relations\MorphMany
{ {
return $this->morphMany(Document::class, 'documentable'); return $this->morphMany(Document::class, 'documentable');
} }

View File

@ -395,6 +395,9 @@ class Company extends BaseModel
return $this->calculate_taxes && in_array($this->getSetting('country_id'), $this->tax_coverage_countries); return $this->calculate_taxes && in_array($this->getSetting('country_id'), $this->tax_coverage_countries);
} }
/**
* @return \Illuminate\Database\Eloquent\Relations\MorphMany<Document>
*/
public function documents() public function documents()
{ {
return $this->morphMany(Document::class, 'documentable'); return $this->morphMany(Document::class, 'documentable');

View File

@ -44,28 +44,6 @@ use Illuminate\Database\Eloquent\Relations\Pivot;
* @property-read \App\Models\User $user * @property-read \App\Models\User $user
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\User> $users * @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\User> $users
* @property-read int|null $users_count * @property-read int|null $users_count
* @method static \Illuminate\Database\Eloquent\Builder|CompanyUser authCompany()
* @method static \Illuminate\Database\Eloquent\Builder|CompanyUser newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|CompanyUser newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|CompanyUser onlyTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|CompanyUser query()
* @method static \Illuminate\Database\Eloquent\Builder|CompanyUser whereAccountId($value)
* @method static \Illuminate\Database\Eloquent\Builder|CompanyUser whereCompanyId($value)
* @method static \Illuminate\Database\Eloquent\Builder|CompanyUser whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|CompanyUser whereDeletedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|CompanyUser whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|CompanyUser whereIsAdmin($value)
* @method static \Illuminate\Database\Eloquent\Builder|CompanyUser whereIsLocked($value)
* @method static \Illuminate\Database\Eloquent\Builder|CompanyUser whereIsOwner($value)
* @method static \Illuminate\Database\Eloquent\Builder|CompanyUser whereNinjaPortalUrl($value)
* @method static \Illuminate\Database\Eloquent\Builder|CompanyUser whereNotifications($value)
* @method static \Illuminate\Database\Eloquent\Builder|CompanyUser wherePermissions($value)
* @method static \Illuminate\Database\Eloquent\Builder|CompanyUser wherePermissionsUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|CompanyUser whereReactSettings($value)
* @method static \Illuminate\Database\Eloquent\Builder|CompanyUser whereSettings($value)
* @method static \Illuminate\Database\Eloquent\Builder|CompanyUser whereSlackWebhookUrl($value)
* @method static \Illuminate\Database\Eloquent\Builder|CompanyUser whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|CompanyUser whereUserId($value)
* @method static \Illuminate\Database\Eloquent\Builder|CompanyUser withTrashed() * @method static \Illuminate\Database\Eloquent\Builder|CompanyUser withTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|CompanyUser withoutTrashed() * @method static \Illuminate\Database\Eloquent\Builder|CompanyUser withoutTrashed()
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\CompanyToken> $token * @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\CompanyToken> $token
@ -130,18 +108,18 @@ class CompanyUser extends Pivot
/** /**
* *
* @return \Illuminate\Database\Eloquent\Relations\HasOne * @return \Illuminate\Database\Eloquent\Relations\HasOne<User>
*/ */
public function user_pivot() public function user_pivot(): \Illuminate\Database\Eloquent\Relations\HasOne
{ {
return $this->hasOne(User::class)->withPivot('permissions', 'settings', 'react_settings', 'is_admin', 'is_owner', 'is_locked', 'slack_webhook_url', 'migrating'); return $this->hasOne(User::class)->withPivot('permissions', 'settings', 'react_settings', 'is_admin', 'is_owner', 'is_locked', 'slack_webhook_url', 'migrating');
} }
/** /**
* *
* @return \Illuminate\Database\Eloquent\Relations\HasOne * @return \Illuminate\Database\Eloquent\Relations\HasOne<Company>
*/ */
public function company_pivot() public function company_pivot(): \Illuminate\Database\Eloquent\Relations\HasOne
{ {
return $this->hasOne(Company::class)->withPivot('permissions', 'settings', 'react_settings', 'is_admin', 'is_owner', 'is_locked', 'slack_webhook_url', 'migrating'); return $this->hasOne(Company::class)->withPivot('permissions', 'settings', 'react_settings', 'is_admin', 'is_owner', 'is_locked', 'slack_webhook_url', 'migrating');
} }
@ -156,6 +134,9 @@ class CompanyUser extends Pivot
return $this->belongsTo(Company::class); return $this->belongsTo(Company::class);
} }
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function users(): \Illuminate\Database\Eloquent\Relations\HasMany public function users(): \Illuminate\Database\Eloquent\Relations\HasMany
{ {
return $this->hasMany(User::class)->withTrashed(); return $this->hasMany(User::class)->withTrashed();

View File

@ -270,6 +270,9 @@ class Credit extends BaseModel
return $this->belongsTo(Invoice::class); return $this->belongsTo(Invoice::class);
} }
/**
* @return \Illuminate\Database\Eloquent\Relations\MorphMany<CompanyLedger>
*/
public function company_ledger(): \Illuminate\Database\Eloquent\Relations\MorphMany public function company_ledger(): \Illuminate\Database\Eloquent\Relations\MorphMany
{ {
return $this->morphMany(CompanyLedger::class, 'company_ledgerable'); return $this->morphMany(CompanyLedger::class, 'company_ledgerable');
@ -289,11 +292,17 @@ class Credit extends BaseModel
return $this->belongsToMany(Invoice::class)->using(Paymentable::class); return $this->belongsToMany(Invoice::class)->using(Paymentable::class);
} }
/**
* @return \Illuminate\Database\Eloquent\Relations\MorphToMany<Payment>
*/
public function payments(): \Illuminate\Database\Eloquent\Relations\MorphToMany public function payments(): \Illuminate\Database\Eloquent\Relations\MorphToMany
{ {
return $this->morphToMany(Payment::class, 'paymentable'); return $this->morphToMany(Payment::class, 'paymentable');
} }
/**
* @return \Illuminate\Database\Eloquent\Relations\MorphMany<Document>
*/
public function documents(): \Illuminate\Database\Eloquent\Relations\MorphMany public function documents(): \Illuminate\Database\Eloquent\Relations\MorphMany
{ {
return $this->morphMany(Document::class, 'documentable'); return $this->morphMany(Document::class, 'documentable');

View File

@ -150,7 +150,10 @@ class Expense extends BaseModel
return self::class; return self::class;
} }
public function documents() /**
* @return \Illuminate\Database\Eloquent\Relations\MorphMany<Document>
*/
public function documents(): \Illuminate\Database\Eloquent\Relations\MorphMany
{ {
return $this->morphMany(Document::class, 'documentable'); return $this->morphMany(Document::class, 'documentable');
} }

View File

@ -102,7 +102,10 @@ class GroupSetting extends StaticModel
return $this->hasMany(Client::class, 'id', 'group_settings_id'); return $this->hasMany(Client::class, 'id', 'group_settings_id');
} }
public function documents() /**
* @return \Illuminate\Database\Eloquent\Relations\MorphMany<Document>
*/
public function documents(): \Illuminate\Database\Eloquent\Relations\MorphMany
{ {
return $this->morphMany(Document::class, 'documentable'); return $this->morphMany(Document::class, 'documentable');
} }

View File

@ -31,6 +31,7 @@ use App\Helpers\Invoice\InvoiceSumInclusive;
use App\Utils\Traits\Invoice\ActionsInvoice; use App\Utils\Traits\Invoice\ActionsInvoice;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use App\Events\Invoice\InvoiceReminderWasEmailed; use App\Events\Invoice\InvoiceReminderWasEmailed;
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
/** /**
* App\Models\Invoice * App\Models\Invoice
@ -302,16 +303,25 @@ class Invoice extends BaseModel
return $this->belongsTo(Subscription::class)->withTrashed(); return $this->belongsTo(Subscription::class)->withTrashed();
} }
/**
* @return \Illuminate\Database\Eloquent\Relations\MorphMany<Document>
*/
public function documents(): \Illuminate\Database\Eloquent\Relations\MorphMany public function documents(): \Illuminate\Database\Eloquent\Relations\MorphMany
{ {
return $this->morphMany(Document::class, 'documentable'); return $this->morphMany(Document::class, 'documentable');
} }
/**
* @return \Illuminate\Database\Eloquent\Relations\MorphToMany<Payment>
*/
public function payments(): \Illuminate\Database\Eloquent\Relations\MorphToMany public function payments(): \Illuminate\Database\Eloquent\Relations\MorphToMany
{ {
return $this->morphToMany(Payment::class, 'paymentable')->withTrashed()->withPivot('amount', 'refunded')->withTimestamps(); return $this->morphToMany(Payment::class, 'paymentable')->withTrashed()->withPivot('amount', 'refunded')->withTimestamps();
} }
/**
* @return \Illuminate\Database\Eloquent\Relations\MorphMany<CompanyLedger>
*/
public function company_ledger(): \Illuminate\Database\Eloquent\Relations\MorphMany public function company_ledger(): \Illuminate\Database\Eloquent\Relations\MorphMany
{ {
return $this->morphMany(CompanyLedger::class, 'company_ledgerable'); return $this->morphMany(CompanyLedger::class, 'company_ledgerable');
@ -322,32 +332,41 @@ class Invoice extends BaseModel
return $this->hasMany(Activity::class)->orderBy('id', 'DESC')->take(50); return $this->hasMany(Activity::class)->orderBy('id', 'DESC')->take(50);
} }
public function history() /**
* @return \Illuminate\Database\Eloquent\Relations\HasManyThrough<Backup>
*/
public function history(): \Illuminate\Database\Eloquent\Relations\HasManyThrough
{ {
return $this->hasManyThrough(Backup::class, Activity::class); return $this->hasManyThrough(Backup::class, Activity::class);
} }
public function credits() public function credits(): \Illuminate\Database\Eloquent\Relations\HasMany
{ {
return $this->hasMany(Credit::class); return $this->hasMany(Credit::class);
} }
public function tasks() public function tasks(): \Illuminate\Database\Eloquent\Relations\HasMany
{ {
return $this->hasMany(Task::class); return $this->hasMany(Task::class);
} }
public function task() /**
* @return \Illuminate\Database\Eloquent\Relations\HasOne<Task>
*/
public function task(): \Illuminate\Database\Eloquent\Relations\HasOne
{ {
return $this->hasOne(Task::class); return $this->hasOne(Task::class);
} }
public function expenses() public function expenses(): \Illuminate\Database\Eloquent\Relations\HasMany
{ {
return $this->hasMany(Expense::class); return $this->hasMany(Expense::class);
} }
public function expense() /**
* @return \Illuminate\Database\Eloquent\Relations\HasOne<Expense>
*/
public function expense(): \Illuminate\Database\Eloquent\Relations\HasOne
{ {
return $this->hasOne(Expense::class); return $this->hasOne(Expense::class);
} }

View File

@ -216,21 +216,24 @@ class Payment extends BaseModel
} }
/** /**
* @return MorphedByMany * @return \Illuminate\Database\Eloquent\Relations\MorphToMany<Paymentable>
*/ */
public function invoices() public function invoices(): \Illuminate\Database\Eloquent\Relations\MorphToMany
{ {
return $this->morphedByMany(Invoice::class, 'paymentable')->withTrashed()->withPivot('amount', 'refunded')->withTimestamps(); return $this->morphedByMany(Invoice::class, 'paymentable')->withTrashed()->withPivot('amount', 'refunded')->withTimestamps();
} }
/** /**
* @return MorphedByMany * @return \Illuminate\Database\Eloquent\Relations\MorphToMany<Paymentable>
*/ */
public function credits() public function credits(): \Illuminate\Database\Eloquent\Relations\MorphToMany
{ {
return $this->morphedByMany(Credit::class, 'paymentable')->withTrashed()->withPivot('amount', 'refunded')->withTimestamps(); return $this->morphedByMany(Credit::class, 'paymentable')->withTrashed()->withPivot('amount', 'refunded')->withTimestamps();
} }
/**
* @return \Illuminate\Database\Eloquent\Relations\MorphMany<CompanyLedger>
*/
public function company_ledger(): \Illuminate\Database\Eloquent\Relations\MorphMany public function company_ledger(): \Illuminate\Database\Eloquent\Relations\MorphMany
{ {
return $this->morphMany(CompanyLedger::class, 'company_ledgerable'); return $this->morphMany(CompanyLedger::class, 'company_ledgerable');
@ -266,7 +269,7 @@ class Payment extends BaseModel
return $this->belongsTo(Project::class); return $this->belongsTo(Project::class);
} }
public function translatedType() public function translatedType(): string
{ {
if (! $this->type_id) { if (! $this->type_id) {
return ''; return '';

View File

@ -227,6 +227,9 @@ class Quote extends BaseModel
return $this->belongsTo(Vendor::class); return $this->belongsTo(Vendor::class);
} }
/**
* @return \Illuminate\Database\Eloquent\Relations\HasManyThrough<Backup>
*/
public function history(): \Illuminate\Database\Eloquent\Relations\HasManyThrough public function history(): \Illuminate\Database\Eloquent\Relations\HasManyThrough
{ {
return $this->hasManyThrough(Backup::class, Activity::class); return $this->hasManyThrough(Backup::class, Activity::class);
@ -267,6 +270,9 @@ class Quote extends BaseModel
return $this->hasMany(QuoteInvitation::class); return $this->hasMany(QuoteInvitation::class);
} }
/**
* @return \Illuminate\Database\Eloquent\Relations\MorphMany<Document>
*/
public function documents(): \Illuminate\Database\Eloquent\Relations\MorphMany public function documents(): \Illuminate\Database\Eloquent\Relations\MorphMany
{ {
return $this->morphMany(Document::class, 'documentable'); return $this->morphMany(Document::class, 'documentable');

View File

@ -80,7 +80,7 @@ class ImportCustomers
{ {
$account = $this->stripe->company_gateway->company->account; $account = $this->stripe->company_gateway->company->account;
if (Ninja::isHosted() && ! $account->isPaidHostedClient() && Client::where('company_id', $this->stripe->company_gateway->company_id)->count() > config('ninja.quotas.free.clients')) { if (Ninja::isHosted() && ! $account->isPaidHostedClient() && Client::query()->where('company_id', $this->stripe->company_gateway->company_id)->count() > config('ninja.quotas.free.clients')) {
return; return;
} }
@ -115,7 +115,7 @@ class ImportCustomers
$client->phone = $customer->address->phone ? $customer->phone : ''; $client->phone = $customer->address->phone ? $customer->phone : '';
if ($customer->address->country) { if ($customer->address->country) {
$country = Country::where('iso_3166_2', $customer->address->country)->first(); $country = Country::query()->where('iso_3166_2', $customer->address->country)->first();
if ($country) { if ($country) {
$client->country_id = $country->id; $client->country_id = $country->id;
@ -124,7 +124,7 @@ class ImportCustomers
} }
if ($customer->currency) { if ($customer->currency) {
$currency = Currency::where('code', $customer->currency)->first(); $currency = Currency::query()->where('code', $customer->currency)->first();
if ($currency) { if ($currency) {
$settings = $client->settings; $settings = $client->settings;
@ -209,7 +209,7 @@ class ImportCustomers
// nlog(count($searchResults)); // nlog(count($searchResults));
if (count($searchResults) == 1) { if (count($searchResults) == 1) {
$cgt = ClientGatewayToken::where('gateway_customer_reference', $searchResults->data[0]->id)->where('company_id', $this->stripe->company_gateway->company->id)->exists(); $cgt = ClientGatewayToken::query()->where('gateway_customer_reference', $searchResults->data[0]->id)->where('company_id', $this->stripe->company_gateway->company->id)->exists();
if (! $cgt) { if (! $cgt) {
nlog('customer '.$searchResults->data[0]->id.' does not exist.'); nlog('customer '.$searchResults->data[0]->id.' does not exist.');