From fec8e8b5209c3634a33b1fcb51b97e38c3de3ee2 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 20 Jul 2020 07:54:10 +1000 Subject: [PATCH] Fix bug where restoring a credit wouldn't work --- app/Http/Controllers/CreditController.php | 7 +++++++ app/Http/Middleware/StartupCheck.php | 5 ----- app/Providers/EventServiceProvider.php | 2 +- app/Repositories/BaseRepository.php | 2 +- app/Services/Invoice/TriggeredActions.php | 6 +++--- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/app/Http/Controllers/CreditController.php b/app/Http/Controllers/CreditController.php index 73588356f343..87bd4b1de5b4 100644 --- a/app/Http/Controllers/CreditController.php +++ b/app/Http/Controllers/CreditController.php @@ -536,6 +536,13 @@ class CreditController extends BaseController case 'archive': $this->credit_repository->archive($credit); + if (!$bulk) { + return $this->listResponse($credit); + } + break; + case 'restore': + $this->credit_repository->restore($credit); + if (!$bulk) { return $this->listResponse($credit); } diff --git a/app/Http/Middleware/StartupCheck.php b/app/Http/Middleware/StartupCheck.php index 84a0e1f37cb1..c37fd2fa012e 100644 --- a/app/Http/Middleware/StartupCheck.php +++ b/app/Http/Middleware/StartupCheck.php @@ -39,11 +39,6 @@ class StartupCheck public function handle(Request $request, Closure $next) { // $start = microtime(true); - // Log::error('start up check'); - - if ($request->has('clear_cache')) { - Session::flash('message', 'Cache cleared'); - } /* Make sure our cache is built */ $cached_tables = config('ninja.cached_tables'); diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index 16ced64cc8cc..8019d9409a7d 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -185,7 +185,7 @@ class EventServiceProvider extends ServiceProvider // CreateInvoicePdf::class, ], InvoiceWasPaid::class => [ - CreateInvoiceHtmlBackup::class, + // CreateInvoiceHtmlBackup::class, ], InvoiceWasViewed::class => [ InvoiceViewedActivity::class, diff --git a/app/Repositories/BaseRepository.php b/app/Repositories/BaseRepository.php index fe6a6d2586e8..c96cdf52577f 100644 --- a/app/Repositories/BaseRepository.php +++ b/app/Repositories/BaseRepository.php @@ -252,7 +252,7 @@ class BaseRepository $invitations = collect($data['invitations']); /* Get array of Keys which have been removed from the invitations array and soft delete each invitation */ - $model->invitations->pluck('key')->diff($invitations->pluck('key'))->each(function ($invitation) { + $model->invitations->pluck('key')->diff($invitations->pluck('key'))->each(function ($invitation) use($resource){ $this->getInvitation($invitation, $resource)->delete(); }); diff --git a/app/Services/Invoice/TriggeredActions.php b/app/Services/Invoice/TriggeredActions.php index 8b807031e825..e5b1bfd204f1 100644 --- a/app/Services/Invoice/TriggeredActions.php +++ b/app/Services/Invoice/TriggeredActions.php @@ -44,15 +44,15 @@ class TriggeredActions extends AbstractService public function run() { - if($this->request->has('auto_bill')) { + if($this->request->has('auto_bill') && $this->request->input('auto_bill') == 'true') { $this->invoice = $this->invoice->service()->autoBill()->save(); } - if($this->request->has('paid') && (bool)$this->request->input('paid') !== false) { + if($this->request->has('paid') && $this->request->input('paid') == 'true') { $this->invoice = $this->invoice->service()->markPaid()->save(); } - if($this->request->has('send_email') && (bool)$this->request->input('send_email') !== false) { + if($this->request->has('send_email') && $this->request->input('send_email') == 'true') { $this->sendEmail(); }