From 2f49bc83823516f93eaba6cbf3f4517d858417d8 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 30 Jun 2023 15:43:28 +1000 Subject: [PATCH] v5.6.5 --- VERSION.txt | 2 +- app/Services/Credit/ApplyPayment.php | 4 +-- app/Services/Credit/CreditService.php | 29 +++++++++++++++---- app/Services/Credit/MarkSent.php | 2 +- app/Services/Invoice/ApplyPayment.php | 2 +- app/Services/Invoice/InvoiceService.php | 4 +-- app/Services/Invoice/MarkPaid.php | 2 +- app/Services/Payment/UpdateInvoicePayment.php | 2 +- .../PurchaseOrder/TriggeredActions.php | 4 --- app/Services/Quote/MarkSent.php | 2 +- app/Services/Quote/QuoteService.php | 20 +++++++++++-- app/Services/Recurring/RecurringService.php | 19 +++++++++++- .../Subscription/SubscriptionService.php | 2 +- config/ninja.php | 4 +-- 14 files changed, 73 insertions(+), 25 deletions(-) diff --git a/VERSION.txt b/VERSION.txt index 2a06a418a7..fad8076f30 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.6.4 \ No newline at end of file +5.6.5 \ No newline at end of file diff --git a/app/Services/Credit/ApplyPayment.php b/app/Services/Credit/ApplyPayment.php index 0f8af8b4ae..70639ce020 100644 --- a/app/Services/Credit/ApplyPayment.php +++ b/app/Services/Credit/ApplyPayment.php @@ -137,7 +137,7 @@ class ApplyPayment ->updateBalance($this->amount_applied * -1) ->updatePaidToDate($this->amount_applied) ->updateStatus() - ->touchPdf() + ->deletePdf() ->save(); $this->credit @@ -147,7 +147,7 @@ class ApplyPayment event(new InvoiceWasUpdated($this->invoice, $this->invoice->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null))); if ((int) $this->invoice->balance == 0) { - $this->invoice->service()->touchPdf(); + $this->invoice->service()->deletePdf(); $this->invoice = $this->invoice->fresh(); event(new InvoiceWasPaid($this->invoice, $this->payment, $this->payment->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null))); } diff --git a/app/Services/Credit/CreditService.php b/app/Services/Credit/CreditService.php index ccc61a03d5..811ea7e4cf 100644 --- a/app/Services/Credit/CreditService.php +++ b/app/Services/Credit/CreditService.php @@ -11,15 +11,17 @@ namespace App\Services\Credit; -use App\Factory\PaymentFactory; -use App\Jobs\Entity\CreateEntityPdf; -use App\Jobs\Util\UnlinkFile; +use App\Utils\Ninja; use App\Models\Credit; use App\Models\Payment; use App\Models\PaymentType; +use App\Jobs\Util\UnlinkFile; +use App\Factory\PaymentFactory; +use App\Utils\Traits\MakesHash; +use App\Jobs\Entity\CreateEntityPdf; use App\Repositories\CreditRepository; use App\Repositories\PaymentRepository; -use App\Utils\Traits\MakesHash; +use Illuminate\Support\Facades\Storage; class CreditService { @@ -235,7 +237,24 @@ class CreditService public function deletePdf() { $this->credit->invitations->each(function ($invitation) { - (new UnlinkFile(config('filesystems.default'), $this->credit->client->credit_filepath($invitation).$this->credit->numberFormatter().'.pdf'))->handle(); + // (new UnlinkFile(config('filesystems.default'), $this->credit->client->credit_filepath($invitation).$this->credit->numberFormatter().'.pdf'))->handle(); + + //30-06-2023 + try { + // if (Storage::disk(config('filesystems.default'))->exists($this->invoice->client->invoice_filepath($invitation).$this->invoice->numberFormatter().'.pdf')) { + Storage::disk(config('filesystems.default'))->delete($this->credit->client->credit_filepath($invitation).$this->credit->numberFormatter().'.pdf'); + // } + + // if (Ninja::isHosted() && Storage::disk('public')->exists($this->invoice->client->invoice_filepath($invitation).$this->invoice->numberFormatter().'.pdf')) { + if (Ninja::isHosted()) { + Storage::disk('public')->delete($this->credit->client->credit_filepath($invitation).$this->credit->numberFormatter().'.pdf'); + } + } catch (\Exception $e) { + nlog($e->getMessage()); + } + + + }); return $this; diff --git a/app/Services/Credit/MarkSent.php b/app/Services/Credit/MarkSent.php index 3402a019aa..890f6887c7 100644 --- a/app/Services/Credit/MarkSent.php +++ b/app/Services/Credit/MarkSent.php @@ -42,7 +42,7 @@ class MarkSent ->setStatus(Credit::STATUS_SENT) ->applyNumber() ->adjustBalance($this->credit->amount) - ->touchPdf() + ->deletePdf() ->save(); $this->client diff --git a/app/Services/Invoice/ApplyPayment.php b/app/Services/Invoice/ApplyPayment.php index 542e871876..a0a2fb5f83 100644 --- a/app/Services/Invoice/ApplyPayment.php +++ b/app/Services/Invoice/ApplyPayment.php @@ -92,7 +92,7 @@ class ApplyPayment extends AbstractService } }); - $this->invoice->service()->applyNumber()->workFlow()->touchPdf()->save(); + $this->invoice->service()->applyNumber()->workFlow()->deletePdf()->save(); return $this->invoice; } diff --git a/app/Services/Invoice/InvoiceService.php b/app/Services/Invoice/InvoiceService.php index e0a98b604c..d5a0715ee7 100644 --- a/app/Services/Invoice/InvoiceService.php +++ b/app/Services/Invoice/InvoiceService.php @@ -338,7 +338,7 @@ class InvoiceService return $item; })->toArray(); - $this->touchPdf(); + $this->deletePdf(); return $this; } @@ -405,7 +405,7 @@ class InvoiceService })->toArray(); $this->invoice = $this->invoice->calc()->getInvoice(); - $this->touchPdf(); + $this->deletePdf(); /* 24-03-2022 */ $new_balance = $this->invoice->balance; diff --git a/app/Services/Invoice/MarkPaid.php b/app/Services/Invoice/MarkPaid.php index a056da4b60..6b2c515a97 100644 --- a/app/Services/Invoice/MarkPaid.php +++ b/app/Services/Invoice/MarkPaid.php @@ -102,7 +102,7 @@ class MarkPaid extends AbstractService $this->invoice ->service() ->applyNumber() - ->touchPdf() + ->deletePdf() ->save(); $payment->ledger() diff --git a/app/Services/Payment/UpdateInvoicePayment.php b/app/Services/Payment/UpdateInvoicePayment.php index 4f088eacfc..882cba3e95 100644 --- a/app/Services/Payment/UpdateInvoicePayment.php +++ b/app/Services/Payment/UpdateInvoicePayment.php @@ -79,7 +79,7 @@ class UpdateInvoicePayment $invoice = $invoice->service() ->clearPartial() ->updateStatus() - ->touchPdf() + ->deletePdf() ->workFlow() ->save(); diff --git a/app/Services/PurchaseOrder/TriggeredActions.php b/app/Services/PurchaseOrder/TriggeredActions.php index 02e9e0bdc8..38510fc709 100644 --- a/app/Services/PurchaseOrder/TriggeredActions.php +++ b/app/Services/PurchaseOrder/TriggeredActions.php @@ -43,10 +43,6 @@ class TriggeredActions extends AbstractService $this->purchase_order = $this->purchase_order->service()->markSent()->touchPdf()->save(); } - // if ($this->request->has('cancel') && $this->request->input('cancel') == 'true') { - // $this->purchase_order = $this->purchase_order->service()->handleCancellation()->save(); - // } - if ($this->request->has('save_default_footer') && $this->request->input('save_default_footer') == 'true') { $company = $this->purchase_order->company; $settings = $company->settings; diff --git a/app/Services/Quote/MarkSent.php b/app/Services/Quote/MarkSent.php index fa9c75a565..9969cbfc3f 100644 --- a/app/Services/Quote/MarkSent.php +++ b/app/Services/Quote/MarkSent.php @@ -47,7 +47,7 @@ class MarkSent ->service() ->setStatus(Quote::STATUS_SENT) ->applyNumber() - ->touchPdf() + ->deletePdf() ->save(); event(new QuoteWasMarkedSent($this->quote, $this->quote->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null))); diff --git a/app/Services/Quote/QuoteService.php b/app/Services/Quote/QuoteService.php index fe6189106c..45b38cc0b5 100644 --- a/app/Services/Quote/QuoteService.php +++ b/app/Services/Quote/QuoteService.php @@ -19,6 +19,7 @@ use App\Exceptions\QuoteConversion; use App\Jobs\Entity\CreateEntityPdf; use App\Repositories\QuoteRepository; use App\Events\Quote\QuoteWasApproved; +use Illuminate\Support\Facades\Storage; class QuoteService { @@ -115,7 +116,7 @@ class QuoteService $this->invoice ->service() ->markSent() - ->touchPdf() + ->deletePdf() ->save(); } @@ -224,7 +225,22 @@ class QuoteService public function deletePdf() { $this->quote->invitations->each(function ($invitation) { - (new UnlinkFile(config('filesystems.default'), $this->quote->client->quote_filepath($invitation).$this->quote->numberFormatter().'.pdf'))->handle(); + // (new UnlinkFile(config('filesystems.default'), $this->quote->client->quote_filepath($invitation).$this->quote->numberFormatter().'.pdf'))->handle(); + + //30-06-2023 + try { + // if (Storage::disk(config('filesystems.default'))->exists($this->invoice->client->invoice_filepath($invitation).$this->invoice->numberFormatter().'.pdf')) { + Storage::disk(config('filesystems.default'))->delete($this->quote->client->quote_filepath($invitation).$this->quote->numberFormatter().'.pdf'); + // } + + // if (Ninja::isHosted() && Storage::disk('public')->exists($this->invoice->client->invoice_filepath($invitation).$this->invoice->numberFormatter().'.pdf')) { + if (Ninja::isHosted()) { + Storage::disk('public')->delete($this->quote->client->quote_filepath($invitation).$this->quote->numberFormatter().'.pdf'); + } + } catch (\Exception $e) { + nlog($e->getMessage()); + } + }); return $this; diff --git a/app/Services/Recurring/RecurringService.php b/app/Services/Recurring/RecurringService.php index c962b5f45f..721b94dcd1 100644 --- a/app/Services/Recurring/RecurringService.php +++ b/app/Services/Recurring/RecurringService.php @@ -11,11 +11,13 @@ namespace App\Services\Recurring; +use App\Utils\Ninja; use App\Jobs\Util\UnlinkFile; use App\Models\RecurringQuote; use Illuminate\Support\Carbon; use App\Models\RecurringExpense; use App\Models\RecurringInvoice; +use Illuminate\Support\Facades\Storage; use App\Jobs\RecurringInvoice\SendRecurring; class RecurringService @@ -88,7 +90,22 @@ class RecurringService public function deletePdf() { $this->recurring_entity->invitations->each(function ($invitation) { - (new UnlinkFile(config('filesystems.default'), $this->recurring_entity->client->recurring_invoice_filepath($invitation) . $this->recurring_entity->numberFormatter().'.pdf'))->handle(); + // (new UnlinkFile(config('filesystems.default'), $this->recurring_entity->client->recurring_invoice_filepath($invitation) . $this->recurring_entity->numberFormatter().'.pdf'))->handle(); + + //30-06-2023 + try { + Storage::disk(config('filesystems.default'))->delete($this->recurring_entity->client->recurring_invoice_filepath($invitation) . $this->recurring_entity->numberFormatter().'.pdf'); + // if (Storage::disk(config('filesystems.default'))->exists($this->invoice->client->invoice_filepath($invitation).$this->invoice->numberFormatter().'.pdf')) { + // } + + // if (Ninja::isHosted() && Storage::disk('public')->exists($this->invoice->client->invoice_filepath($invitation).$this->invoice->numberFormatter().'.pdf')) { + Storage::disk('public')->delete($this->recurring_entity->client->recurring_invoice_filepath($invitation) . $this->recurring_entity->numberFormatter().'.pdf'); + if (Ninja::isHosted()) { + } + } catch (\Exception $e) { + nlog($e->getMessage()); + } + }); diff --git a/app/Services/Subscription/SubscriptionService.php b/app/Services/Subscription/SubscriptionService.php index 32df7b7468..782f08446b 100644 --- a/app/Services/Subscription/SubscriptionService.php +++ b/app/Services/Subscription/SubscriptionService.php @@ -188,7 +188,7 @@ class SubscriptionService //update the invoice and attach to the recurring invoice!!!!! $invoice->recurring_id = $recurring_invoice->id; $invoice->is_proforma = false; - $invoice->service()->touchPdf(); + $invoice->service()->deletePdf(); $invoice->save(); $contact = $invoice->client->contacts()->whereNotNull('email')->first(); diff --git a/config/ninja.php b/config/ninja.php index 482d013122..86642783a8 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -15,8 +15,8 @@ return [ 'require_https' => env('REQUIRE_HTTPS', true), 'app_url' => rtrim(env('APP_URL', ''), '/'), 'app_domain' => env('APP_DOMAIN', 'invoicing.co'), - 'app_version' => '5.6.4', - 'app_tag' => '5.6.4', + 'app_version' => '5.6.5', + 'app_tag' => '5.6.5', 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', ''),