diff --git a/app/Http/Requests/VendorPortal/Documents/ShowDocumentRequest.php b/app/Http/Requests/VendorPortal/Documents/ShowDocumentRequest.php index 691cfe1d0558..dd1202d22a14 100644 --- a/app/Http/Requests/VendorPortal/Documents/ShowDocumentRequest.php +++ b/app/Http/Requests/VendorPortal/Documents/ShowDocumentRequest.php @@ -28,8 +28,7 @@ class ShowDocumentRequest extends FormRequest { /** @var \App\Models\VendorContact auth()->guard('vendor')->user() */ - - return auth()->guard('vendor')->user()->client_id == $this->document->documentable_id + return auth()->guard('vendor')->user()->vendor_id == $this->document->documentable_id || $this->document->company_id == auth()->guard('vendor')->user()->company_id; } diff --git a/app/Jobs/Bank/MatchBankTransactions.php b/app/Jobs/Bank/MatchBankTransactions.php index c4084047dff0..7b0c9abe2258 100644 --- a/app/Jobs/Bank/MatchBankTransactions.php +++ b/app/Jobs/Bank/MatchBankTransactions.php @@ -47,6 +47,7 @@ class MatchBankTransactions implements ShouldQueue private array $input; + /** @var \App\Models\Company */ protected ?Company $company; public Invoice $invoice; diff --git a/app/Jobs/Company/CompanyExport.php b/app/Jobs/Company/CompanyExport.php index 0cbb91f9a5c1..0a496b4c9f2c 100644 --- a/app/Jobs/Company/CompanyExport.php +++ b/app/Jobs/Company/CompanyExport.php @@ -48,9 +48,9 @@ class CompanyExport implements ShouldQueue /** * Create a new job instance. * - * @param Company $company - * @param User $user - * @param string $custom_token_name + * @param \App\Models\Company $company + * @param \App\Models\User $user + * @param string $hash */ public function __construct(public Company $company, private User $user, public string $hash) { diff --git a/app/Jobs/Company/CompanyImport.php b/app/Jobs/Company/CompanyImport.php index 7ec07abc616a..25406a2660f8 100644 --- a/app/Jobs/Company/CompanyImport.php +++ b/app/Jobs/Company/CompanyImport.php @@ -244,7 +244,7 @@ class CompanyImport implements ShouldQueue { MultiDB::setDb($this->company->db); - $this->company = Company::where('company_key', $this->company->company_key)->firstOrFail(); + $this->company = Company::query()->where('company_key', $this->company->company_key)->firstOrFail(); $this->account = $this->company->account; $this->company_owner = $this->company->owner(); @@ -591,6 +591,7 @@ class CompanyImport implements ShouldQueue unset($obj_array['id']); unset($obj_array['tax_rate_id']); + /** @var \App\Models\TaxRate $new_obj */ $new_obj = TaxRate::firstOrNew( ['name' => $obj->name, 'company_id' => $this->company->id, 'rate' => $obj->rate], $obj_array, @@ -1427,7 +1428,7 @@ class CompanyImport implements ShouldQueue if ($class == 'App\Models\Subscription') { $obj_array['product_ids'] = $this->recordProductIds($obj_array['product_ids']); $obj_array['recurring_product_ids'] = $this->recordProductIds($obj_array['recurring_product_ids']); - $obj_array['webhook_configuration'] = json_encode($obj_array['webhook_configuration']); + $obj_array['webhook_configuration'] = \json_encode($obj_array['webhook_configuration']); } $new_obj = $class::firstOrNew( diff --git a/app/Jobs/Credit/ZipCredits.php b/app/Jobs/Credit/ZipCredits.php index b649d6f7ee85..3b648bd7a2c7 100644 --- a/app/Jobs/Credit/ZipCredits.php +++ b/app/Jobs/Credit/ZipCredits.php @@ -62,9 +62,6 @@ class ZipCredits implements ShouldQueue * Execute the job. * * @return void - * @throws \ZipStream\Exception\FileNotFoundException - * @throws \ZipStream\Exception\FileNotReadableException - * @throws \ZipStream\Exception\OverflowException */ public function handle() { diff --git a/app/Jobs/Cron/AutoBillCron.php b/app/Jobs/Cron/AutoBillCron.php index f0e4343964b1..cf2c5f987f5b 100644 --- a/app/Jobs/Cron/AutoBillCron.php +++ b/app/Jobs/Cron/AutoBillCron.php @@ -49,7 +49,8 @@ class AutoBillCron Auth::logout(); if (! config('ninja.db.multi_db_enabled')) { - $auto_bill_partial_invoices = Invoice::whereDate('partial_due_date', '<=', now()) + $auto_bill_partial_invoices = Invoice::query() + ->whereDate('partial_due_date', '<=', now()) ->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL]) ->where('auto_bill_enabled', true) ->where('auto_bill_tries', '<', 3) @@ -70,7 +71,8 @@ class AutoBillCron sleep(2); }); - $auto_bill_invoices = Invoice::whereDate('due_date', '<=', now()) + $auto_bill_invoices = Invoice::query() + ->whereDate('due_date', '<=', now()) ->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL]) ->where('auto_bill_enabled', true) ->where('auto_bill_tries', '<', 3) @@ -95,7 +97,8 @@ class AutoBillCron foreach (MultiDB::$dbs as $db) { MultiDB::setDB($db); - $auto_bill_partial_invoices = Invoice::whereDate('partial_due_date', '<=', now()) + $auto_bill_partial_invoices = Invoice::query() + ->whereDate('partial_due_date', '<=', now()) ->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL]) ->where('auto_bill_enabled', true) ->where('auto_bill_tries', '<', 3) @@ -116,7 +119,8 @@ class AutoBillCron sleep(2); }); - $auto_bill_invoices = Invoice::whereDate('due_date', '<=', now()) + $auto_bill_invoices = Invoice::query() + ->whereDate('due_date', '<=', now()) ->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL]) ->where('auto_bill_enabled', true) ->where('auto_bill_tries', '<', 3) diff --git a/app/Jobs/Cron/SendCompanyRecurring.php b/app/Jobs/Cron/SendCompanyRecurring.php index 6b1d31e7dae4..85dd0bed19d8 100644 --- a/app/Jobs/Cron/SendCompanyRecurring.php +++ b/app/Jobs/Cron/SendCompanyRecurring.php @@ -25,21 +25,11 @@ class SendCompanyRecurring public $tries = 1; - /** - * Create a new job instance. - * - * @return void - */ - + /** @var \App\Models\Company $company */ public $company; - public $db; - - public function __construct($company_id, $db) + public function __construct(private int $company_id, private string $db) { - $this->company_id = $company_id; - - $this->db = $db; } /** diff --git a/app/Jobs/Entity/CreateEntityPdf.php b/app/Jobs/Entity/CreateEntityPdf.php index fe25cd410332..fa6337e1479a 100644 --- a/app/Jobs/Entity/CreateEntityPdf.php +++ b/app/Jobs/Entity/CreateEntityPdf.php @@ -47,19 +47,19 @@ class CreateEntityPdf implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, NumberFormatter, MakesInvoiceHtml, PdfMaker, MakesHash, PageNumbering; - public $entity; + public \App\Models\Invoice | \App\Models\Quote | \App\Models\Credit | \App\Models\RecurringInvoice $entity; - public $company; + public \App\Models\Company $company; - public $contact; + public \App\Models\ClientContact$contact; private $disk; - public $invitation; + public \App\Models\InvoiceInvitation | \App\Models\QuoteInvitation | \App\Models\CreditInvitation | \App\Models\RecurringInvoiceInvitation $invitation; - public $entity_string = ''; + public string $entity_string = ''; - public $client; + public \App\Models\Client $client; public $deleteWhenMissingModels = true; @@ -135,6 +135,7 @@ class CreateEntityPdf implements ShouldQueue $entity_design_id = $this->entity->design_id ? $this->entity->design_id : $this->decodePrimaryKey($this->client->getSetting($entity_design_id)); + /** @var \App\Models\Design $design */ $design = Design::withTrashed()->find($entity_design_id); /* Catch all in case migration doesn't pass back a valid design */ diff --git a/app/Jobs/Inventory/AdjustProductInventory.php b/app/Jobs/Inventory/AdjustProductInventory.php index 8463a10ad7cc..4b5ed184648f 100644 --- a/app/Jobs/Inventory/AdjustProductInventory.php +++ b/app/Jobs/Inventory/AdjustProductInventory.php @@ -71,7 +71,7 @@ class AdjustProductInventory implements ShouldQueue collect($this->invoice->line_items)->filter(function ($item) { return $item->type_id == '1'; })->each(function ($i) { - $p = Product::where('product_key', $i->product_key)->where('company_id', $this->company->id)->first(); + $p = Product::query()->where('product_key', $i->product_key)->where('company_id', $this->company->id)->first(); if ($p) { $p->in_stock_quantity += $i->quantity; @@ -88,7 +88,7 @@ class AdjustProductInventory implements ShouldQueue collect($this->invoice->line_items)->filter(function ($item) { return $item->type_id == '1'; })->each(function ($i) { - $p = Product::where('product_key', $i->product_key)->where('company_id', $this->company->id)->first(); + $p = Product::query()->where('product_key', $i->product_key)->where('company_id', $this->company->id)->first(); if ($p) { $p->in_stock_quantity -= $i->quantity; @@ -109,7 +109,7 @@ class AdjustProductInventory implements ShouldQueue collect($this->invoice->line_items)->filter(function ($item) { return $item->type_id == '1'; })->each(function ($i) { - $p = Product::where('product_key', $i->product_key)->where('company_id', $this->company->id)->first(); + $p = Product::query()->where('product_key', $i->product_key)->where('company_id', $this->company->id)->first(); if ($p) { $p->in_stock_quantity -= $i->quantity; diff --git a/app/Jobs/Invitation/MarkOpened.php b/app/Jobs/Invitation/MarkOpened.php index 89014305625d..6c9b903a8e07 100644 --- a/app/Jobs/Invitation/MarkOpened.php +++ b/app/Jobs/Invitation/MarkOpened.php @@ -45,7 +45,7 @@ class MarkOpened implements ShouldQueue * Execute the job. * * - * @return false + * @return void */ public function handle() { diff --git a/app/Jobs/Invoice/CreateUbl.php b/app/Jobs/Invoice/CreateUbl.php index 441726583507..369b1563ff83 100644 --- a/app/Jobs/Invoice/CreateUbl.php +++ b/app/Jobs/Invoice/CreateUbl.php @@ -197,6 +197,7 @@ class CreateUbl implements ShouldQueue if ($this->invoice->discount != 0) { if ($this->invoice->is_amount_discount) { + /** @var float $invoice_total */ if ($invoice_total + $this->invoice->discount != 0) { $total -= $invoice_total ? ($total / ($invoice_total + $this->invoice->discount) * $this->invoice->discount) : 0; } diff --git a/app/Jobs/Invoice/InvoiceWorkflowSettings.php b/app/Jobs/Invoice/InvoiceWorkflowSettings.php index adb446fb4b0d..615b43ad925f 100644 --- a/app/Jobs/Invoice/InvoiceWorkflowSettings.php +++ b/app/Jobs/Invoice/InvoiceWorkflowSettings.php @@ -25,8 +25,6 @@ class InvoiceWorkflowSettings implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; - public $invoice; - public $client; private $base_repository; @@ -35,11 +33,9 @@ class InvoiceWorkflowSettings implements ShouldQueue * Create a new job instance. * * @param Invoice $invoice - * @param Client|null $client */ - public function __construct(Invoice $invoice) + public function __construct(public Invoice $invoice) { - $this->invoice = $invoice; $this->base_repository = new BaseRepository(); } diff --git a/app/Jobs/Mail/NinjaMailerJob.php b/app/Jobs/Mail/NinjaMailerJob.php index 0e81d544f9be..9d82b6857ab0 100644 --- a/app/Jobs/Mail/NinjaMailerJob.php +++ b/app/Jobs/Mail/NinjaMailerJob.php @@ -51,7 +51,7 @@ class NinjaMailerJob implements ShouldQueue public $override; - /* @var Company $company*/ + /* @var \App\Models\Company $company*/ public ?Company $company; private $mailer; diff --git a/app/Jobs/PostMark/ProcessPostmarkWebhook.php b/app/Jobs/PostMark/ProcessPostmarkWebhook.php index c2497a3b5677..d99455ab322e 100644 --- a/app/Jobs/PostMark/ProcessPostmarkWebhook.php +++ b/app/Jobs/PostMark/ProcessPostmarkWebhook.php @@ -39,20 +39,14 @@ class ProcessPostmarkWebhook implements ShouldQueue public $tries = 1; - private array $request; - public $invitation; + /** * Create a new job instance. * - * @param Payment $payment - * @param $email_builder - * @param $contact - * @param $company */ - public function __construct(array $request) + public function __construct(private array $request) { - $this->request = $request; } /** diff --git a/app/Jobs/Product/UpdateOrCreateProduct.php b/app/Jobs/Product/UpdateOrCreateProduct.php index 7405ed4ee1c6..bc9b5017d990 100644 --- a/app/Jobs/Product/UpdateOrCreateProduct.php +++ b/app/Jobs/Product/UpdateOrCreateProduct.php @@ -78,6 +78,7 @@ class UpdateOrCreateProduct implements ShouldQueue return $item->type_id == 1; }); + /** @var \App\DataMapper\InvoiceItem $item */ foreach ($updateable_products as $item) { if (empty($item->product_key)) { continue; @@ -106,13 +107,6 @@ class UpdateOrCreateProduct implements ShouldQueue $product->quantity = isset($item->quantity) ? $item->quantity : 0; } - // $product->tax_name1 = isset($item->tax_name1) ? $item->tax_name1 : ''; - // $product->tax_rate1 = isset($item->tax_rate1) ? $item->tax_rate1 : 0; - // $product->tax_name2 = isset($item->tax_name2) ? $item->tax_name2 : ''; - // $product->tax_rate2 = isset($item->tax_rate2) ? $item->tax_rate2 : 0; - // $product->tax_name3 = isset($item->tax_name3) ? $item->tax_name3 : ''; - // $product->tax_rate3 = isset($item->tax_rate3) ? $item->tax_rate3 : 0; - if (isset($item->custom_value1) && strlen($item->custom_value1) >=1) { $product->custom_value1 = $item->custom_value1; } diff --git a/app/Jobs/User/UserEmailChanged.php b/app/Jobs/User/UserEmailChanged.php index b400684f052b..c397f1ae65dd 100644 --- a/app/Jobs/User/UserEmailChanged.php +++ b/app/Jobs/User/UserEmailChanged.php @@ -30,26 +30,17 @@ class UserEmailChanged implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; - protected $new_user; - - protected $old_user; - - protected $company; - public $settings; /** * Create a new job instance. * - * @param string $new_email - * @param string $old_email - * @param Company $company + * @param \App\Models\User $new_user + * @param \App\Models\User $old_user + * @param \App\Models\Company $company */ - public function __construct(User $new_user, $old_user, Company $company) + public function __construct(protected User $new_user, protected User $old_user, protected Company $company) { - $this->new_user = $new_user; - $this->old_user = $old_user; - $this->company = $company; $this->settings = $this->company->settings; } diff --git a/app/Jobs/User/VerifyPhone.php b/app/Jobs/User/VerifyPhone.php index e28c77afb420..afeb33566db0 100644 --- a/app/Jobs/User/VerifyPhone.php +++ b/app/Jobs/User/VerifyPhone.php @@ -37,7 +37,7 @@ class VerifyPhone implements ShouldQueue /** * Execute the job. * - * @return User|null + * @return void */ public function handle() : void { diff --git a/app/Jobs/Util/Import.php b/app/Jobs/Util/Import.php index d35b50cb7027..bd6eaa1c89ae 100644 --- a/app/Jobs/Util/Import.php +++ b/app/Jobs/Util/Import.php @@ -173,10 +173,11 @@ class Import implements ShouldQueue /** * Create a new job instance. * - * @param array $data + * @param string $file_path * @param Company $company * @param User $user * @param array $resources + * @param bool $silent_migration */ public function __construct(string $file_path, Company $company, User $user, array $resources = [], $silent_migration = false) { @@ -195,7 +196,6 @@ class Import implements ShouldQueue /** * Execute the job. * - * @return bool */ public function handle() { @@ -302,7 +302,7 @@ class Import implements ShouldQueue // 10/02/21 foreach ($client->payments as $payment) { - $credit_total_applied += $payment->paymentables()->where('paymentable_type', App\Models\Credit::class)->get()->sum(\DB::raw('amount')); + $credit_total_applied += $payment->paymentables()->where('paymentable_type', \App\Models\Credit::class)->get()->sum(\DB::raw('amount')); } if ($credit_total_applied < 0) { @@ -319,7 +319,7 @@ class Import implements ShouldQueue private function setInitialCompanyLedgerBalances() { - Client::where('company_id', $this->company->id)->cursor()->each(function ($client) { + Client::query()->where('company_id', $this->company->id)->cursor()->each(function ($client) { $invoice_balances = $client->invoices->where('is_deleted', false)->where('status_id', '>', 1)->sum('balance'); $company_ledger = CompanyLedgerFactory::create($client->company_id, $client->user_id); @@ -954,6 +954,7 @@ class Import implements ShouldQueue $modified['vendor_id'] = $this->transformId('vendors', $resource['vendor_id']); } + /** @var \App\Models\Expense $expense */ $expense = RecurringExpense::create($modified); if (array_key_exists('created_at', $modified)) { @@ -1622,7 +1623,7 @@ class Import implements ShouldQueue $modified['gateway_key'] = 'd14dd26a37cecc30fdd65700bfb55b23'; } - + /** @var \App\Models\CompanyGateway $company_gateway */ $company_gateway = CompanyGateway::create($modified); $key = "company_gateways_{$resource['id']}"; diff --git a/app/Models/Company.php b/app/Models/Company.php index 932a3899c906..591563d46af2 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -451,6 +451,9 @@ class Company extends BaseModel return $this->hasMany(ClientContact::class)->withTrashed(); } + /** + * @return \Illuminate\Database\Eloquent\Relations\HasManyThrough + */ public function users(): \Illuminate\Database\Eloquent\Relations\HasManyThrough { return $this->hasManyThrough(User::class, CompanyUser::class, 'company_id', 'id', 'id', 'user_id')->withTrashed(); @@ -510,7 +513,7 @@ class Company extends BaseModel return $this->hasMany(Vendor::class)->withTrashed(); } - public function all_activities() :HasMany + public function all_activities() :\Illuminate\Database\Eloquent\Relations\HasMany { return $this->hasMany(Activity::class); } diff --git a/app/Models/TaxRate.php b/app/Models/TaxRate.php index 6caab9a18564..9ae870fcf508 100644 --- a/app/Models/TaxRate.php +++ b/app/Models/TaxRate.php @@ -48,6 +48,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @method static \Illuminate\Database\Eloquent\Builder|TaxRate whereUserId($value) * @method static \Illuminate\Database\Eloquent\Builder|TaxRate withTrashed() * @method static \Illuminate\Database\Eloquent\Builder|TaxRate withoutTrashed() + * @method static \Illuminate\Database\Eloquent\Builder|TaxRate firstOrNew() * @mixin \Eloquent */ class TaxRate extends BaseModel