diff --git a/app/Helpers/Functions/helpers.php b/app/Helpers/Functions/helpers.php index b5247a8363..1e7e1dbf87 100644 --- a/app/Helpers/Functions/helpers.php +++ b/app/Helpers/Functions/helpers.php @@ -25,8 +25,10 @@ declare(strict_types=1); use Carbon\Carbon; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Models\Account; +use FireflyIII\Models\Configuration; use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Support\Facades\Amount; +use FireflyIII\Support\Facades\AppConfiguration; use FireflyIII\Support\Facades\Steam; use Illuminate\Support\Collection; use Illuminate\Support\Facades\Log; @@ -51,6 +53,16 @@ if (!function_exists('env_default_when_empty')) { } } +if(!function_exists('getAppConfiguration')) { + function getAppConfiguration(string $name, mixed $default = null): mixed { + try { + return AppConfiguration::get($name, $default)?->data; + } catch (FireflyException) { + return null; + } + } +} + if(!function_exists('formatAmountBySymbol')) { function formatAmountBySymbol(string $amount, ?string $symbol = null, ?int $decimalPlaces = null, ?bool $coloured = null): string { diff --git a/app/View/Components/Elements/TransactionAmount.php b/app/View/Components/Elements/TransactionAmount.php new file mode 100644 index 0000000000..98ffb9ad51 --- /dev/null +++ b/app/View/Components/Elements/TransactionAmount.php @@ -0,0 +1,37 @@ +type = $type; + $this->amount = $amount; + $this->foreign = $foreign; + $this->account = $account; + $this->pcAmount = $pcAmount; + } + + /** + * Get the view / contents that represent the component. + */ + public function render(): View|Closure|string + { + return view('components.elements.transaction-amount'); + } +} diff --git a/app/View/Components/Elements/TransactionRunningBalance.php b/app/View/Components/Elements/TransactionRunningBalance.php new file mode 100644 index 0000000000..b5778003d8 --- /dev/null +++ b/app/View/Components/Elements/TransactionRunningBalance.php @@ -0,0 +1,46 @@ +balanceDirty = $balanceDirty ?? false; + $this->currency = $currency; + $this->foreign= $foreign; + $this->type = $type; + $this->source = $source; + $this->destination = $destination; + $this->account = $account; + } + + /** + * Get the view / contents that represent the component. + */ + public function render(): View|Closure|string + { + return view('components.elements.transaction-running-balance'); + } +} diff --git a/app/View/Components/Elements/TransactionTypeIcon.php b/app/View/Components/Elements/TransactionTypeIcon.php new file mode 100644 index 0000000000..b43ec3e848 --- /dev/null +++ b/app/View/Components/Elements/TransactionTypeIcon.php @@ -0,0 +1,27 @@ +type = $type; + } + + /** + * Get the view / contents that represent the component. + */ + public function render(): View|Closure|string + { + return view('components.elements.transaction-type-icon'); + } +} diff --git a/resources/views/accounts/index.blade.php b/resources/views/accounts/index.blade.php index 4d60fedbcd..90f05c75f6 100644 --- a/resources/views/accounts/index.blade.php +++ b/resources/views/accounts/index.blade.php @@ -4,45 +4,13 @@
-
-
-
-
{{ trans('firefly.'.$objectType.'_accounts') }}
-
- -
-
+
- +
@if($inactiveCount > 0 && !$inactivePage)

diff --git a/resources/views/components/elements/transaction-amount.blade.php b/resources/views/components/elements/transaction-amount.blade.php new file mode 100644 index 0000000000..9468386bf1 --- /dev/null +++ b/resources/views/components/elements/transaction-amount.blade.php @@ -0,0 +1,113 @@ + +{{-- deposit --}} +@if('Deposit' === $type) + {{-- amount of deposit --}} + {!! formatAmountBySymbol($amount['amount']*-1, $amount['currency_symbol'], $amount['currency_decimal_places']) !!} + {{-- foreign amount of deposit --}} + @if(null !== $foreign['amount']) + ({!! formatAmountBySymbol($foreign['amount']*-1, $foreign['currency_symbol'], $foreign['currency_decimal_places']) !!}) + @endif + {{-- primary currency amount of deposit --}} + @if($convertToPrimary && 0 != $pcAmount) + (~ {!! formatAmountBySymbol($pcAmount*-1, $primaryCurrency->symbol, $primaryCurrency->decimal_places) !!}) + @endif + {{-- transfer --}} +@elseif('Transfer' === $type) + {{-- amount of transfer --}} + + {{-- present as negative. --}} + @if($transaction['source_account_id'] === $account?->id) + neg {!! formatAmountBySymbol($amount['amount'], $amount['currency_symbol'], $amount['currency_decimal_places'], false) !!} + @endif + {{-- present as positive --}} + @if($transaction['source_account_id'] !== $account?->id) + {!! formatAmountBySymbol($amount['amount']*-1, $amount['currency_symbol'], $amount['currency_decimal_places'], false) !!} + @endif + {{-- foreign amount of transfer (negative) --}} + @if(null !== $foreign['amount'] && $transaction['source_account_id'] === $account?->id) + neg ({!! formatAmountBySymbol($foreign['amount'], $foreign['currency_symbol'], $foreign['currency_decimal_places'], false) !!}) + @endif + {{-- foreign amount of transfer (positive) --}} + @if(null !== $foreign['amount'] && $transaction['source_account_id'] !== $account?->id) + ({!! formatAmountBySymbol($foreign['amount']*-1, $foreign['currency_symbol'], $foreign['currency_decimal_places'], false) !!}) + @endif + {{-- transfer in primary currency. Does not care about direction. --}} + @if($convertToPrimary && 0 !== $pcAmount) + (~ {!! formatAmountBySymbol($pcAmount*-1, $primaryCurrency->symbol, $primaryCurrency->decimal_places) !!}) + @endif + + {{-- opening balance --}} +@elseif('Opening balance' === $type) + {{-- Is a positive opening balance, present as positive. --}} + @if('Initial balance account' === $transaction['source_account_type']) + {!! formatAmountBySymbol($amount['amount']*-1, $amount['currency_symbol'], $amount['currency_decimal_places']) !!} + {{-- opening balance may have foreign amount (also pos) --}} + @if(null !== $foreign['amount']) + ({!! formatAmountBySymbol($foreign['amount']*-1, $foreign['currency_symbol'], $foreign['currency_decimal_places']) !!}) + @endif + {{-- possibly, primary amount. --}} + @if($convertToPrimary && 0 !== $pcAmount) + (~ {!! formatAmountBySymbol($pcAmount*-1, $primaryCurrency->symbol, $primaryCurrency->decimal_places) !!}) + @endif + @else + {{-- withdrawal but also any other transaction type: --}} + {!! formatAmountBySymbol($amount['amount'], $amount['currency_symbol'], $amount['currency_decimal_places']) !!} + @if(null !== $foreign['amount']) + ({!! formatAmountBySymbol($foreign['amount'], $foreign['currency_symbol'], $foreign['currency_decimal_places']) !!}) + @endif + @if($convertToPrimary && 0 !== $pcAmount) + (~ {!! formatAmountBySymbol($pcAmount, $primaryCurrency->symbol, $primaryCurrency->decimal_places) !!}) + @endif + @endif +@elseif('Reconciliation' === $type) + {{-- Reconciliation positive--}} + @if('Reconciliation account' === $transaction['source_account_type']) + {{-- amount, also foreign and converted. --}} + {!! formatAmountBySymbol($amount['amount']*-1, $amount['currency_symbol'], $amount['currency_decimal_places']) !!} + @if(null !== $foreign['amount']) + ({!! formatAmountBySymbol($foreign['amount']*-1, $foreign['currency_symbol'], $foreign['currency_decimal_places']) !!}) + @endif + @if($convertToPrimary && 0 !== $pcAmount) + (~ {!! formatAmountBySymbol($pcAmount*-1, $primaryCurrency->symbol, $primaryCurrency->decimal_places) !!}) + @endif + @else + {{-- Reconciliation negative --}} + {!! formatAmountBySymbol($amount['amount'], $amount['currency_symbol'], $amount['currency_decimal_places']) !!} + @if(null !== $foreign['amount']) + ({!! formatAmountBySymbol($foreign['amount'], $foreign['currency_symbol'], $foreign['currency_decimal_places']) !!}) + @endif + @if($convertToPrimary && 0 !== $pcAmount) + (~ {!! formatAmountBySymbol($pcAmount, $primaryCurrency->symbol, $primaryCurrency->decimal_places) !!}) + @endif + @endif +@elseif('Liability credit' === $type) + {{-- liability credit positive--}} + @if('Liability credit' === $transaction['source_account_type']) + {!! formatAmountBySymbol($amount['amount'], $amount['currency_symbol'], $amount['currency_decimal_places']) !!} + @if(null !== $foreign['amount']) + ({!! formatAmountBySymbol($foreign['amount'], $foreign['currency_symbol'], $foreign['currency_decimal_places']) !!}) + @endif + @if($convertToPrimary && 0 !== $pcAmount) + (~ {!! formatAmountBySymbol($pcAmount, $primaryCurrency->symbol, $primaryCurrency->decimal_places) !!}) + @endif + @else + {!! formatAmountBySymbol($amount['amount']*-1, $amount['currency_symbol'], $amount['currency_decimal_places']) !!} + @if(null !== $foreign['amount']) + ({!! formatAmountBySymbol($foreign['amount']*-1, $foreign['currency_symbol'], $foreign['currency_decimal_places']) !!}) + @endif + @if($convertToPrimary && 0 !== $pcAmount) + (~ {!! formatAmountBySymbol($pcAmount*-1, $primaryCurrency->symbol, $primaryCurrency->decimal_places) !!}) + @endif + @endif +@else + {{-- THE REST most likely, withdrawal but also any other transaction type: --}} + {!! formatAmountBySymbol($amount['amount'], $amount['currency_symbol'], $amount['currency_decimal_places']) !!} + {{-- foreign amount of withdrawal --}} + @if(null !== $foreign['amount']) + ({!! formatAmountBySymbol($foreign['amount'], $foreign['currency_symbol'], $foreign['currency_decimal_places']) !!}) + @endif + {{-- primary currency amount of withdrawal, if not in foreign currency --}} + @if($convertToPrimary && 0 !== $pcAmount && $primaryCurrency->id !== $foreign['currency_id']) + (~ {!! formatAmountBySymbol($pcAmount, $primaryCurrency->symbol, $primaryCurrency->decimal_places) !!}) + @endif +@endif diff --git a/resources/views/components/elements/transaction-running-balance.blade.php b/resources/views/components/elements/transaction-running-balance.blade.php new file mode 100644 index 0000000000..6601490346 --- /dev/null +++ b/resources/views/components/elements/transaction-running-balance.blade.php @@ -0,0 +1,57 @@ +{{-- RUNNING BALANCE --}} +@if(false === $balanceDirty && '' !== $destination['balance_after'] && '' !== $source['balance_after']) + @if('Deposit' === $type) + @if($source['id'] === $account?->id) + {!! formatAmountBySymbol($source['balance_after'], $currency['symbol'], $currency['decimal_places']) !!} + @else + @if('Revenue account' === $source['type']) + {!! formatAmountBySymbol($destination['balance_after'], $currency['symbol'], $currency['decimal_places']) !!} + @else + {!! formatAmountBySymbol($destination['balance_after'], $foreign['currency_symbol'], $foreign['decimal_places']) !!} + @endif + {{-- if this is a deposit from revenue account, use the destination account currency? For #12043 and #12169. Otherwise, keep at source account -}} + {{-- changed from normal currency_symbol to foreign_currency_symbol for #12043 --}} + @endif + @elseif('Withdrawal' === $type) + {{-- withdrawal into a liability --}} + @if(in_array($destination['type'], ['Mortgage','Debt','Loan'], true)) + @if($account?->id === $source['id']) + {!! formatAmountBySymbol($source['balance_after'], $currency['symbol'], $currency['decimal_places']) !!} + @elseif($account?->id === $destination['id']) + {!! formatAmountBySymbol($destination['balance_after'], $currency['symbol'], $currency['decimal_places']) !!} + @else + - + @endif + {{-- withdrawal into an expense account --}} + @else + @if($account?->id === $source['id']) + {!! formatAmountBySymbol($source['balance_after'], $currency['symbol'], $currency['decimal_places']) !!} + @elseif($account?->id === $destination['id']) + {!! formatAmountBySymbol($destination['balance_after'], $currency['symbol'], $currency['decimal_places']) !!} + @else + - + @endif + @endif + @elseif('Opening balance' === $type) + @if($account?->id == $source['id']) + {!! formatAmountBySymbol($source['balance_after'], $currency['symbol'], $currency['decimal_places']) !!} + @elseif($account?->id == $destination['id']) + {!! formatAmountBySymbol($destination['balance_after'], $currency['symbol'], $currency['decimal_places']) !!} + @else + - + @endif + @elseif('Transfer' === $type) + @if($account?->id == $source['id']) + {!! formatAmountBySymbol($source['balance_after'], $currency['symbol'], $currency['decimal_places']) !!} + @else + @if(null === $foreign['id']) + {!! formatAmountBySymbol($destination['balance_after'], $currency['symbol'], $currency['decimal_places']) !!} + @endif + @if(null !== $foreign['id']) + {!! formatAmountBySymbol($destination['balance_after'], $foreign['currency_symbol'], $foreign['decimal_places']) !!} + @endif + @endif + @else +   + @endif +@endif diff --git a/resources/views/components/elements/transaction-type-icon.blade.php b/resources/views/components/elements/transaction-type-icon.blade.php new file mode 100644 index 0000000000..fa0afecd6b --- /dev/null +++ b/resources/views/components/elements/transaction-type-icon.blade.php @@ -0,0 +1,22 @@ + +@if('Withdrawal' === $type) + +@endif + +@if('Deposit' === $type) + +@endif + +@if('Transfer' === $type) + +@endif + +@if('Reconciliation' === $type) + +@endif +@if('Opening balance' === $type) + +@endif +@if('Liability credit' === $type) + +@endif diff --git a/resources/views/components/layout/sidebar.blade.php b/resources/views/components/layout/sidebar.blade.php index 2133ef6d24..29f91a70c6 100644 --- a/resources/views/components/layout/sidebar.blade.php +++ b/resources/views/components/layout/sidebar.blade.php @@ -65,25 +65,25 @@