1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-09 20:52:56 +01:00

Static analysis

This commit is contained in:
David Bomba 2023-08-11 14:18:58 +10:00
parent 8f1ca3f945
commit e5d5b9d25c
31 changed files with 238 additions and 173 deletions

View File

@ -820,6 +820,8 @@ class CompanySettings extends BaseSettings
{
$company_settings = (object) get_class_vars(self::class);
$settings = new \stdClass;
foreach ($company_settings as $key => $value) {
if (! property_exists($settings, $key)) {
$settings->{$key} = self::castAttribute($key, $company_settings->{$key});

View File

@ -12,6 +12,7 @@
namespace App\Filters;
use App\Models\Payment;
use Illuminate\Contracts\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Database\Eloquent\Builder;
/**
@ -117,6 +118,8 @@ class PaymentFilters extends QueryFilters
/**
* Returns a list of payments that can be matched to bank transactions
* @param ?string $value
* @return Builder
*/
public function match_transactions($value = 'true'): Builder
{
@ -124,7 +127,7 @@ class PaymentFilters extends QueryFilters
if ($value == 'true') {
return $this->builder
->where('is_deleted', 0)
->where(function ($query) {
->where(function (Builder $query) {
$query->whereNull('transaction_id')
->orWhere("transaction_id", "")
->company();

View File

@ -301,6 +301,7 @@ class MigrationController extends BaseController
$user = auth()->user();
$company_count = $user->account->companies()->count();
$fresh_company = false;
// Look for possible existing company (based on company keys).
$existing_company = Company::whereRaw('BINARY `company_key` = ?', [$company['company_key']])->first();

View File

@ -74,6 +74,7 @@ class OneTimeTokenController extends BaseController
'user_id' => $user->id,
'company_key'=> $user->company()->company_key,
'context' => $request->input('context'),
'is_react' => $request->has('react') && $request->query('react') == 'true' ? true : false,
];
Cache::put($hash, $data, 3600);

View File

@ -181,8 +181,8 @@ class PreviewPurchaseOrderController extends BaseController
DB::connection(config('database.default'))->beginTransaction();
if ($request->has('entity_id')) {
/** @var \App\Models\PurchaseOrder|\Illuminate\Database\Eloquent\Builder $entity_obj **/
$entity_obj = $class::on(config('database.default'))
/** @var \App\Models\PurchaseOrder|\Illuminate\Contracts\Database\Eloquent\Builder $entity_obj **/
$entity_obj = \App\Models\PurchaseOrder::on(config('database.default'))
->with('vendor.company')
->where('id', $this->decodePrimaryKey($request->input('entity_id')))
->where('company_id', $company->id)

View File

@ -32,7 +32,6 @@ class StripeConnectController extends BaseController
*/
public function initialize(InitializeStripeConnectRequest $request, string $token)
{
// Should we check if company has set country in the ap? Otherwise this will fail.
if (! is_array($request->getTokenContent())) {
abort(400, 'Invalid token');
@ -40,8 +39,6 @@ class StripeConnectController extends BaseController
MultiDB::findAndSetDbByCompanyKey($request->getTokenContent()['company_key']);
$company = Company::where('company_key', $request->getTokenContent()['company_key'])->first();
$company_gateway = CompanyGateway::query()
->where('gateway_key', 'd14dd26a47cecc30fdd65700bfb67b34')
->where('company_id', $request->getCompany()->id)
@ -71,6 +68,20 @@ class StripeConnectController extends BaseController
}
try {
/** @class \stdClass $response
* @property string $scope
* @property string $stripe_user_id
* @property string $stripe_publishable_key
* @property string $refresh_token
* @property string $livemode
* @property string $access_token
* @property string $token_type
* @property string $stripe_user
* @property string $stripe_account
* @property string $error
*/
/** @var \stdClass $response */
$response = \Stripe\OAuth::token([
'grant_type' => 'authorization_code',
'code' => $request->input('code'),
@ -81,8 +92,7 @@ class StripeConnectController extends BaseController
MultiDB::findAndSetDbByCompanyKey($request->getTokenContent()['company_key']);
/** @var \App\Models\Company $company */
$company = Company::where('company_key', $request->getTokenContent()['company_key'])->first();
$company = Company::query()->where('company_key', $request->getTokenContent()['company_key'])->first();
$company_gateway = CompanyGateway::query()
->where('gateway_key', 'd14dd26a47cecc30fdd65700bfb67b34')
@ -97,7 +107,6 @@ class StripeConnectController extends BaseController
$company_gateway->fees_and_limits = $fees_and_limits;
$company_gateway->setConfig([]);
$company_gateway->token_billing = 'always';
// $company_gateway->save();
}
$payload = [
@ -116,39 +125,14 @@ class StripeConnectController extends BaseController
$company_gateway->save();
// StripeWebhook::dispatch($company->company_key, $company_gateway->id);
//response here
return view('auth.connect.completed');
}
private function checkAccountAlreadyLinkToEmail($company_gateway, $email)
{
$client = Client::first() ? Client::first() : new Client;
//Pull the list of Stripe Accounts and see if we match
$accounts = $company_gateway->driver($client)->getAllConnectedAccounts()->data;
foreach ($accounts as $account) {
if ($account['email'] == $email) {
return $account['id'];
}
if(isset($request->getTokenContent()['is_react']) && $request->getTokenContent()['is_react']) {
$redirect_uri = 'https://app.invoicing.co/#/settings/online_payments';
} else {
$redirect_uri = 'https://invoicing.co/stripe/completed';
}
return false;
//response here
return view('auth.connect.completed', ['url' => $redirect_uri]);
}
/*********************************
* Stripe OAuth
*/
// public function initialize(InitializeStripeConnectRequest $request, string $token)
// {
// $stripe_key = config('ninja.ninja_stripe_key');
// $endpoint = "https://connect.stripe.com/oauth/authorize?response_type=code&client_id={$stripe_key}&scope=read_write";
// return redirect($endpoint);
// }
}

View File

@ -62,9 +62,6 @@ class ZipPurchaseOrders implements ShouldQueue
* Execute the job.
*
* @return void
* @throws \ZipStream\Exception\FileNotFoundException
* @throws \ZipStream\Exception\FileNotReadableException
* @throws \ZipStream\Exception\OverflowException
*/
public function handle()
{

View File

@ -37,7 +37,6 @@ use Illuminate\Database\Eloquent\ModelNotFoundException as ModelNotFoundExceptio
* @property int $assigned_user_id
* @method BaseModel service()
* @property \App\Models\Company $company
* @property \App\Models\Vendor $vendor
* @method static BaseModel find($value)
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel<static> company()
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel|Illuminate\Database\Eloquent\Relations\BelongsTo|\Awobaz\Compoships\Database\Eloquent\Relations\BelongsTo|\App\Models\Company company()
@ -63,11 +62,15 @@ use Illuminate\Database\Eloquent\ModelNotFoundException as ModelNotFoundExceptio
* @method int companyId()
* @method createInvitations()
* @method Builder scopeCompany(Builder $builder)
* @method static \Illuminate\Database\Eloquent\Builder<static> company()
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel|\Illuminate\Database\Query\Builder withTrashed(bool $withTrashed = true)
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel|\Illuminate\Database\Query\Builder onlyTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel|\Illuminate\Database\Query\Builder withoutTrashed()
* @mixin \Eloquent
* @mixin \Illuminate\Database\Eloquent\Builder
*
* @property \Illuminate\Support\Collection $tax_map
* @property array $total_tax_map
*/
class BaseModel extends Model
{
@ -119,7 +122,11 @@ class BaseModel extends Model
return parent::__call($method, $params);
}
/**
* @param \Illuminate\Database\Eloquent\Builder $query
* @extends \Illuminate\Database\Eloquent\Builder
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeCompany($query): \Illuminate\Database\Eloquent\Builder
{
/** @var \App\Models\User $user */

View File

@ -93,29 +93,30 @@ use Illuminate\Database\Eloquent\Relations\MorphMany;
* @property string|null $reminder_last_sent
* @property float $paid_to_date
* @property int|null $subscription_id
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Activity> $activities
* @property-read int|null $activities_count
* @property-read \App\Models\User|null $assigned_user
* @property-read \App\Models\Client $client
* @property-read \App\Models\Company $company
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\CompanyLedger> $company_ledger
* @property-read int|null $company_ledger_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Document> $documents
* @property-read int|null $documents_count
* @property-read mixed $hashed_id
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Backup> $history
* @property-read int|null $history_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\CreditInvitation> $invitations
* @property-read int|null $invitations_count
* @property-read \App\Models\Invoice|null $invoice
* @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\Payment> $payments
* @property-read int|null $payments_count
* @property-read \App\Models\Project|null $project
* @property-read \App\Models\User $user
* @property-read \App\Models\Client $client
* @property-read \App\Models\Vendor|null $vendor
* @property \Illuminate\Database\Eloquent\Collection<int, \App\Models\Activity> $activities
* @property int|null $activities_count
* @property \App\Models\User|null $assigned_user
* @property \App\Models\Client $client
* @property \App\Models\Company $company
* @property \App\Models\CreditInvitation $invitation
* @property \Illuminate\Database\Eloquent\Collection<int, \App\Models\CompanyLedger> $company_ledger
* @property int|null $company_ledger_count
* @property \Illuminate\Database\Eloquent\Collection<int, \App\Models\Document> $documents
* @property int|null $documents_count
* @property mixed $hashed_id
* @property \Illuminate\Database\Eloquent\Collection<int, \App\Models\Backup> $history
* @property int|null $history_count
* @property \Illuminate\Database\Eloquent\Collection<int, \App\Models\CreditInvitation> $invitations
* @property int|null $invitations_count
* @property \App\Models\Invoice|null $invoice
* @property \Illuminate\Database\Eloquent\Collection<int, \App\Models\Invoice> $invoices
* @property int|null $invoices_count
* @property \Illuminate\Database\Eloquent\Collection<int, \App\Models\Payment> $payments
* @property int|null $payments_count
* @property \App\Models\Project|null $project
* @property \App\Models\User $user
* @property \App\Models\Client $client
* @property \App\Models\Vendor|null $vendor
* @property-read mixed $pivot
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Activity> $activities
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\CompanyLedger> $company_ledger

View File

@ -41,11 +41,11 @@ use Illuminate\Support\Facades\Storage;
* @property int|null $deleted_at
* @property string|null $signature_ip
* @property string|null $email_status
* @property-read \App\Models\Company $company
* @property-read \App\Models\ClientContact $contact
* @property-read \App\Models\Credit $credit
* @property-read mixed $hashed_id
* @property-read \App\Models\User $user
* @property \App\Models\Company $company
* @property \App\Models\ClientContact $contact
* @property \App\Models\Credit $credit
* @property mixed $hashed_id
* @property \App\Models\User $user
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel company()
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel exclude($columns)
* @method static \Database\Factories\CreditInvitationFactory factory($count = null, $state = [])

View File

@ -99,12 +99,13 @@ use App\Events\Invoice\InvoiceReminderWasEmailed;
* @property int $auto_bill_tries
* @property bool $is_proforma
* @property-read int|null $activities_count
* @property-read \App\Models\User|null $assigned_user
* @property \App\Models\User|null $assigned_user
* @property \App\Models\Client $client
* @property-read \App\Models\Company $company
* @property \App\Models\InvoiceInvitation $invitation
* @property \App\Models\Company $company
* @property-read int|null $company_ledger_count
* @property-read int|null $credits_count
* @property-read \App\Models\Design|null $design
* @property \App\Models\Design|null $design
* @property-read int|null $documents_count
* @property-read \App\Models\Expense|null $expense
* @property-read int|null $expenses_count

View File

@ -43,11 +43,11 @@ use Illuminate\Support\Facades\Storage;
* @property int|null $deleted_at
* @property string|null $signature_ip
* @property string|null $email_status
* @property-read \App\Models\Company $company
* @property-read \App\Models\ClientContact $contact
* @property-read mixed $hashed_id
* @property-read \App\Models\Invoice $invoice
* @property-read \App\Models\User $user
* @property \App\Models\Company $company
* @property \App\Models\ClientContact $contact
* @property mixed $hashed_id
* @property \App\Models\Invoice $invoice
* @property \App\Models\User $user
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel company()
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel exclude($columns)
* @method static \Database\Factories\InvoiceInvitationFactory factory($count = null, $state = [])

View File

@ -87,17 +87,17 @@ use Illuminate\Support\Facades\Storage;
* @property int|null $expense_id
* @property int|null $currency_id
* @property-read int|null $activities_count
* @property-read \App\Models\User|null $assigned_user
* @property-read \App\Models\Client|null $client
* @property-read \App\Models\Company $company
* @property \App\Models\User|null $assigned_user
* @property \App\Models\Client|null $client
* @property \App\Models\Company $company
* @property-read int|null $documents_count
* @property-read \App\Models\Expense|null $expense
* @property-read mixed $hashed_id
* @property-read \App\Models\Invoice|null $invoice
* @property-read \App\Models\Project|null $project
* @property-read \App\Models\User $user
* @property \App\Models\Vendor|null $vendor
* @method static \Illuminate\Database\Eloquent\Builder|PurchaseOrder company()
* @property \App\Models\Expense|null $expense
* @property string $hashed_id
* @property \App\Models\Invoice|null $invoice
* @property \App\Models\Project|null $project
* @property \App\Models\User $user
* @property \App\Models\Vendor $vendor
* @property \App\Models\PurchaseOrderInvitation $invitation
* @method static \Illuminate\Database\Eloquent\Builder|PurchaseOrder exclude($columns)
* @method static \Database\Factories\PurchaseOrderFactory factory($count = null, $state = [])
* @method static \Illuminate\Database\Eloquent\Builder|PurchaseOrder filter(\App\Filters\QueryFilters $filters)
@ -110,10 +110,8 @@ use Illuminate\Support\Facades\Storage;
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Document> $documents
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Backup> $history
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\PurchaseOrderInvitation> $invitations
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Invoice> $invoices
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Payment> $payments
* @method static \Illuminate\Database\Eloquent\Builder|Task withTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|Task withoutTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|PurchaseOrder withTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|PurchaseOrder withoutTrashed()
* @mixin \Eloquent
*/
class PurchaseOrder extends BaseModel
@ -236,6 +234,9 @@ class PurchaseOrder extends BaseModel
return $this->belongsTo(User::class, 'assigned_user_id', 'id')->withTrashed();
}
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function vendor(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(Vendor::class)->withTrashed();

View File

@ -40,11 +40,11 @@ use Illuminate\Support\Str;
* @property int|null $updated_at
* @property int|null $deleted_at
* @property string|null $email_status
* @property-read \App\Models\Company $company
* @property-read \App\Models\VendorContact $contact
* @property-read mixed $hashed_id
* @property-read \App\Models\PurchaseOrder $purchase_order
* @property-read \App\Models\User $user
* @property \App\Models\Company $company
* @property \App\Models\VendorContact $contact
* @property string $hashed_id
* @property \App\Models\PurchaseOrder $purchase_order
* @property \App\Models\User $user
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel company()
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel exclude($columns)
* @method static \Database\Factories\PurchaseOrderInvitationFactory factory($count = null, $state = [])

View File

@ -91,9 +91,10 @@ use Laracasts\Presenter\PresentableTrait;
* @property string|null $reminder_last_sent
* @property string $paid_to_date
* @property int|null $subscription_id
* @property-read \App\Models\User|null $assigned_user
* @property-read \App\Models\Client $client
* @property-read \App\Models\Company $company
* @property \App\Models\User|null $assigned_user
* @property \App\Models\Client $client
* @property \App\Models\Company $company
* @property \App\Models\QuoteInvitation $invitation
* @property-read mixed $balance_due
* @property-read mixed $hashed_id
* @property-read mixed $total

View File

@ -41,11 +41,11 @@ use Illuminate\Support\Facades\Storage;
* @property int|null $deleted_at
* @property string|null $signature_ip
* @property string|null $email_status
* @property-read \App\Models\Company $company
* @property-read \App\Models\ClientContact $contact
* @property-read mixed $hashed_id
* @property-read \App\Models\Quote $quote
* @property-read \App\Models\User $user
* @property \App\Models\Company $company
* @property \App\Models\ClientContact $contact
* @property mixed $hashed_id
* @property \App\Models\Quote $quote
* @property \App\Models\User $user
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel company()
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel exclude($columns)
* @method static \Database\Factories\QuoteInvitationFactory factory($count = null, $state = [])

View File

@ -91,6 +91,7 @@ use Laracasts\Presenter\PresentableTrait;
* @property-read \App\Models\User|null $assigned_user
* @property-read \App\Models\Client $client
* @property-read \App\Models\Company $company
* @property \App\Models\RecurringInvoiceInvitation $invitation
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Document> $documents
* @property-read int|null $documents_count
* @property-read mixed $hashed_id

View File

@ -37,11 +37,11 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @property string|null $viewed_date
* @property string|null $opened_date
* @property string|null $email_status
* @property-read \App\Models\Company $company
* @property-read \App\Models\ClientContact $contact
* @property-read mixed $hashed_id
* @property-read \App\Models\RecurringInvoice $recurring_invoice
* @property-read \App\Models\User $user
* @property \App\Models\Company $company
* @property \App\Models\ClientContact $contact
* @property string $hashed_id
* @property \App\Models\RecurringInvoice $recurring_invoice
* @property \App\Models\User $user
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel company()
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel exclude($columns)
* @method static \Illuminate\Database\Eloquent\Builder|RecurringInvoiceInvitation newModelQuery()

View File

@ -95,6 +95,7 @@ use Illuminate\Foundation\Auth\User as Authenticatable;
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\CompanyUser> $company_users
* @property-read \Illuminate\Notifications\DatabaseNotificationCollection<int, \Illuminate\Notifications\DatabaseNotification> $notifications
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\CompanyToken> $tokens
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Company> $companies
* @method bool hasPermissionTo(string $permission)
* @method \App\Models\Company getCompany()
* @method \App\Models\Company company()

View File

@ -66,7 +66,6 @@ use Laracasts\Presenter\PresentableTrait;
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\VendorContact> $primary_contact
* @property-read int|null $primary_contact_count
* @property-read \App\Models\User $user
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel company()
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel exclude($columns)
* @method static \Database\Factories\VendorFactory factory($count = null, $state = [])
* @method static \Illuminate\Database\Eloquent\Builder|Vendor filter(\App\Filters\QueryFilters $filters)
@ -75,35 +74,6 @@ use Laracasts\Presenter\PresentableTrait;
* @method static \Illuminate\Database\Eloquent\Builder|Vendor onlyTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|Vendor query()
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel scope()
* @method static \Illuminate\Database\Eloquent\Builder|Vendor whereAddress1($value)
* @method static \Illuminate\Database\Eloquent\Builder|Vendor whereAddress2($value)
* @method static \Illuminate\Database\Eloquent\Builder|Vendor whereAssignedUserId($value)
* @method static \Illuminate\Database\Eloquent\Builder|Vendor whereCity($value)
* @method static \Illuminate\Database\Eloquent\Builder|Vendor whereCompanyId($value)
* @method static \Illuminate\Database\Eloquent\Builder|Vendor whereCountryId($value)
* @method static \Illuminate\Database\Eloquent\Builder|Vendor whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|Vendor whereCurrencyId($value)
* @method static \Illuminate\Database\Eloquent\Builder|Vendor whereCustomValue1($value)
* @method static \Illuminate\Database\Eloquent\Builder|Vendor whereCustomValue2($value)
* @method static \Illuminate\Database\Eloquent\Builder|Vendor whereCustomValue3($value)
* @method static \Illuminate\Database\Eloquent\Builder|Vendor whereCustomValue4($value)
* @method static \Illuminate\Database\Eloquent\Builder|Vendor whereDeletedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|Vendor whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|Vendor whereIdNumber($value)
* @method static \Illuminate\Database\Eloquent\Builder|Vendor whereIsDeleted($value)
* @method static \Illuminate\Database\Eloquent\Builder|Vendor whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|Vendor whereNumber($value)
* @method static \Illuminate\Database\Eloquent\Builder|Vendor wherePhone($value)
* @method static \Illuminate\Database\Eloquent\Builder|Vendor wherePostalCode($value)
* @method static \Illuminate\Database\Eloquent\Builder|Vendor wherePrivateNotes($value)
* @method static \Illuminate\Database\Eloquent\Builder|Vendor wherePublicNotes($value)
* @method static \Illuminate\Database\Eloquent\Builder|Vendor whereState($value)
* @method static \Illuminate\Database\Eloquent\Builder|Vendor whereTransactionName($value)
* @method static \Illuminate\Database\Eloquent\Builder|Vendor whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|Vendor whereUserId($value)
* @method static \Illuminate\Database\Eloquent\Builder|Vendor whereVatNumber($value)
* @method static \Illuminate\Database\Eloquent\Builder|Vendor whereVendorHash($value)
* @method static \Illuminate\Database\Eloquent\Builder|Vendor whereWebsite($value)
* @method static \Illuminate\Database\Eloquent\Builder|Vendor withTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|Vendor withoutTrashed()
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Activity> $activities
@ -215,6 +185,9 @@ class Vendor extends BaseModel
return $this->company->timezone();
}
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function company(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(Company::class);
@ -225,7 +198,7 @@ class Vendor extends BaseModel
return $this->belongsTo(User::class)->withTrashed();
}
public function translate_entity()
public function translate_entity(): string
{
return ctrans('texts.vendor');
}
@ -253,7 +226,13 @@ class Vendor extends BaseModel
return $defaults;
}
public function getSetting($setting)
/**
* Returns a vendor settings proxying company setting
*
* @param string $setting
* @return string
*/
public function getSetting($setting): string
{
if ((property_exists($this->company->settings, $setting) != false) && (isset($this->company->settings->{$setting}) !== false)) {
return $this->company->settings->{$setting};

View File

@ -50,7 +50,7 @@ class PaymentIntentFailureWebhook implements ShouldQueue
{
MultiDB::findAndSetDbByCompanyKey($this->company_key);
$company = Company::where('company_key', $this->company_key)->first();
$company = Company::query()->where('company_key', $this->company_key)->first();
foreach ($this->stripe_request as $transaction) {
if (array_key_exists('payment_intent', $transaction)) {
@ -78,7 +78,7 @@ class PaymentIntentFailureWebhook implements ShouldQueue
$payment->status_id = Payment::STATUS_FAILED;
$payment->save();
$payment_hash = PaymentHash::where('payment_id', $payment->id)->first();
$payment_hash = PaymentHash::query()->where('payment_id', $payment->id)->first();
if ($payment_hash) {
$error = ctrans('texts.client_payment_failure_body', [

View File

@ -208,17 +208,24 @@ class UpdatePaymentMethods
switch ($type_id) {
case GatewayType::CREDIT_CARD:
$payment_meta = new \stdClass;
$payment_meta->exp_month = (string) $method->card->exp_month;
$payment_meta->exp_year = (string) $method->card->exp_year;
$payment_meta->brand = (string) $method->card->brand;
$payment_meta->last4 = (string) $method->card->last4;
$payment_meta->type = GatewayType::CREDIT_CARD;
return $payment_meta;
break;
/**
* @class \Stripe\PaymentMethod $method
* @property \Stripe\StripeObject $card
* @class \Stripe\StripeObject $card
* @property string $exp_year
* @property string $exp_month
* @property string $brand
* @property string $last4
*/
$payment_meta = new \stdClass;
$payment_meta->exp_month = (string) $method->card->exp_month;
$payment_meta->exp_year = (string) $method->card->exp_year;
$payment_meta->brand = (string) $method->card->brand;
$payment_meta->last4 = (string) $method->card->last4;
$payment_meta->type = GatewayType::CREDIT_CARD;
return $payment_meta;
case GatewayType::ALIPAY:
case GatewayType::SOFORT:

View File

@ -155,7 +155,8 @@ class ClientService
return false;
}
return $this->emailStatement($pdf, $statement->options);
$this->emailStatement($pdf, $statement->options);
return;
}
return $pdf;

View File

@ -133,7 +133,7 @@ class PdfMock
$entity->vendor = Vendor::factory()->make();
break;
default:
# code...
$entity = false;
break;
}
@ -152,11 +152,12 @@ class PdfMock
*/
public function getMergedSettings() :object
{
$settings = $this->company->settings;
match ($this->request['settings_type']) {
'group' => $settings = ClientSettings::buildClientSettings($this->company->settings, $this->request['settings']),
'client' => $settings = ClientSettings::buildClientSettings($this->company->settings, $this->request['settings']),
'company' => $settings = (object)$this->request['settings'],
default => $settings = $this->company->settings,
'company' => $settings = (object)$this->request['settings']
};
$settings = CompanySettings::setProperties($settings);
@ -168,9 +169,9 @@ class PdfMock
/**
* getTaxMap
*
* @return void
* @return \Illuminate\Support\Collection
*/
private function getTaxMap()
private function getTaxMap(): \Illuminate\Support\Collection
{
return collect([['name' => 'GST', 'total' => 10]]);
}
@ -178,9 +179,9 @@ class PdfMock
/**
* getTotalTaxMap
*
* @return void
* @return array
*/
private function getTotalTaxMap()
private function getTotalTaxMap(): array
{
return [['name' => 'GST', 'total' => 10]];
}
@ -188,8 +189,9 @@ class PdfMock
/**
* getStubVariables
*
* @return array
*/
public function getStubVariables()
public function getStubVariables(): array
{
return ['values' =>
[

View File

@ -227,10 +227,13 @@ class StubBuilder
private function createClient(): self
{
$this->recipient = Client::factory()->create([
/** @var \App\Models\Client $client */
$client = Client::factory()->create([
'user_id' => $this->user->id,
'company_id' => $this->company->id,
]);
$this->recipient = $client;
$this->contact = ClientContact::factory()->create([
'user_id' => $this->user->id,
@ -245,10 +248,13 @@ class StubBuilder
private function createVendor(): self
{
$this->recipient = Vendor::factory()->create([
/** @var \App\Models\Vendor $vendor */
$vendor = Vendor::factory()->create([
'user_id' => $this->user->id,
'company_id' => $this->user->company()->id,
]);
$this->recipient = $vendor;
$this->contact = VendorContact::factory()->create([
'user_id' => $this->user->id,
@ -276,7 +282,8 @@ class StubBuilder
private function createInvoice()
{
$this->entity = Invoice::factory()->create([
/** @var \App\Models\Invoice $invoice */
$invoice = Invoice::factory()->create([
'user_id' => $this->user->id,
'company_id' => $this->company->id,
'client_id' => $this->recipient->id,
@ -285,6 +292,8 @@ class StubBuilder
'status_id' => Invoice::STATUS_PAID,
]);
$this->entity = $invoice;
$this->invitation = InvoiceInvitation::factory()->create([
'user_id' => $this->user->id,
'company_id' => $this->company->id,

View File

@ -12,6 +12,7 @@
namespace App\Transformers;
use App\Models\Account;
use App\Models\Company;
use App\Models\BankIntegration;
use App\Models\BankTransaction;
use App\Utils\Traits\MakesHash;

View File

@ -11,11 +11,12 @@
namespace App\Transformers;
use App\Models\CompanyGateway;
use stdClass;
use App\Models\Gateway;
use App\Models\SystemLog;
use App\Models\CompanyGateway;
use App\Utils\Traits\MakesHash;
use Illuminate\Database\Eloquent\SoftDeletes;
use stdClass;
/**
* Class CompanyGatewayTransformer.

View File

@ -113,6 +113,7 @@
"phpstan/phpstan": "^1.9",
"phpunit/phpunit": "^9.5.10",
"spatie/laravel-ignition": "^1.0",
"spaze/phpstan-stripe": "^3.0",
"vimeo/psalm": "^4.24"
},
"autoload": {

64
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "be16996524279f340c44e2f6c9a0ba53",
"content-hash": "9d7348352c913eb82fcca2e67670e1f8",
"packages": [
{
"name": "adrienrn/php-mimetyper",
@ -17898,6 +17898,68 @@
],
"time": "2023-01-03T19:28:04+00:00"
},
{
"name": "spaze/phpstan-stripe",
"version": "v3.0.0",
"source": {
"type": "git",
"url": "https://github.com/spaze/phpstan-stripe.git",
"reference": "6e5debe4f65b15192a28bd01f01670ced8250443"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spaze/phpstan-stripe/zipball/6e5debe4f65b15192a28bd01f01670ced8250443",
"reference": "6e5debe4f65b15192a28bd01f01670ced8250443",
"shasum": ""
},
"require": {
"php": "^8.0",
"phpstan/phpstan": "^1.7"
},
"require-dev": {
"nikic/php-parser": "^4.13",
"php-parallel-lint/php-console-highlighter": "^1.0",
"php-parallel-lint/php-parallel-lint": "^1.2",
"spaze/coding-standard": "^1.1",
"stripe/stripe-php": "^8.7|^9.9|^10.8"
},
"suggest": {
"phpstan/extension-installer": "Allows automatic requirement of extension.neon"
},
"type": "phpstan-extension",
"extra": {
"phpstan": {
"includes": [
"extension.neon"
]
}
},
"autoload": {
"psr-4": {
"Spaze\\PHPStan\\Stripe\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michal Špaček",
"email": "mail@michalspacek.cz",
"homepage": "https://www.michalspacek.cz"
}
],
"description": "Stripe SDK extension for PHPStan",
"keywords": [
"static analysis"
],
"support": {
"issues": "https://github.com/spaze/phpstan-stripe/issues",
"source": "https://github.com/spaze/phpstan-stripe/tree/v3.0.0"
},
"time": "2023-03-06T00:39:29+00:00"
},
{
"name": "symfony/polyfill-php81",
"version": "v1.27.0",

View File

@ -1,5 +1,6 @@
includes:
- ./vendor/nunomaduro/larastan/extension.neon
- ./vendor/spaze/phpstan-stripe/extension.neon
parameters:
level: 2
paths:

View File

@ -8,6 +8,6 @@
</div>
<p>Connecting your account using Stripe has been successfully completed.</p>
<span>Click <a class="font-semibold hover:underline" href="{{ url('/#/settings/company_gateways') }}">here</a> to continue.</span>
<span>Click <a class="font-semibold hover:underline" href="{{ $url ?? url('/#/settings/company_gateways') }}">here</a> to continue.</span>
</div>
@endsection