mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
Updates for static analysis
This commit is contained in:
parent
73274f545a
commit
f01fa763c1
@ -66,7 +66,6 @@ class RecurringInvoiceExport extends BaseExport
|
||||
'vendor' => 'vendor_id',
|
||||
'project' => 'project_id',
|
||||
'frequency_id' => 'frequency_id',
|
||||
'next_send_date' => 'next_send_date'
|
||||
];
|
||||
|
||||
private array $decorate_keys = [
|
||||
|
@ -89,9 +89,12 @@ class InvoicesTable extends Component
|
||||
->withTrashed()
|
||||
->paginate($this->per_page);
|
||||
|
||||
/** @var \App\Models\ClientContact $client_contact */
|
||||
$client_contact = auth()->user();
|
||||
|
||||
return render('components.livewire.invoices-table', [
|
||||
'invoices' => $query,
|
||||
'gateway_available' => ! empty(auth()->user()->client->service()->getPaymentMethods(-1)),
|
||||
'gateway_available' => ! empty($client_contact->client->service()->getPaymentMethods(-1)),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ class UpdateDefaultMethod extends Component
|
||||
|
||||
MultiDB::setDb($this->company->db);
|
||||
|
||||
$this->is_disabled = $this->token->is_default;
|
||||
// $this->is_disabled = $this->token->is_default;
|
||||
}
|
||||
|
||||
public function makeDefault(): void
|
||||
|
@ -52,7 +52,7 @@ class RequiredClientInfo extends Component
|
||||
public $contact;
|
||||
|
||||
/**
|
||||
* @var Client
|
||||
* @var \App\Models\Client
|
||||
*/
|
||||
public $client;
|
||||
|
||||
@ -227,6 +227,7 @@ class RequiredClientInfo extends Component
|
||||
->push();
|
||||
|
||||
if ($contact_update && $client_update) {
|
||||
/** @var \App\Models\CompanyGateway $cg */
|
||||
$cg = CompanyGateway::find($this->company_gateway_id);
|
||||
|
||||
if ($cg && $cg->update_details) {
|
||||
|
@ -53,7 +53,7 @@ class WepaySignup extends Component
|
||||
|
||||
public $saved;
|
||||
|
||||
public $company;
|
||||
public Company $company;
|
||||
|
||||
protected $rules = [
|
||||
'first_name' => ['required'],
|
||||
@ -71,7 +71,7 @@ class WepaySignup extends Component
|
||||
MultiDB::setDb($this->company->db);
|
||||
|
||||
$user = User::find($this->user_id);
|
||||
$this->company = Company::where('company_key', $this->company->company_key)->first();
|
||||
$this->company = Company::query()->where('company_key', $this->company->company_key)->first();
|
||||
|
||||
$this->fill([
|
||||
'wepay_payment_tos_agree' => '',
|
||||
@ -100,7 +100,7 @@ class WepaySignup extends Component
|
||||
$data = $this->validate($this->rules);
|
||||
|
||||
//need to create or get a new WePay CompanyGateway
|
||||
$cg = CompanyGateway::where('gateway_key', '8fdeed552015b3c7b44ed6c8ebd9e992')
|
||||
$cg = CompanyGateway::query()->where('gateway_key', '8fdeed552015b3c7b44ed6c8ebd9e992')
|
||||
->where('company_id', $this->company->id)
|
||||
->firstOrNew();
|
||||
|
||||
|
@ -25,7 +25,10 @@ class ClientPortalEnabled
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if (auth()->user()->client->getSetting('enable_client_portal') === false) {
|
||||
/** @var \App\Models\ClientContact $client_contact */
|
||||
$client_contact = auth()->user();
|
||||
|
||||
if ($client_contact->client->getSetting('enable_client_portal') === false) {
|
||||
return redirect()->route('client.error')->with(['title' => ctrans('texts.client_portal'), 'notification' => 'This section of the app has been disabled by the administrator.']);
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@ class ContactAccount
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if (! Ninja::isHosted()) {
|
||||
/** @var \App\Models\Account $account */
|
||||
$account = Account::first();
|
||||
|
||||
session()->put('account_key', $account->key);
|
||||
|
@ -67,7 +67,7 @@ class ContactKeyLogin
|
||||
}
|
||||
} elseif ($request->segment(3) && config('ninja.db.multi_db_enabled')) {
|
||||
if (MultiDB::findAndSetDbByContactKey($request->segment(3))) {
|
||||
if ($client_contact = ClientContact::with('company')->where('contact_key', $request->segment(3))->first()) {
|
||||
if ($client_contact = ClientContact::query()->with('company')->where('contact_key', $request->segment(3))->first()) {
|
||||
if ($client_contact->company->settings->enable_client_portal_password) {
|
||||
return redirect()->route('client.login', ['company_key' => $client_contact->company->company_key]);
|
||||
}
|
||||
@ -107,7 +107,7 @@ class ContactKeyLogin
|
||||
}
|
||||
} elseif ($request->has('client_hash') && config('ninja.db.multi_db_enabled')) {
|
||||
if (MultiDB::findAndSetDbByClientHash($request->input('client_hash'))) {
|
||||
if ($client = Client::where('client_hash', $request->input('client_hash'))->first()) {
|
||||
if ($client = Client::query()->where('client_hash', $request->input('client_hash'))->first()) {
|
||||
$primary_contact = $client->primary_contact()->first();
|
||||
|
||||
if (empty($primary_contact->email)) {
|
||||
|
@ -30,7 +30,7 @@ class ContactRegister
|
||||
'portal_mode' => 'subdomain',
|
||||
];
|
||||
|
||||
$company = Company::where($query)->first();
|
||||
$company = Company::query()->where($query)->first();
|
||||
|
||||
if ($company) {
|
||||
if (! $company->client_can_register) {
|
||||
|
@ -43,7 +43,7 @@ class UpdateCalculatedFields
|
||||
|
||||
if (! config('ninja.db.multi_db_enabled')) {
|
||||
|
||||
Project::with('tasks')->whereHas('tasks', function ($query){
|
||||
Project::query()->with('tasks')->whereHas('tasks', function ($query){
|
||||
$query->where('updated_at', '>', now()->subHours(2));
|
||||
})
|
||||
->cursor()
|
||||
|
@ -40,7 +40,7 @@ class OAuth
|
||||
const SOCIAL_APPLE = 8;
|
||||
|
||||
/**
|
||||
* @param Socialite $user
|
||||
* @param \Laravel\Socialite\Facades\Socialite $socialite_user
|
||||
* @return bool | \App\Models\User | \App\Models\User | null
|
||||
*/
|
||||
public static function handleAuth($socialite_user, $provider)
|
||||
|
@ -36,7 +36,7 @@ class DownloadBackup extends Mailable
|
||||
{
|
||||
App::setLocale($this->company->getLocale());
|
||||
|
||||
$company = Company::where('company_key', $this->company->company_key)->first();
|
||||
$company = Company::query()->where('company_key', $this->company->company_key)->first();
|
||||
|
||||
return $this->from(config('mail.from.address'), config('mail.from.name'))
|
||||
->subject(ctrans('texts.download_backup_subject', ['company' => $company->present()->name()]))
|
||||
|
@ -106,6 +106,7 @@ use Illuminate\Contracts\Translation\HasLocalePreference;
|
||||
* @method static \Database\Factories\ClientFactory factory($count = null, $state = [])
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Client filter(\App\Filters\QueryFilters $filters)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Client without()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Client select()
|
||||
* @property string $payment_balance
|
||||
* @property mixed $tax_data
|
||||
* @property int $is_tax_exempt
|
||||
|
@ -76,7 +76,6 @@ use Laracasts\Presenter\PresentableTrait;
|
||||
* @property-read int|null $quote_invitations_count
|
||||
* @property-read int|null $recurring_invoice_invitations_count
|
||||
* @property-read \App\Models\User $user
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ClientContact company()
|
||||
* @method static \Database\Factories\ClientContactFactory factory($count = null, $state = [])
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ClientContact newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ClientContact newQuery()
|
||||
|
@ -69,27 +69,27 @@ class ClientGatewayToken extends BaseModel
|
||||
return self::class;
|
||||
}
|
||||
|
||||
public function client()
|
||||
public function client(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Client::class)->withTrashed();
|
||||
}
|
||||
|
||||
public function gateway()
|
||||
public function gateway(): \Illuminate\Database\Eloquent\Relations\HasOne
|
||||
{
|
||||
return $this->hasOne(CompanyGateway::class, 'id', 'company_gateway_id');
|
||||
}
|
||||
|
||||
public function gateway_type()
|
||||
public function gateway_type(): \Illuminate\Database\Eloquent\Relations\HasOne
|
||||
{
|
||||
return $this->hasOne(GatewayType::class, 'id', 'gateway_type_id');
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
* @property bool $update_details
|
||||
* @property bool $is_deleted
|
||||
* @property string $config
|
||||
* @property object $fees_and_limits
|
||||
* @property mixed $fees_and_limits
|
||||
* @property string|null $custom_value1
|
||||
* @property string|null $custom_value2
|
||||
* @property string|null $custom_value3
|
||||
|
@ -13,8 +13,6 @@ namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Relations\Pivot;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* App\Models\CompanyUser
|
||||
@ -79,34 +77,6 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\CompanyUser> $cu
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\CompanyToken> $token
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\CompanyToken> $tokens
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\User> $users
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\CompanyToken> $token
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\CompanyToken> $tokens
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\User> $users
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\CompanyToken> $token
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\CompanyToken> $tokens
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\User> $users
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\CompanyToken> $token
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\CompanyToken> $tokens
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\User> $users
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\CompanyToken> $token
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\CompanyToken> $tokens
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\User> $users
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\CompanyToken> $token
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\CompanyToken> $tokens
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\User> $users
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\CompanyToken> $token
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\CompanyToken> $tokens
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\User> $users
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\CompanyToken> $token
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\CompanyToken> $tokens
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\User> $users
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\CompanyToken> $token
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\CompanyToken> $tokens
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\User> $users
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\CompanyToken> $token
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\CompanyToken> $tokens
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\User> $users
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class CompanyUser extends Pivot
|
||||
@ -153,32 +123,40 @@ class CompanyUser extends Pivot
|
||||
return self::class;
|
||||
}
|
||||
|
||||
public function account()
|
||||
public function account(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Account::class);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasOne
|
||||
*/
|
||||
public function user_pivot()
|
||||
{
|
||||
return $this->hasOne(User::class)->withPivot('permissions', 'settings', 'react_settings', 'is_admin', 'is_owner', 'is_locked', 'slack_webhook_url', 'migrating');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasOne
|
||||
*/
|
||||
public function company_pivot()
|
||||
{
|
||||
return $this->hasOne(Company::class)->withPivot('permissions', 'settings', 'react_settings', 'is_admin', 'is_owner', 'is_locked', 'slack_webhook_url', 'migrating');
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class)->withTrashed();
|
||||
}
|
||||
|
||||
public function company()
|
||||
public function company(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Company::class);
|
||||
}
|
||||
|
||||
public function users()
|
||||
public function users(): \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
{
|
||||
return $this->hasMany(User::class)->withTrashed();
|
||||
}
|
||||
@ -189,7 +167,7 @@ class CompanyUser extends Pivot
|
||||
return $this->hasMany(CompanyToken::class, 'user_id', 'user_id');
|
||||
}
|
||||
|
||||
public function tokens()
|
||||
public function tokens(): \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
{
|
||||
return $this->hasMany(CompanyToken::class, 'user_id', 'user_id');
|
||||
}
|
||||
|
@ -180,46 +180,52 @@ class Payment extends BaseModel
|
||||
return self::class;
|
||||
}
|
||||
|
||||
public function client()
|
||||
public function client(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Client::class)->withTrashed();
|
||||
}
|
||||
|
||||
public function company_gateway()
|
||||
public function company_gateway(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(CompanyGateway::class)->withTrashed();
|
||||
}
|
||||
|
||||
public function company()
|
||||
public function company(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Company::class);
|
||||
}
|
||||
|
||||
public function contact()
|
||||
public function contact(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(ClientContact::class);
|
||||
}
|
||||
|
||||
public function user()
|
||||
public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class)->withTrashed();
|
||||
}
|
||||
|
||||
public function assigned_user()
|
||||
public function assigned_user(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'assigned_user_id', 'id')->withTrashed();
|
||||
}
|
||||
|
||||
public function documents()
|
||||
public function documents(): \Illuminate\Database\Eloquent\Relations\MorphMany
|
||||
{
|
||||
return $this->morphMany(Document::class, 'documentable');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MorphedByMany
|
||||
*/
|
||||
public function invoices()
|
||||
{
|
||||
return $this->morphedByMany(Invoice::class, 'paymentable')->withTrashed()->withPivot('amount', 'refunded')->withTimestamps();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MorphedByMany
|
||||
*/
|
||||
public function credits()
|
||||
{
|
||||
return $this->morphedByMany(Credit::class, 'paymentable')->withTrashed()->withPivot('amount', 'refunded')->withTimestamps();
|
||||
@ -230,32 +236,32 @@ class Payment extends BaseModel
|
||||
return $this->morphMany(CompanyLedger::class, 'company_ledgerable');
|
||||
}
|
||||
|
||||
public function type()
|
||||
public function type(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(PaymentType::class);
|
||||
}
|
||||
|
||||
public function currency()
|
||||
public function currency(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Currency::class);
|
||||
}
|
||||
|
||||
public function transaction()
|
||||
public function transaction(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(BankTransaction::class);
|
||||
}
|
||||
|
||||
public function exchange_currency()
|
||||
public function exchange_currency(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Currency::class, 'exchange_currency_id', 'id');
|
||||
}
|
||||
|
||||
public function vendor()
|
||||
public function vendor(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Vendor::class);
|
||||
}
|
||||
|
||||
public function project()
|
||||
public function project(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Project::class);
|
||||
}
|
||||
@ -271,7 +277,7 @@ class Payment extends BaseModel
|
||||
return $pt->name($this->type_id);
|
||||
}
|
||||
|
||||
public function gateway_type()
|
||||
public function gateway_type(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(GatewayType::class);
|
||||
}
|
||||
@ -457,12 +463,12 @@ class Payment extends BaseModel
|
||||
];
|
||||
}
|
||||
|
||||
public function translate_entity()
|
||||
public function translate_entity(): string
|
||||
{
|
||||
return ctrans('texts.payment');
|
||||
}
|
||||
|
||||
public function portalUrl($use_react_url)
|
||||
public function portalUrl($use_react_url): string
|
||||
{
|
||||
return $use_react_url ? config('ninja.react_url')."/#/payments/{$this->hashed_id}/edit" : config('ninja.app_url');
|
||||
}
|
||||
|
@ -55,6 +55,7 @@ class CheckoutSetupWebhook implements ShouldQueue
|
||||
|
||||
MultiDB::findAndSetDbByCompanyKey($this->company_key);
|
||||
|
||||
/** @var \App\Models\CompanyGateway $company_gateway */
|
||||
$company_gateway = CompanyGateway::find($this->company_gateway_id);
|
||||
|
||||
$this->checkout = $company_gateway->driver()->init();
|
||||
|
@ -95,7 +95,7 @@ class ACH
|
||||
{
|
||||
$stripe_event = $event['data']['object'];
|
||||
|
||||
$token = ClientGatewayToken::where('token', $stripe_event['id'])
|
||||
$token = ClientGatewayToken::query()->where('token', $stripe_event['id'])
|
||||
->where('gateway_customer_reference', $stripe_event['customer'])
|
||||
->first();
|
||||
|
||||
|
@ -1357,13 +1357,13 @@ class SubscriptionService
|
||||
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:
|
||||
@ -1397,13 +1397,13 @@ class SubscriptionService
|
||||
case RecurringInvoice::FREQUENCY_MONTHLY:
|
||||
return $date->addMonthNoOverflow();
|
||||
case RecurringInvoice::FREQUENCY_TWO_MONTHS:
|
||||
return $date->addMonthNoOverflow(2);
|
||||
return $date->addMonthsNoOverflow(2);
|
||||
case RecurringInvoice::FREQUENCY_THREE_MONTHS:
|
||||
return $date->addMonthNoOverflow(3);
|
||||
return $date->addMonthsNoOverflow(3);
|
||||
case RecurringInvoice::FREQUENCY_FOUR_MONTHS:
|
||||
return $date->addMonthNoOverflow(4);
|
||||
return $date->addMonthsNoOverflow(4);
|
||||
case RecurringInvoice::FREQUENCY_SIX_MONTHS:
|
||||
return $date->addMonthNoOverflow(6);
|
||||
return $date->addMonthsNoOverflow(6);
|
||||
case RecurringInvoice::FREQUENCY_ANNUALLY:
|
||||
return $date->addYear();
|
||||
case RecurringInvoice::FREQUENCY_TWO_YEARS:
|
||||
|
@ -1,165 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://www.elastic.co/licensing/elastic-license
|
||||
*/
|
||||
|
||||
namespace App\Services\TaskScheduler;
|
||||
|
||||
use App\Export\CSV\ClientExport;
|
||||
use App\Export\CSV\ContactExport;
|
||||
use App\Export\CSV\CreditExport;
|
||||
use App\Export\CSV\DocumentExport;
|
||||
use App\Export\CSV\ExpenseExport;
|
||||
use App\Export\CSV\InvoiceExport;
|
||||
use App\Export\CSV\InvoiceItemExport;
|
||||
use App\Export\CSV\PaymentExport;
|
||||
use App\Export\CSV\ProductExport;
|
||||
use App\Export\CSV\QuoteExport;
|
||||
use App\Export\CSV\QuoteItemExport;
|
||||
use App\Export\CSV\RecurringInvoiceExport;
|
||||
use App\Export\CSV\TaskExport;
|
||||
use App\Http\Requests\Report\GenericReportRequest;
|
||||
use App\Http\Requests\TaskScheduler\CreateScheduledTaskRequest;
|
||||
use App\Http\Requests\TaskScheduler\UpdateScheduledJobRequest;
|
||||
use App\Http\Requests\TaskScheduler\UpdateScheduleRequest;
|
||||
use App\Jobs\Report\ProfitAndLoss;
|
||||
use App\Models\Scheduler;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
//@deprecated - never used....
|
||||
class TaskSchedulerService
|
||||
{
|
||||
public function __construct(public Scheduler $scheduler)
|
||||
{
|
||||
}
|
||||
|
||||
public function store(Scheduler $scheduler, CreateScheduledTaskRequest $request)
|
||||
{
|
||||
$scheduler->action_name = $request->job;
|
||||
$scheduler->paused = $request->get('paused', false);
|
||||
$scheduler->start_from = $request->get('start_from') ? Carbon::parse((int) $request->get('start_from')) : Carbon::now();
|
||||
$scheduler->repeat_every = $request->get('repeat_every');
|
||||
$scheduler->scheduled_run = $request->get('start_from') ? Carbon::parse((int) $request->get('start_from')) : Carbon::now();
|
||||
$scheduler->company_id = auth()->user()->company()->id;
|
||||
$scheduler = $this->setJobParameters($scheduler, $request);
|
||||
$scheduler->save();
|
||||
}
|
||||
|
||||
public function update(Scheduler $scheduler, UpdateScheduleRequest $request)
|
||||
{
|
||||
if (array_key_exists('job', $request->all())) {
|
||||
$scheduler->action_name = $request->get('job');
|
||||
$scheduler = $this->setJobParameters($scheduler, $request);
|
||||
}
|
||||
$data = $request->validated();
|
||||
$update = $this->scheduler->update($data);
|
||||
}
|
||||
|
||||
private function runValidation($form_request, $data)
|
||||
{
|
||||
$_syn_request_class = new $form_request();
|
||||
$_syn_request_class->setContainer(app());
|
||||
$_syn_request_class->initialize($data);
|
||||
$_syn_request_class->prepareForValidation();
|
||||
$_syn_request_class->setValidator(Validator::make($_syn_request_class->all(), $_syn_request_class->rules()));
|
||||
|
||||
return $_syn_request_class->validated();
|
||||
}
|
||||
|
||||
public function setJobParameters(Scheduler $scheduler, $request)
|
||||
{
|
||||
switch ($scheduler->action_name) {
|
||||
case Scheduler::CREATE_CLIENT_REPORT:
|
||||
$scheduler->action_name = Scheduler::CREATE_CLIENT_REPORT;
|
||||
$scheduler->action_class = $this->getClassPath(ClientExport::class);
|
||||
$scheduler->parameters = $this->runValidation(GenericReportRequest::class, $request->all());
|
||||
break;
|
||||
case Scheduler::CREATE_CLIENT_CONTACT_REPORT:
|
||||
$scheduler->action_name = Scheduler::CREATE_CLIENT_CONTACT_REPORT;
|
||||
$scheduler->action_class = $this->getClassPath(ContactExport::class);
|
||||
$scheduler->parameters = $this->runValidation(GenericReportRequest::class, $request->all());
|
||||
break;
|
||||
case Scheduler::CREATE_CREDIT_REPORT:
|
||||
|
||||
$scheduler->action_name = Scheduler::CREATE_CREDIT_REPORT;
|
||||
$scheduler->action_class = $this->getClassPath(CreditExport::class);
|
||||
$scheduler->parameters = $this->runValidation(GenericReportRequest::class, $request->all());
|
||||
break;
|
||||
case Scheduler::CREATE_DOCUMENT_REPORT:
|
||||
$scheduler->action_name = Scheduler::CREATE_DOCUMENT_REPORT;
|
||||
$scheduler->action_class = $this->getClassPath(DocumentExport::class);
|
||||
$scheduler->parameters = $this->runValidation(GenericReportRequest::class, $request->all());
|
||||
break;
|
||||
case Scheduler::CREATE_EXPENSE_REPORT:
|
||||
$scheduler->action_name = Scheduler::CREATE_EXPENSE_REPORT;
|
||||
$scheduler->action_class = $this->getClassPath(ExpenseExport::class);
|
||||
$scheduler->parameters = $this->runValidation(GenericReportRequest::class, $request->all());
|
||||
break;
|
||||
case Scheduler::CREATE_INVOICE_ITEM_REPORT:
|
||||
$scheduler->action_name = Scheduler::CREATE_INVOICE_ITEM_REPORT;
|
||||
$scheduler->action_class = $this->getClassPath(InvoiceItemExport::class);
|
||||
$scheduler->parameters = $this->runValidation(GenericReportRequest::class, $request->all());
|
||||
break;
|
||||
case Scheduler::CREATE_INVOICE_REPORT:
|
||||
$scheduler->action_name = Scheduler::CREATE_INVOICE_REPORT;
|
||||
$scheduler->action_class = $this->getClassPath(InvoiceExport::class);
|
||||
$scheduler->parameters = $this->runValidation(GenericReportRequest::class, $request->all());
|
||||
break;
|
||||
case Scheduler::CREATE_PAYMENT_REPORT:
|
||||
$scheduler->action_name = Scheduler::CREATE_PAYMENT_REPORT;
|
||||
$scheduler->action_class = $this->getClassPath(PaymentExport::class);
|
||||
$scheduler->parameters = $this->runValidation(GenericReportRequest::class, $request->all());
|
||||
break;
|
||||
case Scheduler::CREATE_PRODUCT_REPORT:
|
||||
$scheduler->action_name = Scheduler::CREATE_PRODUCT_REPORT;
|
||||
$scheduler->action_class = $this->getClassPath(ProductExport::class);
|
||||
$scheduler->parameters = $this->runValidation(GenericReportRequest::class, $request->all());
|
||||
break;
|
||||
case Scheduler::CREATE_PROFIT_AND_LOSS_REPORT:
|
||||
$scheduler->action_name = Scheduler::CREATE_PROFIT_AND_LOSS_REPORT;
|
||||
$scheduler->action_class = $this->getClassPath(ProfitAndLoss::class);
|
||||
$scheduler->parameters = $this->runValidation(GenericReportRequest::class, $request->all());
|
||||
break;
|
||||
case Scheduler::CREATE_QUOTE_ITEM_REPORT:
|
||||
$scheduler->action_name = Scheduler::CREATE_QUOTE_ITEM_REPORT;
|
||||
$scheduler->action_class = $this->getClassPath(QuoteItemExport::class);
|
||||
$scheduler->parameters = $this->runValidation(GenericReportRequest::class, $request->all());
|
||||
break;
|
||||
case Scheduler::CREATE_QUOTE_REPORT:
|
||||
$scheduler->action_name = Scheduler::CREATE_QUOTE_REPORT;
|
||||
$scheduler->action_class = $this->getClassPath(QuoteExport::class);
|
||||
$scheduler->parameters = $this->runValidation(GenericReportRequest::class, $request->all());
|
||||
break;
|
||||
case Scheduler::CREATE_RECURRING_INVOICE_REPORT:
|
||||
$scheduler->action_name = Scheduler::CREATE_RECURRING_INVOICE_REPORT;
|
||||
$scheduler->action_class = $this->getClassPath(RecurringInvoiceExport::class);
|
||||
$scheduler->parameters = $this->runValidation(GenericReportRequest::class, $request->all());
|
||||
break;
|
||||
case Scheduler::CREATE_TASK_REPORT:
|
||||
$scheduler->action_name = Scheduler::CREATE_TASK_REPORT;
|
||||
$scheduler->action_class = $this->getClassPath(TaskExport::class);
|
||||
$scheduler->parameters = $this->runValidation(GenericReportRequest::class, $request->all());
|
||||
break;
|
||||
}
|
||||
|
||||
return $scheduler;
|
||||
}
|
||||
|
||||
public function getClassPath($class): string
|
||||
{
|
||||
return $class = is_object($class) ? get_class($class) : $class;
|
||||
}
|
||||
|
||||
public function updateJob(Scheduler $scheduler, UpdateScheduledJobRequest $request)
|
||||
{
|
||||
$scheduler = $this->setJobParameters($scheduler, $request);
|
||||
$scheduler->save();
|
||||
}
|
||||
}
|
@ -24,7 +24,7 @@ class TaskStatusTransformer extends EntityTransformer
|
||||
'id' => (string) $this->encodePrimaryKey($task_status->id),
|
||||
'name' => (string) $task_status->name,
|
||||
'color' => (string) $task_status->color,
|
||||
'sort_order' => (int) $task_status->sort_order, //deprecated
|
||||
// 'sort_order' => (int) $task_status->sort_order, //deprecated
|
||||
'is_deleted' => (bool) $task_status->is_deleted,
|
||||
'created_at' => (int) $task_status->created_at,
|
||||
'updated_at' => (int) $task_status->updated_at,
|
||||
|
Loading…
Reference in New Issue
Block a user