diff --git a/app/Http/Controllers/SetupController.php b/app/Http/Controllers/SetupController.php index 07d0ea1ed22e..66ad2612676a 100644 --- a/app/Http/Controllers/SetupController.php +++ b/app/Http/Controllers/SetupController.php @@ -52,11 +52,7 @@ class SetupController extends Controller if ($check['system_health'] == true && $check['simple_db_check'] && Schema::hasTable('accounts') && $account = Account::all()->first()) { return redirect('/'); } - - // not sure if we really need this. - // if(File::exists(base_path('.env'))) - // abort(400, '.env file already exists, delete file to start Setup again.'); - + return view('setup.index', ['check' => $check]); } diff --git a/app/Listeners/Invoice/InvoiceArchivedActivity.php b/app/Listeners/Invoice/InvoiceArchivedActivity.php index 4b37f0070c08..63903cda928b 100644 --- a/app/Listeners/Invoice/InvoiceArchivedActivity.php +++ b/app/Listeners/Invoice/InvoiceArchivedActivity.php @@ -42,8 +42,6 @@ class InvoiceArchivedActivity implements ShouldQueue public function handle($event) { MultiDB::setDb($event->company->db); - - // $event->invoice->service()->deletePdf(); $fields = new stdClass; diff --git a/app/Services/Invoice/InvoiceService.php b/app/Services/Invoice/InvoiceService.php index 97919f0a5011..5b91c111a66b 100644 --- a/app/Services/Invoice/InvoiceService.php +++ b/app/Services/Invoice/InvoiceService.php @@ -11,6 +11,7 @@ namespace App\Services\Invoice; +use App\Events\Invoice\InvoiceWasArchived; use App\Jobs\Entity\CreateEntityPdf; use App\Jobs\Invoice\InvoiceWorkflowSettings; use App\Jobs\Util\UnlinkFile; @@ -539,35 +540,16 @@ class InvoiceService if ($this->invoice->status_id == Invoice::STATUS_PAID && $this->invoice->client->getSetting('auto_archive_invoice')) { /* Throws: Payment amount xxx does not match invoice totals. */ - $base_repository = new BaseRepository(); - $base_repository->archive($this->invoice); - - } + if ($this->invoice->trashed()) + return; - /* - //if paid invoice is attached to a recurring invoice - check if we need to unpause the recurring invoice + $this->invoice->delete(); + + event(new InvoiceWasArchived($this->invoice, $this->invoice->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null))); - if ($this->invoice->status_id == Invoice::STATUS_PAID && - $this->invoice->recurring_id && - $this->invoice->company->pause_recurring_until_paid && - ($this->invoice->recurring_invoice->status_id != RecurringInvoice::STATUS_ACTIVE || $this->invoice->recurring_invoice->status_id != RecurringInvoice::STATUS_COMPLETED)) - { - $recurring_invoice = $this->invoice->recurring_invoice; - - // Check next_send_date if it is in the past - calculate - $next_send_date = Carbon::parse($recurring_invoice->next_send_date)->startOfDay(); - - if(next_send_date->lt(now())){ - $recurring_invoice->next_send_date = $recurring_invoice->nextDateByFrequency(now()->format('Y-m-d')); - $recurring_invoice->save(); - } - - // Start the recurring invoice - $recurring_invoice->service() - ->start(); } - */ + return $this; } diff --git a/app/Services/Payment/UpdateInvoicePayment.php b/app/Services/Payment/UpdateInvoicePayment.php index 1a7529058ec7..3a34b2e80310 100644 --- a/app/Services/Payment/UpdateInvoicePayment.php +++ b/app/Services/Payment/UpdateInvoicePayment.php @@ -71,6 +71,9 @@ class UpdateInvoicePayment ->updatePaidToDate($paid_amount) ->updateStatus() ->touchPdf() + ->save(); + + $invoice->service() ->workFlow() ->save();