From 5f3d48e189dca6e62235793f61811bb3efd8019e Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 2 Sep 2022 07:36:41 +1000 Subject: [PATCH 01/11] Check for valid bank account property before attempting to iterate --- app/PaymentDrivers/Stripe/UpdatePaymentMethods.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/PaymentDrivers/Stripe/UpdatePaymentMethods.php b/app/PaymentDrivers/Stripe/UpdatePaymentMethods.php index b56173334704..860b590602fb 100644 --- a/app/PaymentDrivers/Stripe/UpdatePaymentMethods.php +++ b/app/PaymentDrivers/Stripe/UpdatePaymentMethods.php @@ -74,6 +74,9 @@ class UpdatePaymentMethods { $sources = $customer->sources; + if(!property_exists($sources, 'data')) + return; + foreach ($sources->data as $method) { $token_exists = ClientGatewayToken::where([ 'gateway_customer_reference' => $customer->id, From 59ac21662d821c46ace36f87da8efafcff9fdcb9 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 2 Sep 2022 09:52:00 +1000 Subject: [PATCH 02/11] Set required fields to lazy --- .../components/livewire/required-client-info.blade.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/views/portal/ninja2020/components/livewire/required-client-info.blade.php b/resources/views/portal/ninja2020/components/livewire/required-client-info.blade.php index 3a5b764ec540..032ec9a4e379 100644 --- a/resources/views/portal/ninja2020/components/livewire/required-client-info.blade.php +++ b/resources/views/portal/ninja2020/components/livewire/required-client-info.blade.php @@ -15,7 +15,7 @@ @if(!array_key_exists('filled', $field)) @component('portal.ninja2020.components.general.card-element', ['title' => $field['label']]) @if($field['name'] == 'client_country_id' || $field['name'] == 'client_shipping_country_id') - @foreach($countries as $country) @@ -25,7 +25,7 @@ @endforeach @else - + @endif @if(session()->has('validation_errors') && array_key_exists($field['name'], session('validation_errors'))) From a43f30adbc894b853da6998f2f7b14e6cdcb8a9a Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 2 Sep 2022 10:38:27 +1000 Subject: [PATCH 03/11] Refactor for switch plans --- app/Http/Livewire/SubscriptionPlanSwitch.php | 11 ++++++++++- .../Subscription/SubscriptionService.php | 12 ++++++++---- .../livewire/subscription-plan-switch.blade.php | 16 +++++++++++++--- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/app/Http/Livewire/SubscriptionPlanSwitch.php b/app/Http/Livewire/SubscriptionPlanSwitch.php index c1ea73efebfa..aac881662462 100644 --- a/app/Http/Livewire/SubscriptionPlanSwitch.php +++ b/app/Http/Livewire/SubscriptionPlanSwitch.php @@ -56,6 +56,7 @@ class SubscriptionPlanSwitch extends Component */ public $total; + public $hide_button = false; /** * @var array */ @@ -139,12 +140,20 @@ class SubscriptionPlanSwitch extends Component public function handlePaymentNotRequired() { - return $this->target->service()->createChangePlanCredit([ + $this->hide_button = true; + + $response = $this->target->service()->createChangePlanCredit([ 'recurring_invoice' => $this->recurring_invoice, 'subscription' => $this->subscription, 'target' => $this->target, 'hash' => $this->hash, ]); + + $this->hide_button = true; + + $this->dispatchBrowserEvent('redirectRoute', ['route' => $response]); + + // return redirect($response); } public function render() diff --git a/app/Services/Subscription/SubscriptionService.php b/app/Services/Subscription/SubscriptionService.php index 7f74fcb9be46..a79ccd9ab081 100644 --- a/app/Services/Subscription/SubscriptionService.php +++ b/app/Services/Subscription/SubscriptionService.php @@ -477,10 +477,14 @@ class SubscriptionService nlog($response); - if($credit) - return $this->handleRedirect('/client/credits/'.$credit->hashed_id); - else - return $this->handleRedirect('/client/credits'); + if($credit){ + // return $this->handleRedirect('/client/credits/'.$credit->hashed_id); + return '/client/credits/'.$credit->hashed_id; + } + else{ + // return $this->handleRedirect('/client/credits'); + return '/client/credits'; + } } diff --git a/resources/views/portal/ninja2020/components/livewire/subscription-plan-switch.blade.php b/resources/views/portal/ninja2020/components/livewire/subscription-plan-switch.blade.php index 7d53d6c5caf5..8d3c0301d58b 100644 --- a/resources/views/portal/ninja2020/components/livewire/subscription-plan-switch.blade.php +++ b/resources/views/portal/ninja2020/components/livewire/subscription-plan-switch.blade.php @@ -1,3 +1,4 @@ +
@@ -62,6 +63,7 @@
@elseif($amount <= 0) +

{{ ctrans('texts.total') }}: {{ \App\Utils\Number::formatMoney($amount, $subscription->company) }} @@ -69,12 +71,20 @@

- -
@endif
+ + + \ No newline at end of file From cbc10359e349cf62e3aa0bdac6ffd5a50f7a022d Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 2 Sep 2022 12:30:02 +1000 Subject: [PATCH 04/11] Better logging around setLateFee() --- app/Jobs/Util/ReminderJob.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Jobs/Util/ReminderJob.php b/app/Jobs/Util/ReminderJob.php index cac419fb3e71..738feaa85c49 100644 --- a/app/Jobs/Util/ReminderJob.php +++ b/app/Jobs/Util/ReminderJob.php @@ -201,7 +201,7 @@ class ReminderJob implements ShouldQueue $client = $invoice->client; $client = $client->fresh(); - nlog('adjusting client balance and invoice balance by '.($invoice->balance - $temp_invoice_balance)); + nlog('adjusting client balance and invoice balance by #'.$invoice->number.' '.($invoice->balance - $temp_invoice_balance)); $client->service()->updateBalance($invoice->balance - $temp_invoice_balance)->save(); $invoice->ledger()->updateInvoiceBalance($invoice->balance - $temp_invoice_balance, "Late Fee Adjustment for invoice {$invoice->number}"); From 6bd300a49b188be57a82c43dd0b49e7e7129a832 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 2 Sep 2022 12:33:00 +1000 Subject: [PATCH 05/11] Better logging around setLateFee() --- app/Jobs/Util/ReminderJob.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/Jobs/Util/ReminderJob.php b/app/Jobs/Util/ReminderJob.php index 738feaa85c49..78d233d357bd 100644 --- a/app/Jobs/Util/ReminderJob.php +++ b/app/Jobs/Util/ReminderJob.php @@ -14,8 +14,10 @@ namespace App\Jobs\Util; use App\DataMapper\InvoiceItem; use App\Events\Invoice\InvoiceWasEmailed; use App\Jobs\Entity\EmailEntity; +use App\Jobs\Ninja\TransactionLog; use App\Libraries\MultiDB; use App\Models\Invoice; +use App\Models\TransactionEvent; use App\Utils\Ninja; use App\Utils\Traits\MakesDates; use App\Utils\Traits\MakesReminders; @@ -205,6 +207,16 @@ class ReminderJob implements ShouldQueue $client->service()->updateBalance($invoice->balance - $temp_invoice_balance)->save(); $invoice->ledger()->updateInvoiceBalance($invoice->balance - $temp_invoice_balance, "Late Fee Adjustment for invoice {$invoice->number}"); + $transaction = [ + 'invoice' => $invoice->transaction_event(), + 'payment' => [], + 'client' => $client->transaction_event(), + 'credit' => [], + 'metadata' => ['setLateFee'], + ]; + + TransactionLog::dispatch(TransactionEvent::CLIENT_STATUS, $transaction, $invoice->company->db); + return $invoice; } } From fee7d2c697b7321d522eff21ee73dfcf0eb6d2b2 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 2 Sep 2022 14:22:04 +1000 Subject: [PATCH 06/11] Fresh client prior to updating --- app/Services/Invoice/ApplyPayment.php | 1 + app/Services/Invoice/ApplyPaymentAmount.php | 3 +++ app/Services/Invoice/MarkSent.php | 1 + 3 files changed, 5 insertions(+) diff --git a/app/Services/Invoice/ApplyPayment.php b/app/Services/Invoice/ApplyPayment.php index eea48ba3974e..fd818c726428 100644 --- a/app/Services/Invoice/ApplyPayment.php +++ b/app/Services/Invoice/ApplyPayment.php @@ -88,6 +88,7 @@ class ApplyPayment extends AbstractService $this->invoice ->client + ->fresh() ->service() ->updateBalance($amount_paid) ->save(); diff --git a/app/Services/Invoice/ApplyPaymentAmount.php b/app/Services/Invoice/ApplyPaymentAmount.php index 564d84f37b2a..3e5db3db72d0 100644 --- a/app/Services/Invoice/ApplyPaymentAmount.php +++ b/app/Services/Invoice/ApplyPaymentAmount.php @@ -17,6 +17,7 @@ use App\Factory\PaymentFactory; use App\Jobs\Invoice\InvoiceWorkflowSettings; use App\Jobs\Payment\EmailPayment; use App\Libraries\Currency\Conversion\CurrencyApi; +use App\Models\Client; use App\Models\Invoice; use App\Models\Payment; use App\Services\AbstractService; @@ -87,11 +88,13 @@ class ApplyPaymentAmount extends AbstractService $this->invoice ->client + ->fresh() ->service() ->updateBalance($payment->amount * -1) ->updatePaidToDate($payment->amount) ->save(); + if ($this->invoice->client->getSetting('client_manual_payment_notification')) { $payment->service()->sendEmail(); } diff --git a/app/Services/Invoice/MarkSent.php b/app/Services/Invoice/MarkSent.php index a8b6d17b2481..d95d7365bd6c 100644 --- a/app/Services/Invoice/MarkSent.php +++ b/app/Services/Invoice/MarkSent.php @@ -69,6 +69,7 @@ class MarkSent extends AbstractService $client = Client::withTrashed()->where('id', $this->client->id)->lockForUpdate()->first(); $client->balance += $adjustment; $client->save(); + }, 1); $this->invoice->markInvitationsSent(); From 0187e7408f6e6375c3f384a0537dc38cd10f53ad Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 2 Sep 2022 20:39:17 +1000 Subject: [PATCH 07/11] Update project name to just project for label --- app/Utils/HtmlEngine.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Utils/HtmlEngine.php b/app/Utils/HtmlEngine.php index 635fc002e99d..c4d6cf6fe0db 100644 --- a/app/Utils/HtmlEngine.php +++ b/app/Utils/HtmlEngine.php @@ -160,7 +160,7 @@ class HtmlEngine $data['$date'] = ['value' => $this->translateDate($this->entity->date, $this->client->date_format(), $this->client->locale()) ?: ' ', 'label' => ctrans('texts.invoice_date')]; if($this->entity->project) { - $data['$project.name'] = ['value' => $this->entity->project->name, 'label' => ctrans('texts.project_name')]; + $data['$project.name'] = ['value' => $this->entity->project->name, 'label' => ctrans('texts.project')]; $data['$invoice.project'] = &$data['$project.name']; } From 0934925071d97ffdb2f48ed8bf51a58f98d0f472 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 2 Sep 2022 20:43:35 +1000 Subject: [PATCH 08/11] Add option to send payment email when invoice has been marked as paid --- app/DataMapper/CompanySettings.php | 5 ++++- app/Services/Invoice/MarkPaid.php | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/DataMapper/CompanySettings.php b/app/DataMapper/CompanySettings.php index 92a0ae31a2cc..31c90f38e32d 100644 --- a/app/DataMapper/CompanySettings.php +++ b/app/DataMapper/CompanySettings.php @@ -436,9 +436,12 @@ class CompanySettings extends BaseSettings public $auto_archive_invoice_cancelled = false; - public $vendor_portal_enable_uploads=false; + public $vendor_portal_enable_uploads = false; + + public $send_email_on_mark_paid = false; public static $casts = [ + 'send_email_on_mark_paid' => 'bool', 'vendor_portal_enable_uploads' => 'bool', 'besr_id' => 'string', 'qr_iban' => 'string', diff --git a/app/Services/Invoice/MarkPaid.php b/app/Services/Invoice/MarkPaid.php index ccfd3e25cd1c..1cfe1b5bdd48 100644 --- a/app/Services/Invoice/MarkPaid.php +++ b/app/Services/Invoice/MarkPaid.php @@ -92,6 +92,9 @@ class MarkPaid extends AbstractService $payment->service()->applyNumber()->save(); + if($payment->company->getSetting('send_email_on_mark_paid')) + $payment->service()->sendEmail(); + $this->setExchangeRate($payment); /* Create a payment relationship to the invoice entity */ From a963fe1aee24f608a3a12be5f85c45f4c6eccb68 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 2 Sep 2022 20:53:32 +1000 Subject: [PATCH 09/11] Fixes for canvaskit path --- app/Http/Controllers/BaseController.php | 5 +++++ resources/views/index/index.blade.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/BaseController.php b/app/Http/Controllers/BaseController.php index a2695f0c6d20..ea6b7d56f0de 100644 --- a/app/Http/Controllers/BaseController.php +++ b/app/Http/Controllers/BaseController.php @@ -900,6 +900,10 @@ class BaseController extends Controller return redirect('/')->with(['signup' => 'true']); } + $canvas_path_array = parse_url(config('ninja.app_url')); + + $canvas_path = (array_key_exists('path', $canvas_path_array)) ? $canvas_path_array['path'] : ''; + $data = []; //pass report errors bool to front end @@ -910,6 +914,7 @@ class BaseController extends Controller $data['build'] = request()->has('build') ? request()->input('build') : ''; $data['login'] = request()->has('login') ? request()->input('login') : 'false'; $data['signup'] = request()->has('signup') ? request()->input('signup') : 'false'; + $data['canvas_path'] = $canvas_path; if (request()->session()->has('login')) { $data['login'] = 'true'; diff --git a/resources/views/index/index.blade.php b/resources/views/index/index.blade.php index f66926c193c2..186f03091ab8 100644 --- a/resources/views/index/index.blade.php +++ b/resources/views/index/index.blade.php @@ -21,7 +21,7 @@ From 6a60c89b380983dc36bc905151299754ccbb20dd Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 2 Sep 2022 21:26:59 +1000 Subject: [PATCH 10/11] Fixes for inventory notifications --- app/Jobs/Inventory/AdjustProductInventory.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Jobs/Inventory/AdjustProductInventory.php b/app/Jobs/Inventory/AdjustProductInventory.php index 1cf9476d4ed2..72b07d70d075 100644 --- a/app/Jobs/Inventory/AdjustProductInventory.php +++ b/app/Jobs/Inventory/AdjustProductInventory.php @@ -80,9 +80,9 @@ class AdjustProductInventory implements ShouldQueue $p->in_stock_quantity -= $item->quantity; $p->saveQuietly(); - if ($p->stock_notification_threshold && $p->in_stock_quantity <= $p->stock_notification_threshold) { + if ($this->company->stock_notification && $p->stock_notification && $p->stock_notification_threshold && $p->in_stock_quantity <= $p->stock_notification_threshold) { $this->notifyStockLevels($p, 'product'); - } elseif ($this->company->stock_notification_threshold && $p->in_stock_quantity <= $this->company->stock_notification_threshold) { + } elseif ($this->company->stock_notification && $p->stock_notification && $this->company->inventory_notification_threshold && $p->in_stock_quantity <= $this->company->inventory_notification_threshold) { $this->notifyStocklevels($p, 'company'); } } From 249785a8e2a0432ca7616461db1296a221b44127 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 2 Sep 2022 21:40:08 +1000 Subject: [PATCH 11/11] v5.5.19 --- VERSION.txt | 2 +- config/ninja.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/VERSION.txt b/VERSION.txt index f810c24459ff..c850dd977c51 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.5.18 \ No newline at end of file +5.5.19 \ No newline at end of file diff --git a/config/ninja.php b/config/ninja.php index 299e67c66820..7caef9120046 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -14,8 +14,8 @@ return [ 'require_https' => env('REQUIRE_HTTPS', true), 'app_url' => rtrim(env('APP_URL', ''), '/'), 'app_domain' => env('APP_DOMAIN', 'invoicing.co'), - 'app_version' => '5.5.18', - 'app_tag' => '5.5.18', + 'app_version' => '5.5.19', + 'app_tag' => '5.5.19', 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', ''),