mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-12 01:42:32 +00:00
Replace enum
This commit is contained in:
@@ -45,7 +45,7 @@ class JournalList implements BinderInterface
|
||||
// get the journals by using the collector.
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setTypes([TransactionTypeEnum::WITHDRAWAL->value, TransactionType::DEPOSIT, TransactionType::TRANSFER, TransactionType::RECONCILIATION]);
|
||||
$collector->setTypes([TransactionTypeEnum::WITHDRAWAL->value, TransactionType::DEPOSIT, TransactionTypeEnum::TRANSFER->value, TransactionType::RECONCILIATION]);
|
||||
$collector->withCategoryInformation()->withBudgetInformation()->withTagInformation()->withAccountInformation();
|
||||
$collector->setJournalIds($list);
|
||||
$result = $collector->getExtractedJournals();
|
||||
|
||||
@@ -25,6 +25,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Support\Http\Api;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Enums\TransactionTypeEnum;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
@@ -223,7 +224,7 @@ class AccountBalanceGrouped
|
||||
|
||||
|| (
|
||||
(
|
||||
TransactionType::TRANSFER === $journal['transaction_type_type']
|
||||
TransactionTypeEnum::TRANSFER->value === $journal['transaction_type_type']
|
||||
|| TransactionType::RECONCILIATION === $journal['transaction_type_type']
|
||||
|| TransactionType::OPENING_BALANCE === $journal['transaction_type_type']
|
||||
)
|
||||
|
||||
@@ -41,7 +41,7 @@ trait TransactionFilter
|
||||
'all' => [
|
||||
TransactionTypeEnum::WITHDRAWAL->value,
|
||||
TransactionType::DEPOSIT,
|
||||
TransactionType::TRANSFER,
|
||||
TransactionTypeEnum::TRANSFER->value,
|
||||
TransactionType::OPENING_BALANCE,
|
||||
TransactionType::RECONCILIATION,
|
||||
],
|
||||
@@ -52,14 +52,14 @@ trait TransactionFilter
|
||||
'income' => [TransactionType::DEPOSIT],
|
||||
'deposit' => [TransactionType::DEPOSIT],
|
||||
'deposits' => [TransactionType::DEPOSIT],
|
||||
'transfer' => [TransactionType::TRANSFER],
|
||||
'transfers' => [TransactionType::TRANSFER],
|
||||
'transfer' => [TransactionTypeEnum::TRANSFER->value],
|
||||
'transfers' => [TransactionTypeEnum::TRANSFER->value],
|
||||
'opening_balance' => [TransactionType::OPENING_BALANCE],
|
||||
'reconciliation' => [TransactionType::RECONCILIATION],
|
||||
'reconciliations' => [TransactionType::RECONCILIATION],
|
||||
'special' => [TransactionType::OPENING_BALANCE, TransactionType::RECONCILIATION],
|
||||
'specials' => [TransactionType::OPENING_BALANCE, TransactionType::RECONCILIATION],
|
||||
'default' => [TransactionTypeEnum::WITHDRAWAL->value, TransactionType::DEPOSIT, TransactionType::TRANSFER],
|
||||
'default' => [TransactionTypeEnum::WITHDRAWAL->value, TransactionType::DEPOSIT, TransactionTypeEnum::TRANSFER->value],
|
||||
];
|
||||
$return = [];
|
||||
$parts = explode(',', $type);
|
||||
|
||||
@@ -114,7 +114,7 @@ trait PeriodOverview
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setAccounts(new Collection([$account]));
|
||||
$collector->setRange($start, $end);
|
||||
$collector->setTypes([TransactionType::TRANSFER]);
|
||||
$collector->setTypes([TransactionTypeEnum::TRANSFER->value]);
|
||||
$transferSet = $collector->getExtractedJournals();
|
||||
|
||||
// loop dates
|
||||
@@ -288,7 +288,7 @@ trait PeriodOverview
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setCategory($category);
|
||||
$collector->setRange($start, $end);
|
||||
$collector->setTypes([TransactionType::TRANSFER]);
|
||||
$collector->setTypes([TransactionTypeEnum::TRANSFER->value]);
|
||||
$transferSet = $collector->getExtractedJournals();
|
||||
foreach ($dates as $currentDate) {
|
||||
$spent = $this->filterJournalsByDate($spentSet, $currentDate['start'], $currentDate['end']);
|
||||
@@ -410,7 +410,7 @@ trait PeriodOverview
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->withoutCategory();
|
||||
$collector->setRange($start, $end);
|
||||
$collector->setTypes([TransactionType::TRANSFER]);
|
||||
$collector->setTypes([TransactionTypeEnum::TRANSFER->value]);
|
||||
$transferSet = $collector->getExtractedJournals();
|
||||
|
||||
/** @var array $currentDate */
|
||||
@@ -479,7 +479,7 @@ trait PeriodOverview
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setTag($tag);
|
||||
$collector->setRange($start, $end);
|
||||
$collector->setTypes([TransactionType::TRANSFER]);
|
||||
$collector->setTypes([TransactionTypeEnum::TRANSFER->value]);
|
||||
$transferSet = $collector->getExtractedJournals();
|
||||
|
||||
// filer all of them:
|
||||
|
||||
@@ -61,7 +61,7 @@ trait TransactionCalculation
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
|
||||
$collector->setAccounts($accounts)->setRange($start, $end)->setTypes([TransactionTypeEnum::WITHDRAWAL->value, TransactionType::TRANSFER])
|
||||
$collector->setAccounts($accounts)->setRange($start, $end)->setTypes([TransactionTypeEnum::WITHDRAWAL->value, TransactionTypeEnum::TRANSFER->value])
|
||||
->setTags($tags)->withAccountInformation()
|
||||
;
|
||||
|
||||
@@ -75,7 +75,7 @@ trait TransactionCalculation
|
||||
{
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setAccounts($accounts)->setRange($start, $end)->setTypes([TransactionTypeEnum::WITHDRAWAL->value, TransactionType::TRANSFER])
|
||||
$collector->setAccounts($accounts)->setRange($start, $end)->setTypes([TransactionTypeEnum::WITHDRAWAL->value, TransactionTypeEnum::TRANSFER->value])
|
||||
->setBudgets($budgets)->withAccountInformation()
|
||||
;
|
||||
|
||||
@@ -92,7 +92,7 @@ trait TransactionCalculation
|
||||
$collector
|
||||
->setAccounts($accounts)
|
||||
->setRange($start, $end)
|
||||
->setTypes([TransactionTypeEnum::WITHDRAWAL->value, TransactionType::TRANSFER])
|
||||
->setTypes([TransactionTypeEnum::WITHDRAWAL->value, TransactionTypeEnum::TRANSFER->value])
|
||||
->setCategories($categories)
|
||||
->withAccountInformation()
|
||||
;
|
||||
@@ -107,7 +107,7 @@ trait TransactionCalculation
|
||||
{
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setAccounts($accounts)->setRange($start, $end)->setTypes([TransactionType::DEPOSIT, TransactionType::TRANSFER])
|
||||
$collector->setAccounts($accounts)->setRange($start, $end)->setTypes([TransactionType::DEPOSIT, TransactionTypeEnum::TRANSFER->value])
|
||||
->setCategories($categories)->withAccountInformation()
|
||||
;
|
||||
|
||||
@@ -135,7 +135,7 @@ trait TransactionCalculation
|
||||
{
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setAccounts($accounts)->setRange($start, $end)->setTypes([TransactionType::DEPOSIT, TransactionType::TRANSFER])
|
||||
$collector->setAccounts($accounts)->setRange($start, $end)->setTypes([TransactionType::DEPOSIT, TransactionTypeEnum::TRANSFER->value])
|
||||
->setTags($tags)->withAccountInformation()
|
||||
;
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ trait UserNavigation
|
||||
return false;
|
||||
}
|
||||
$type = $journal->transactionType->type;
|
||||
$editable = [TransactionTypeEnum::WITHDRAWAL->value, TransactionType::TRANSFER, TransactionType::DEPOSIT, TransactionType::RECONCILIATION];
|
||||
$editable = [TransactionTypeEnum::WITHDRAWAL->value, TransactionTypeEnum::TRANSFER->value, TransactionType::DEPOSIT, TransactionType::RECONCILIATION];
|
||||
|
||||
return in_array($type, $editable, true);
|
||||
}
|
||||
|
||||
@@ -83,12 +83,12 @@ class TransactionGroupTwig extends AbstractExtension
|
||||
$sourceType = $array['source_account_type'] ?? 'invalid';
|
||||
$amount = $this->signAmount($amount, $type, $sourceType);
|
||||
|
||||
if (TransactionType::TRANSFER === $type) {
|
||||
if (TransactionTypeEnum::TRANSFER->value === $type) {
|
||||
$colored = false;
|
||||
}
|
||||
|
||||
$result = app('amount')->formatFlat($array['currency_symbol'], (int) $array['currency_decimal_places'], $amount, $colored);
|
||||
if (TransactionType::TRANSFER === $type) {
|
||||
if (TransactionTypeEnum::TRANSFER->value === $type) {
|
||||
$result = sprintf('<span class="text-info money-transfer">%s</span>', $result);
|
||||
}
|
||||
|
||||
@@ -127,11 +127,11 @@ class TransactionGroupTwig extends AbstractExtension
|
||||
$sourceType = $array['source_account_type'] ?? 'invalid';
|
||||
$amount = $this->signAmount($amount, $type, $sourceType);
|
||||
|
||||
if (TransactionType::TRANSFER === $type) {
|
||||
if (TransactionTypeEnum::TRANSFER->value === $type) {
|
||||
$colored = false;
|
||||
}
|
||||
$result = app('amount')->formatFlat($array['foreign_currency_symbol'], (int) $array['foreign_currency_decimal_places'], $amount, $colored);
|
||||
if (TransactionType::TRANSFER === $type) {
|
||||
if (TransactionTypeEnum::TRANSFER->value === $type) {
|
||||
$result = sprintf('<span class="text-info money-transfer">%s</span>', $result);
|
||||
}
|
||||
|
||||
@@ -173,11 +173,11 @@ class TransactionGroupTwig extends AbstractExtension
|
||||
|
||||
$amount = $this->signAmount($amount, $type, $sourceType);
|
||||
|
||||
if (TransactionType::TRANSFER === $type) {
|
||||
if (TransactionTypeEnum::TRANSFER->value === $type) {
|
||||
$colored = false;
|
||||
}
|
||||
$result = app('amount')->formatFlat($currency->symbol, $currency->decimal_places, $amount, $colored);
|
||||
if (TransactionType::TRANSFER === $type) {
|
||||
if (TransactionTypeEnum::TRANSFER->value === $type) {
|
||||
$result = sprintf('<span class="text-info money-transfer">%s</span>', $result);
|
||||
}
|
||||
|
||||
@@ -208,11 +208,11 @@ class TransactionGroupTwig extends AbstractExtension
|
||||
|
||||
$amount = $this->signAmount($amount, $type, $sourceType);
|
||||
|
||||
if (TransactionType::TRANSFER === $type) {
|
||||
if (TransactionTypeEnum::TRANSFER->value === $type) {
|
||||
$colored = false;
|
||||
}
|
||||
$result = app('amount')->formatFlat($currency->symbol, $currency->decimal_places, $amount, $colored);
|
||||
if (TransactionType::TRANSFER === $type) {
|
||||
if (TransactionTypeEnum::TRANSFER->value === $type) {
|
||||
$result = sprintf('<span class="text-info money-transfer">%s</span>', $result);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user