1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-13 06:32:40 +01:00
This commit is contained in:
David Bomba 2022-06-24 23:49:29 +10:00
commit 91b658918a
67 changed files with 230 additions and 235 deletions

View File

@ -131,9 +131,9 @@ class CreateAccount extends Command
'settings' => null,
]);
CreateCompanyPaymentTerms::dispatchNow($company, $user);
CreateCompanyTaskStatuses::dispatchNow($company, $user);
VersionCheck::dispatchNow();
CreateCompanyPaymentTerms::dispatchSync($company, $user);
CreateCompanyTaskStatuses::dispatchSync($company, $user);
VersionCheck::dispatchSync();
}
private function warmCache()

View File

@ -188,7 +188,7 @@ class CreateSingleAccount extends Command
$this->createClient($company, $user);
}
CreateCompanyTaskStatuses::dispatchNow($company, $user);
CreateCompanyTaskStatuses::dispatchSync($company, $user);
for ($x = 0; $x < $this->count; $x++) {
$client = $company->clients->random();

View File

@ -112,9 +112,9 @@ class DemoMode extends Command
$this->info('Seeding Random Data');
$this->createSmallAccount();
VersionCheck::dispatchNow();
VersionCheck::dispatchSync();
CompanySizeCheck::dispatchNow();
CompanySizeCheck::dispatchSync();
}
private function createSmallAccount()
@ -164,8 +164,8 @@ class DemoMode extends Command
]);
}
CreateCompanyPaymentTerms::dispatchNow($company, $user);
CreateCompanyTaskStatuses::dispatchNow($company, $user);
CreateCompanyPaymentTerms::dispatchSync($company, $user);
CreateCompanyTaskStatuses::dispatchSync($company, $user);
$company_token = new CompanyToken;
$company_token->user_id = $user->id;

View File

@ -43,13 +43,13 @@ class HostedUsers extends Command
{
Company::on('db-ninja-01')->each(function ($company) {
if (Ninja::isHosted()) {
\Modules\Admin\Jobs\Account\NinjaUser::dispatchNow([], $company);
\Modules\Admin\Jobs\Account\NinjaUser::dispatchSync([], $company);
}
});
Company::on('db-ninja-02')->each(function ($company) {
if (Ninja::isHosted()) {
\Modules\Admin\Jobs\Account\NinjaUser::dispatchNow([], $company);
\Modules\Admin\Jobs\Account\NinjaUser::dispatchSync([], $company);
}
});
}

View File

@ -47,6 +47,6 @@ class RecurringCommand extends Command
*/
public function handle()
{
RecurringInvoicesCron::dispatchNow();
RecurringInvoicesCron::dispatchSync();
}
}

View File

@ -96,6 +96,6 @@ class SendTestEmails extends Command
$nmo->settings = $user->account->companies()->first()->settings;
$nmo->to_user = $user;
NinjaMailerJob::dispatchNow($nmo);
NinjaMailerJob::dispatchSync($nmo);
}
}

View File

@ -143,8 +143,7 @@ class AccountController extends BaseController
*/
public function store(CreateAccountRequest $request)
{
$account = CreateAccount::dispatchNow($request->all(), $request->getClientIp());
$account = (new CreateAccount($request->all(), $request->getClientIp()))->handle();
if (! ($account instanceof Account)) {
return $account;
}

View File

@ -186,13 +186,13 @@ class LoginController extends BaseController
if ($user->google_2fa_secret && $request->has('one_time_password')) {
$google2fa = new Google2FA();
if (strlen($request->input('one_time_password')) == 0 || ! $google2fa->verifyKey(decrypt($user->google_2fa_secret), $request->input('one_time_password'))) {
if (strlen($request->input('one_time_password')) == 0 || !$google2fa->verifyKey(decrypt($user->google_2fa_secret), $request->input('one_time_password'))) {
return response()
->json(['message' => ctrans('texts.invalid_one_time_password')], 401)
->header('X-App-Version', config('ninja.app_version'))
->header('X-Api-Version', config('ninja.minimum_client_version'));
->json(['message' => ctrans('texts.invalid_one_time_password')], 401)
->header('X-App-Version', config('ninja.app_version'))
->header('X-Api-Version', config('ninja.minimum_client_version'));
}
} elseif ($user->google_2fa_secret && ! $request->has('one_time_password')) {
} elseif ($user->google_2fa_secret && !$request->has('one_time_password')) {
return response()
->json(['message' => ctrans('texts.invalid_one_time_password')], 401)
->header('X-App-Version', config('ninja.app_version'))
@ -200,7 +200,7 @@ class LoginController extends BaseController
}
/* If for some reason we lose state on the default company ie. a company is deleted - always make sure we can default to a company*/
if (! $user->account->default_company) {
if (!$user->account->default_company) {
$account = $user->account;
$account->default_company_id = $user->companies->first()->id;
$account->save();
@ -214,7 +214,7 @@ class LoginController extends BaseController
}
/*On the hosted platform, only owners can login for free/pro accounts*/
if (Ninja::isHosted() && ! $cu->first()->is_owner && ! $user->account->isEnterpriseClient()) {
if (Ninja::isHosted() && !$cu->first()->is_owner && !$user->account->isEnterpriseClient()) {
return response()->json(['message' => 'Pro / Free accounts only the owner can log in. Please upgrade'], 403);
}
@ -293,7 +293,7 @@ class LoginController extends BaseController
$cu->first()->account->companies->each(function ($company) use ($cu, $request) {
if ($company->tokens()->where('is_system', true)->count() == 0) {
CreateCompanyToken::dispatchNow($company, $cu->first()->user, $request->server('HTTP_USER_AGENT'));
CreateCompanyToken::dispatchSync($company, $cu->first()->user, $request->server('HTTP_USER_AGENT'));
}
});
@ -301,7 +301,7 @@ class LoginController extends BaseController
$cu->where('company_id', $company_token->company_id);
}
if (Ninja::isHosted() && ! $cu->first()->is_owner && ! $cu->first()->user->account->isEnterpriseClient()) {
if (Ninja::isHosted() && !$cu->first()->is_owner && !$cu->first()->user->account->isEnterpriseClient()) {
return response()->json(['message' => 'Pro / Free accounts only the owner can log in. Please upgrade'], 403);
}
@ -371,7 +371,7 @@ class LoginController extends BaseController
'oauth_provider_id' => $provider,
];
if ($existing_user = MultiDB::hasUser($query)) {
if (! $existing_user->account) {
if (!$existing_user->account) {
return response()->json(['message' => 'User exists, but not attached to any companies! Orphaned user!'], 400);
}
@ -383,7 +383,7 @@ class LoginController extends BaseController
return response()->json(['message' => 'User found, but not attached to any companies, please see your administrator'], 400);
}
if (Ninja::isHosted() && ! $cu->first()->is_owner && ! $existing_user->account->isEnterpriseClient()) {
if (Ninja::isHosted() && !$cu->first()->is_owner && !$existing_user->account->isEnterpriseClient()) {
return response()->json(['message' => 'Pro / Free accounts only the owner can log in. Please upgrade'], 403);
}
@ -391,7 +391,7 @@ class LoginController extends BaseController
}
//If this is a result user/email combo - lets add their OAuth details details
if ($existing_login_user = MultiDB::hasUser(['email' => $user->email])) {
if (! $existing_login_user->account) {
if (!$existing_login_user->account) {
return response()->json(['message' => 'User exists, but not attached to any companies! Orphaned user!'], 400);
}
@ -408,7 +408,7 @@ class LoginController extends BaseController
return response()->json(['message' => 'User found, but not attached to any companies, please see your administrator'], 400);
}
if (Ninja::isHosted() && ! $cu->first()->is_owner && ! $existing_login_user->account->isEnterpriseClient()) {
if (Ninja::isHosted() && !$cu->first()->is_owner && !$existing_login_user->account->isEnterpriseClient()) {
return response()->json(['message' => 'Pro / Free accounts only the owner can log in. Please upgrade'], 403);
}
@ -427,7 +427,7 @@ class LoginController extends BaseController
MultiDB::setDefaultDatabase();
$account = CreateAccount::dispatchNow($new_account, request()->getClientIp());
$account = (new CreateAccount($new_account, request()->getClientIp()))->handle();
Auth::login($account->default_company->owner(), true);
auth()->user()->email_verified_at = now();
@ -439,7 +439,7 @@ class LoginController extends BaseController
return response()->json(['message' => 'User found, but not attached to any companies, please see your administrator'], 400);
}
if (Ninja::isHosted() && ! $cu->first()->is_owner && ! auth()->user()->account->isEnterpriseClient()) {
if (Ninja::isHosted() && !$cu->first()->is_owner && !auth()->user()->account->isEnterpriseClient()) {
return response()->json(['message' => 'Pro / Free accounts only the owner can log in. Please upgrade'], 403);
}
@ -475,8 +475,8 @@ class LoginController extends BaseController
if (auth()->user()->company_users()->count() != auth()->user()->tokens()->distinct('company_id')->count()) {
auth()->user()->companies->each(function ($company) {
if (! CompanyToken::where('user_id', auth()->user()->id)->where('company_id', $company->id)->exists()) {
CreateCompanyToken::dispatchNow($company, auth()->user(), 'Google_O_Auth');
if (!CompanyToken::where('user_id', auth()->user()->id)->where('company_id', $company->id)->exists()) {
CreateCompanyToken::dispatchSync($company, auth()->user(), 'Google_O_Auth');
}
});
}
@ -498,8 +498,8 @@ class LoginController extends BaseController
$graph->setAccessToken($accessToken);
$user = $graph->createRequest('GET', '/me')
->setReturnType(Model\User::class)
->execute();
->setReturnType(Model\User::class)
->execute();
if ($user) {
$account = request()->input('account');
@ -507,11 +507,11 @@ class LoginController extends BaseController
$query = [
'oauth_user_id' => $user->getId(),
'oauth_provider_id'=> 'microsoft',
'oauth_provider_id' => 'microsoft',
];
if ($existing_user = MultiDB::hasUser($query)) {
if (! $existing_user->account) {
if (!$existing_user->account) {
return response()->json(['message' => 'User exists, but not attached to any companies! Orphaned user!'], 400);
}
@ -520,7 +520,7 @@ class LoginController extends BaseController
//If this is a result user/email combo - lets add their OAuth details details
if ($existing_login_user = MultiDB::hasUser(['email' => $email])) {
if (! $existing_login_user->account) {
if (!$existing_login_user->account) {
return response()->json(['message' => 'User exists, but not attached to any companies! Orphaned user!'], 400);
}
@ -553,7 +553,7 @@ class LoginController extends BaseController
return response()->json(['message' => 'User found, but not attached to any companies, please see your administrator'], 400);
}
if (Ninja::isHosted() && ! $cu->first()->is_owner && ! $existing_user->account->isEnterpriseClient()) {
if (Ninja::isHosted() && !$cu->first()->is_owner && !$existing_user->account->isEnterpriseClient()) {
return response()->json(['message' => 'Pro / Free accounts only the owner can log in. Please upgrade'], 403);
}
@ -564,7 +564,7 @@ class LoginController extends BaseController
{
auth()->user()->update([
'oauth_user_id' => $oauth_user_id,
'oauth_provider_id'=> $provider,
'oauth_provider_id' => $provider,
]);
$cu = $this->hydrateCompanyUser();
@ -573,7 +573,7 @@ class LoginController extends BaseController
return response()->json(['message' => 'User found, but not attached to any companies, please see your administrator'], 400);
}
if (Ninja::isHosted() && ! $cu->first()->is_owner && ! auth()->user()->account->isEnterpriseClient()) {
if (Ninja::isHosted() && !$cu->first()->is_owner && !auth()->user()->account->isEnterpriseClient()) {
return response()->json(['message' => 'Pro / Free accounts only the owner can log in. Please upgrade'], 403);
}
@ -591,11 +591,11 @@ class LoginController extends BaseController
if (is_array($user)) {
$query = [
'oauth_user_id' => $google->harvestSubField($user),
'oauth_provider_id'=> 'google',
'oauth_provider_id' => 'google',
];
if ($existing_user = MultiDB::hasUser($query)) {
if (! $existing_user->account) {
if (!$existing_user->account) {
return response()->json(['message' => 'User exists, but not attached to any companies! Orphaned user!'], 400);
}
@ -604,7 +604,7 @@ class LoginController extends BaseController
//If this is a result user/email combo - lets add their OAuth details details
if ($existing_login_user = MultiDB::hasUser(['email' => $google->harvestEmail($user)])) {
if (! $existing_login_user->account) {
if (!$existing_login_user->account) {
return response()->json(['message' => 'User exists, but not attached to any companies! Orphaned user!'], 400);
}
@ -618,7 +618,7 @@ class LoginController extends BaseController
//check the user doesn't already exist in some form
if ($existing_login_user = MultiDB::hasUser(['email' => $google->harvestEmail($user)])) {
if (! $existing_login_user->account) {
if (!$existing_login_user->account) {
return response()->json(['message' => 'User exists, but not attached to any companies! Orphaned user!'], 400);
}
@ -643,18 +643,17 @@ class LoginController extends BaseController
}
return response()
->json(['message' => ctrans('texts.invalid_credentials')], 401)
->header('X-App-Version', config('ninja.app_version'))
->header('X-Api-Version', config('ninja.minimum_client_version'));
->json(['message' => ctrans('texts.invalid_credentials')], 401)
->header('X-App-Version', config('ninja.app_version'))
->header('X-Api-Version', config('ninja.minimum_client_version'));
}
private function createNewAccount($new_account)
{
MultiDB::setDefaultDatabase();
$account = CreateAccount::dispatchNow($new_account, request()->getClientIp());
if (! $account instanceof Account) {
$account = (new CreateAccount($new_account, request()->getClientIp()))->handle();
if (!$account instanceof Account) {
return $account;
}
@ -668,7 +667,7 @@ class LoginController extends BaseController
return response()->json(['message' => 'User found, but not attached to any companies, please see your administrator'], 400);
}
if (Ninja::isHosted() && ! $cu->first()->is_owner && ! auth()->user()->account->isEnterpriseClient()) {
if (Ninja::isHosted() && !$cu->first()->is_owner && !auth()->user()->account->isEnterpriseClient()) {
return response()->json(['message' => 'Pro / Free accounts only the owner can log in. Please upgrade'], 403);
}
@ -683,18 +682,18 @@ class LoginController extends BaseController
if ($provider == 'google') {
$scopes = ['https://www.googleapis.com/auth/gmail.send', 'email', 'profile', 'openid'];
$parameters = ['access_type' => 'offline', 'prompt' => 'consent select_account', 'redirect_uri' => config('ninja.app_url').'/auth/google'];
$parameters = ['access_type' => 'offline', 'prompt' => 'consent select_account', 'redirect_uri' => config('ninja.app_url') . '/auth/google'];
}
if ($provider == 'microsoft') {
$scopes = ['email', 'Mail.ReadWrite', 'Mail.Send', 'offline_access', 'profile', 'User.Read openid'];
$parameters = ['response_type' => 'code', 'redirect_uri' => config('ninja.app_url').'/auth/microsoft'];
$parameters = ['response_type' => 'code', 'redirect_uri' => config('ninja.app_url') . '/auth/microsoft'];
}
if (request()->has('code')) {
return $this->handleProviderCallback($provider);
} else {
if (! in_array($provider, ['google', 'microsoft'])) {
if (!in_array($provider, ['google', 'microsoft'])) {
return abort(400, 'Invalid provider');
}
@ -747,8 +746,8 @@ class LoginController extends BaseController
$socialite_user = Socialite::driver($provider)->user();
nlog($socialite_user);
nlog('refresh token '.$socialite_user->accessTokenResponseBody['refresh_token']);
nlog('access token '.$socialite_user->accessTokenResponseBody['access_token']);
nlog('refresh token ' . $socialite_user->accessTokenResponseBody['refresh_token']);
nlog('access token ' . $socialite_user->accessTokenResponseBody['access_token']);
$oauth_user_token = $socialite_user->accessTokenResponseBody['access_token'];

View File

@ -197,7 +197,7 @@ class InvitationController extends Controller
$file_name = $invitation->{$entity}->numberFormatter().'.pdf';
$file = CreateRawPdf::dispatchNow($invitation, $invitation->company->db);
$file = (new CreateRawPdf($invitation, $invitation->company->db))->handle();
$headers = ['Content-Type' => 'application/pdf'];

View File

@ -63,7 +63,7 @@ class ProfileController extends Controller
//update avatar if needed
if ($request->file('logo')) {
$path = UploadAvatar::dispatchNow($request->file('logo'), auth()->user()->client->client_hash);
$path = (new UploadAvatar($request->file('logo'), auth()->user()->client->client_hash))->handle();
if ($path) {
$client->logo = $path;

View File

@ -211,10 +211,9 @@ class CompanyController extends BaseController
{
$this->forced_includes = ['company_user'];
$company = CreateCompany::dispatchNow($request->all(), auth()->user()->company()->account);
CreateCompanyPaymentTerms::dispatchNow($company, auth()->user());
CreateCompanyTaskStatuses::dispatchNow($company, auth()->user());
$company = (new CreateCompany($request->all(), auth()->user()->company()->account))->handle();
CreateCompanyPaymentTerms::dispatchSync($company, auth()->user());
CreateCompanyTaskStatuses::dispatchSync($company, auth()->user());
$company = $this->company_repo->save($request->all(), $company);
@ -244,8 +243,7 @@ class CompanyController extends BaseController
*/
$user_agent = request()->has('token_name') ? request()->input('token_name') : request()->server('HTTP_USER_AGENT');
$company_token = CreateCompanyToken::dispatchNow($company, auth()->user(), $user_agent);
$company_token = (new CreateCompanyToken($company, auth()->user(), $user_agent))->handle();
$this->entity_transformer = CompanyUserTransformer::class;
$this->entity_type = CompanyUser::class;

View File

@ -36,7 +36,7 @@ class HostedMigrationController extends Controller
return response()->json(['error' => 'This user is not able to perform a migration. Please contact us at contact@invoiceninja.com to discuss.'], 401);
}
$account = CreateAccount::dispatchNow($request->all(), $request->getClientIp());
$account = (new CreateAccount($request->all(), $request->getClientIp()))->handle();
$account->hosted_client_count = 100;
$account->hosted_company_count = 10;
$account->save();
@ -44,8 +44,8 @@ class HostedMigrationController extends Controller
$company = $account->companies->first();
$company_token = CompanyToken::where('user_id', auth()->user()->id)
->where('company_id', $company->id)
->first();
->where('company_id', $company->id)
->first();
return response()->json(['token' => $company_token->token], 200);
}
@ -64,7 +64,7 @@ class HostedMigrationController extends Controller
$forward_url = $company->domain();
$billing_transferred = \Modules\Admin\Jobs\Account\TransferAccountPlan::dispatchNow($input);
$billing_transferred = (new \Modules\Admin\Jobs\Account\TransferAccountPlan($input))->handle();
return response()->json(['forward_url' => $forward_url, 'billing_transferred' => $billing_transferred], 200);
}

View File

@ -170,8 +170,8 @@ class PreviewController extends BaseController
}
//else
$file_path = PreviewPdf::dispatchNow($maker->getCompiledHTML(true), auth()->user()->company());
$file_path = (new PreviewPdf($maker->getCompiledHTML(true), auth()->user()->company()))->handle();
return response()->download($file_path, basename($file_path), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true);
}
@ -295,7 +295,7 @@ class PreviewController extends BaseController
return $pdf;
}
$file_path = PreviewPdf::dispatchNow($maker->getCompiledHTML(true), $company);
$file_path = (new PreviewPdf($maker->getCompiledHTML(true), $company))->handle();
if (Ninja::isHosted()) {
LightLogs::create(new LivePreview())
@ -369,7 +369,7 @@ class PreviewController extends BaseController
return $pdf;
}
$file_path = PreviewPdf::dispatchNow($maker->getCompiledHTML(true), auth()->user()->company());
$file_path = (new PreviewPdf($maker->getCompiledHTML(true), auth()->user()->company()))->handle();
$response = Response::make($file_path, 200);
$response->header('Content-Type', 'application/pdf');
@ -464,7 +464,8 @@ class PreviewController extends BaseController
return $pdf;
}
$file_path = PreviewPdf::dispatchNow($maker->getCompiledHTML(true), auth()->user()->company());
$file_path = (new PreviewPdf($maker->getCompiledHTML(true), auth()->user()->company()))->handle();
$response = Response::make($file_path, 200);
$response->header('Content-Type', 'application/pdf');

View File

@ -145,10 +145,10 @@ class SetupController extends Controller
/* Create the first account. */
if (Account::count() == 0) {
CreateAccount::dispatchNow($request->all(), $request->getClientIp());
CreateAccount::dispatchSync($request->all(), $request->getClientIp());
}
VersionCheck::dispatchNow();
VersionCheck::dispatchSync();
$this->buildCache(true);
@ -316,7 +316,7 @@ class SetupController extends Controller
$this->buildCache(true);
SchedulerCheck::dispatchNow();
SchedulerCheck::dispatchSync();
return redirect('/');
}

View File

@ -208,7 +208,7 @@ class UserController extends BaseController
$user_agent = request()->input('token_name') ?: request()->server('HTTP_USER_AGENT');
$ct = CreateCompanyToken::dispatchNow($company, $user, $user_agent);
$ct = (new CreateCompanyToken($company, $user, $user_agent))->handle();
event(new UserWasCreated($user, auth()->user(), $company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));

View File

@ -463,7 +463,7 @@ class BillingPortalPurchase extends Component
$mailer->settings = $this->subscription->company->settings;
$mailer->to_user = $contact;
NinjaMailerJob::dispatchNow($mailer);
NinjaMailerJob::dispatchSync($mailer);
$this->steps['passwordless_login_sent'] = true;
$this->passwordless_login_btn = false;

View File

@ -90,15 +90,15 @@ class CreateAccount
$sp794f3f->save();
$sp035a66 = CreateCompany::dispatchNow($this->request, $sp794f3f);
$sp035a66 = (new CreateCompany($this->request,$sp794f3f))->handle();
$sp035a66->load('account');
$sp794f3f->default_company_id = $sp035a66->id;
$sp794f3f->save();
$spaa9f78 = CreateUser::dispatchNow($this->request, $sp794f3f, $sp035a66, true);
$spaa9f78 = (new CreateUser($this->request, $sp794f3f, $sp035a66, true))->handle();
CreateCompanyPaymentTerms::dispatchNow($sp035a66, $spaa9f78);
CreateCompanyTaskStatuses::dispatchNow($sp035a66, $spaa9f78);
CreateCompanyPaymentTerms::dispatchSync($sp035a66, $spaa9f78);
CreateCompanyTaskStatuses::dispatchSync($sp035a66, $spaa9f78);
if ($spaa9f78) {
auth()->login($spaa9f78, false);
@ -108,8 +108,7 @@ class CreateAccount
$this->setLoginCache($spaa9f78);
$spafe62e = isset($this->request['token_name']) ? $this->request['token_name'] : request()->server('HTTP_USER_AGENT');
$sp2d97e8 = CreateCompanyToken::dispatchNow($sp035a66, $spaa9f78, $spafe62e);
$sp2d97e8 = (new CreateCompanyToken($sp035a66, $spaa9f78, $spafe62e))->handle();
if ($spaa9f78) {
event(new AccountCreated($spaa9f78, $sp035a66, Ninja::eventVars()));
}

View File

@ -282,7 +282,7 @@ class CompanyImport implements ShouldQueue
$nmo->company = $_company;
$nmo->settings = $_company->settings;
$nmo->to_user = $_company->owner();
NinjaMailerJob::dispatchNow($nmo);
NinjaMailerJob::dispatchSync($nmo);
} catch (\Exception $e) {
info($e->getMessage());
}
@ -1441,6 +1441,6 @@ class CompanyImport implements ShouldQueue
$nmo->company = $this->company;
$nmo->settings = $this->company->settings;
$nmo->to_user = $this->company->owner();
NinjaMailerJob::dispatchNow($nmo);
NinjaMailerJob::dispatchSync($nmo);
}
}

View File

@ -80,7 +80,7 @@ class ZipCredits implements ShouldQueue
$path = $this->credits->first()->client->quote_filepath($invitation);
$this->credits->each(function ($credit) {
CreateEntityPdf::dispatchNow($credit->invitations()->first());
CreateEntityPdf::dispatchSync($credit->invitations()->first());
});
try {

View File

@ -74,7 +74,7 @@ class RecurringInvoicesCron
}
try {
SendRecurring::dispatchNow($recurring_invoice, $recurring_invoice->company->db);
SendRecurring::dispatchSync($recurring_invoice, $recurring_invoice->company->db);
} catch (\Exception $e) {
nlog("Unable to sending recurring invoice {$recurring_invoice->id} ".$e->getMessage());
}
@ -114,7 +114,7 @@ class RecurringInvoicesCron
}
try {
SendRecurring::dispatchNow($recurring_invoice, $recurring_invoice->company->db);
SendRecurring::dispatchSync($recurring_invoice, $recurring_invoice->company->db);
} catch (\Exception $e) {
nlog("Unable to sending recurring invoice {$recurring_invoice->id} ".$e->getMessage());
}

View File

@ -126,7 +126,7 @@ class EmailEntity implements ShouldQueue
$nmo->reminder_template = $this->reminder_template;
$nmo->entity = $this->entity;
NinjaMailerJob::dispatchNow($nmo);
NinjaMailerJob::dispatchSync($nmo);
}
private function resolveEntityString() :string

View File

@ -80,7 +80,7 @@ class ZipInvoices implements ShouldQueue
$path = $this->invoices->first()->client->invoice_filepath($invitation);
$this->invoices->each(function ($invoice) {
CreateEntityPdf::dispatchNow($invoice->invitations()->first());
CreateEntityPdf::dispatchSync($invoice->invitations()->first());
});
try {

View File

@ -39,7 +39,7 @@ class CheckDbStatus implements ShouldQueue
*/
public function handle()
{
DbStatus::dispatchNow('db-ninja-01', 'db.status.db-ninja-01');
DbStatus::dispatchNow('db-ninja-02', 'db.status.db-ninja-02');
DbStatus::dispatchSync('db-ninja-01', 'db.status.db-ninja-01');
DbStatus::dispatchSync('db-ninja-02', 'db.status.db-ninja-02');
}
}

View File

@ -214,7 +214,7 @@ class SendReminders implements ShouldQueue
if ($this->checkSendSetting($invoice, $template) && $invoice->company->account->hasFeature(Account::FEATURE_EMAIL_TEMPLATES_REMINDERS)) {
nlog('firing email');
EmailEntity::dispatchNow($invitation, $invitation->company, $template);
EmailEntity::dispatchSync($invitation, $invitation->company, $template);
}
});

View File

@ -89,7 +89,7 @@ class PurchaseOrderEmail implements ShouldQueue
$nmo->reminder_template = 'purchase_order';
$nmo->entity = $invitation->purchase_order;
NinjaMailerJob::dispatchNow($nmo);
NinjaMailerJob::dispatchSync($nmo);
});
if ($this->purchase_order->invitations->count() >= 1) {

View File

@ -82,7 +82,7 @@ class ZipPurchaseOrders implements ShouldQueue
$path = $this->purchase_orders->first()->vendor->purchase_order_filepath($invitation);
$this->purchase_orders->each(function ($purchase_order) {
CreatePurchaseOrderPdf::dispatchNow($purchase_order->invitations()->first());
CreatePurchaseOrderPdf::dispatchSync($purchase_order->invitations()->first());
});
try {

View File

@ -80,7 +80,7 @@ class ZipQuotes implements ShouldQueue
$path = $this->quotes->first()->client->quote_filepath($invitation);
$this->quotes->each(function ($quote) {
CreateEntityPdf::dispatchNow($quote->invitations()->first());
CreateEntityPdf::dispatchSync($quote->invitations()->first());
});
try {

View File

@ -215,7 +215,7 @@ class Import implements ShouldQueue
$data = $array['data'];
foreach ($this->available_imports as $import) {
if (! array_key_exists($import, $data)) {
if (!array_key_exists($import, $data)) {
info("Resource {$import} is not available for migration.");
continue;
}
@ -253,7 +253,7 @@ class Import implements ShouldQueue
$this->setInitialCompanyLedgerBalances();
// $this->fixClientBalances();
$check_data = CheckCompanyData::dispatchNow($this->company, md5(time()));
$check_data = (new CheckCompanyData($this->company, md5(time())))->handle();
// if(Ninja::isHosted() && array_key_exists('ninja_tokens', $data))
$this->processNinjaTokens($data['ninja_tokens']);
@ -273,7 +273,7 @@ class Import implements ShouldQueue
/*After a migration first some basic jobs to ensure the system is up to date*/
VersionCheck::dispatch();
info('Completed🚀🚀🚀🚀🚀 at '.now());
info('Completed🚀🚀🚀🚀🚀 at ' . now());
unlink($this->file_path);
}
@ -327,7 +327,7 @@ class Import implements ShouldQueue
});
}
private function processAccount(array $data) :void
private function processAccount(array $data): void
{
if (array_key_exists('token', $data)) {
$this->token = $data['token'];
@ -364,7 +364,7 @@ class Import implements ShouldQueue
$data = $this->transformCompanyData($data);
if (Ninja::isHosted()) {
if (! MultiDB::checkDomainAvailable($data['subdomain'])) {
if (!MultiDB::checkDomainAvailable($data['subdomain'])) {
$data['subdomain'] = MultiDB::randomSubdomainGenerator();
}
@ -426,7 +426,7 @@ class Import implements ShouldQueue
$company_repository = null;
}
private function parseCustomFields($fields) :array
private function parseCustomFields($fields): array
{
if (array_key_exists('account1', $fields)) {
$fields['company1'] = $fields['account1'];
@ -453,7 +453,7 @@ class Import implements ShouldQueue
}
foreach ($fields as &$value) {
$value = (string) $value;
$value = (string)$value;
}
return $fields;
@ -468,7 +468,7 @@ class Import implements ShouldQueue
if ($key == 'invoice_design_id' || $key == 'quote_design_id' || $key == 'credit_design_id') {
$value = $this->encodePrimaryKey($value);
if (! $value) {
if (!$value) {
$value = $this->encodePrimaryKey(1);
}
}
@ -581,7 +581,7 @@ class Import implements ShouldQueue
$user_agent = array_key_exists('token_name', $resource) ?: request()->server('HTTP_USER_AGENT');
CreateCompanyToken::dispatchNow($this->company, $user, $user_agent);
CreateCompanyToken::dispatchSync($this->company, $user, $user_agent);
$key = "users_{$resource['id']}";
@ -605,12 +605,12 @@ class Import implements ShouldQueue
$value = trim($value);
$model_query = $model::where($column, $value)
->where('company_id', $this->company->id)
->withTrashed()
->exists();
->where('company_id', $this->company->id)
->withTrashed()
->exists();
if ($model_query) {
return $value.'_'.Str::random(5);
return $value . '_' . Str::random(5);
}
return $value;
@ -679,13 +679,13 @@ class Import implements ShouldQueue
foreach ($resource['contacts'] as $key => $old_contact) {
$contact_match = ClientContact::where('contact_key', $old_contact['contact_key'])
->where('company_id', $this->company->id)
->where('client_id', $client->id)
->withTrashed()
->first();
->where('company_id', $this->company->id)
->where('client_id', $client->id)
->withTrashed()
->first();
if ($contact_match) {
$this->ids['client_contacts']['client_contacts_'.$old_contact['id']] = [
$this->ids['client_contacts']['client_contacts_' . $old_contact['id']] = [
'old' => $old_contact['id'],
'new' => $contact_match->id,
];
@ -831,7 +831,7 @@ class Import implements ShouldQueue
$product_repository = null;
}
private function processRecurringExpenses(array $data) :void
private function processRecurringExpenses(array $data): void
{
RecurringExpense::unguard();
@ -893,7 +893,7 @@ class Import implements ShouldQueue
$data = null;
}
private function processRecurringInvoices(array $data) :void
private function processRecurringInvoices(array $data): void
{
RecurringInvoice::unguard();
@ -912,7 +912,7 @@ class Import implements ShouldQueue
foreach ($data as $key => $resource) {
$modified = $resource;
if (array_key_exists('client_id', $resource) && ! array_key_exists('clients', $this->ids)) {
if (array_key_exists('client_id', $resource) && !array_key_exists('clients', $this->ids)) {
throw new ResourceDependencyMissing('Processing invoices failed, because of missing dependency - clients.');
}
@ -989,14 +989,14 @@ class Import implements ShouldQueue
foreach ($data as $key => $resource) {
$modified = $resource;
if (array_key_exists('client_id', $resource) && ! array_key_exists('clients', $this->ids)) {
if (array_key_exists('client_id', $resource) && !array_key_exists('clients', $this->ids)) {
throw new ResourceDependencyMissing('Processing invoices failed, because of missing dependency - clients.');
}
$modified['client_id'] = $this->transformId('clients', $resource['client_id']);
if (array_key_exists('recurring_id', $resource) && ! is_null($resource['recurring_id'])) {
$modified['recurring_id'] = $this->transformId('recurring_invoices', (string) $resource['recurring_id']);
if (array_key_exists('recurring_id', $resource) && !is_null($resource['recurring_id'])) {
$modified['recurring_id'] = $this->transformId('recurring_invoices', (string)$resource['recurring_id']);
}
$modified['user_id'] = $this->processUserId($resource);
@ -1041,7 +1041,7 @@ class Import implements ShouldQueue
/* Prevent edge case where V4 has inserted multiple invitations for a resource for a client contact */
private function deDuplicateInvitations($invitations)
{
return array_intersect_key($invitations, array_unique(array_column($invitations, 'client_contact_id')));
return array_intersect_key($invitations, array_unique(array_column($invitations, 'client_contact_id')));
}
private function processCredits(array $data): void
@ -1063,7 +1063,7 @@ class Import implements ShouldQueue
foreach ($data as $resource) {
$modified = $resource;
if (array_key_exists('client_id', $resource) && ! array_key_exists('clients', $this->ids)) {
if (array_key_exists('client_id', $resource) && !array_key_exists('clients', $this->ids)) {
throw new ResourceDependencyMissing('Processing credits failed, because of missing dependency - clients.');
}
@ -1127,7 +1127,7 @@ class Import implements ShouldQueue
foreach ($data as $resource) {
$modified = $resource;
if (array_key_exists('client_id', $resource) && ! array_key_exists('clients', $this->ids)) {
if (array_key_exists('client_id', $resource) && !array_key_exists('clients', $this->ids)) {
throw new ResourceDependencyMissing('Processing quotes failed, because of missing dependency - clients.');
}
@ -1224,7 +1224,7 @@ class Import implements ShouldQueue
foreach ($data as $resource) {
$modified = $resource;
if (array_key_exists('client_id', $resource) && ! array_key_exists('clients', $this->ids)) {
if (array_key_exists('client_id', $resource) && !array_key_exists('clients', $this->ids)) {
throw new ResourceDependencyMissing('Processing payments failed, because of missing dependency - clients.');
}
@ -1297,15 +1297,15 @@ class Import implements ShouldQueue
$invoices->each(function ($invoice) use ($payment) {
if ($payment->refunded > 0 && in_array($invoice->status_id, [Invoice::STATUS_SENT])) {
$invoice->service()
->updateBalance($payment->refunded)
->updatePaidToDate($payment->refunded * -1)
->updateStatus()
->save();
->updateBalance($payment->refunded)
->updatePaidToDate($payment->refunded * -1)
->updateStatus()
->save();
}
});
}
private function updatePaymentForStatus($payment, $status_id) :Payment
private function updatePaymentForStatus($payment, $status_id): Payment
{
// define('PAYMENT_STATUS_PENDING', 1);
// define('PAYMENT_STATUS_VOIDED', 2);
@ -1354,12 +1354,12 @@ class Import implements ShouldQueue
foreach ($data as $resource) {
$modified = $resource;
if (array_key_exists('invoice_id', $resource) && $resource['invoice_id'] && ! array_key_exists('invoices', $this->ids)) {
if (array_key_exists('invoice_id', $resource) && $resource['invoice_id'] && !array_key_exists('invoices', $this->ids)) {
return;
//throw new ResourceDependencyMissing('Processing documents failed, because of missing dependency - invoices.');
}
if (array_key_exists('expense_id', $resource) && $resource['expense_id'] && ! array_key_exists('expenses', $this->ids)) {
if (array_key_exists('expense_id', $resource) && $resource['expense_id'] && !array_key_exists('expenses', $this->ids)) {
return;
//throw new ResourceDependencyMissing('Processing documents failed, because of missing dependency - expenses.');
}
@ -1389,7 +1389,7 @@ class Import implements ShouldQueue
}
}
if (! $entity) {
if (!$entity) {
continue;
}
// throw new Exception("Resource invoice/quote document not available.");
@ -1402,7 +1402,7 @@ class Import implements ShouldQueue
$file_url = $resource['url'];
$file_name = $resource['name'];
$file_path = sys_get_temp_dir().'/'.$file_name;
$file_path = sys_get_temp_dir() . '/' . $file_name;
try {
file_put_contents($file_path, $this->curlGet($file_url));
@ -1410,13 +1410,13 @@ class Import implements ShouldQueue
$file_info = $finfo->file($file_path);
$uploaded_file = new UploadedFile(
$file_path,
$file_name,
$file_info,
filesize($file_path),
0,
false
);
$file_path,
$file_name,
$file_info,
filesize($file_path),
0,
false
);
$this->saveDocument($uploaded_file, $entity, $is_public = true);
} catch (\Exception $e) {
@ -1426,7 +1426,7 @@ class Import implements ShouldQueue
}
}
private function processPaymentTerms(array $data) :void
private function processPaymentTerms(array $data): void
{
PaymentTerm::unguard();
@ -1446,7 +1446,7 @@ class Import implements ShouldQueue
$data = null;
}
private function processCompanyGateways(array $data) :void
private function processCompanyGateways(array $data): void
{
CompanyGateway::unguard();
@ -1477,7 +1477,7 @@ class Import implements ShouldQueue
$modified['fees_and_limits'] = $this->cleanFeesAndLimits($modified['fees_and_limits']);
}
if (! array_key_exists('accepted_credit_cards', $modified) || (array_key_exists('accepted_credit_cards', $modified) && empty($modified['accepted_credit_cards']))) {
if (!array_key_exists('accepted_credit_cards', $modified) || (array_key_exists('accepted_credit_cards', $modified) && empty($modified['accepted_credit_cards']))) {
$modified['accepted_credit_cards'] = 0;
}
@ -1513,7 +1513,7 @@ class Import implements ShouldQueue
$data = null;
}
private function processClientGatewayTokens(array $data) :void
private function processClientGatewayTokens(array $data): void
{
ClientGatewayToken::unguard();
@ -1544,7 +1544,7 @@ class Import implements ShouldQueue
$data = null;
}
private function processTaskStatuses(array $data) :void
private function processTaskStatuses(array $data): void
{
info('in task statuses');
TaskStatus::unguard();
@ -1573,7 +1573,7 @@ class Import implements ShouldQueue
info('finished task statuses');
}
private function processExpenseCategories(array $data) :void
private function processExpenseCategories(array $data): void
{
ExpenseCategory::unguard();
@ -1602,7 +1602,7 @@ class Import implements ShouldQueue
$data = null;
}
private function processTasks(array $data) :void
private function processTasks(array $data): void
{
Task::unguard();
@ -1657,7 +1657,7 @@ class Import implements ShouldQueue
$data = null;
}
private function processProjects(array $data) :void
private function processProjects(array $data): void
{
Project::unguard();
@ -1688,7 +1688,7 @@ class Import implements ShouldQueue
$data = null;
}
private function processExpenses(array $data) :void
private function processExpenses(array $data): void
{
Expense::unguard();
@ -1765,7 +1765,7 @@ class Import implements ShouldQueue
{
$user = MultiDB::hasUser(['email' => $data]);
if (! $user) {
if (!$user) {
$user = UserFactory::create($this->company->account->id);
}
@ -1780,12 +1780,12 @@ class Import implements ShouldQueue
*/
public function transformId($resource, string $old): int
{
if (! array_key_exists($resource, $this->ids)) {
if (!array_key_exists($resource, $this->ids)) {
info(print_r($resource, 1));
throw new Exception("Resource {$resource} not available.");
}
if (! array_key_exists("{$resource}_{$old}", $this->ids[$resource])) {
if (!array_key_exists("{$resource}_{$old}", $this->ids[$resource])) {
throw new Exception("Missing resource key: {$resource}_{$old}");
}
@ -1794,11 +1794,11 @@ class Import implements ShouldQueue
private function tryTransformingId($resource, string $old): ?int
{
if (! array_key_exists($resource, $this->ids)) {
if (!array_key_exists($resource, $this->ids)) {
return false;
}
if (! array_key_exists("{$resource}_{$old}", $this->ids[$resource])) {
if (!array_key_exists("{$resource}_{$old}", $this->ids[$resource])) {
return false;
}
@ -1814,11 +1814,11 @@ class Import implements ShouldQueue
*/
public function processUserId(array $resource)
{
if (! array_key_exists('user_id', $resource)) {
if (!array_key_exists('user_id', $resource)) {
return $this->user->id;
}
if (array_key_exists('user_id', $resource) && ! array_key_exists('users', $this->ids)) {
if (array_key_exists('user_id', $resource) && !array_key_exists('users', $this->ids)) {
return $this->user->id;
}
@ -1834,7 +1834,7 @@ class Import implements ShouldQueue
$job_failure->string_metric6 = $exception->getMessage();
LightLogs::create($job_failure)
->queue();
->queue();
info(print_r($exception->getMessage(), 1));
@ -1866,7 +1866,8 @@ class Import implements ShouldQueue
if (Ninja::isHosted()) {
try {
\Modules\Admin\Jobs\Account\NinjaUser::dispatchNow($data, $this->company);
\Modules\Admin\Jobs\Account\NinjaUser::dispatchSync($data, $this->company);
} catch (\Exception $e) {
nlog($e->getMessage());
}

View File

@ -116,7 +116,7 @@ class StartMigration implements ShouldQueue
throw new NonExistingMigrationFile('Migration file does not exist, or it is corrupted.');
}
Import::dispatchNow($file, $this->company, $this->user);
Import::dispatchSync($file, $this->company, $this->user);
Storage::deleteDirectory(public_path("storage/migrations/{$filename}"));

View File

@ -27,6 +27,6 @@ class ReachWorkflowSettings
{
MultiDB::setDb($event->company->db);
QuoteWorkflowSettings::dispatchNow($event->quote);
QuoteWorkflowSettings::dispatchSync($event->quote);
}
}

View File

@ -133,7 +133,7 @@ class TemplateEmail extends Mailable
}
if ($this->invitation && $this->invitation->invoice && $settings->ubl_email_attachment && $this->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) {
$ubl_string = CreateUbl::dispatchNow($this->invitation->invoice);
$ubl_string = (new CreateUbl($this->invitation->invoice))->handle();
if ($ubl_string) {
$this->attachData($ubl_string, $this->invitation->invoice->getFileName('xml'));

View File

@ -283,7 +283,7 @@ class Credit extends BaseModel
if (Ninja::isHosted() && $portal && Storage::disk(config('filesystems.default'))->exists($file_path)) {
return Storage::disk(config('filesystems.default'))->{$type}($file_path);
} elseif (Ninja::isHosted() && $portal) {
$file_path = CreateEntityPdf::dispatchNow($invitation, config('filesystems.default'));
$file_path = (new CreateEntityPdf($invitation, config('filesystems.default')))->handle();
return Storage::disk(config('filesystems.default'))->{$type}($file_path);
}
@ -292,7 +292,8 @@ class Credit extends BaseModel
return Storage::disk('public')->{$type}($file_path);
}
$file_path = CreateEntityPdf::dispatchNow($invitation);
$file_path = (new CreateEntityPdf($invitation))->handle();
return Storage::disk('public')->{$type}($file_path);
}

View File

@ -130,7 +130,7 @@ class CreditInvitation extends BaseModel
if (! Storage::exists($this->credit->client->credit_filepath($this).$this->credit->numberFormatter().'.pdf')) {
event(new CreditWasUpdated($this, $this->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
CreateEntityPdf::dispatchNow($this);
CreateEntityPdf::dispatchSync($this);
}
return $storage_path;

View File

@ -443,7 +443,7 @@ class Invoice extends BaseModel
if (Ninja::isHosted() && $portal && $file_exists) {
return Storage::disk(config('filesystems.default'))->{$type}($file_path);
} elseif (Ninja::isHosted()) {
$file_path = CreateEntityPdf::dispatchNow($invitation, config('filesystems.default'));
$file_path = (new CreateEntityPdf($invitation, config('filesystems.default')))->handle();
return Storage::disk(config('filesystems.default'))->{$type}($file_path);
}
@ -458,7 +458,7 @@ class Invoice extends BaseModel
return Storage::disk('public')->{$type}($file_path);
}
$file_path = CreateEntityPdf::dispatchNow($invitation);
$file_path = (new CreateEntityPdf($invitation))->handle();
return Storage::disk('public')->{$type}($file_path);
}

View File

@ -112,7 +112,7 @@ class InvoiceInvitation extends BaseModel
if (! Storage::exists($this->invoice->client->invoice_filepath($this).$this->invoice->numberFormatter().'.pdf')) {
event(new InvoiceWasUpdated($this->invoice, $this->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
CreateEntityPdf::dispatchNow($this);
CreateEntityPdf::dispatchSync($this);
}
return $storage_path;

View File

@ -212,7 +212,7 @@ class PurchaseOrder extends BaseModel
if (Ninja::isHosted() && $portal && Storage::disk(config('filesystems.default'))->exists($file_path)) {
return Storage::disk(config('filesystems.default'))->{$type}($file_path);
} elseif (Ninja::isHosted() && $portal) {
$file_path = CreatePurchaseOrderPdf::dispatchNow($invitation, config('filesystems.default'));
$file_path = (new CreatePurchaseOrderPdf($invitation, config('filesystems.default')))->handle();
return Storage::disk(config('filesystems.default'))->{$type}($file_path);
}
@ -221,8 +221,7 @@ class PurchaseOrder extends BaseModel
return Storage::disk('public')->{$type}($file_path);
}
$file_path = CreatePurchaseOrderPdf::dispatchNow($invitation);
$file_path = (new CreatePurchaseOrderPdf($invitation))->handle();
return Storage::disk('public')->{$type}($file_path);
}

View File

@ -242,8 +242,8 @@ class Quote extends BaseModel
if (Ninja::isHosted() && $portal && Storage::disk(config('filesystems.default'))->exists($file_path)) {
return Storage::disk(config('filesystems.default'))->{$type}($file_path);
} elseif (Ninja::isHosted() && $portal) {
$file_path = CreateEntityPdf::dispatchNow($invitation, config('filesystems.default'));
$file_path = (new CreateEntityPdf($invitation, config('filesystems.default')))->handle();
return Storage::disk(config('filesystems.default'))->{$type}($file_path);
}
@ -251,7 +251,7 @@ class Quote extends BaseModel
return Storage::disk('public')->{$type}($file_path);
}
$file_path = CreateEntityPdf::dispatchNow($invitation);
$file_path = (new CreateEntityPdf($invitation))->handle();
return Storage::disk('public')->{$type}($file_path);
}

View File

@ -134,7 +134,7 @@ class QuoteInvitation extends BaseModel
if (! Storage::exists($this->quote->client->quote_filepath($this).$this->quote->numberFormatter().'.pdf')) {
event(new QuoteWasUpdated($this->quote, $this->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
CreateEntityPdf::dispatchNow($this);
CreateEntityPdf::dispatchSync($this);
}
return $storage_path;

View File

@ -94,7 +94,7 @@ class BaseNotification extends Notification
}
if ($this->entity instanceof Invoice && $this->settings->ubl_email_attachment) {
$ubl_string = CreateUbl::dispatchNow($this->entity);
$ubl_string = (new Createubl($this->entity))->handle();
$mail_message->attachData($ubl_string, $this->entity->getFileName('xml'));
}

View File

@ -164,7 +164,7 @@ class PaymentRepository extends BaseRepository
if ($credit) {
$credit = $credit->service()->markSent()->save();
ApplyCreditPayment::dispatchNow($credit, $payment, $paid_credit['amount'], $credit->company);
ApplyCreditPayment::dispatchSync($credit, $payment, $paid_credit['amount'], $credit->company);
}
}
}

View File

@ -196,7 +196,7 @@ class CreditService
try {
if ($force) {
$this->credit->invitations->each(function ($invitation) {
CreateEntityPdf::dispatchNow($invitation);
CreateEntityPdf::dispatchSync($invitation);
});
return $this;
@ -243,7 +243,7 @@ class CreditService
public function deletePdf()
{
$this->credit->invitations->each(function ($invitation) {
UnlinkFile::dispatchNow(config('filesystems.default'), $this->credit->client->credit_filepath($invitation).$this->credit->numberFormatter().'.pdf');
UnlinkFile::dispatchSync(config('filesystems.default'), $this->credit->client->credit_filepath($invitation).$this->credit->numberFormatter().'.pdf');
});
return $this;

View File

@ -44,8 +44,7 @@ class GetCreditPdf extends AbstractService
// $disk = 'public';
$disk = config('filesystems.default');
$file_path = CreateEntityPdf::dispatchNow($this->invitation);
$file_path = (new CreateEntityPdf($this->invitation))->handle();
return $file_path;
}
}

View File

@ -48,7 +48,7 @@ class SendEmail
// $email_builder = (new CreditEmail())->build($invitation, $this->reminder_template);
// EmailCredit::dispatchNow($email_builder, $invitation, $invitation->company);
EmailEntity::dispatchNow($invitation, $invitation->company, $this->reminder_template);
EmailEntity::dispatchSync($invitation, $invitation->company, $this->reminder_template);
}
});

View File

@ -49,7 +49,7 @@ class GetInvoicePdf extends AbstractService
$file = Storage::disk($disk)->exists($file_path);
if (! $file) {
$file_path = CreateEntityPdf::dispatchNow($invitation);
$file_path = (new CreateEntityPdf($invitation))->handle();
}
return $file_path;

View File

@ -418,7 +418,7 @@ class InvoiceService
try {
if ($force) {
$this->invoice->invitations->each(function ($invitation) {
CreateEntityPdf::dispatchNow($invitation);
CreateEntityPdf::dispatchSync($invitation);
});
return $this;
@ -557,7 +557,7 @@ class InvoiceService
public function adjustInventory($old_invoice = [])
{
if ($this->invoice->company->track_inventory) {
AdjustProductInventory::dispatchNow($this->invoice->company, $this->invoice, $old_invoice);
AdjustProductInventory::dispatchSync($this->invoice->company, $this->invoice, $old_invoice);
}
return $this;

View File

@ -45,7 +45,7 @@ class SendEmail extends AbstractService
$this->invoice->invitations->each(function ($invitation) {
if (! $invitation->contact->trashed() && $invitation->contact->email) {
EmailEntity::dispatchNow($invitation, $invitation->company, $this->reminder_template);
EmailEntity::dispatchSync($invitation, $invitation->company, $this->reminder_template);
}
});
}

View File

@ -36,9 +36,9 @@ class SendEmail
$this->payment->client->contacts->each(function ($contact) {
if ($contact->email) {
EmailPayment::dispatchNow($this->payment, $this->payment->company, $contact);
return false;
// dispatchSync always returns 0, in this case we can handle it without returning false;
return EmailPayment::dispatchSync($this->payment, $this->payment->company, $contact);
// return false;
//11-01-2021 only send payment receipt to the first contact
}
});

View File

@ -49,7 +49,7 @@ class GetPurchaseOrderPdf extends AbstractService
$file = Storage::disk($disk)->exists($file_path);
if (! $file) {
$file_path = CreatePurchaseOrderPdf::dispatchNow($invitation);
$file_path = (new CreatePurchaseOrderPdf($invitation))->handle();
}
return $file_path;

View File

@ -91,7 +91,7 @@ class PurchaseOrderService
try {
if ($force) {
$this->purchase_order->invitations->each(function ($invitation) {
CreatePurchaseOrderPdf::dispatchNow($invitation);
CreatePurchaseOrderPdf::dispatchSync($invitation);
});
return $this;

View File

@ -29,7 +29,7 @@ class GetQuotePdf extends AbstractService
public function run()
{
if (! $this->contact) {
if (!$this->contact) {
$this->contact = $this->quote->client->primary_contact()->first() ?: $this->quote->client->contacts()->first();
}
@ -37,12 +37,13 @@ class GetQuotePdf extends AbstractService
$path = $this->quote->client->quote_filepath($invitation);
$file_path = $path.$this->quote->numberFormatter().'.pdf';
$file_path = $path . $this->quote->numberFormatter() . '.pdf';
// $disk = 'public';
$disk = config('filesystems.default');
$file_path = CreateEntityPdf::dispatchNow($invitation);
$file_path = (new CreateEntityPdf($invitation))->handle();
return $file_path;
//return Storage::disk($disk)->path($file_path);

View File

@ -136,7 +136,7 @@ class QuoteService
try {
if ($force) {
$this->quote->invitations->each(function ($invitation) {
CreateEntityPdf::dispatchNow($invitation);
CreateEntityPdf::dispatchSync($invitation);
});
return $this;
@ -225,7 +225,7 @@ class QuoteService
public function deletePdf()
{
$this->quote->invitations->each(function ($invitation) {
UnlinkFile::dispatchNow(config('filesystems.default'), $this->quote->client->quote_filepath($invitation).$this->quote->numberFormatter().'.pdf');
UnlinkFile::dispatchSync(config('filesystems.default'), $this->quote->client->quote_filepath($invitation).$this->quote->numberFormatter().'.pdf');
});
return $this;

View File

@ -43,7 +43,7 @@ class SendEmail
$this->quote->invitations->each(function ($invitation) {
if (! $invitation->contact->trashed() && $invitation->contact->email) {
EmailEntity::dispatchNow($invitation, $invitation->company, $this->reminder_template);
EmailEntity::dispatchSync($invitation, $invitation->company, $this->reminder_template);
}
});

View File

@ -46,7 +46,7 @@ class GetInvoicePdf extends AbstractService
$file = Storage::disk($disk)->exists($file_path);
if (! $file) {
$file_path = CreateEntityPdf::dispatchNow($invitation);
$file_path = (new CreateEntityPdf($invitation))->handle();
}
return $file_path;

View File

@ -85,7 +85,7 @@ class RecurringService
public function deletePdf()
{
$this->recurring_entity->invitations->each(function ($invitation) {
UnlinkFile::dispatchNow(config('filesystems.default'), $this->recurring_entity->client->recurring_invoice_filepath($invitation).$this->recurring_entity->numberFormatter().'.pdf');
UnlinkFile::dispatchSync(config('filesystems.default'), $this->recurring_entity->client->recurring_invoice_filepath($invitation).$this->recurring_entity->numberFormatter().'.pdf');
});
return $this;

View File

@ -34,7 +34,7 @@ trait SavesDocuments
}
foreach ($document_array as $document) {
$document = UploadFile::dispatchNow(
$document = (new UploadFile(
$document,
UploadFile::DOCUMENT,
$user,
@ -42,7 +42,7 @@ trait SavesDocuments
$entity,
null,
$is_public
);
))->handle();
}
}
@ -62,7 +62,7 @@ trait SavesDocuments
return false;
}
$document = UploadFile::dispatchNow(
$document = (new UploadFile(
$document,
UploadFile::DOCUMENT,
$user,
@ -70,6 +70,6 @@ trait SavesDocuments
$entity,
null,
$is_public
);
))->handle();
}
}

View File

@ -23,15 +23,14 @@ trait Uploadable
public function removeLogo($company)
{
if (Storage::exists($company->settings->company_logo)) {
UnlinkFile::dispatchNow(config('filesystems.default'), $company->settings->company_logo);
UnlinkFile::dispatchSync(config('filesystems.default'), $company->settings->company_logo);
}
}
public function uploadLogo($file, $company, $entity)
{
if ($file) {
$path = UploadAvatar::dispatchNow($file, $company->company_key);
$path = (new UploadAvatar($file, $company->company_key))->handle();
if ($path) {
$settings = $entity->settings;
$settings->company_logo = $path;

View File

@ -28,7 +28,7 @@ class ExportCompanyTest extends TestCase
use MakesHash;
use MockAccountData;
protected function setUp() :void
protected function setUp(): void
{
parent::setUp();
@ -42,14 +42,14 @@ class ExportCompanyTest extends TestCase
$this->withoutExceptionHandling();
if (! config('ninja.testvars.stripe')) {
if (!config('ninja.testvars.stripe')) {
$this->markTestSkipped('Cannot write to TMP - skipping');
}
}
public function testCompanyExport()
{
$res = CompanyExport::dispatchNow($this->company, $this->company->users->first());
$res = (new CompanyExport($this->company, $this->company->users->first()))->handle();
$this->assertTrue($res);
}

View File

@ -87,7 +87,7 @@ class ImportCsvTest extends TestCase
Cache::put($hash.'-client', base64_encode($csv), 360);
CSVImport::dispatchNow($data, $this->company);
CSVImport::dispatchSync($data, $this->company);
$this->assertGreaterThan($pre_import, Client::count());
}
@ -117,7 +117,7 @@ class ImportCsvTest extends TestCase
Cache::put($hash.'-client', base64_encode($csv), 360);
CSVImport::dispatchNow($data, $this->company);
CSVImport::dispatchSync($data, $this->company);
/*Now import invoices*/
$csv = file_get_contents(base_path().'/tests/Feature/Import/invoice.csv');
@ -152,7 +152,7 @@ class ImportCsvTest extends TestCase
Cache::put($hash.'-invoice', base64_encode($csv), 360);
CSVImport::dispatchNow($data, $this->company);
CSVImport::dispatchSync($data, $this->company);
$this->assertGreaterThan($pre_import, Invoice::count());
}
@ -181,7 +181,7 @@ class ImportCsvTest extends TestCase
Cache::put($hash.'-vendor', base64_encode($csv), 360);
CSVImport::dispatchNow($data, $this->company);
CSVImport::dispatchSync($data, $this->company);
$this->assertGreaterThan($pre_import, Vendor::count());
}
@ -207,7 +207,7 @@ class ImportCsvTest extends TestCase
Cache::put($hash.'-product', base64_encode($csv), 360);
CSVImport::dispatchNow($data, $this->company);
CSVImport::dispatchSync($data, $this->company);
$this->assertGreaterThan($pre_import, Product::count());
}
@ -233,7 +233,7 @@ class ImportCsvTest extends TestCase
Cache::put($hash.'-expense', base64_encode($csv), 360);
CSVImport::dispatchNow($data, $this->company);
CSVImport::dispatchSync($data, $this->company);
$this->assertGreaterThan($pre_import, Expense::count());
}
@ -264,7 +264,7 @@ class ImportCsvTest extends TestCase
Cache::put($hash.'-client', base64_encode($csv), 360);
CSVImport::dispatchNow($data, $this->company);
CSVImport::dispatchSync($data, $this->company);
/*Now import invoices*/
$csv = file_get_contents(base_path().'/tests/Feature/Import/invoice.csv');
@ -299,7 +299,7 @@ class ImportCsvTest extends TestCase
Cache::put($hash.'-invoice', base64_encode($csv), 360);
CSVImport::dispatchNow($data, $this->company);
CSVImport::dispatchSync($data, $this->company);
/* Test Now import payments*/
@ -324,7 +324,7 @@ class ImportCsvTest extends TestCase
Cache::put($hash.'-payment', base64_encode($csv), 360);
CSVImport::dispatchNow($data, $this->company);
CSVImport::dispatchSync($data, $this->company);
$this->assertGreaterThan($pre_import, Payment::count());
}

View File

@ -61,7 +61,7 @@ class InvoiceEmailTest extends TestCase
$this->invoice->invitations->each(function ($invitation) {
if ($invitation->contact->send_email && $invitation->contact->email) {
EmailEntity::dispatchNow($invitation, $invitation->company);
EmailEntity::dispatch($invitation, $invitation->company);
$this->expectsJobs(EmailEntity::class);
}
@ -89,7 +89,7 @@ class InvoiceEmailTest extends TestCase
$this->invoice->invitations->each(function ($invitation) {
if ($invitation->contact->send_email && $invitation->contact->email) {
EmailEntity::dispatchNow($invitation, $invitation->company);
EmailEntity::dispatch($invitation, $invitation->company);
$this->expectsJobs(EmailEntity::class);
}
@ -117,7 +117,7 @@ class InvoiceEmailTest extends TestCase
$this->invoice->invitations->each(function ($invitation) {
if ($invitation->contact->send_email && $invitation->contact->email) {
EmailEntity::dispatchNow($invitation, $invitation->company);
EmailEntity::dispatch($invitation, $invitation->company);
$this->expectsJobs(EmailEntity::class);
}
@ -140,7 +140,7 @@ class InvoiceEmailTest extends TestCase
$this->invoice->invitations->each(function ($invitation) {
if ($invitation->contact->send_email && $invitation->contact->email) {
EmailEntity::dispatchNow($invitation, $invitation->company);
EmailEntity::dispatch($invitation, $invitation->company);
$this->expectsJobs(EmailEntity::class);
}

View File

@ -39,21 +39,21 @@ class PdfCreatorTest extends TestCase
public function testCreditPdfCreated()
{
$credit_path = CreateEntityPdf::dispatchNow($this->credit->invitations->first());
$credit_path = (new CreateEntityPdf($this->credit->invitations->first()))->handle();
$this->assertTrue(Storage::disk('public')->exists($credit_path));
}
public function testInvoicePdfCreated()
{
$invoice_path = CreateEntityPdf::dispatchNow($this->invoice->invitations->first());
$invoice_path = (new CreateEntityPdf($this->invoice->invitations->first()))->handle();
$this->assertTrue(Storage::disk('public')->exists($invoice_path));
}
public function testQuotePdfCreated()
{
$quote_path = CreateEntityPdf::dispatchNow($this->quote->invitations->first());
$quote_path = (new CreateEntityPdf($this->quote->invitations->first()))->handle();
$this->assertTrue(Storage::disk('public')->exists($quote_path));
}

View File

@ -55,7 +55,7 @@ class UpdateExchangeRatesTest extends TestCase
$currency_api = json_decode($response->getBody());
UpdateExchangeRates::dispatchNow();
UpdateExchangeRates::dispatchSync();
$currencies = Cache::get('currencies');

View File

@ -34,7 +34,7 @@ class InvoiceUploadTest extends TestCase
public function testInvoiceUploadWorks()
{
CreateEntityPdf::dispatchNow($this->invoice->invitations->first());
CreateEntityPdf::dispatchSync($this->invoice->invitations->first());
$this->assertNotNull($this->invoice->service()->getInvoicePdf($this->invoice->client->primary_contact()->first()));
}

View File

@ -70,7 +70,7 @@ class PostmarkWebhookTest extends TestCase
$invitation->message_id = '00000000-0000-0000-0000-000000000000';
$invitation->save();
ProcessPostmarkWebhook::dispatchNow([
ProcessPostmarkWebhook::dispatchSync([
'RecordType' => 'Delivery',
'ServerID' => '23',
'MessageStream' => 'outbound',
@ -118,7 +118,7 @@ class PostmarkWebhookTest extends TestCase
$invitation->message_id = '00000000-0000-0000-0000-000000000001';
$invitation->save();
ProcessPostmarkWebhook::dispatchNow([
ProcessPostmarkWebhook::dispatchSync([
'RecordType' => 'SpamComplaint',
'ServerID' => '23',
'MessageStream' => 'outbound',

View File

@ -42,13 +42,13 @@ class UploadFileTest extends TestCase
{
$image = UploadedFile::fake()->image('avatar.jpg');
$document = UploadFile::dispatchNow(
$document = (new UploadFile(
$image,
UploadFile::IMAGE,
$this->invoice->user,
$this->invoice->company,
$this->invoice
);
))->handle();
$this->assertNotNull($document);
}

View File

@ -236,7 +236,7 @@ trait MockAccountData
// auth()->login($user);
CreateCompanyTaskStatuses::dispatchNow($this->company, $this->user);
CreateCompanyTaskStatuses::dispatchSync($this->company, $this->user);
$this->cu = CompanyUserFactory::create($user->id, $this->company->id, $this->account->id);
$this->cu->is_owner = true;

View File

@ -25,7 +25,7 @@ class CompanyDocumentsTest extends TestCase
use MockAccountData;
use DatabaseTransactions;
protected function setUp() :void
protected function setUp(): void
{
parent::setUp();
@ -44,13 +44,13 @@ class CompanyDocumentsTest extends TestCase
$image = UploadedFile::fake()->image('avatar.jpg');
$document = UploadFile::dispatchNow(
$document = (new UploadFile(
$image,
UploadFile::IMAGE,
$this->user,
$this->company,
$this->invoice
);
$this->invoice))->handle();
$this->assertNotNull($document);

View File

@ -38,8 +38,7 @@ class UBLInvoiceTest extends TestCase
public function testUblGenerates()
{
$ubl = CreateUbl::dispatchNow($this->invoice);
$ubl = (new CreateUbl($this->invoice))->handle();
$this->assertNotNull($ubl);
}
}