Static analysis cleanup

This commit is contained in:
David Bomba 2023-08-01 23:01:48 +10:00
parent 908161eae7
commit 82784582f0
8 changed files with 61 additions and 81 deletions

View File

@ -81,7 +81,7 @@ class RefundPaymentRequest extends Request
return $rules; return $rules;
} }
public function payment() :?Payment public function payment(): ?\App\Models\Payment
{ {
$input = $this->all(); $input = $this->all();

View File

@ -46,6 +46,7 @@ class ValidRefundableRequest implements Rule
return false; return false;
} }
/**@var \App\Models\Payment $payment */
$payment = Payment::whereId($this->input['id'])->withTrashed()->first(); $payment = Payment::whereId($this->input['id'])->withTrashed()->first();
if (! $payment) { if (! $payment) {
@ -76,6 +77,7 @@ class ValidRefundableRequest implements Rule
private function checkInvoiceIsPaymentable($invoice, $payment) private function checkInvoiceIsPaymentable($invoice, $payment)
{ {
/**@var \App\Models\Invoice $invoice */
$invoice = Invoice::whereId($invoice['invoice_id'])->whereCompanyId($payment->company_id)->withTrashed()->first(); $invoice = Invoice::whereId($invoice['invoice_id'])->whereCompanyId($payment->company_id)->withTrashed()->first();
if (! $invoice) { if (! $invoice) {
@ -99,24 +101,25 @@ class ValidRefundableRequest implements Rule
} }
} }
private function checkCreditIsPaymentable($credit, $payment) // private function checkCreditIsPaymentable($credit, $payment)
{ // {
$credit = Credit::whereId($credit['credit_id'])->whereCompanyId($payment->company_id)->first(); // /** @var \App\Models\Credit $credit */
// $credit = Credit::whereId($credit['credit_id'])->whereCompanyId($payment->company_id)->first();
if ($payment->credits()->exists()) { // if ($payment->credits()->exists()) {
$paymentable_credit = $payment->credits->where('id', $credit->id)->first(); // $paymentable_credit = $payment->credits->where('id', $credit->id)->first();
if (! $paymentable_credit) { // if (! $paymentable_credit) {
$this->error_msg = ctrans('texts.credit_not_related_to_payment', ['credit' => $credit->hashed_id]); // $this->error_msg = ctrans('texts.credit_not_related_to_payment', ['credit' => $credit->hashed_id]);
return false; // return false;
} // }
} else { // } else {
$this->error_msg = ctrans('texts.credit_not_related_to_payment', ['credit' => $credit->hashed_id]); // $this->error_msg = ctrans('texts.credit_not_related_to_payment', ['credit' => $credit->hashed_id]);
return false; // return false;
} // }
} // }
private function checkInvoice($paymentable, $request_invoices) private function checkInvoice($paymentable, $request_invoices)
{ {
@ -145,32 +148,32 @@ class ValidRefundableRequest implements Rule
} }
} }
private function checkCredit($paymentable, $request_credits) // private function checkCredit($paymentable, $request_credits)
{ // {
$record_found = null; // $record_found = null;
foreach ($request_credits as $request_credit) { // foreach ($request_credits as $request_credit) {
if ($request_credit['credit_id'] == $paymentable->pivot->paymentable_id) { // if ($request_credit['credit_id'] == $paymentable->pivot->paymentable_id) {
$record_found = true; // $record_found = true;
$refundable_amount = ($paymentable->pivot->amount - $paymentable->pivot->refunded); // $refundable_amount = ($paymentable->pivot->amount - $paymentable->pivot->refunded);
if ($request_credit['amount'] > $refundable_amount) { // if ($request_credit['amount'] > $refundable_amount) {
$credit = $paymentable; // $credit = $paymentable;
$this->error_msg = ctrans('texts.max_refundable_credit', ['credit' => $credit->hashed_id, 'amount' => $refundable_amount]); // $this->error_msg = ctrans('texts.max_refundable_credit', ['credit' => $credit->hashed_id, 'amount' => $refundable_amount]);
return false; // return false;
} // }
} // }
} // }
if (! $record_found) { // if (! $record_found) {
$this->error_msg = ctrans('texts.refund_without_credits'); // $this->error_msg = ctrans('texts.refund_without_credits');
return false; // return false;
} // }
} // }
/** /**
* @return string * @return string

View File

@ -45,7 +45,7 @@ class ValidRefundableInvoices implements Rule
return false; return false;
} }
/**@var \App\Models\Payment $payment */ /**@var \App\Models\Payment $payment **/
$payment = Payment::whereId($this->input['id'])->first(); $payment = Payment::whereId($this->input['id'])->first();
if (! $payment) { if (! $payment) {

View File

@ -35,32 +35,30 @@ use Illuminate\Database\Eloquent\ModelNotFoundException as ModelNotFoundExceptio
* @property \App\Models\Company $company * @property \App\Models\Company $company
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel|Illuminate\Database\Eloquent\Relations\BelongsTo|\Awobaz\Compoships\Database\Eloquent\Relations\BelongsTo|\App\Models\Company company() * @method static \Illuminate\Database\Eloquent\Builder|BaseModel|Illuminate\Database\Eloquent\Relations\BelongsTo|\Awobaz\Compoships\Database\Eloquent\Relations\BelongsTo|\App\Models\Company company()
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel|Illuminate\Database\Eloquent\Relations\HasMany|BaseModel orderBy() * @method static \Illuminate\Database\Eloquent\Builder|BaseModel|Illuminate\Database\Eloquent\Relations\HasMany|BaseModel orderBy()
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel exclude($columns) * @method static \Illuminate\Database\Eloquent\Builder exclude($columns)
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel with($value) * @method static \Illuminate\Database\Eloquent\Builder company()
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel newModelQuery($query) * @method static \Illuminate\Database\Eloquent\Builder with($value)
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel newQuery($query) * @method static \Illuminate\Database\Eloquent\Builder newModelQuery($query)
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel query() * @method static \Illuminate\Database\Eloquent\Builder newQuery($query)
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel exclude(array $excludeable) * @method static \Illuminate\Database\Eloquent\Builder query()
* @method static \Illuminate\Database\Eloquent\Builder exclude(array $excludeable)
* @method static \Illuminate\Database\Eloquent\Builder withTrashed() * @method static \Illuminate\Database\Eloquent\Builder withTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel scopeExclude($query) * @method static \Illuminate\Database\Eloquent\Builder scopeExclude($query)
* @method static BaseModel find($value) * @method static BaseModel find($value)
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel whereIn($query) * @method static \Illuminate\Database\Eloquent\Builder whereIn($query)
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel where($query) * @method static \Illuminate\Database\Eloquent\Builder where($query)
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel count() * @method static \Illuminate\Database\Eloquent\Builder count()
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel create($query) * @method static \Illuminate\Database\Eloquent\Builder create($query)
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel insert($query) * @method static \Illuminate\Database\Eloquent\Builder insert($query)
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel service() * @method static \Illuminate\Database\Eloquent\Builder service()
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel orderBy($column, $direction) * @method static \Illuminate\Database\Eloquent\Builder orderBy($column, $direction)
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel invitations() * @method static \Illuminate\Database\Eloquent\Builder invitations()
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel whereHas($query) * @method static \Illuminate\Database\Eloquent\Builder whereHas($query)
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\InvoiceInvitation | \App\Models\CreditInvitation | \App\Models\QuoteInvitation | \App\Models\RecurringInvoiceInvitation> $invitations * @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\InvoiceInvitation | \App\Models\CreditInvitation | \App\Models\QuoteInvitation | \App\Models\RecurringInvoiceInvitation> $invitations
* @property-read int|null $invitations_count * @property-read int|null $invitations_count
* *
* @method \App\Models\Company company()
* @method int companyId() * @method int companyId()
* @method createInvitations() * @method createInvitations()
* @method Builder|static exclude($columns)
* @method static \Illuminate\Database\Eloquent\Builder exclude(array $columns)
* @mixin \Eloquent * @mixin \Eloquent
* @mixin \Illuminate\Database\Eloquent\Builder * @mixin \Illuminate\Database\Eloquent\Builder
*/ */

View File

@ -552,6 +552,7 @@ class Client extends BaseModel implements HasLocalePreference
foreach ($pms as $pm) { foreach ($pms as $pm) {
if ($pm['gateway_type_id'] == GatewayType::CREDIT_CARD) { if ($pm['gateway_type_id'] == GatewayType::CREDIT_CARD) {
/**@var \App\Models\CompanyGateway $cg */
$cg = CompanyGateway::find($pm['company_gateway_id']); $cg = CompanyGateway::find($pm['company_gateway_id']);
if ($cg && ! property_exists($cg->fees_and_limits, strval(GatewayType::CREDIT_CARD))) { if ($cg && ! property_exists($cg->fees_and_limits, strval(GatewayType::CREDIT_CARD))) {

View File

@ -28,8 +28,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @property bool $update_details * @property bool $update_details
* @property bool $is_deleted * @property bool $is_deleted
* @property string $config * @property string $config
* @property mixed $fees_and_limits * @property object $fees_and_limits
* @property-write mixed $fees_and_limits
* @property string|null $custom_value1 * @property string|null $custom_value1
* @property string|null $custom_value2 * @property string|null $custom_value2
* @property string|null $custom_value3 * @property string|null $custom_value3

View File

@ -122,17 +122,6 @@ use App\Events\Invoice\InvoiceReminderWasEmailed;
* @property-read int|null $tasks_count * @property-read int|null $tasks_count
* @property-read \App\Models\User $user * @property-read \App\Models\User $user
* @property-read \App\Models\Vendor|null $vendor * @property-read \App\Models\Vendor|null $vendor
* @method static \Illuminate\Database\Eloquent\Builder company()
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel exclude($columns)
* @method static \Database\Factories\InvoiceFactory factory($count = null, $state = [])
* @method static \Illuminate\Database\Eloquent\Builder|Invoice filter(\App\Filters\QueryFilters $filters)
* @method static \Illuminate\Database\Eloquent\Builder|Invoice newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|Invoice newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|Invoice onlyTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|Invoice query()
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel scope()
* @method static \Illuminate\Database\Eloquent\Builder|Invoice withTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|Invoice withoutTrashed()
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Activity> $activities * @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Activity> $activities
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\CompanyLedger> $company_ledger * @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\CompanyLedger> $company_ledger
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Credit> $credits * @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Credit> $credits

View File

@ -56,6 +56,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @property float $exchange_rate * @property float $exchange_rate
* @property int $currency_id * @property int $currency_id
* @property int|null $exchange_currency_id * @property int|null $exchange_currency_id
* @property \App\Models\Paymentable $paymentables
* @property object|null $meta * @property object|null $meta
* @property string|null $custom_value1 * @property string|null $custom_value1
* @property string|null $custom_value2 * @property string|null $custom_value2
@ -67,27 +68,17 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @property-read \App\Models\Client $client * @property-read \App\Models\Client $client
* @property-read \App\Models\Company $company * @property-read \App\Models\Company $company
* @property-read \App\Models\CompanyGateway|null $company_gateway * @property-read \App\Models\CompanyGateway|null $company_gateway
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\CompanyLedger> $company_ledger
* @property-read int|null $company_ledger_count
* @property-read \App\Models\ClientContact|null $contact * @property-read \App\Models\ClientContact|null $contact
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Credit> $credits
* @property-read int|null $credits_count
* @property-read \App\Models\Currency|null $currency * @property-read \App\Models\Currency|null $currency
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Document> $documents
* @property-read int|null $documents_count
* @property-read \App\Models\Currency|null $exchange_currency * @property-read \App\Models\Currency|null $exchange_currency
* @property-read \App\Models\GatewayType|null $gateway_type * @property-read \App\Models\GatewayType|null $gateway_type
* @property-read mixed $hashed_id * @property-read mixed $hashed_id
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Invoice> $invoices
* @property-read int|null $invoices_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Paymentable> $paymentables
* @property-read int|null $paymentables_count
* @property-read \App\Models\Project|null $project * @property-read \App\Models\Project|null $project
* @property-read \App\Models\PaymentType|null $type * @property-read \App\Models\PaymentType|null $type
* @property-read \App\Models\User|null $user * @property-read \App\Models\User|null $user
* @property-read \App\Models\Vendor|null $vendor * @property-read \App\Models\Vendor|null $vendor
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel company() * @method static \Illuminate\Database\Eloquent\Builder company()
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel exclude($columns) * @method static \Illuminate\Database\Eloquent\Builder exclude($columns)
* @method static \Database\Factories\PaymentFactory factory($count = null, $state = []) * @method static \Database\Factories\PaymentFactory factory($count = null, $state = [])
* @method static \Illuminate\Database\Eloquent\Builder|Payment filter(\App\Filters\QueryFilters $filters) * @method static \Illuminate\Database\Eloquent\Builder|Payment filter(\App\Filters\QueryFilters $filters)
* @method static \Illuminate\Database\Eloquent\Builder|Payment newModelQuery() * @method static \Illuminate\Database\Eloquent\Builder|Payment newModelQuery()
@ -95,7 +86,6 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @method static \Illuminate\Database\Eloquent\Builder|Payment onlyTrashed() * @method static \Illuminate\Database\Eloquent\Builder|Payment onlyTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|Payment query() * @method static \Illuminate\Database\Eloquent\Builder|Payment query()
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel scope() * @method static \Illuminate\Database\Eloquent\Builder|BaseModel scope()
* @method static \Illuminate\Database\Eloquent\Builder|Payment withTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|Payment withoutTrashed() * @method static \Illuminate\Database\Eloquent\Builder|Payment withoutTrashed()
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\CompanyLedger> $company_ledger * @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\CompanyLedger> $company_ledger
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Credit> $credits * @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Credit> $credits
@ -288,7 +278,7 @@ class Payment extends BaseModel
return $this->belongsTo(GatewayType::class); return $this->belongsTo(GatewayType::class);
} }
public function paymentables() public function paymentables(): \Illuminate\Database\Eloquent\Relations\HasMany
{ {
return $this->hasMany(Paymentable::class); return $this->hasMany(Paymentable::class);
} }