From 0f001bb0569a2167c1ccc76e174cea2aa353581e Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 26 Sep 2021 18:44:41 +1000 Subject: [PATCH 1/5] Adjust injection of flutter build --- app/Http/Controllers/BaseController.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/BaseController.php b/app/Http/Controllers/BaseController.php index 0cc06230a100..2da7852bed65 100644 --- a/app/Http/Controllers/BaseController.php +++ b/app/Http/Controllers/BaseController.php @@ -765,6 +765,9 @@ class BaseController extends Controller if(request()->has('build')) { $build = request()->input('build'); } + elseif(Ninja::isHosted()){ + return 'main.dart.js'; + } switch ($build) { case 'wasm': @@ -776,13 +779,10 @@ class BaseController extends Controller case 'next': return 'main.next.dart.js'; case 'profile': - return 'main.profile.dart.js'; + return 'main.profile.dart.js'; default: + return 'main.foss.dart.js'; - if(Ninja::isSelfHost()) - return 'main.foss.dart.js'; - - return 'main.dart.js'; } } From 492dc1cd0442ec93ca90e130fdf67ef17910ef2c Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 26 Sep 2021 19:56:09 +1000 Subject: [PATCH 2/5] Unwind gateway fees prior to marking as paid --- app/Services/Invoice/InvoiceService.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Services/Invoice/InvoiceService.php b/app/Services/Invoice/InvoiceService.php index 7535cae5d0b2..918002f8dbc9 100644 --- a/app/Services/Invoice/InvoiceService.php +++ b/app/Services/Invoice/InvoiceService.php @@ -47,6 +47,8 @@ class InvoiceService */ public function markPaid() { + $this->removeUnpaidGatewayFees(); + $this->invoice = (new MarkPaid($this->invoice))->run(); return $this; From c581c183aca09ca21bdbd588494ee47963ec57a9 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 26 Sep 2021 20:17:09 +1000 Subject: [PATCH 3/5] Clean up Webhook Handler --- app/Jobs/Util/WebhookHandler.php | 6 ++++-- app/PaymentDrivers/BaseDriver.php | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/Jobs/Util/WebhookHandler.php b/app/Jobs/Util/WebhookHandler.php index aad1fb2d537a..5b5a72019b7f 100644 --- a/app/Jobs/Util/WebhookHandler.php +++ b/app/Jobs/Util/WebhookHandler.php @@ -13,6 +13,7 @@ namespace App\Jobs\Util; use App\Jobs\Util\SystemLogger; use App\Libraries\MultiDB; +use App\Models\Client as ClientModel; use App\Models\SystemLog; use App\Models\Webhook; use App\Transformers\ArraySerializer; @@ -147,11 +148,12 @@ class WebhookHandler implements ShouldQueue private function resolveClient() { - if($this->entity->client()->exists()){ + //make sure it isn't an instance of the Client Model + if((!$this->entity instanceof ClientModel) && $this->entity->client()->exists()){ return $this->entity->client; } - return $this->company->clients->first(); + return $this->company->clients()->first(); } public function failed($exception) diff --git a/app/PaymentDrivers/BaseDriver.php b/app/PaymentDrivers/BaseDriver.php index be410cf1134c..eed36b9ff967 100644 --- a/app/PaymentDrivers/BaseDriver.php +++ b/app/PaymentDrivers/BaseDriver.php @@ -287,7 +287,7 @@ class BaseDriver extends AbstractPaymentDriver $invoices->each(function ($invoice) use ($fee_total) { if (collect($invoice->line_items)->contains('type_id', '3')) { - $invoice->service()->toggleFeesPaid()->deletePdf()->save(); + $invoice->service()->toggleFeesPaid()->save(); $invoice->client->service()->updateBalance($fee_total)->save(); $invoice->ledger()->updateInvoiceBalance($fee_total, "Gateway fee adjustment for invoice {$invoice->number}"); } From 7604bf28e6610df3f0c326cad6ac5d1b7979ed14 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 26 Sep 2021 20:46:49 +1000 Subject: [PATCH 4/5] Set nullable type for Backup --- app/Transformers/InvoiceHistoryTransformer.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Transformers/InvoiceHistoryTransformer.php b/app/Transformers/InvoiceHistoryTransformer.php index 2c83cc76b3d2..fa8341e7972b 100644 --- a/app/Transformers/InvoiceHistoryTransformer.php +++ b/app/Transformers/InvoiceHistoryTransformer.php @@ -27,8 +27,11 @@ class InvoiceHistoryTransformer extends EntityTransformer 'activity', ]; - public function transform(Backup $backup) + public function transform(?Backup $backup) { + if(!$backup) + return []; + return [ 'id' => $this->encodePrimaryKey($backup->id), 'activity_id' => $this->encodePrimaryKey($backup->activity_id), From f7251524341697248b7e8bfea8a6ac2f98b415bc Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 26 Sep 2021 22:27:18 +1000 Subject: [PATCH 5/5] Fixes for document inline display --- app/Http/Controllers/DocumentController.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/DocumentController.php b/app/Http/Controllers/DocumentController.php index 73ef54f22d5e..4d0e81101eb1 100644 --- a/app/Http/Controllers/DocumentController.php +++ b/app/Http/Controllers/DocumentController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers; use App\Filters\DocumentFilters; use App\Http\Requests\Document\DestroyDocumentRequest; +use App\Http\Requests\Document\EditDocumentRequest; use App\Http\Requests\Document\ShowDocumentRequest; use App\Http\Requests\Document\StoreDocumentRequest; use App\Http\Requests\Document\UpdateDocumentRequest; @@ -114,9 +115,16 @@ class DocumentController extends BaseController public function download(ShowDocumentRequest $request, Document $document) { + + $headers = []; + + if(request()->input('inline') == 'true') + $headers = array_merge($headers, ['Content-Disposition' => 'inline']); + return response()->streamDownload(function () use ($document) { echo file_get_contents($document->generateUrl()); - }, basename($document->generateUrl())); + }, basename($document->generateUrl()), $headers); + } /** @@ -126,7 +134,7 @@ class DocumentController extends BaseController * @param Document $document * @return Response */ - public function edit(EditDocumentRegquest $request, Document $document) + public function edit(EditDocumentRequest $request, Document $document) { return $this->itemResponse($document); }