From 58628034341ec997e8e454cde5192f046d4df6f0 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 25 Dec 2015 09:34:23 +0100 Subject: [PATCH] This saves some queries. --- app/Models/TransactionJournal.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/app/Models/TransactionJournal.php b/app/Models/TransactionJournal.php index aee80cdfc4..0aff8fd74f 100644 --- a/app/Models/TransactionJournal.php +++ b/app/Models/TransactionJournal.php @@ -68,6 +68,7 @@ use Watson\Validating\ValidatingTrait; * @property-read int $account_id * @property string $name * @property-read string $symbol + * @property-read string $type * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Attachment[] $attachments * @property-read mixed $amount_positive */ @@ -503,6 +504,10 @@ class TransactionJournal extends Model */ public function isWithdrawal() { + if (!is_null($this->type)) { + return $this->type == TransactionType::WITHDRAWAL; + } + return $this->transactionType->isWithdrawal(); } @@ -511,6 +516,10 @@ class TransactionJournal extends Model */ public function isDeposit() { + if (!is_null($this->type)) { + return $this->type == TransactionType::DEPOSIT; + } + return $this->transactionType->isDeposit(); } @@ -519,6 +528,10 @@ class TransactionJournal extends Model */ public function isTransfer() { + if (!is_null($this->type)) { + return $this->type == TransactionType::TRANSFER; + } + return $this->transactionType->isTransfer(); } @@ -527,6 +540,10 @@ class TransactionJournal extends Model */ public function isOpeningBalance() { + if (!is_null($this->type)) { + return $this->type == TransactionType::OPENING_BALANCE; + } + return $this->transactionType->isOpeningBalance(); } }