From 091673a7acd77ec6e05a390450045cbccc36c0e5 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 8 Oct 2019 09:05:41 +1000 Subject: [PATCH] Payment edge cases --- app/Models/Payment.php | 3 +++ app/Utils/Traits/MakesDates.php | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/Models/Payment.php b/app/Models/Payment.php index 36e315d61918..d7e532931683 100644 --- a/app/Models/Payment.php +++ b/app/Models/Payment.php @@ -104,6 +104,9 @@ class Payment extends BaseModel public function clientPaymentDate() { + if(!$this->payment_date) + return ''; + $date_format = DateFormat::find($this->client->getSetting('date_format_id')); return $this->createClientDate($this->payment_date, $this->client->timezone()->name)->format($date_format->format); diff --git a/app/Utils/Traits/MakesDates.php b/app/Utils/Traits/MakesDates.php index 7ca2ef1f0955..623af46926c6 100644 --- a/app/Utils/Traits/MakesDates.php +++ b/app/Utils/Traits/MakesDates.php @@ -32,7 +32,7 @@ trait MakesDates if(is_string($utc_date)) $utc_date = $this->convertToDateObject($utc_date); - + return $utc_date->setTimezone(new \DateTimeZone($timezone)); } @@ -79,7 +79,7 @@ trait MakesDates public function formatDateTimestamp($timestamp, string $format) :string { - return Carbon::createFromTimestamp($date)->format($format); + return Carbon::createFromTimestamp($timestamp)->format($format); }