Fixes for restore invoice numbering

This commit is contained in:
David Bomba 2021-05-21 07:58:46 +10:00
parent c0e258eabb
commit 0b7891e24f
4 changed files with 29 additions and 2 deletions

View File

@ -107,6 +107,12 @@ class LicenseController extends BaseController
'errors' => new stdClass, 'errors' => new stdClass,
]; ];
$account->plan_term = Account::PLAN_TERM_YEARLY;
$account->plan_paid = null;
$account->plan_expires = null;
$account->plan = Account::PLAN_FREE;
$account->save();
return response()->json($error, 400); return response()->json($error, 400);
} else { } else {
$account = auth()->user()->company()->account; $account = auth()->user()->company()->account;

View File

@ -116,10 +116,12 @@ class NinjaMailerJob implements ShouldQueue
} catch (\Exception $e) { } catch (\Exception $e) {
nlog("error failed with {$e->getMessage()}"); nlog("error failed with {$e->getMessage()}");
// nlog($e);
if($this->nmo->entity) if($this->nmo->entity)
$this->entityEmailFailed($e->getMessage()); $this->entityEmailFailed($e->getMessage());
if(Ninja::isHosted())
app('sentry')->captureException($e);
} }
} }

View File

@ -1618,6 +1618,9 @@ class Import implements ShouldQueue
->batch(); ->batch();
info(print_r($exception->getMessage(), 1)); info(print_r($exception->getMessage(), 1));
if(Ninja::isHosted())
app('sentry')->captureException($exception);
} }

View File

@ -13,9 +13,13 @@ namespace App\Services\Invoice;
use App\Models\Invoice; use App\Models\Invoice;
use App\Services\AbstractService; use App\Services\AbstractService;
use App\Utils\Ninja;
use App\Utils\Traits\GeneratesCounter;
class HandleRestore extends AbstractService class HandleRestore extends AbstractService
{ {
use GeneratesCounter;
private $invoice; private $invoice;
private $payment_total = 0; private $payment_total = 0;
@ -100,10 +104,22 @@ class HandleRestore extends AbstractService
} }
try { try {
$exists = Invoice::where(['company_id' => $this->invoice->company_id, 'number' => $new_invoice_number])->exists();
if($exists)
$this->invoice->number = $this->getNextInvoiceNumber($this->invoice->client, $this->invoice, $this->invoice->recurring_id);
else
$this->invoice->number = $new_invoice_number; $this->invoice->number = $new_invoice_number;
$this->invoice->save(); $this->invoice->save();
} catch (\Exception $e) { } catch (\Exception $e) {
info("I could not wind back the invoice number"); nlog("I could not wind back the invoice number");
if(Ninja::isHosted()){
\Sentry\captureMessage("I could not wind back the invoice number");
app('sentry')->captureException($e);
}
} }
} }
} }