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 {
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');

View File

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

View File

@ -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 {