diff --git a/VERSION.txt b/VERSION.txt index 29a1e2867ec1..62fcb18413f5 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.6.22 \ No newline at end of file +5.6.23 \ No newline at end of file diff --git a/app/Export/CSV/BaseExport.php b/app/Export/CSV/BaseExport.php index 483872efaeee..4650b990f7d4 100644 --- a/app/Export/CSV/BaseExport.php +++ b/app/Export/CSV/BaseExport.php @@ -650,20 +650,20 @@ class BaseExport } if($column == 'amount') - return $entity->payments()->exists() ? $entity->payments()->sum('paymentables.amount') : ctrans('texts.unpaid'); + return $entity->payments()->exists() ? $entity->payments()->withoutTrashed()->sum('paymentables.amount') : ctrans('texts.unpaid'); if($column == 'refunded') { - return $entity->payments()->exists() ? $entity->payments()->sum('paymentables.refunded') : 0; + return $entity->payments()->exists() ? $entity->payments()->withoutTrashed()->sum('paymentables.refunded') : ''; } if($column == 'applied') { - $refunded = $entity->payments()->sum('paymentables.refunded'); - $amount = $entity->payments()->sum('paymentables.amount'); + $refunded = $entity->payments()->withoutTrashed()->sum('paymentables.refunded'); + $amount = $entity->payments()->withoutTrashed()->sum('paymentables.amount'); - return $entity->payments()->exists() ? ($amount - $refunded) : 0; + return $entity->payments()->withoutTrashed()->exists() ? ($amount - $refunded) : ''; } - $payment = $entity->payments()->first(); + $payment = $entity->payments()->withoutTrashed()->first(); if(!$payment) return ''; diff --git a/app/Mail/SupportMessageSent.php b/app/Mail/SupportMessageSent.php index ea8f34f49373..7a230fcf5b6d 100644 --- a/app/Mail/SupportMessageSent.php +++ b/app/Mail/SupportMessageSent.php @@ -67,7 +67,7 @@ class SupportMessageSent extends Mailable $db = str_replace('db-ninja-', '', $company->db); $is_large = $company->is_large ? 'L' : 'S'; $platform = array_key_exists('platform', $this->data) ? $this->data['platform'] : 'U'; - $migrated = strlen($company->company_key) == 32 ? 'M' : ''; + $migrated = ctype_lower(preg_replace('/[0-9]+/', '', $company->company_key)) ? 'M' : ''; $trial = $account->isTrial() ? 'T' : ''; $plan = str_replace('_', ' ', $plan); diff --git a/app/Utils/Traits/MakesReminders.php b/app/Utils/Traits/MakesReminders.php index d886ffaacbb8..06560db29e38 100644 --- a/app/Utils/Traits/MakesReminders.php +++ b/app/Utils/Traits/MakesReminders.php @@ -30,18 +30,13 @@ trait MakesReminders $offset = $this->client->timezone_offset(); - // nlog($schedule_reminder. " ". $num_days_reminder); - // nlog("date = " . Carbon::parse($this->date)->addDays($num_days_reminder)->startOfDay()->addSeconds($offset)); - // nlog("due date = " . Carbon::parse($this->due_date)->addDays($num_days_reminder)->startOfDay()->addSeconds($offset)); - // nlog("now = " . Carbon::now()->startOfDay()->format('Y-m-d H:i:s')); - switch ($schedule_reminder) { case 'after_invoice_date': - return Carbon::parse($this->date)->addDays($num_days_reminder)->startOfDay()->addSeconds($offset)->eq(Carbon::now()); + return Carbon::parse($this->date)->addDays($num_days_reminder)->startOfDay()->addSeconds($offset)->isSameDay(Carbon::now()); case 'before_due_date': - return Carbon::parse($this->due_date)->subDays($num_days_reminder)->startOfDay()->addSeconds($offset)->eq(Carbon::now()); + return Carbon::parse($this->due_date)->subDays($num_days_reminder)->startOfDay()->addSeconds($offset)->isSameDay(Carbon::now()); case 'after_due_date': - return Carbon::parse($this->due_date)->addDays($num_days_reminder)->startOfDay()->addSeconds($offset)->eq(Carbon::now()); + return Carbon::parse($this->due_date)->addDays($num_days_reminder)->startOfDay()->addSeconds($offset)->isSameDay(Carbon::now()); default: return null; } @@ -81,7 +76,6 @@ trait MakesReminders return $entity_string; } - //also implement endless reminders here } private function checkEndlessReminder($last_sent_date, $endless_reminder_frequency_id) :bool diff --git a/config/ninja.php b/config/ninja.php index f36da4e8a710..6fa3bbdaff40 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' => env('APP_VERSION','5.6.22'), - 'app_tag' => env('APP_TAG','5.6.22'), + 'app_version' => env('APP_VERSION','5.6.23'), + 'app_tag' => env('APP_TAG','5.6.23'), 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', ''), diff --git a/tests/Unit/LateFeeTest.php b/tests/Unit/LateFeeTest.php index b99bfac50398..383e9b2424dd 100644 --- a/tests/Unit/LateFeeTest.php +++ b/tests/Unit/LateFeeTest.php @@ -96,6 +96,8 @@ class LateFeeTest extends TestCase public function testLateFeeAdded() { + $this->travelTo(now()->subDays(15)); + $settings = CompanySettings::defaults(); $settings->client_online_payment_notification = false; $settings->client_manual_payment_notification = false; @@ -105,6 +107,7 @@ class LateFeeTest extends TestCase $settings->enable_reminder1 = true; $settings->num_days_reminder1 = 10; $settings->schedule_reminder1 = 'after_due_date'; + $settings->entity_send_time = '0'; $client = $this->buildData($settings); @@ -117,7 +120,7 @@ class LateFeeTest extends TestCase 'status_id' => 2, 'total_taxes' => 1, 'date' => now()->format('Y-m-d'), - 'due_date' => now()->subDays(10)->format('Y-m-d'), + 'due_date' => now()->addDays(10)->format('Y-m-d'), 'terms' => 'nada', 'discount' => 0, 'tax_rate1' => 0, @@ -131,11 +134,15 @@ class LateFeeTest extends TestCase ]); $i = $i->calc()->getInvoice(); - $i->service()->applyNumber()->createInvitations()->save(); + $i->service()->markSent()->setReminder()->applyNumber()->createInvitations()->save(); + + // $this->travelBack(); + $this->travelTo(now()->addDays(20)->startOfDay()->format('Y-m-d')); + $i = $i->fresh(); $this->assertEquals(10, $i->amount); $this->assertEquals(10, $i->balance); - + $reflectionMethod = new \ReflectionMethod(ReminderJob::class, 'sendReminderForInvoice'); $reflectionMethod->setAccessible(true); $reflectionMethod->invokeArgs(new ReminderJob(), [$i]); @@ -144,6 +151,8 @@ class LateFeeTest extends TestCase $this->assertEquals(20, $i->balance); + $this->travelBack(); + } public function testLateFeeAddedToNewInvoiceWithLockedInvoiceConfig()