1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00

Set Recurring to draft if not being sent at time of creation

This commit is contained in:
David Bomba 2021-08-05 09:06:13 +10:00
parent 3a3f43a36f
commit be85175134
3 changed files with 21 additions and 12 deletions

View File

@ -193,7 +193,7 @@ class PreviewController extends BaseController
try { try {
DB::connection(config('database.default'))->beginTransaction(); DB::connection(auth()->user()->company()->db)->beginTransaction();
if($request->has('entity_id')){ if($request->has('entity_id')){
@ -253,7 +253,7 @@ class PreviewController extends BaseController
->design($template) ->design($template)
->build(); ->build();
DB::connection(config('database.default'))->rollBack(); DB::connection(auth()->user()->company()->db)->rollBack();
if (request()->query('html') == 'true') { if (request()->query('html') == 'true') {
return $maker->getCompiledHTML; return $maker->getCompiledHTML;
@ -263,7 +263,7 @@ class PreviewController extends BaseController
} }
catch(\Exception $e){ catch(\Exception $e){
DB::connection(config('database.default'))->rollBack(); DB::connection(auth()->user()->company()->db)->rollBack();
return; return;
} }
@ -302,7 +302,7 @@ class PreviewController extends BaseController
$t = app('translator'); $t = app('translator');
$t->replace(Ninja::transformTranslations(auth()->user()->company()->settings)); $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([ $client = Client::factory()->create([
'user_id' => auth()->user()->id, 'user_id' => auth()->user()->id,
@ -377,7 +377,7 @@ class PreviewController extends BaseController
$file_path = PreviewPdf::dispatchNow($maker->getCompiledHTML(true), auth()->user()->company()); $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 = Response::make($file_path, 200);
$response->header('Content-Type', 'application/pdf'); $response->header('Content-Type', 'application/pdf');

View File

@ -61,12 +61,22 @@ class SendRecurring implements ShouldQueue
$invoice->date = now()->format('Y-m-d'); $invoice->date = now()->format('Y-m-d');
$invoice = $invoice->service() if($invoice->client->getSetting('auto_email_invoice'))
->markSent() {
->applyNumber() $invoice = $invoice->service()
->createInvitations() ->markSent()
->fillDefaults() ->applyNumber()
->save(); ->createInvitations()
->fillDefaults()
->save();
}
else{
$invoice = $invoice->service()
->fillDefaults()
->save();
}
nlog("updating recurring invoice dates"); nlog("updating recurring invoice dates");
/* Set next date here to prevent a recurring loop forming */ /* Set next date here to prevent a recurring loop forming */

View File

@ -105,7 +105,6 @@ class ACH
$this->stripe->init(); $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); $bank_account = Customer::retrieveSource($request->customer, $request->source, [], $this->stripe->stripe_connect_auth);
try { try {