diff --git a/app/Http/Controllers/Banking/Transactions.php b/app/Http/Controllers/Banking/Transactions.php index c0c01f697..09433a219 100644 --- a/app/Http/Controllers/Banking/Transactions.php +++ b/app/Http/Controllers/Banking/Transactions.php @@ -45,7 +45,7 @@ class Transactions extends Controller ]; $transactions->each(function ($transaction) use (&$totals) { - if ($transaction->isNotIncome() && $transaction->isNotExpense()) { + if (($transaction->isNotIncome() && $transaction->isNotExpense()) || $transaction->isTransfer()) { return; } diff --git a/app/Models/Banking/Transaction.php b/app/Models/Banking/Transaction.php index 6e57559e7..20c0b80a8 100644 --- a/app/Models/Banking/Transaction.php +++ b/app/Models/Banking/Transaction.php @@ -23,9 +23,11 @@ class Transaction extends Model public const INCOME_TYPE = 'income'; public const INCOME_SPLIT_TYPE = 'income-split'; public const INCOME_RECURRING_TYPE = 'income-recurring'; + public const INCOME_TRANSFER_TYPE = 'income-transfer'; // TODO - convert transfer from category to type public const EXPENSE_TYPE = 'expense'; public const EXPENSE_SPLIT_TYPE = 'expense-split'; public const EXPENSE_RECURRING_TYPE = 'expense-recurring'; + public const EXPENSE_TRANSFER_TYPE = 'expense-transfer'; // TODO - convert transfer from category to type protected $table = 'transactions'; diff --git a/app/Traits/Transactions.php b/app/Traits/Transactions.php index f9ae06a31..8264622bf 100644 --- a/app/Traits/Transactions.php +++ b/app/Traits/Transactions.php @@ -4,6 +4,7 @@ namespace App\Traits; use App\Events\Banking\TransactionPrinting; use App\Models\Banking\Transaction; +use App\Models\Setting\Category; use Illuminate\Support\Str; trait Transactions @@ -44,6 +45,18 @@ trait Transactions return ! $this->isRecurring(); } + public function isTransfer(): bool + { + $category_id = $this->category_id ?? $this->transaction->category_id ?? $this->model->category_id ?? 0; + + return $category_id == Category::transfer(); + } + + public function isNotTransfer(): bool + { + return ! $this->isTransfer(); + } + public function getIncomeTypes($return = 'array') { return $this->getTransactionTypes('income', $return);