Cirkovic/ina 16 fixes (#50)

* Dispatch | PdfCreatorTest | Removed deprecated method

* Dispatch | Remove deprecated dispatchNow() method and use dispatchSync or call handle() on class where return is mandatory.
This commit is contained in:
Nikola Cirkovic 2022-06-24 13:15:14 +02:00 committed by GitHub
parent 6bd785cc66
commit c75b1d303f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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

@ -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'));
}
});
@ -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();
@ -476,7 +476,7 @@ 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');
CreateCompanyToken::dispatchSync($company, auth()->user(), 'Google_O_Auth');
}
});
}
@ -652,8 +652,7 @@ class LoginController extends BaseController
{
MultiDB::setDefaultDatabase();
$account = CreateAccount::dispatchNow($new_account, request()->getClientIp());
$account = (new CreateAccount($new_account, request()->getClientIp()))->handle();
if (!$account instanceof Account) {
return $account;
}

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();
@ -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

@ -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']);
@ -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']}";
@ -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

@ -42,7 +42,8 @@ class GetQuotePdf extends AbstractService
// $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

@ -49,7 +49,7 @@ class ExportCompanyTest extends TestCase
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::dispatchSync($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::dispatchSync($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::dispatchSync($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::dispatchSync($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

@ -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);
}
}