Static Analysis Cleanup

This commit is contained in:
David Bomba 2023-08-08 19:44:52 +10:00
parent f1ab55ec0f
commit 6e64a9c74a
18 changed files with 60 additions and 42 deletions

View File

@ -155,7 +155,7 @@ class BillingPortalPurchase extends Component
public $request_data; public $request_data;
/** /**
* @var string * @var float
*/ */
public $price; public $price;

View File

@ -400,7 +400,7 @@ class MatchBankTransactions implements ShouldQueue
$category = $this->categories->firstWhere('highLevelCategoryId', $this->bt->category_id); $category = $this->categories->firstWhere('highLevelCategoryId', $this->bt->category_id);
$ec = ExpenseCategory::where('company_id', $this->bt->company_id)->where('bank_category_id', $this->bt->category_id)->first(); $ec = ExpenseCategory::query()->where('company_id', $this->bt->company_id)->where('bank_category_id', $this->bt->category_id)->first();
if ($ec) { if ($ec) {
return $ec->id; return $ec->id;

View File

@ -167,17 +167,17 @@ class CompanyGateway extends BaseModel
->take(50); ->take(50);
} }
public function company() public function company(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{ {
return $this->belongsTo(Company::class); return $this->belongsTo(Company::class);
} }
public function client_gateway_tokens() public function client_gateway_tokens(): \Illuminate\Database\Eloquent\Relations\HasMany
{ {
return $this->hasMany(ClientGatewayToken::class); return $this->hasMany(ClientGatewayToken::class);
} }
public function gateway() public function gateway(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{ {
return $this->belongsTo(Gateway::class, 'gateway_key', 'key'); return $this->belongsTo(Gateway::class, 'gateway_key', 'key');
} }

View File

@ -50,12 +50,12 @@ use Illuminate\Support\Facades\Storage;
* @property string|null $private_notes * @property string|null $private_notes
* @property string|null $terms * @property string|null $terms
* @property string|null $tax_name1 * @property string|null $tax_name1
* @property string $tax_rate1 * @property float $tax_rate1
* @property string|null $tax_name2 * @property string|null $tax_name2
* @property string $tax_rate2 * @property float $tax_rate2
* @property string|null $tax_name3 * @property string|null $tax_name3
* @property string $tax_rate3 * @property float $tax_rate3
* @property string $total_taxes * @property float $total_taxes
* @property int $uses_inclusive_taxes * @property int $uses_inclusive_taxes
* @property string|null $reminder1_sent * @property string|null $reminder1_sent
* @property string|null $reminder2_sent * @property string|null $reminder2_sent
@ -74,11 +74,11 @@ use Illuminate\Support\Facades\Storage;
* @property int $custom_surcharge_tax2 * @property int $custom_surcharge_tax2
* @property int $custom_surcharge_tax3 * @property int $custom_surcharge_tax3
* @property int $custom_surcharge_tax4 * @property int $custom_surcharge_tax4
* @property string $exchange_rate * @property float $exchange_rate
* @property string $balance * @property float $balance
* @property float|null $partial * @property float|null $partial
* @property string $amount * @property float $amount
* @property string $paid_to_date * @property float $paid_to_date
* @property string|null $partial_due_date * @property string|null $partial_due_date
* @property string|null $last_viewed * @property string|null $last_viewed
* @property int|null $deleted_at * @property int|null $deleted_at

View File

@ -47,8 +47,8 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @property string|null $recurring_product_ids * @property string|null $recurring_product_ids
* @property string $name * @property string $name
* @property int|null $group_id * @property int|null $group_id
* @property string $price * @property float $price
* @property string $promo_price * @property float $promo_price
* @property int $registration_required * @property int $registration_required
* @property int $use_inventory_management * @property int $use_inventory_management
* @property string|null $optional_product_ids * @property string|null $optional_product_ids
@ -68,6 +68,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel scope() * @method static \Illuminate\Database\Eloquent\Builder|BaseModel scope()
* @method static \Illuminate\Database\Eloquent\Builder|Subscription withTrashed() * @method static \Illuminate\Database\Eloquent\Builder|Subscription withTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|Subscription withoutTrashed() * @method static \Illuminate\Database\Eloquent\Builder|Subscription withoutTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|Subscription with($value)
* @mixin \Eloquent * @mixin \Eloquent
*/ */
class Subscription extends BaseModel class Subscription extends BaseModel

View File

@ -201,7 +201,7 @@ class ACH
public function paymentResponse($request) public function paymentResponse($request)
{ {
$token = ClientGatewayToken::find($this->decodePrimaryKey($request->input('source'))); $token = ClientGatewayToken::query()->find($this->decodePrimaryKey($request->input('source')));
$token_meta = $token->meta; $token_meta = $token->meta;
if (! property_exists($token_meta, 'state') || $token_meta->state != 'authorized') { if (! property_exists($token_meta, 'state') || $token_meta->state != 'authorized') {

View File

@ -137,7 +137,7 @@ class UserRepository extends BaseRepository
$cu->forceDelete(); $cu->forceDelete();
} }
event(new UserWasDeleted($user, auth()->user(), $company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null))); event(new UserWasDeleted($user, auth()->user(), auth()->user()->company(), Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
$user->delete(); $user->delete();

View File

@ -33,6 +33,9 @@ class ProcessBankRules extends AbstractService
protected $invoices; protected $invoices;
/**
* @param \App\Models\BankTransaction $bank_transaction
*/
public function __construct(public BankTransaction $bank_transaction) public function __construct(public BankTransaction $bank_transaction)
{ {
} }
@ -48,14 +51,12 @@ class ProcessBankRules extends AbstractService
private function matchCredit() private function matchCredit()
{ {
/** @var \Illuminate\Database\Eloquent\Collection<Invoice> $this->invoices */
$this->invoices = Invoice::query()->where('company_id', $this->bank_transaction->company_id) $this->invoices = Invoice::query()->where('company_id', $this->bank_transaction->company_id)
->whereIn('status_id', [1,2,3]) ->whereIn('status_id', [1,2,3])
->where('is_deleted', 0) ->where('is_deleted', 0)
->get(); ->get();
$invoice = $this->invoices->first(function ($value, $key) { $invoice = $this->invoices->first(function ($value, $key) {
/** @var \App\Models\Invoice $value */
return str_contains($this->bank_transaction->description, $value->number); return str_contains($this->bank_transaction->description, $value->number);
}); });

View File

@ -25,6 +25,7 @@ class PaymentMethod
private $amount; private $amount;
/** @var \Illuminate\Support\Collection<CompanyGateway> $gateways */
private $gateways; private $gateways;
private $payment_methods; private $payment_methods;
@ -78,7 +79,8 @@ class PaymentMethod
return array_search($model->id, $transformed_ids); // this closure sorts for us return array_search($model->id, $transformed_ids); // this closure sorts for us
}); });
} else { } else {
$this->gateways = CompanyGateway::with('gateway') $this->gateways = CompanyGateway::query()
->with('gateway')
->where('company_id', $this->client->company_id) ->where('company_id', $this->client->company_id)
->where('gateway_key', '!=', '54faab2ab6e3223dbe848b1686490baa') ->where('gateway_key', '!=', '54faab2ab6e3223dbe848b1686490baa')
->whereNull('deleted_at') ->whereNull('deleted_at')
@ -112,7 +114,8 @@ class PaymentMethod
return array_search($model->id, $transformed_ids); // this closure sorts for us return array_search($model->id, $transformed_ids); // this closure sorts for us
}); });
} else { } else {
$this->gateways = CompanyGateway::with('gateway') $this->gateways = CompanyGateway::query()
->with('gateway')
->where('company_id', $this->client->company_id) ->where('company_id', $this->client->company_id)
->where('gateway_key', '54faab2ab6e3223dbe848b1686490baa') ->where('gateway_key', '54faab2ab6e3223dbe848b1686490baa')
->whereNull('deleted_at') ->whereNull('deleted_at')
@ -171,7 +174,7 @@ class PaymentMethod
{ {
foreach ($this->payment_methods as $key => $child_array) { foreach ($this->payment_methods as $key => $child_array) {
foreach ($child_array as $gateway_id => $gateway_type_id) { foreach ($child_array as $gateway_id => $gateway_type_id) {
$gateway = CompanyGateway::find($gateway_id); $gateway = CompanyGateway::query()->find($gateway_id);
$fee_label = $gateway->calcGatewayFeeLabel($this->amount, $this->client, $gateway_type_id); $fee_label = $gateway->calcGatewayFeeLabel($this->amount, $this->client, $gateway_type_id);

View File

@ -100,7 +100,7 @@ class InstantPayment
* Determine the payable amount and the max payable. ie either partial or invoice balance * Determine the payable amount and the max payable. ie either partial or invoice balance
*/ */
$payable_amount = Number::roundValue(Number::parseFloat($payable_invoice['amount'], $client->currency()->precision)); $payable_amount = Number::roundValue(Number::parseFloat($payable_invoice['amount']), $client->currency()->precision);
$invoice_balance = Number::roundValue(($invoice->partial > 0 ? $invoice->partial : $invoice->balance), $client->currency()->precision); $invoice_balance = Number::roundValue(($invoice->partial > 0 ? $invoice->partial : $invoice->balance), $client->currency()->precision);
@ -155,7 +155,7 @@ class InstantPayment
return $payable_invoice['invoice_id'] == $inv->hashed_id; return $payable_invoice['invoice_id'] == $inv->hashed_id;
}); });
$payable_amount = Number::roundValue(Number::parseFloat($payable_invoice['amount'], $client->currency()->precision)); $payable_amount = Number::roundValue(Number::parseFloat($payable_invoice['amount']), $client->currency()->precision);
$invoice_balance = Number::roundValue($invoice->balance, $client->currency()->precision); $invoice_balance = Number::roundValue($invoice->balance, $client->currency()->precision);
$payable_invoice['due_date'] = $this->formatDate($invoice->due_date, $invoice->client->date_format()); $payable_invoice['due_date'] = $this->formatDate($invoice->due_date, $invoice->client->date_format());

View File

@ -302,6 +302,7 @@ class FacturaEInvoice extends AbstractService
private function resolvePaymentMethod(\App\Models\Payment $payment): array private function resolvePaymentMethod(\App\Models\Payment $payment): array
{ {
$data = []; $data = [];
$method = FacturaePayment::TYPE_CARD;
match($payment->type_id){ match($payment->type_id){
PaymentType::BANK_TRANSFER => $method = FacturaePayment::TYPE_TRANSFER , PaymentType::BANK_TRANSFER => $method = FacturaePayment::TYPE_TRANSFER ,

View File

@ -42,7 +42,8 @@ class StubBuilder
public $entity_type; public $entity_type;
public \App\Models\Client | \App\Models\Vendor $recipient; /** @var Client | Vendor $recipient **/
public Client | Vendor $recipient;
public mixed $contact; public mixed $contact;
@ -178,7 +179,7 @@ class StubBuilder
$design_string = "{$this->entity_type}_design_id"; $design_string = "{$this->entity_type}_design_id";
$design = DesignModel::withTrashed()->find($this->decodePrimaryKey($html->settings->{$design_string})); $design = DesignModel::query()->withTrashed()->find($this->decodePrimaryKey($html->settings->{$design_string}));
$template = new PdfMakerDesign(strtolower($design->name)); $template = new PdfMakerDesign(strtolower($design->name));

View File

@ -293,7 +293,7 @@ class ProfitLoss
foreach ($payment->paymentables as $pivot) { foreach ($payment->paymentables as $pivot) {
if ($pivot->paymentable_type == 'invoices') { if ($pivot->paymentable_type == 'invoices') {
$invoice = Invoice::withTrashed()->find($pivot->paymentable_id); $invoice = Invoice::query()->withTrashed()->find($pivot->paymentable_id);
$amount_payment_paid += $pivot->amount - $pivot->refunded; $amount_payment_paid += $pivot->amount - $pivot->refunded;
$amount_payment_paid_converted += $amount_payment_paid / ($payment->exchange_rate ?: 1); $amount_payment_paid_converted += $amount_payment_paid / ($payment->exchange_rate ?: 1);

View File

@ -213,7 +213,7 @@ class SubscriptionService
$email_object->body = ctrans('texts.white_label_body', ['license_key' => $license_key]); $email_object->body = ctrans('texts.white_label_body', ['license_key' => $license_key]);
$email_object->client_id = $invoice->client_id; $email_object->client_id = $invoice->client_id;
$email_object->client_contact_id = $contact->id; $email_object->client_contact_id = $contact->id;
$email_object->invitation_key = $invitation->invitation_key; $email_object->invitation_key = $invitation->key;
$email_object->invitation_id = $invitation->id; $email_object->invitation_id = $invitation->id;
$email_object->entity_id = $invoice->id; $email_object->entity_id = $invoice->id;
$email_object->entity_class = Invoice::class; $email_object->entity_class = Invoice::class;
@ -676,7 +676,7 @@ class SubscriptionService
$pro_rata_refund_amount = $this->calculateProRataRefund($last_invoice, $old_subscription); $pro_rata_refund_amount = $this->calculateProRataRefund($last_invoice, $old_subscription);
} elseif ($last_invoice->balance > 0) { } elseif ($last_invoice->balance > 0) {
$pro_rata_charge_amount = $this->calculateProRataCharge($last_invoice, $old_subscription); $pro_rata_charge_amount = $this->calculateProRataCharge($last_invoice);
nlog("pro rata charge = {$pro_rata_charge_amount}"); nlog("pro rata charge = {$pro_rata_charge_amount}");
} else { } else {
$pro_rata_refund_amount = $this->calculateProRataRefund($last_invoice, $old_subscription) * -1; $pro_rata_refund_amount = $this->calculateProRataRefund($last_invoice, $old_subscription) * -1;
@ -740,7 +740,7 @@ class SubscriptionService
} }
if ($last_invoice->balance > 0) { if ($last_invoice->balance > 0) {
$pro_rata_charge_amount = $this->calculateProRataCharge($last_invoice, $old_subscription); $pro_rata_charge_amount = $this->calculateProRataCharge($last_invoice);
nlog("pro rata charge = {$pro_rata_charge_amount}"); nlog("pro rata charge = {$pro_rata_charge_amount}");
} else { } else {
$pro_rata_refund_amount = $this->calculateProRataRefund($last_invoice, $old_subscription) * -1; $pro_rata_refund_amount = $this->calculateProRataRefund($last_invoice, $old_subscription) * -1;
@ -807,7 +807,7 @@ class SubscriptionService
{ {
nlog("handle plan change"); nlog("handle plan change");
$old_recurring_invoice = RecurringInvoice::find($this->decodePrimaryKey($payment_hash->data->billing_context->recurring_invoice)); $old_recurring_invoice = RecurringInvoice::query()->find($this->decodePrimaryKey($payment_hash->data->billing_context->recurring_invoice));
if (!$old_recurring_invoice) { if (!$old_recurring_invoice) {
return $this->handleRedirect('/client/recurring_invoices/'); return $this->handleRedirect('/client/recurring_invoices/');
@ -816,7 +816,7 @@ class SubscriptionService
$recurring_invoice = $this->createNewRecurringInvoice($old_recurring_invoice); $recurring_invoice = $this->createNewRecurringInvoice($old_recurring_invoice);
//update the invoice and attach to the recurring invoice!!!!! //update the invoice and attach to the recurring invoice!!!!!
$invoice = Invoice::find($payment_hash->fee_invoice_id); $invoice = Invoice::query()->find($payment_hash->fee_invoice_id);
$invoice->recurring_id = $recurring_invoice->id; $invoice->recurring_id = $recurring_invoice->id;
$invoice->is_proforma = false; $invoice->is_proforma = false;
$invoice->save(); $invoice->save();
@ -1243,7 +1243,7 @@ class SubscriptionService
/** /**
* Get available upgrades & downgrades for the plan. * Get available upgrades & downgrades for the plan.
* *
* @return \Illuminate\Database\Eloquent\Builder[]|\Illuminate\Database\Eloquent\Collection * @return \Illuminate\Database\Eloquent\Collection
*/ */
public function getPlans() public function getPlans()
{ {

View File

@ -11,16 +11,24 @@
namespace App\Transformers; namespace App\Transformers;
use App\Models\Activity;
use App\Models\Backup;
use App\Models\ClientContact;
use App\Models\Invoice;
use App\Models\PurchaseOrder;
use App\Models\Task; use App\Models\Task;
use App\Models\User; use App\Models\User;
use App\Models\Quote;
use App\Models\Backup;
use App\Models\Client;
use App\Models\Credit;
use App\Models\Vendor; use App\Models\Vendor;
use App\Models\Expense;
use App\Models\Invoice;
use App\Models\Payment;
use App\Models\Activity;
use App\Models\ClientContact;
use App\Models\PurchaseOrder;
use App\Models\VendorContact; use App\Models\VendorContact;
use App\Utils\Traits\MakesHash; use App\Utils\Traits\MakesHash;
use App\Models\RecurringInvoice;
use App\Transformers\EntityTransformer;
use App\Transformers\InvoiceHistoryTransformer;
class ActivityTransformer extends EntityTransformer class ActivityTransformer extends EntityTransformer
{ {

View File

@ -14,6 +14,7 @@ namespace App\Transformers;
use App\Models\Account; use App\Models\Account;
use App\Models\BankIntegration; use App\Models\BankIntegration;
use App\Utils\Traits\MakesHash; use App\Utils\Traits\MakesHash;
use App\Transformers\EntityTransformer;
/** /**
* Class BankIntegrationTransformer. * Class BankIntegrationTransformer.

View File

@ -43,7 +43,7 @@ class BankTransactionRuleTransformer extends EntityTransformer
]; ];
/** /**
* @param BankTransaction $bank_integration * @param BankTransactionRule $bank_transaction_rule
* @return array * @return array
*/ */
public function transform(BankTransactionRule $bank_transaction_rule) public function transform(BankTransactionRule $bank_transaction_rule)

View File

@ -11,9 +11,11 @@
namespace App\Transformers; namespace App\Transformers;
use App\Models\BankTransaction; use App\Models\Vendor;
use App\Models\Company; use App\Models\Company;
use App\Models\Expense; use App\Models\Expense;
use App\Models\Payment;
use App\Models\BankTransaction;
use App\Utils\Traits\MakesHash; use App\Utils\Traits\MakesHash;
/** /**