diff --git a/VERSION.txt b/VERSION.txt index 475e18429482..25c1b355a168 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.6.2 \ No newline at end of file +5.6.3 \ No newline at end of file diff --git a/app/Http/Requests/Payment/StorePaymentRequest.php b/app/Http/Requests/Payment/StorePaymentRequest.php index 196c302e57a7..b178717caa1e 100644 --- a/app/Http/Requests/Payment/StorePaymentRequest.php +++ b/app/Http/Requests/Payment/StorePaymentRequest.php @@ -88,7 +88,7 @@ class StorePaymentRequest extends Request // $input['is_manual'] = true; if (! isset($input['date'])) { - $input['date'] = now()->format('Y-m-d'); + $input['date'] = now()->addSeconds(auth()->user()->company()->timezone()->utc_offset)->format('Y-m-d'); } $this->replace($input); diff --git a/app/Jobs/Cron/AutoBill.php b/app/Jobs/Cron/AutoBill.php index 824f9463f29a..5376571d7ced 100644 --- a/app/Jobs/Cron/AutoBill.php +++ b/app/Jobs/Cron/AutoBill.php @@ -67,6 +67,9 @@ class AutoBill implements ShouldQueue if ($invitation->contact && ! $invitation->contact->trashed() && strlen($invitation->contact->email) >= 1 && $invoice->client->getSetting('auto_email_invoice')) { try { EmailEntity::dispatch($invitation, $invoice->company)->delay(rand(1, 2)); + + $invoice->entityEmailEvent($invitation, 'invoice', 'email_template_invoice'); + } catch (\Exception $e) { nlog($e->getMessage()); } diff --git a/app/PaymentDrivers/BaseDriver.php b/app/PaymentDrivers/BaseDriver.php index fcc36d4b698a..4bad13f054a3 100644 --- a/app/PaymentDrivers/BaseDriver.php +++ b/app/PaymentDrivers/BaseDriver.php @@ -320,7 +320,7 @@ class BaseDriver extends AbstractPaymentDriver $payment->company_gateway_id = $this->company_gateway->id; $payment->status_id = $status; $payment->currency_id = $this->client->getSetting('currency_id'); - $payment->date = Carbon::now(); + $payment->date = Carbon::now()->addSeconds($this->client->company->timezone()->utc_offset)->format('Y-m-d'); $payment->gateway_type_id = $data['gateway_type_id']; $client_contact = $this->getContact(); diff --git a/app/Services/Credit/CreditService.php b/app/Services/Credit/CreditService.php index 4adc71cd290c..26c9228e3804 100644 --- a/app/Services/Credit/CreditService.php +++ b/app/Services/Credit/CreditService.php @@ -119,7 +119,7 @@ class CreditService $payment->type_id = PaymentType::CREDIT; $payment->is_manual = true; $payment->currency_id = $this->credit->client->getSetting('currency_id'); - $payment->date = now(); + $payment->date = now()->addSeconds($this->credit->company->timezone()->utc_offset)->format('Y-m-d'); $payment->saveQuietly(); $payment->number = $payment->client->getNextPaymentNumber($payment->client, $payment); diff --git a/app/Services/Invoice/AutoBillInvoice.php b/app/Services/Invoice/AutoBillInvoice.php index de76290a75e0..d67b4fa8607f 100644 --- a/app/Services/Invoice/AutoBillInvoice.php +++ b/app/Services/Invoice/AutoBillInvoice.php @@ -179,7 +179,7 @@ class AutoBillInvoice extends AbstractService $payment->applied = $amount; $payment->client_id = $this->invoice->client_id; $payment->currency_id = $this->invoice->client->getSetting('currency_id'); - $payment->date = now(); + $payment->date = now()->addSeconds($this->invoice->company->timezone()->utc_offset)->format('Y-m-d'); $payment->status_id = Payment::STATUS_COMPLETED; $payment->type_id = PaymentType::CREDIT; $payment->service()->applyNumber()->save(); diff --git a/app/Services/Scheduler/EmailStatementService.php b/app/Services/Scheduler/EmailStatementService.php index 3ce5d5f7f7bf..c701913f5cc2 100644 --- a/app/Services/Scheduler/EmailStatementService.php +++ b/app/Services/Scheduler/EmailStatementService.php @@ -11,11 +11,11 @@ namespace App\Services\Scheduler; +use App\DataMapper\Schedule\EmailStatement; use App\Models\Client; use App\Models\Scheduler; -use App\Utils\Traits\MakesHash; -use App\DataMapper\Schedule\EmailStatement; use App\Utils\Traits\MakesDates; +use App\Utils\Traits\MakesHash; use Carbon\Carbon; class EmailStatementService @@ -38,7 +38,7 @@ class EmailStatementService //Email only the selected clients if (count($this->scheduler->parameters['clients']) >= 1) { $query->whereIn('id', $this->transformKeys($this->scheduler->parameters['clients'])); - }else { + } else { $query->where('balance', '>', 0); } @@ -95,7 +95,7 @@ class EmailStatementService EmailStatement::THIS_YEAR => [now()->startOfDay()->firstOfYear()->format('Y-m-d'), now()->startOfDay()->lastOfYear()->format('Y-m-d')], EmailStatement::LAST_YEAR => [now()->startOfDay()->subYearNoOverflow()->firstOfYear()->format('Y-m-d'), now()->startOfDay()->subYearNoOverflow()->lastOfYear()->format('Y-m-d')], EmailStatement::ALL_TIME => [ - Invoice::withTrashed()->where('client_id', $client->id)->selectRaw('MIN(invoices.date) as start_date')->pluck('start_date')->first() + $client->invoices()->selectRaw('MIN(invoices.date) as start_date')->pluck('start_date')->first() ?: Carbon::now()->format('Y-m-d'), Carbon::now()->format('Y-m-d') ], diff --git a/app/Utils/Traits/Inviteable.php b/app/Utils/Traits/Inviteable.php index 530c3f92c229..98584eed484a 100644 --- a/app/Utils/Traits/Inviteable.php +++ b/app/Utils/Traits/Inviteable.php @@ -69,7 +69,7 @@ trait Inviteable $qr = $writer->writeString($this->getPaymentLink(), 'utf-8'); return " - {$qr}"; + {$qr}"; } public function getUnsubscribeLink() diff --git a/config/ninja.php b/config/ninja.php index 75f811bc12a6..77cf14b0d32d 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.2', - 'app_tag' => '5.6.2', + 'app_version' => '5.6.3', + 'app_tag' => '5.6.3', 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', ''), diff --git a/tests/Feature/Scheduler/SchedulerTest.php b/tests/Feature/Scheduler/SchedulerTest.php index c4f58e235ff5..6cafea26ef54 100644 --- a/tests/Feature/Scheduler/SchedulerTest.php +++ b/tests/Feature/Scheduler/SchedulerTest.php @@ -40,6 +40,8 @@ class SchedulerTest extends TestCase use WithoutEvents; use DatabaseTransactions; + protected $faker; + protected function setUp(): void { parent::setUp(); @@ -594,12 +596,6 @@ class SchedulerTest extends TestCase $scheduler->save(); $scheduler->calculateNextRun(); - // $service_object = new SchedulerService($scheduler); - - // $reflectionMethod = new \ReflectionMethod(SchedulerService::class, 'calculateNextRun'); - // $reflectionMethod->setAccessible(true); - // $method = $reflectionMethod->invoke(new SchedulerService($scheduler)); - $scheduler->fresh(); $offset = $this->company->timezone_offset(); @@ -634,7 +630,7 @@ class SchedulerTest extends TestCase $reflectionMethod = new \ReflectionMethod(EmailStatementService::class, 'calculateStartAndEndDates'); $reflectionMethod->setAccessible(true); - $method = $reflectionMethod->invoke(new EmailStatementService($scheduler)); + $method = $reflectionMethod->invoke(new EmailStatementService($scheduler), $this->client); $this->assertIsArray($method); @@ -668,7 +664,7 @@ class SchedulerTest extends TestCase $reflectionMethod = new \ReflectionMethod(EmailStatementService::class, 'calculateStatementProperties'); $reflectionMethod->setAccessible(true); - $method = $reflectionMethod->invoke(new EmailStatementService($scheduler)); // 'baz' + $method = $reflectionMethod->invoke(new EmailStatementService($scheduler), $this->client); $this->assertIsArray($method);