diff --git a/app/Http/Livewire/BillingPortalPurchase.php b/app/Http/Livewire/BillingPortalPurchase.php index 821d8f56e6ba..6c0415bfe2f5 100644 --- a/app/Http/Livewire/BillingPortalPurchase.php +++ b/app/Http/Livewire/BillingPortalPurchase.php @@ -64,9 +64,9 @@ class BillingPortalPurchase extends Component /** * Instance of subscription. * - * @var Subscription + * @var \App\Models\Subscription $subscription */ - public $subscription; + public Subscription $subscription; /** * Instance of client contact. diff --git a/app/Jobs/Company/CompanyImport.php b/app/Jobs/Company/CompanyImport.php index 25406a2660f8..c1962bec02b1 100644 --- a/app/Jobs/Company/CompanyImport.php +++ b/app/Jobs/Company/CompanyImport.php @@ -280,7 +280,7 @@ class CompanyImport implements ShouldQueue 'errors' => [] ]; - $_company = Company::find($this->company->id); + $_company = Company::query()->find($this->company->id); $nmo = new NinjaMailerObject; $nmo->mailable = new ImportCompleted($_company, $data); diff --git a/app/Jobs/Entity/CreateRawPdf.php b/app/Jobs/Entity/CreateRawPdf.php index 4231b6595b44..d1f8ff624bc6 100644 --- a/app/Jobs/Entity/CreateRawPdf.php +++ b/app/Jobs/Entity/CreateRawPdf.php @@ -122,11 +122,11 @@ class CreateRawPdf implements ShouldQueue $entity_design_id = $this->entity->design_id ? $this->entity->design_id : $this->decodePrimaryKey($this->entity->client->getSetting($entity_design_id)); - $design = Design::withTrashed()->find($entity_design_id); + $design = Design::query()->withTrashed()->find($entity_design_id); /* Catch all in case migration doesn't pass back a valid design */ if (! $design) { - $design = Design::find(2); + $design = Design::query()->find(2); } $html = new HtmlEngine($this->invitation); diff --git a/app/Jobs/Inventory/AdjustProductInventory.php b/app/Jobs/Inventory/AdjustProductInventory.php index 4b5ed184648f..8ee86b0cbda2 100644 --- a/app/Jobs/Inventory/AdjustProductInventory.php +++ b/app/Jobs/Inventory/AdjustProductInventory.php @@ -131,7 +131,7 @@ class AdjustProductInventory implements ShouldQueue collect($this->old_invoice)->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/Ledger/ClientLedgerBalanceUpdate.php b/app/Jobs/Ledger/ClientLedgerBalanceUpdate.php index d3293116a6c1..29d780bfabb8 100644 --- a/app/Jobs/Ledger/ClientLedgerBalanceUpdate.php +++ b/app/Jobs/Ledger/ClientLedgerBalanceUpdate.php @@ -43,16 +43,16 @@ class ClientLedgerBalanceUpdate implements ShouldQueue MultiDB::setDb($this->company->db); - CompanyLedger::where('balance', 0)->where('client_id', $this->client->id)->orderBy('updated_at', 'ASC')->cursor()->each(function ($company_ledger) { + CompanyLedger::query()->where('balance', 0)->where('client_id', $this->client->id)->orderBy('updated_at', 'ASC')->cursor()->each(function ($company_ledger) { if ($company_ledger->balance == 0) { - $last_record = CompanyLedger::where('client_id', $company_ledger->client_id) + $last_record = CompanyLedger::query()->where('client_id', $company_ledger->client_id) ->where('company_id', $company_ledger->company_id) ->where('balance', '!=', 0) ->orderBy('id', 'DESC') ->first(); if (! $last_record) { - $last_record = CompanyLedger::where('client_id', $company_ledger->client_id) + $last_record = CompanyLedger::query()->where('client_id', $company_ledger->client_id) ->where('company_id', $company_ledger->company_id) ->orderBy('id', 'DESC') ->first(); diff --git a/app/Jobs/Mail/NinjaMailerJob.php b/app/Jobs/Mail/NinjaMailerJob.php index 9d82b6857ab0..ee38fbb77181 100644 --- a/app/Jobs/Mail/NinjaMailerJob.php +++ b/app/Jobs/Mail/NinjaMailerJob.php @@ -51,7 +51,7 @@ class NinjaMailerJob implements ShouldQueue public $override; - /* @var \App\Models\Company $company*/ + /** @var \App\Models\Company $company | null **/ public ?Company $company; private $mailer; @@ -83,7 +83,7 @@ class NinjaMailerJob implements ShouldQueue MultiDB::setDb($this->nmo->company->db); /* Serializing models from other jobs wipes the primary key */ - $this->company = Company::where('company_key', $this->nmo->company->company_key)->first(); + $this->company = Company::query()->where('company_key', $this->nmo->company->company_key)->first(); /* If any pre conditions fail, we return early here */ if (!$this->company || $this->preFlightChecksFail()) { @@ -552,7 +552,7 @@ class NinjaMailerJob implements ShouldQueue * Logs any errors to the SystemLog * * @param string $errors - * @param App\Models\User | App\Models\Client | null $recipient_object + * @param \App\Models\User | \App\Models\Client | null $recipient_object * @return void */ private function logMailError($errors, $recipient_object) :void diff --git a/app/Jobs/Mail/PaymentFailureMailer.php b/app/Jobs/Mail/PaymentFailureMailer.php index 336c8009c101..2a0e256db0b3 100644 --- a/app/Jobs/Mail/PaymentFailureMailer.php +++ b/app/Jobs/Mail/PaymentFailureMailer.php @@ -84,7 +84,14 @@ class PaymentFailureMailer implements ShouldQueue if (($key = array_search('mail', $methods)) !== false) { unset($methods[$key]); - $mail_obj = (new PaymentFailureObject($this->client, $this->error, $this->company, $this->amount, null))->build(); + $use_react_link = false; + + if(isset($company_user->react_settings->react_notification_link) && $company_user->react_settings->react_notification_link) { + $use_react_link = true; + } + + + $mail_obj = (new PaymentFailureObject($this->client, $this->error, $this->company, $this->amount, null, $use_react_link))->build(); $nmo = new NinjaMailerObject; $nmo->mailable = new NinjaMailer($mail_obj); diff --git a/app/Jobs/RecurringInvoice/UpdateRecurring.php b/app/Jobs/RecurringInvoice/UpdateRecurring.php index ee0527bcab83..b52ea17f2c83 100644 --- a/app/Jobs/RecurringInvoice/UpdateRecurring.php +++ b/app/Jobs/RecurringInvoice/UpdateRecurring.php @@ -42,7 +42,7 @@ class UpdateRecurring implements ShouldQueue $this->user->setCompany($this->company); - RecurringInvoice::where('company_id', $this->company->id) + RecurringInvoice::query()->where('company_id', $this->company->id) ->whereIn('id', $this->ids) ->chunk(100, function ($recurring_invoices) { foreach ($recurring_invoices as $recurring_invoice) { diff --git a/app/Jobs/Util/Import.php b/app/Jobs/Util/Import.php index bd6eaa1c89ae..bcc5a8da0cf5 100644 --- a/app/Jobs/Util/Import.php +++ b/app/Jobs/Util/Import.php @@ -1654,8 +1654,8 @@ class Import implements ShouldQueue $modified['company_gateway_id'] = $this->transformId('company_gateways', $resource['company_gateway_id']); //$modified['user_id'] = $this->processUserId($resource); - - $cgt = ClientGatewayToken::Create($modified); + /** @var \App\Models\ClientGatewayToken $cgt **/ + $cgt = ClientGatewayToken::create($modified); $key = "client_gateway_tokens_{$resource['id']}"; @@ -1684,7 +1684,8 @@ class Import implements ShouldQueue $modified['company_id'] = $this->company->id; $modified['user_id'] = $this->processUserId($resource); - $task_status = TaskStatus::Create($modified); + /** @var \App\Models\TaskStatus $task_status **/ + $task_status = TaskStatus::create($modified); $key = "task_statuses_{$resource['id']}"; @@ -1712,7 +1713,8 @@ class Import implements ShouldQueue $modified['company_id'] = $this->company->id; $modified['user_id'] = $this->processUserId($resource); - $expense_category = ExpenseCategory::Create($modified); + /** @var \App\Models\ExpenseCategory $expense_category **/ + $expense_category = ExpenseCategory::create($modified); $old_user_key = array_key_exists('user_id', $resource) ?? $this->user->id; @@ -1757,7 +1759,8 @@ class Import implements ShouldQueue $modified['status_id'] = $this->transformId('task_statuses', $resource['status_id']); } - $task = Task::Create($modified); + /** @var \App\Models\Task $task **/ + $task = Task::create($modified); if (array_key_exists('created_at', $modified)) { $task->created_at = Carbon::parse($modified['created_at']); @@ -1767,8 +1770,6 @@ class Import implements ShouldQueue $task->updated_at = Carbon::parse($modified['updated_at']); } - - $task->save(['timestamps' => false]); $old_user_key = array_key_exists('user_id', $resource) ?? $this->user->id; @@ -1871,6 +1872,7 @@ try { $modified['updated_at'] = $modified['created_at']; + /** @var \App\Models\Activity $act **/ $act = Activity::make($modified); $act->save(['timestamps' => false]); @@ -1921,7 +1923,8 @@ nlog("could not import activity: {$e->getMessage()}"); $modified['vendor_id'] = $this->transformId('vendors', $resource['vendor_id']); } - $expense = Expense::Create($modified); + /** @var \App\Models\Expense $expense **/ + $expense = Expense::create($modified); if (array_key_exists('created_at', $modified)) { $expense->created_at = Carbon::parse($modified['created_at']); @@ -1931,8 +1934,6 @@ nlog("could not import activity: {$e->getMessage()}"); $expense->updated_at = Carbon::parse($modified['updated_at']); } - - $expense->save(['timestamps' => false]); $old_user_key = array_key_exists('user_id', $resource) ?? $this->user->id; diff --git a/app/Jobs/Util/ImportStripeCustomers.php b/app/Jobs/Util/ImportStripeCustomers.php index 3a8422cbddd9..17a1c22dfc55 100644 --- a/app/Jobs/Util/ImportStripeCustomers.php +++ b/app/Jobs/Util/ImportStripeCustomers.php @@ -44,13 +44,13 @@ class ImportStripeCustomers implements ShouldQueue /** * Execute the job. * - * @return bool */ public function handle() { MultiDB::setDb($this->company->db); - $cgs = CompanyGateway::where('company_id', $this->company->id) + $cgs = CompanyGateway::query() + ->where('company_id', $this->company->id) ->where('is_deleted', 0) ->whereIn('gateway_key', $this->stripe_keys) ->get(); diff --git a/app/Jobs/Util/ReminderJob.php b/app/Jobs/Util/ReminderJob.php index 27a0f0632577..6c0521bfe361 100644 --- a/app/Jobs/Util/ReminderJob.php +++ b/app/Jobs/Util/ReminderJob.php @@ -159,7 +159,7 @@ class ReminderJob implements ShouldQueue } } - private function addFeeToNewInvoice(Invoice $over_due_invoice, string $reminder_template, array $fees): void + private function addFeeToNewInvoice(Invoice $over_due_invoice, string $reminder_template, array $fees) { $amount = $fees[0]; diff --git a/app/Jobs/Util/StripeUpdatePaymentMethods.php b/app/Jobs/Util/StripeUpdatePaymentMethods.php index b693a1c4a181..57f99ce9d9bb 100644 --- a/app/Jobs/Util/StripeUpdatePaymentMethods.php +++ b/app/Jobs/Util/StripeUpdatePaymentMethods.php @@ -42,13 +42,13 @@ class StripeUpdatePaymentMethods implements ShouldQueue /** * Execute the job. * - * @return bool */ public function handle() { MultiDB::setDb($this->company->db); - $cgs = CompanyGateway::where('company_id', $this->company->id) + $cgs = CompanyGateway::query() + ->where('company_id', $this->company->id) ->whereIn('gateway_key', $this->stripe_keys) ->get(); diff --git a/app/Jobs/Util/UploadFile.php b/app/Jobs/Util/UploadFile.php index d8a77385222c..43417f3529a1 100644 --- a/app/Jobs/Util/UploadFile.php +++ b/app/Jobs/Util/UploadFile.php @@ -51,6 +51,8 @@ class UploadFile implements ShouldQueue public $entity; + public $disk; + public function __construct($file, $type, $user, $company, $entity, $disk = null, $is_public = false) { $this->file = $file; diff --git a/app/Jobs/Util/WebhookHandler.php b/app/Jobs/Util/WebhookHandler.php index fd5f5d228fb7..2deaedca3bb3 100644 --- a/app/Jobs/Util/WebhookHandler.php +++ b/app/Jobs/Util/WebhookHandler.php @@ -43,7 +43,6 @@ class WebhookHandler implements ShouldQueue /** * Execute the job. * - * @return bool */ public function handle() { @@ -54,7 +53,8 @@ class WebhookHandler implements ShouldQueue return true; } - Webhook::where('company_id', $this->company->id) + Webhook::query() + ->where('company_id', $this->company->id) ->where('event_id', $this->event_id) ->cursor() ->each(function ($subscription) { diff --git a/app/Libraries/OAuth/OAuth.php b/app/Libraries/OAuth/OAuth.php index c684c62ac675..ba92d70106e8 100644 --- a/app/Libraries/OAuth/OAuth.php +++ b/app/Libraries/OAuth/OAuth.php @@ -39,6 +39,10 @@ class OAuth const SOCIAL_APPLE = 8; + public $provider_instance; + + public $provider_id; + /** * @param \Laravel\Socialite\Facades\Socialite $socialite_user * @return bool | \App\Models\User | \App\Models\User | null @@ -87,6 +91,8 @@ class OAuth return 'microsoft'; case self::SOCIAL_APPLE: return 'apple'; + default: + return 'google'; } } @@ -109,6 +115,8 @@ class OAuth return self::SOCIAL_MICROSOFT; case 'apple': return self::SOCIAL_APPLE; + default: + return self::SOCIAL_GOOGLE; } } diff --git a/app/Mail/MigrationCompleted.php b/app/Mail/MigrationCompleted.php index 9b62fb6fbab7..5890eecc25b5 100644 --- a/app/Mail/MigrationCompleted.php +++ b/app/Mail/MigrationCompleted.php @@ -38,7 +38,7 @@ class MigrationCompleted extends Mailable public function build() { MultiDB::setDb($this->db); - $this->company = Company::find($this->company_id); + $this->company = Company::query()->find($this->company_id); App::forgetInstance('translator'); $t = app('translator'); diff --git a/app/Models/Client.php b/app/Models/Client.php index c4aa239c1cd7..570e497ebc2d 100644 --- a/app/Models/Client.php +++ b/app/Models/Client.php @@ -537,8 +537,8 @@ class Client extends BaseModel implements HasLocalePreference foreach ($pms as $pm) { if ($pm['gateway_type_id'] == GatewayType::CREDIT_CARD) { - /**@var \App\Models\CompanyGateway $cg */ - $cg = CompanyGateway::find($pm['company_gateway_id']); + + $cg = CompanyGateway::query()->find($pm['company_gateway_id']); if ($cg && ! property_exists($cg->fees_and_limits, strval(GatewayType::CREDIT_CARD))) { $fees_and_limits = $cg->fees_and_limits; @@ -561,7 +561,7 @@ class Client extends BaseModel implements HasLocalePreference foreach ($pms as $pm) { if ($pm['gateway_type_id'] == GatewayType::BACS) { - $cg = CompanyGateway::find($pm['company_gateway_id']); + $cg = CompanyGateway::query()->find($pm['company_gateway_id']); if ($cg && ! property_exists($cg->fees_and_limits, GatewayType::BACS)) { $fees_and_limits = $cg->fees_and_limits; @@ -587,7 +587,7 @@ class Client extends BaseModel implements HasLocalePreference if ($this->currency()->code == 'USD' && in_array(GatewayType::BANK_TRANSFER, array_column($pms, 'gateway_type_id'))) { foreach ($pms as $pm) { if ($pm['gateway_type_id'] == GatewayType::BANK_TRANSFER) { - $cg = CompanyGateway::find($pm['company_gateway_id']); + $cg = CompanyGateway::query()->find($pm['company_gateway_id']); if ($cg && ! property_exists($cg->fees_and_limits, GatewayType::BANK_TRANSFER)) { $fees_and_limits = $cg->fees_and_limits; @@ -606,7 +606,7 @@ class Client extends BaseModel implements HasLocalePreference if ($this->currency()->code == 'EUR' && (in_array(GatewayType::BANK_TRANSFER, array_column($pms, 'gateway_type_id')) || in_array(GatewayType::SEPA, array_column($pms, 'gateway_type_id')))) { foreach ($pms as $pm) { if ($pm['gateway_type_id'] == GatewayType::SEPA) { - $cg = CompanyGateway::find($pm['company_gateway_id']); + $cg = CompanyGateway::query()->find($pm['company_gateway_id']); if ($cg && $cg->fees_and_limits->{GatewayType::SEPA}->is_enabled) { return $cg; @@ -618,7 +618,7 @@ class Client extends BaseModel implements HasLocalePreference if (in_array(GatewayType::DIRECT_DEBIT, array_column($pms, 'gateway_type_id'))) { foreach ($pms as $pm) { if ($pm['gateway_type_id'] == GatewayType::DIRECT_DEBIT) { - $cg = CompanyGateway::find($pm['company_gateway_id']); + $cg = CompanyGateway::query()->find($pm['company_gateway_id']); if ($cg && $cg->fees_and_limits->{GatewayType::DIRECT_DEBIT}->is_enabled) { return $cg; diff --git a/app/Models/Company.php b/app/Models/Company.php index 591563d46af2..5fb8a4477791 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -67,6 +67,10 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo; * @property bool $is_large * @property int $enable_shop_api * @property string $default_auto_bill + * @property string $custom_value1 + * @property string $custom_value2 + * @property string $custom_value3 + * @property string $custom_value4 * @property bool $mark_expenses_invoiceable * @property bool $mark_expenses_paid * @property bool $invoice_expense_documents diff --git a/app/Models/PaymentHash.php b/app/Models/PaymentHash.php index d0c8722fdfbe..9905feddab65 100644 --- a/app/Models/PaymentHash.php +++ b/app/Models/PaymentHash.php @@ -18,7 +18,7 @@ use Illuminate\Database\Eloquent\Model; * * @property int $id * @property string $hash - * @property string $fee_total + * @property float $fee_total * @property int|null $fee_invoice_id * @property mixed $data * @property int|null $payment_id diff --git a/app/Models/Webhook.php b/app/Models/Webhook.php index 5a921eb1d8f2..22e87e833966 100644 --- a/app/Models/Webhook.php +++ b/app/Models/Webhook.php @@ -31,7 +31,6 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @property-read \App\Models\Company|null $company * @property-read mixed $hashed_id * @property-read \App\Models\User|null $user - * @method static \Illuminate\Database\Eloquent\Builder|BaseModel company() * @method static \Illuminate\Database\Eloquent\Builder|BaseModel exclude($columns) * @method static \Illuminate\Database\Eloquent\Builder|Webhook filter(\App\Filters\QueryFilters $filters) * @method static \Illuminate\Database\Eloquent\Builder|Webhook newModelQuery() diff --git a/app/Services/Client/ClientService.php b/app/Services/Client/ClientService.php index 869f9e51f01a..81cd527c615f 100644 --- a/app/Services/Client/ClientService.php +++ b/app/Services/Client/ClientService.php @@ -166,7 +166,6 @@ class ClientService * * @param mixed $pdf The pdf blob * @param array $options The statement options array - * @return void */ private function emailStatement($pdf, array $options): void { diff --git a/app/Services/ClientPortal/InstantPayment.php b/app/Services/ClientPortal/InstantPayment.php index a76482273d71..9d0de18ac540 100644 --- a/app/Services/ClientPortal/InstantPayment.php +++ b/app/Services/ClientPortal/InstantPayment.php @@ -52,7 +52,7 @@ class InstantPayment $is_credit_payment = true; } - $gateway = CompanyGateway::find($this->request->input('company_gateway_id')); + $gateway = CompanyGateway::query()->find($this->request->input('company_gateway_id')); /** * find invoices diff --git a/app/Services/Credit/SendEmail.php b/app/Services/Credit/SendEmail.php index 1f01f6ba67f1..40ce3240f438 100644 --- a/app/Services/Credit/SendEmail.php +++ b/app/Services/Credit/SendEmail.php @@ -33,7 +33,6 @@ class SendEmail /** * Builds the correct template to send. - * @return void */ public function run() { diff --git a/app/Services/Invoice/AutoBillInvoice.php b/app/Services/Invoice/AutoBillInvoice.php index f776cbc4af10..0585f888bd66 100644 --- a/app/Services/Invoice/AutoBillInvoice.php +++ b/app/Services/Invoice/AutoBillInvoice.php @@ -194,7 +194,7 @@ class AutoBillInvoice extends AbstractService $current_credit = false; foreach ($this->used_credit as $credit) { - $current_credit = Credit::find($credit['credit_id']); + $current_credit = Credit::query()->find($credit['credit_id']); $payment->credits() ->attach($current_credit->id, ['amount' => $credit['amount']]);