From 81e507271a5a0a555fe77fdb0cbd9ed83202dc38 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 18 Jun 2022 13:52:30 +1000 Subject: [PATCH 1/8] Fixes for reminders when no due date is set --- app/Services/Invoice/UpdateReminder.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/Services/Invoice/UpdateReminder.php b/app/Services/Invoice/UpdateReminder.php index 50148c2367..52f604263e 100644 --- a/app/Services/Invoice/UpdateReminder.php +++ b/app/Services/Invoice/UpdateReminder.php @@ -58,6 +58,7 @@ class UpdateReminder extends AbstractService } if (is_null($this->invoice->reminder1_sent) && + $this->invoice->due_date && $this->settings->schedule_reminder1 == 'before_due_date') { $reminder_date = Carbon::parse($this->invoice->due_date)->startOfDay()->subDays($this->settings->num_days_reminder1)->addSeconds($offset); @@ -66,6 +67,7 @@ class UpdateReminder extends AbstractService } if (is_null($this->invoice->reminder1_sent) && + $this->invoice->due_date && $this->settings->schedule_reminder1 == 'after_due_date') { $reminder_date = Carbon::parse($this->invoice->due_date)->startOfDay()->addDays($this->settings->num_days_reminder1)->addSeconds($offset); @@ -82,6 +84,7 @@ class UpdateReminder extends AbstractService } if (is_null($this->invoice->reminder2_sent) && + $this->invoice->due_date && $this->settings->schedule_reminder2 == 'before_due_date') { $reminder_date = Carbon::parse($this->invoice->due_date)->startOfDay()->subDays($this->settings->num_days_reminder2)->addSeconds($offset); @@ -90,6 +93,7 @@ class UpdateReminder extends AbstractService } if (is_null($this->invoice->reminder2_sent) && + $this->invoice->due_date && $this->settings->schedule_reminder2 == 'after_due_date') { $reminder_date = Carbon::parse($this->invoice->due_date)->startOfDay()->addDays($this->settings->num_days_reminder2)->addSeconds($offset); @@ -106,6 +110,7 @@ class UpdateReminder extends AbstractService } if (is_null($this->invoice->reminder3_sent) && + $this->invoice->due_date && $this->settings->schedule_reminder3 == 'before_due_date') { $reminder_date = Carbon::parse($this->invoice->due_date)->startOfDay()->subDays($this->settings->num_days_reminder3)->addSeconds($offset); @@ -114,6 +119,7 @@ class UpdateReminder extends AbstractService } if (is_null($this->invoice->reminder3_sent) && + $this->invoice->due_date && $this->settings->schedule_reminder3 == 'after_due_date') { $reminder_date = Carbon::parse($this->invoice->due_date)->startOfDay()->addDays($this->settings->num_days_reminder3)->addSeconds($offset); From 7b7fbc5c13e6863a80bf2770b323b20b50979a77 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 18 Jun 2022 14:25:29 +1000 Subject: [PATCH 2/8] Add dedicated :MONTHYEAR reserved keyword --- app/Utils/Helpers.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app/Utils/Helpers.php b/app/Utils/Helpers.php index 28cf1adc25..2bd59028e7 100644 --- a/app/Utils/Helpers.php +++ b/app/Utils/Helpers.php @@ -116,6 +116,11 @@ class Helpers $replacements = [ 'literal' => [ + ':MONTHYEAR' => \sprintf( + '%s %s', + Carbon::createFromDate(now()->month)->translatedFormat('F'), + now()->year, + ), ':MONTH' => Carbon::createFromDate(now()->year, now()->month)->translatedFormat('F'), ':YEAR' => now()->year, ':QUARTER' => 'Q' . now()->quarter, @@ -139,6 +144,7 @@ class Helpers ), ], 'raw' => [ + ':MONTHYEAR' => now()->month, ':MONTH' => now()->month, ':YEAR' => now()->year, ':QUARTER' => now()->quarter, @@ -256,6 +262,18 @@ class Helpers $output = \Carbon\Carbon::create()->month($output)->translatedFormat('F'); } + if ($matches->keys()->first() == ':MONTHYEAR') { + + $final_date = now()->addMonths($output-now()->month); + + $output = \sprintf( + '%s %s', + $final_date->translatedFormat('F'), + $final_date->year, + ); + + } + $value = preg_replace( $target, $output, $value, 1 ); From f014cda4e64dadb0590545aafbbeaa498526e9ae Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 18 Jun 2022 17:10:15 +1000 Subject: [PATCH 3/8] Ensure we save auto_bill_tries --- app/Services/Invoice/AutoBillInvoice.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/Services/Invoice/AutoBillInvoice.php b/app/Services/Invoice/AutoBillInvoice.php index 4a5c8cafca..fa0f8f0bea 100644 --- a/app/Services/Invoice/AutoBillInvoice.php +++ b/app/Services/Invoice/AutoBillInvoice.php @@ -123,6 +123,7 @@ class AutoBillInvoice extends AbstractService ->setPaymentHash($payment_hash) ->tokenBilling($gateway_token, $payment_hash); } catch (\Exception $e) { + $this->invoice->auto_bill_tries += 1; if ($this->invoice->auto_bill_tries == 3) { @@ -131,6 +132,8 @@ class AutoBillInvoice extends AbstractService $this->invoice->save(); } + $this->invoice->save(); + nlog("payment NOT captured for " . $this->invoice->number . " with error " . $e->getMessage()); } From e8108ed34ca2c16a187778bebcfda82fe3c16135 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 19 Jun 2022 13:01:29 +1000 Subject: [PATCH 4/8] Updates for hosted platform --- app/Console/Commands/CheckData.php | 2 +- app/Models/Account.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Console/Commands/CheckData.php b/app/Console/Commands/CheckData.php index 96dec67b68..835038859f 100644 --- a/app/Console/Commands/CheckData.php +++ b/app/Console/Commands/CheckData.php @@ -866,7 +866,7 @@ class CheckData extends Command foreach(Invoice::with(['payments'])->whereHas('payments')->where('status_id', 4)->where('balance', '>', 0)->where('is_deleted',0)->cursor() as $invoice) { - $this->$this->wrong_paid_status++; + $this->wrong_paid_status++; $this->logMessage("# {$invoice->id} " . ' - '.$invoice->number." - Marked as paid, but balance = {$invoice->balance}"); diff --git a/app/Models/Account.php b/app/Models/Account.php index 0ad6674c9f..d41ec4e952 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -375,7 +375,7 @@ class Account extends BaseModel { if(Carbon::createFromTimestamp($this->created_at)->diffInWeeks() == 0) - return 50; + return 20; if($this->isPaid()){ $limit = $this->paid_plan_email_quota; From ad1bea598cb35c6cef89dc0652993132393945f5 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 19 Jun 2022 16:10:37 +1000 Subject: [PATCH 5/8] Minor fixes for bcc's --- app/Mail/TemplateEmail.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Mail/TemplateEmail.php b/app/Mail/TemplateEmail.php index 86ae1adbf5..a8879c0511 100644 --- a/app/Mail/TemplateEmail.php +++ b/app/Mail/TemplateEmail.php @@ -90,8 +90,10 @@ class TemplateEmail extends Mailable if (strlen($settings->bcc_email) > 1){ - if(Ninja::isHosted()) - $this->bcc(reset(explode(",",str_replace(" ", "", $settings->bcc_email))));//remove whitespace if any has been inserted. + if(Ninja::isHosted()){ + $bccs = explode(",",str_replace(" ", "", $settings->bcc_email)); + $this->bcc(reset($bccs));//remove whitespace if any has been inserted. + } else $this->bcc(explode(",",str_replace(" ", "", $settings->bcc_email)));//remove whitespace if any has been inserted. From 9fbe81302e45ee7d2fea6e33d1f388741ecb945c Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 19 Jun 2022 17:39:25 +1000 Subject: [PATCH 6/8] Add logging for payment intents --- app/PaymentDrivers/Stripe/Jobs/PaymentIntentWebhook.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/PaymentDrivers/Stripe/Jobs/PaymentIntentWebhook.php b/app/PaymentDrivers/Stripe/Jobs/PaymentIntentWebhook.php index dfbe20efcf..48d8bcd33d 100644 --- a/app/PaymentDrivers/Stripe/Jobs/PaymentIntentWebhook.php +++ b/app/PaymentDrivers/Stripe/Jobs/PaymentIntentWebhook.php @@ -118,6 +118,9 @@ class PaymentIntentWebhook implements ShouldQueue if(!$payment_hash) return; + nlog("payment intent"); + nlog($this->stripe_request); + if(optional($this->stripe_request['object']['charges']['data'][0]['metadata']['payment_hash']) && in_array('card', $this->stripe_request['object']['allowed_source_types'])) { nlog("hash found"); From 78780001cff3e71709541b0d8a154d6c175744c1 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 19 Jun 2022 18:07:51 +1000 Subject: [PATCH 7/8] Fixes for migrations with incompatible types --- .../2022_05_18_162152_create_scheduled_jobs_table.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/migrations/2022_05_18_162152_create_scheduled_jobs_table.php b/database/migrations/2022_05_18_162152_create_scheduled_jobs_table.php index 80fcf410f4..1b3a966db7 100644 --- a/database/migrations/2022_05_18_162152_create_scheduled_jobs_table.php +++ b/database/migrations/2022_05_18_162152_create_scheduled_jobs_table.php @@ -26,7 +26,7 @@ class CreateScheduledJobsTable extends Migration $table->id(); $table->string('action_name'); $table->string('action_class'); - $table->json('parameters')->nullable(); + $table->mediumText('parameters')->nullable(); $table->foreignIdFor(\App\Models\Company::class); $table->foreignIdFor(\App\Models\Scheduler::class); $table->timestamps(); From c1584659df75e2653f876e79063cda56c900214f Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 19 Jun 2022 18:08:46 +1000 Subject: [PATCH 8/8] v5.4.4 --- VERSION.txt | 2 +- config/ninja.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/VERSION.txt b/VERSION.txt index b5db1702f3..3238344b3b 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.4.3 \ No newline at end of file +5.4.4 \ No newline at end of file diff --git a/config/ninja.php b/config/ninja.php index 4d911b56bf..508852f4a7 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.4.3', - 'app_tag' => '5.4.3', + 'app_version' => '5.4.4', + 'app_tag' => '5.4.4', 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', ''),