diff --git a/app/Http/Controllers/PreviewController.php b/app/Http/Controllers/PreviewController.php index ba81318fcf..eab8fd4388 100644 --- a/app/Http/Controllers/PreviewController.php +++ b/app/Http/Controllers/PreviewController.php @@ -193,7 +193,7 @@ class PreviewController extends BaseController try { - DB::connection(config('database.default'))->beginTransaction(); + DB::connection(auth()->user()->company()->db)->beginTransaction(); if($request->has('entity_id')){ @@ -253,7 +253,7 @@ class PreviewController extends BaseController ->design($template) ->build(); - DB::connection(config('database.default'))->rollBack(); + DB::connection(auth()->user()->company()->db)->rollBack(); if (request()->query('html') == 'true') { return $maker->getCompiledHTML; @@ -263,7 +263,7 @@ class PreviewController extends BaseController } catch(\Exception $e){ - DB::connection(config('database.default'))->rollBack(); + DB::connection(auth()->user()->company()->db)->rollBack(); return; } @@ -302,7 +302,7 @@ class PreviewController extends BaseController $t = app('translator'); $t->replace(Ninja::transformTranslations(auth()->user()->company()->settings)); - DB::connection(config('database.default'))->beginTransaction(); + DB::connection(auth()->user()->company()->db)->beginTransaction(); $client = Client::factory()->create([ 'user_id' => auth()->user()->id, @@ -377,7 +377,7 @@ class PreviewController extends BaseController $file_path = PreviewPdf::dispatchNow($maker->getCompiledHTML(true), auth()->user()->company()); - DB::connection(config('database.default'))->rollBack(); + DB::connection(auth()->user()->company()->db)->rollBack(); $response = Response::make($file_path, 200); $response->header('Content-Type', 'application/pdf'); diff --git a/app/Jobs/RecurringInvoice/SendRecurring.php b/app/Jobs/RecurringInvoice/SendRecurring.php index 96ed926e73..6d5b6986fc 100644 --- a/app/Jobs/RecurringInvoice/SendRecurring.php +++ b/app/Jobs/RecurringInvoice/SendRecurring.php @@ -61,12 +61,22 @@ class SendRecurring implements ShouldQueue $invoice->date = now()->format('Y-m-d'); - $invoice = $invoice->service() - ->markSent() - ->applyNumber() - ->createInvitations() - ->fillDefaults() - ->save(); + if($invoice->client->getSetting('auto_email_invoice')) + { + $invoice = $invoice->service() + ->markSent() + ->applyNumber() + ->createInvitations() + ->fillDefaults() + ->save(); + + } + else{ + + $invoice = $invoice->service() + ->fillDefaults() + ->save(); + } nlog("updating recurring invoice dates"); /* Set next date here to prevent a recurring loop forming */ diff --git a/app/PaymentDrivers/Stripe/ACH.php b/app/PaymentDrivers/Stripe/ACH.php index ea9dc59887..1e4a365305 100644 --- a/app/PaymentDrivers/Stripe/ACH.php +++ b/app/PaymentDrivers/Stripe/ACH.php @@ -105,7 +105,6 @@ class ACH $this->stripe->init(); - // $bank_account = Customer::retrieveSource($request->customer, ['source' => $request->source], $this->stripe->stripe_connect_auth); $bank_account = Customer::retrieveSource($request->customer, $request->source, [], $this->stripe->stripe_connect_auth); try {