diff --git a/app/Filters/TaskFilters.php b/app/Filters/TaskFilters.php index f0b3a1afc2..3e09a0d2ad 100644 --- a/app/Filters/TaskFilters.php +++ b/app/Filters/TaskFilters.php @@ -56,7 +56,7 @@ class TaskFilters extends QueryFilters * - all * - invoiced * - * @param string client_status The invoice status as seen by the client + * @param string $value The invoice status as seen by the client * @return Builder */ public function client_status(string $value = ''): Builder diff --git a/app/Helpers/Invoice/InvoiceItemSumInclusive.php b/app/Helpers/Invoice/InvoiceItemSumInclusive.php index 264c76ec41..9e792c0d71 100644 --- a/app/Helpers/Invoice/InvoiceItemSumInclusive.php +++ b/app/Helpers/Invoice/InvoiceItemSumInclusive.php @@ -230,7 +230,6 @@ class InvoiceItemSumInclusive $item_tax += $this->formatValue($item_tax_rate1_total, $this->currency->precision); - // if($item_tax_rate1_total != 0) if (strlen($this->item->tax_name1) > 1) { $this->groupTax($this->item->tax_name1, $this->item->tax_rate1, $item_tax_rate1_total); } diff --git a/app/Helpers/Invoice/ProRata.php b/app/Helpers/Invoice/ProRata.php index 92f1000ef5..34e52cc1a2 100644 --- a/app/Helpers/Invoice/ProRata.php +++ b/app/Helpers/Invoice/ProRata.php @@ -111,13 +111,13 @@ class ProRata case RecurringInvoice::FREQUENCY_MONTHLY: return now()->diffInDays(now()->addMonthNoOverflow()); case RecurringInvoice::FREQUENCY_TWO_MONTHS: - return now()->diffInDays(now()->addMonthNoOverflow(2)); + return now()->diffInDays(now()->addMonthsNoOverflow(2)); case RecurringInvoice::FREQUENCY_THREE_MONTHS: - return now()->diffInDays(now()->addMonthNoOverflow(3)); + return now()->diffInDays(now()->addMonthsNoOverflow(3)); case RecurringInvoice::FREQUENCY_FOUR_MONTHS: - return now()->diffInDays(now()->addMonthNoOverflow(4)); + return now()->diffInDays(now()->addMonthsNoOverflow(4)); case RecurringInvoice::FREQUENCY_SIX_MONTHS: - return now()->diffInDays(now()->addMonthNoOverflow(6)); + return now()->diffInDays(now()->addMonthsNoOverflow(6)); case RecurringInvoice::FREQUENCY_ANNUALLY: return now()->diffInDays(now()->addYear()); case RecurringInvoice::FREQUENCY_TWO_YEARS: diff --git a/app/Helpers/Subscription/SubscriptionCalculator.php b/app/Helpers/Subscription/SubscriptionCalculator.php index dd9675bef4..99049bab39 100644 --- a/app/Helpers/Subscription/SubscriptionCalculator.php +++ b/app/Helpers/Subscription/SubscriptionCalculator.php @@ -64,6 +64,7 @@ class SubscriptionCalculator } if ($refund_invoice) { + /** @var \App\Models\Subscription $subscription **/ $subscription = Subscription::find($this->invoice->subscription_id); $pro_rata = new ProRata; diff --git a/app/Http/Controllers/ActivityController.php b/app/Http/Controllers/ActivityController.php index 7f4a7bd7fc..2b377c7f5e 100644 --- a/app/Http/Controllers/ActivityController.php +++ b/app/Http/Controllers/ActivityController.php @@ -58,7 +58,7 @@ class ActivityController extends BaseController $system = ctrans('texts.system'); - $data = $activities->cursor()->map(function ($activity) use ($system) { + $data = $activities->cursor()->map(function ($activity) { return $activity->activity_string(); @@ -90,7 +90,7 @@ class ActivityController extends BaseController $system = ctrans('texts.system'); - $data = $activities->cursor()->map(function ($activity) use ($system) { + $data = $activities->cursor()->map(function ($activity) { return $activity->activity_string(); diff --git a/app/Http/Controllers/Auth/ContactForgotPasswordController.php b/app/Http/Controllers/Auth/ContactForgotPasswordController.php index cda2357312..251d199b0e 100644 --- a/app/Http/Controllers/Auth/ContactForgotPasswordController.php +++ b/app/Http/Controllers/Auth/ContactForgotPasswordController.php @@ -62,11 +62,15 @@ class ContactForgotPasswordController extends Controller if (Ninja::isHosted() && $request->session()->has('company_key')) { MultiDB::findAndSetDbByCompanyKey($request->session()->get('company_key')); + + /** @var \App\Models\Company $company **/ $company = Company::where('company_key', $request->session()->get('company_key'))->first(); $account = $company->account; } if (! $account) { + + /** @var \App\Models\Account $account **/ $account = Account::first(); $company = $account->companies->first(); } diff --git a/app/Models/ClientContact.php b/app/Models/ClientContact.php index 8dc2cf9d41..0116d611b4 100644 --- a/app/Models/ClientContact.php +++ b/app/Models/ClientContact.php @@ -215,7 +215,7 @@ class ClientContact extends Authenticatable implements HasLocalePreference } } - public function client() + public function client(): \Illuminate\Database\Eloquent\Relations\BelongsTo { return $this->belongsTo(Client::class)->withTrashed(); } @@ -225,32 +225,32 @@ class ClientContact extends Authenticatable implements HasLocalePreference return $this->where('is_primary', true); } - public function company() + public function company(): \Illuminate\Database\Eloquent\Relations\BelongsTo { return $this->belongsTo(Company::class); } - public function user() + public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo { return $this->belongsTo(User::class)->withTrashed(); } - public function invoice_invitations() + public function invoice_invitations(): \Illuminate\Database\Eloquent\Relations\HasMany { return $this->hasMany(InvoiceInvitation::class); } - public function recurring_invoice_invitations() + public function recurring_invoice_invitations(): \Illuminate\Database\Eloquent\Relations\HasMany { return $this->hasMany(RecurringInvoiceInvitation::class); } - public function quote_invitations() + public function quote_invitations(): \Illuminate\Database\Eloquent\Relations\HasMany { return $this->hasMany(QuoteInvitation::class); } - public function credit_invitations() + public function credit_invitations(): \Illuminate\Database\Eloquent\Relations\HasMany { return $this->hasMany(CreditInvitation::class); } diff --git a/app/Models/StaticModel.php b/app/Models/StaticModel.php index f6b3a5747f..9165e72652 100644 --- a/app/Models/StaticModel.php +++ b/app/Models/StaticModel.php @@ -22,9 +22,9 @@ use Illuminate\Database\Eloquent\ModelNotFoundException as ModelNotFoundExceptio * @property-read mixed $id * @method static \Illuminate\Database\Eloquent\Builder|StaticModel company() * @method static \Illuminate\Database\Eloquent\Builder|StaticModel exclude($columns) - * @method static \Illuminate\Database\Eloquent\Builder|StaticModel newModelQuery($value) - * @method static \Illuminate\Database\Eloquent\Builder|StaticModel newQuery($value) - * @method static \Illuminate\Database\Eloquent\Builder|StaticModel query(?$value) + * @method static \Illuminate\Database\Eloquent\Builder|StaticModel newModelQuery() + * @method static \Illuminate\Database\Eloquent\Builder|StaticModel newQuery() + * @method static \Illuminate\Database\Eloquent\Builder|StaticModel query() * @method static \Illuminate\Database\Eloquent\Builder|StaticModel find($value) * @method static \Illuminate\Database\Eloquent\Builder|StaticModel with($value) * @method static \Illuminate\Database\Eloquent\Builder|StaticModel withTrashed($value) diff --git a/app/Models/Subscription.php b/app/Models/Subscription.php index 1e2f67ce8c..3798a69433 100644 --- a/app/Models/Subscription.php +++ b/app/Models/Subscription.php @@ -66,41 +66,6 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @method static \Illuminate\Database\Eloquent\Builder|Subscription onlyTrashed() * @method static \Illuminate\Database\Eloquent\Builder|Subscription query() * @method static \Illuminate\Database\Eloquent\Builder|BaseModel scope() - * @method static \Illuminate\Database\Eloquent\Builder|Subscription whereAllowCancellation($value) - * @method static \Illuminate\Database\Eloquent\Builder|Subscription whereAllowPlanChanges($value) - * @method static \Illuminate\Database\Eloquent\Builder|Subscription whereAllowQueryOverrides($value) - * @method static \Illuminate\Database\Eloquent\Builder|Subscription whereAssignedUserId($value) - * @method static \Illuminate\Database\Eloquent\Builder|Subscription whereAutoBill($value) - * @method static \Illuminate\Database\Eloquent\Builder|Subscription whereCompanyId($value) - * @method static \Illuminate\Database\Eloquent\Builder|Subscription whereCreatedAt($value) - * @method static \Illuminate\Database\Eloquent\Builder|Subscription whereCurrencyId($value) - * @method static \Illuminate\Database\Eloquent\Builder|Subscription whereDeletedAt($value) - * @method static \Illuminate\Database\Eloquent\Builder|Subscription whereFrequencyId($value) - * @method static \Illuminate\Database\Eloquent\Builder|Subscription whereGroupId($value) - * @method static \Illuminate\Database\Eloquent\Builder|Subscription whereId($value) - * @method static \Illuminate\Database\Eloquent\Builder|Subscription whereIsAmountDiscount($value) - * @method static \Illuminate\Database\Eloquent\Builder|Subscription whereIsDeleted($value) - * @method static \Illuminate\Database\Eloquent\Builder|Subscription whereMaxSeatsLimit($value) - * @method static \Illuminate\Database\Eloquent\Builder|Subscription whereMinSeatsLimit($value) - * @method static \Illuminate\Database\Eloquent\Builder|Subscription whereName($value) - * @method static \Illuminate\Database\Eloquent\Builder|Subscription whereOptionalProductIds($value) - * @method static \Illuminate\Database\Eloquent\Builder|Subscription whereOptionalRecurringProductIds($value) - * @method static \Illuminate\Database\Eloquent\Builder|Subscription wherePerSeatEnabled($value) - * @method static \Illuminate\Database\Eloquent\Builder|Subscription wherePlanMap($value) - * @method static \Illuminate\Database\Eloquent\Builder|Subscription wherePrice($value) - * @method static \Illuminate\Database\Eloquent\Builder|Subscription whereProductIds($value) - * @method static \Illuminate\Database\Eloquent\Builder|Subscription wherePromoCode($value) - * @method static \Illuminate\Database\Eloquent\Builder|Subscription wherePromoDiscount($value) - * @method static \Illuminate\Database\Eloquent\Builder|Subscription wherePromoPrice($value) - * @method static \Illuminate\Database\Eloquent\Builder|Subscription whereRecurringProductIds($value) - * @method static \Illuminate\Database\Eloquent\Builder|Subscription whereRefundPeriod($value) - * @method static \Illuminate\Database\Eloquent\Builder|Subscription whereRegistrationRequired($value) - * @method static \Illuminate\Database\Eloquent\Builder|Subscription whereTrialDuration($value) - * @method static \Illuminate\Database\Eloquent\Builder|Subscription whereTrialEnabled($value) - * @method static \Illuminate\Database\Eloquent\Builder|Subscription whereUpdatedAt($value) - * @method static \Illuminate\Database\Eloquent\Builder|Subscription whereUseInventoryManagement($value) - * @method static \Illuminate\Database\Eloquent\Builder|Subscription whereUserId($value) - * @method static \Illuminate\Database\Eloquent\Builder|Subscription whereWebhookConfiguration($value) * @method static \Illuminate\Database\Eloquent\Builder|Subscription withTrashed() * @method static \Illuminate\Database\Eloquent\Builder|Subscription withoutTrashed() * @mixin \Eloquent diff --git a/app/PaymentDrivers/Sample/CreditCard.php b/app/PaymentDrivers/Sample/CreditCard.php index 2165a56d83..b8813769aa 100644 --- a/app/PaymentDrivers/Sample/CreditCard.php +++ b/app/PaymentDrivers/Sample/CreditCard.php @@ -69,7 +69,9 @@ class CreditCard // $error .= " - {$response->approval_message}"; // $error_code = property_exists($response, 'approval_message') ? $response->approval_message : 'Undefined code'; - + $error = ''; + $error_code = ''; + $data = [ 'response' => $response, 'error' => $error, diff --git a/app/PaymentDrivers/Square/CreditCard.php b/app/PaymentDrivers/Square/CreditCard.php index 1cec62101c..f3589b9833 100644 --- a/app/PaymentDrivers/Square/CreditCard.php +++ b/app/PaymentDrivers/Square/CreditCard.php @@ -100,6 +100,7 @@ class CreditCard implements MethodInterface ); if ($request->shouldUseToken()) { + /** @var \App\Models\ClientGatewayToken $cgt **/ $cgt = ClientGatewayToken::where('token', $request->token)->first(); $token = $cgt->token; } diff --git a/app/PaymentDrivers/Stripe/Jobs/PaymentIntentProcessingWebhook.php b/app/PaymentDrivers/Stripe/Jobs/PaymentIntentProcessingWebhook.php index 28f3b92c5d..ed34fdf940 100644 --- a/app/PaymentDrivers/Stripe/Jobs/PaymentIntentProcessingWebhook.php +++ b/app/PaymentDrivers/Stripe/Jobs/PaymentIntentProcessingWebhook.php @@ -61,11 +61,13 @@ class PaymentIntentProcessingWebhook implements ShouldQueue foreach ($this->stripe_request as $transaction) { if (array_key_exists('payment_intent', $transaction)) { + /** @var \App\Models\Payment $payment **/ $payment = Payment::query() ->where('company_id', $company->id) ->where('transaction_reference', $transaction['payment_intent']) ->first(); } else { + /** @var \App\Models\Payment $payment **/ $payment = Payment::query() ->where('company_id', $company->id) ->where('transaction_reference', $transaction['id']) @@ -80,6 +82,7 @@ class PaymentIntentProcessingWebhook implements ShouldQueue } if (isset($transaction['payment_method'])) { + /** @var \App\Models\ClientGatewayToken $cgt **/ $cgt = ClientGatewayToken::where('token', $transaction['payment_method'])->first(); if ($cgt && $cgt->meta?->state == 'unauthorized') { @@ -94,7 +97,7 @@ class PaymentIntentProcessingWebhook implements ShouldQueue if ($this->payment_completed) { return; } - + /** @var \App\Models\CompanyGateway $company_gateway **/ $company_gateway = CompanyGateway::find($this->company_gateway_id); $stripe_driver = $company_gateway->driver()->init(); @@ -123,8 +126,10 @@ class PaymentIntentProcessingWebhook implements ShouldQueue return; } + /** @var \App\Models\Company $company **/ $company = Company::where('company_key', $this->company_key)->first(); - + + /** @var \App\Models\Payment $payment **/ $payment = Payment::query() ->where('company_id', $company->id) ->where('transaction_reference', $charge['id']) diff --git a/app/PaymentDrivers/Stripe/Jobs/PaymentIntentWebhook.php b/app/PaymentDrivers/Stripe/Jobs/PaymentIntentWebhook.php index 70417665ae..b476db2fea 100644 --- a/app/PaymentDrivers/Stripe/Jobs/PaymentIntentWebhook.php +++ b/app/PaymentDrivers/Stripe/Jobs/PaymentIntentWebhook.php @@ -113,8 +113,10 @@ class PaymentIntentWebhook implements ShouldQueue return; } + /** @var \App\Models\Company $company **/ $company = Company::where('company_key', $this->company_key)->first(); + /** @var \App\Models\Payment $payment **/ $payment = Payment::query() ->where('company_id', $company->id) ->where('transaction_reference', $charge['id']) diff --git a/app/PaymentDrivers/Stripe/Jobs/StripeWebhook.php b/app/PaymentDrivers/Stripe/Jobs/StripeWebhook.php index 3dfc94805e..9424d76d91 100644 --- a/app/PaymentDrivers/Stripe/Jobs/StripeWebhook.php +++ b/app/PaymentDrivers/Stripe/Jobs/StripeWebhook.php @@ -58,6 +58,7 @@ class StripeWebhook implements ShouldQueue $company = Company::where('company_key', $this->company_key)->first(); + /** @var \App\Models\CompanyGateway $company_gateway **/ $company_gateway = CompanyGateway::find($this->company_gateway_id); $stripe = $company_gateway->driver()->init(); diff --git a/app/PaymentDrivers/Stripe/Jobs/UpdateCustomer.php b/app/PaymentDrivers/Stripe/Jobs/UpdateCustomer.php index af6e9d4906..f274db47c6 100644 --- a/app/PaymentDrivers/Stripe/Jobs/UpdateCustomer.php +++ b/app/PaymentDrivers/Stripe/Jobs/UpdateCustomer.php @@ -49,6 +49,7 @@ class UpdateCustomer implements ShouldQueue $company = Company::where('company_key', $this->company_key)->first(); + /** @var \App\Models\CompanyGateway $company_gateway **/ $company_gateway = CompanyGateway::find($this->company_gateway_id); $client = Client::withTrashed()->find($this->client_id); diff --git a/phpstan.neon b/phpstan.neon index 8cd766f92d..2b60d7d202 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -9,6 +9,7 @@ parameters: - 'app/Jobs/Ninja/*' - 'app/Console/Commands/*' - 'app/DataMapper/Analytics/*' + - 'app/PaymentDrivers/Authorize/*' universalObjectCratesClasses: - App\DataMapper\Tax\RuleInterface - App\DataMapper\FeesAndLimits