mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Updated static analysis
This commit is contained in:
parent
01cc61b586
commit
cd7d78d20b
@ -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;
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,7 @@ class MatchBankTransactions implements ShouldQueue
|
||||
|
||||
private array $input;
|
||||
|
||||
/** @var \App\Models\Company */
|
||||
protected ?Company $company;
|
||||
|
||||
public Invoice $invoice;
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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(
|
||||
|
@ -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()
|
||||
{
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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 */
|
||||
|
@ -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;
|
||||
|
@ -45,7 +45,7 @@ class MarkOpened implements ShouldQueue
|
||||
* Execute the job.
|
||||
*
|
||||
*
|
||||
* @return false
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ class NinjaMailerJob implements ShouldQueue
|
||||
|
||||
public $override;
|
||||
|
||||
/* @var Company $company*/
|
||||
/* @var \App\Models\Company $company*/
|
||||
public ?Company $company;
|
||||
|
||||
private $mailer;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ class VerifyPhone implements ShouldQueue
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return User|null
|
||||
* @return void
|
||||
*/
|
||||
public function handle() : void
|
||||
{
|
||||
|
@ -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']}";
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user