From 4b3e09faf879392fdecc57abbb689691d007e133 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 28 Feb 2022 07:45:42 +1100 Subject: [PATCH 1/7] Fixes for key login --- .../Controllers/ClientPortal/ContactHashLoginController.php | 2 +- app/Http/Middleware/ContactKeyLogin.php | 2 ++ app/Http/Middleware/SetInviteDb.php | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/ClientPortal/ContactHashLoginController.php b/app/Http/Controllers/ClientPortal/ContactHashLoginController.php index 51ca60adf347..c1280ff8bdc6 100644 --- a/app/Http/Controllers/ClientPortal/ContactHashLoginController.php +++ b/app/Http/Controllers/ClientPortal/ContactHashLoginController.php @@ -51,7 +51,7 @@ class ContactHashLoginController extends Controller return render('generic.error', ['title' => session()->get('title'), 'notification' => session()->get('notification')]); } - private function setRedirectPath() + private function setRedirectPath() { if(auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_INVOICES) diff --git a/app/Http/Middleware/ContactKeyLogin.php b/app/Http/Middleware/ContactKeyLogin.php index 93d2c1edf423..9891236cfbd5 100644 --- a/app/Http/Middleware/ContactKeyLogin.php +++ b/app/Http/Middleware/ContactKeyLogin.php @@ -123,6 +123,8 @@ class ContactKeyLogin return redirect($this->setRedirectPath()); } } + //28-02-2022 middleware should not allow this to progress as we should have redirected by this stage. + abort(404, "Unable to authenticate."); return $next($request); } diff --git a/app/Http/Middleware/SetInviteDb.php b/app/Http/Middleware/SetInviteDb.php index 4b8e8cdcbfe9..914fdbf536fc 100644 --- a/app/Http/Middleware/SetInviteDb.php +++ b/app/Http/Middleware/SetInviteDb.php @@ -46,6 +46,9 @@ class SetInviteDb if($entity == "pay") $entity = "invoice"; + if(!in_array($entity, ['invoice','quote','credit','recurring_invoice'])) + abort(404,'I could not find this resource.'); + /* Try and determine the DB from the invitation key STRING*/ if (config('ninja.db.multi_db_enabled')) { From f7ff5d34df1d4207d96145bdfdaaf03d096766fd Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 28 Feb 2022 10:15:36 +1100 Subject: [PATCH 2/7] add helper for Invoice payable amount --- app/Models/Invoice.php | 14 ++++++++++++++ .../views/portal/ninja2020/invoices/show.blade.php | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index 3fcfb4ddf012..c85230a96bf0 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -498,6 +498,20 @@ class Invoice extends BaseModel return $this->calc()->getTotal(); } + public function getPayableAmount() + { + if($this->partial > 0) + return $this->partial; + + if($this->balance > 0) + return $this->balance; + + if($this->status_id = 1) + return $this->amount; + + return 0; + } + public function entityEmailEvent($invitation, $reminder_template, $template) { switch ($reminder_template) { diff --git a/resources/views/portal/ninja2020/invoices/show.blade.php b/resources/views/portal/ninja2020/invoices/show.blade.php index f374b14593ad..f56fbca5dfb2 100644 --- a/resources/views/portal/ninja2020/invoices/show.blade.php +++ b/resources/views/portal/ninja2020/invoices/show.blade.php @@ -59,7 +59,7 @@ @if($settings->client_portal_allow_under_payment || $settings->client_portal_allow_over_payment) @else - @livewire('pay-now-dropdown', ['total' => $invoice->partial > 0 ? $invoice->partial : $invoice->balance, 'company' => $company]) + @livewire('pay-now-dropdown', ['total' => $invoice->getPayableAmount(), 'company' => $company]) @endif From 5b06b268fb1dd0dacdb3e5546f95d70f94591e1d Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 28 Feb 2022 13:17:34 +1100 Subject: [PATCH 3/7] Minor cleanup --- app/Jobs/Mail/PaymentFailedMailer.php | 5 +---- app/Mail/Admin/ClientPaymentFailureObject.php | 2 -- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/app/Jobs/Mail/PaymentFailedMailer.php b/app/Jobs/Mail/PaymentFailedMailer.php index aebc9cbb330c..b8221c235652 100644 --- a/app/Jobs/Mail/PaymentFailedMailer.php +++ b/app/Jobs/Mail/PaymentFailedMailer.php @@ -110,13 +110,10 @@ class PaymentFailedMailer implements ShouldQueue }); //add client payment failures here. - nlog("pre client failure email"); - + // if($contact = $this->client->primary_contact()->first()) { - nlog("inside failure"); - $mail_obj = (new ClientPaymentFailureObject($this->client, $this->error, $this->company, $this->payment_hash))->build(); $nmo = new NinjaMailerObject; diff --git a/app/Mail/Admin/ClientPaymentFailureObject.php b/app/Mail/Admin/ClientPaymentFailureObject.php index 265845280538..d0a24b514efe 100644 --- a/app/Mail/Admin/ClientPaymentFailureObject.php +++ b/app/Mail/Admin/ClientPaymentFailureObject.php @@ -57,7 +57,6 @@ class ClientPaymentFailureObject public function build() { if(!$this->payment_hash){ - nlog("no payment has for failure notification - ClientPaymentFailureObject"); return; } @@ -124,7 +123,6 @@ class ClientPaymentFailureObject 'settings' => $this->client->getMergedSettings(), 'whitelabel' => $this->company->account->isPaid() ? true : false, 'url' => $this->invoices->first()->invitations->first()->getPaymentLink(), - // 'button' => 'texts.pay_now', 'button' => ctrans('texts.pay_now'), 'additional_info' => false, 'company' => $this->company, From 32596b4287d138c98f1ee75da2948e26cdd627f2 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 28 Feb 2022 14:38:13 +1100 Subject: [PATCH 4/7] Fixes for CSV import --- app/Http/Controllers/ClientPortal/NinjaPlanController.php | 2 ++ app/Import/Transformer/Csv/InvoiceTransformer.php | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/ClientPortal/NinjaPlanController.php b/app/Http/Controllers/ClientPortal/NinjaPlanController.php index 6c064a2ef541..d980dd3a27ec 100644 --- a/app/Http/Controllers/ClientPortal/NinjaPlanController.php +++ b/app/Http/Controllers/ClientPortal/NinjaPlanController.php @@ -159,6 +159,8 @@ class NinjaPlanController extends Controller $recurring_invoice->next_send_date = now()->addDays(14)->format('Y-m-d'); $recurring_invoice->save(); + $recurring_invoice = $recurring_invoice->calc()->getRecurringInvoice(); + $recurring_invoice->service()->start(); return redirect('/'); diff --git a/app/Import/Transformer/Csv/InvoiceTransformer.php b/app/Import/Transformer/Csv/InvoiceTransformer.php index 992ad63f2e5b..b632e9113ace 100644 --- a/app/Import/Transformer/Csv/InvoiceTransformer.php +++ b/app/Import/Transformer/Csv/InvoiceTransformer.php @@ -125,7 +125,7 @@ class InvoiceTransformer extends BaseTransformer $this->getString($invoice_data, 'invoice.status') )) ] ?? Invoice::STATUS_SENT, - 'archived' => $status === 'archived', + // 'archived' => $status === 'archived', ]; /* If we can't find the client, then lets try and create a client */ From de8ee988b77af712e8e638e46e8730a7152d77fc Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 28 Feb 2022 14:44:06 +1100 Subject: [PATCH 5/7] Improve refunding from subscription upgrades --- app/Services/Subscription/SubscriptionService.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/Services/Subscription/SubscriptionService.php b/app/Services/Subscription/SubscriptionService.php index 2cf99ad5b410..b4c2c2187eeb 100644 --- a/app/Services/Subscription/SubscriptionService.php +++ b/app/Services/Subscription/SubscriptionService.php @@ -228,10 +228,14 @@ class SubscriptionService ->where('is_deleted', 0) ->orderBy('id', 'desc') ->first(); - } - if ($outstanding->count() == 0){ + //need to ensure at this point that a refund is appropriate!! + //28-02-2022 + if($recurring_invoice->invoices()->count() == 0){ + return $target->price; + } + elseif ($outstanding->count() == 0){ //nothing outstanding return $target->price - $this->calculateProRataRefundForSubscription($outstanding_invoice); } From b062204fa6163f8fa7d61799c8b0c6958096edea Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 28 Feb 2022 16:50:25 +1100 Subject: [PATCH 6/7] Fixes for viewed entities --- app/Http/Controllers/ClientPortal/InvitationController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/ClientPortal/InvitationController.php b/app/Http/Controllers/ClientPortal/InvitationController.php index 0bd9c97c5249..37dd12f9b658 100644 --- a/app/Http/Controllers/ClientPortal/InvitationController.php +++ b/app/Http/Controllers/ClientPortal/InvitationController.php @@ -125,7 +125,7 @@ class InvitationController extends Controller } - if (auth()->guard('contact') && ! request()->has('silent') && ! $invitation->viewed_date) { + if (auth()->guard('contact')->user() && ! request()->has('silent') && ! $invitation->viewed_date) { $invitation->markViewed(); event(new InvitationWasViewed($invitation->{$entity}, $invitation, $invitation->{$entity}->company, Ninja::eventVars())); From 2cfc93d40d7d143c7cf48e3f74e05d13717b3624 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 28 Feb 2022 16:52:49 +1100 Subject: [PATCH 7/7] v5.3.63 --- VERSION.txt | 2 +- config/ninja.php | 4 ++-- resources/lang/en/texts.php | 20 +++++++++++++++++++- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/VERSION.txt b/VERSION.txt index a4c570d1143d..2b025406babb 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.3.62 \ No newline at end of file +5.3.63 \ No newline at end of file diff --git a/config/ninja.php b/config/ninja.php index 3106ed149025..e42bd3a24016 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.3.62', - 'app_tag' => '5.3.62', + 'app_version' => '5.3.63', + 'app_tag' => '5.3.63', 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', ''), diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index ffe0ffd314a2..d6679f4db6db 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -4547,7 +4547,25 @@ $LANG = array( 'to_view_entity_set_password' => 'To view the :entity you need to set password.', 'unsubscribe' => 'Unsubscribe', 'unsubscribed' => 'Unsubscribed', - 'unsubscribed_text' => 'You have been removed from notifications for this document' + 'unsubscribed_text' => 'You have been removed from notifications for this document', + 'client_shipping_state' => 'Client Shipping State', + 'client_shipping_city' => 'Client Shipping City', + 'client_shipping_postal_code' => 'Client Shipping Postal Code', + 'client_shipping_country' => 'Client Shipping Country', + 'load_pdf' => 'Load PDF', + 'start_free_trial' => 'Start Free Trial', + 'start_free_trial_message' => 'Start your FREE 14 day trial of the pro plan', + 'due_on_receipt' => 'Due on Receipt', + 'is_paid' => 'Is Paid', + 'age_group_paid' => 'Paid', + 'id' => 'Id', + 'convert_to' => 'Convert To', + 'client_currency' => 'Client Currency', + 'company_currency' => 'Company Currency', + 'custom_emails_disabled_help' => 'To prevent spam we require upgrading to a paid account to customize the email', + 'upgrade_to_add_company' => 'Upgrade your plan to add companies', + 'file_saved_in_downloads_folder' => 'The file has been saved in the downloads folder', + 'small' => 'Small', ); return $LANG;