60 lines
1.9 KiB
PHP
60 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Enums;
|
|
|
|
enum AccountType: string
|
|
{
|
|
case Checking = 'checking';
|
|
case CreditCard = 'credit_card';
|
|
case Investment = 'investment';
|
|
case Loan = 'loan';
|
|
case Retirement = 'retirement';
|
|
case RealEstate = 'real_estate';
|
|
case Savings = 'savings';
|
|
case Others = 'others';
|
|
|
|
/**
|
|
* Whether this account type supports tracking invested amount and gains/losses.
|
|
*/
|
|
public function supportsInvestedAmount(): bool
|
|
{
|
|
return in_array($this, [self::Investment, self::Retirement, self::Savings], true);
|
|
}
|
|
|
|
public function reducesNetWorth(): bool
|
|
{
|
|
return in_array($this, [self::CreditCard, self::Loan], true);
|
|
}
|
|
|
|
/**
|
|
* Whether this account type is non-transactional (balance tracking only).
|
|
*/
|
|
public function isNonTransactional(): bool
|
|
{
|
|
return in_array($this, [self::Investment, self::Retirement, self::RealEstate], true);
|
|
}
|
|
|
|
/**
|
|
* Whether this account type surfaces a transaction ledger in the UI. The
|
|
* account detail page renders a transaction list only for these types.
|
|
*
|
|
* Mirrors the frontend `isTransactionalAccount`. This is intentionally
|
|
* distinct from isNonTransactional(): that is the narrower balance-only
|
|
* concept used for net-worth charts and treats loan accounts as
|
|
* balance-tracking-with-amortization, whereas a loan has no editable ledger.
|
|
*/
|
|
public function hasTransactionLedger(): bool
|
|
{
|
|
return ! in_array($this, [self::Investment, self::Loan, self::Retirement, self::RealEstate], true);
|
|
}
|
|
|
|
/**
|
|
* Whether a bank connection can sync transactions into this account type.
|
|
* Excludes balance/value-tracking types (loan, investment, retirement, real estate).
|
|
*/
|
|
public function canSyncBankTransactions(): bool
|
|
{
|
|
return in_array($this, [self::Checking, self::CreditCard, self::Savings, self::Others], true);
|
|
}
|
|
}
|