Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Fix subscriptions.
James Cole9bf2a9880699
diff --git a/app/View/Components/Lists/PiggyBanks.php b/app/View/Components/Lists/PiggyBanks.phpnew file mode 100644index 0000000000..586a8f2aed--- /dev/null+++ b/app/View/Components/Lists/PiggyBanks.php@@ -0,0 +1,27 @@+<?php++namespace FireflyIII\View\Components\Lists;++use Closure;+use Illuminate\Contracts\View\View;+use Illuminate\View\Component;++class PiggyBanks extends Component+{+ /**+ * Create a new component instance.+ */+ public array $piggyBanks;+ public function __construct(array $piggyBanks)+ {+ $this->piggyBanks = $piggyBanks;+ }++ /**+ * Get the view / contents that represent the component.+ */+ public function render(): View|Closure|string+ {+ return view('components.lists.piggy-banks');+ }+}diff --git a/resources/assets/v3/js/pages/piggy-banks/index.js b/resources/assets/v3/js/pages/piggy-banks/index.jsnew file mode 100644index 0000000000..217ae6c5fb--- /dev/null+++ b/resources/assets/v3/js/pages/piggy-banks/index.js@@ -0,0 +1,61 @@+/*+ * dashboard.js+ * Copyright (c) 2026 [email protected]+ *+ * This file is part of Firefly III (https://github.com/firefly-iii).+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ */++// CSS+import '../../boot/bootstrap.js';+import sidebar from '../../pages/shared/sidebar.js';+import dates from '../shared/dates.js';++let index = function () {+ return {+ foo2: 'bar2',+ init() {+ console.log('init op index xxx');+ }+ }+};+++const comps = {+ index,+ sidebar,+ dates+};++function loadPage(comps) {+ console.log('loadPage');+ Object.keys(comps).forEach(comp => {+ let data = comps[comp]();+ Alpine.data(comp, () => data);+ console.log(comp);+ });+ Alpine.start();+}++// wait for load until bootstrapped event is received.+document.addEventListener('firefly-iii-bootstrapped', () => {+ console.log('Loaded through event listener.');+ loadPage(comps);+});+// or is bootstrapped before event is triggered.+if (window.bootstrapped) {+ console.log('Loaded through window variable.');+ loadPage(comps);+}diff --git a/resources/assets/v3/vite.config.js b/resources/assets/v3/vite.config.jsindex e927689562..09d5a0a5c3 100644--- a/resources/assets/v3/vite.config.js+++ b/resources/assets/v3/vite.config.js@@ -55,6 +55,9 @@ export default defineConfig(({command, mode, isSsrBuild, isPreview}) => {// subscriptions'js/pages/subscriptions/index.js',++ // piggy banks+ 'js/pages/piggy-banks/index.js',],buildDirectory: '../../../../public/build',// publicDirectory: '../../../public',diff --git a/resources/views/components/lists/piggy-banks.blade.php b/resources/views/components/lists/piggy-banks.blade.phpnew file mode 100644index 0000000000..2d92587d7b--- /dev/null+++ b/resources/views/components/lists/piggy-banks.blade.php@@ -0,0 +1,143 @@+@foreach($piggyBanks as $objectGroupOrder => $objectGroup)+ <h5 class="m-3">{{ $objectGroup['object_group_title'] }}</h5>+<table class="table table-hover table-condensed mb-3" id="piggy-sortable">+ <thead>+ <tr>+ <th style="width:50px;" class="d-none d-md-table-cell"> </th>+ <th class="d-table-cell d-md-none"></th>+ <th style="width:50px;"></th>+ <th style="width:30%;">{{ __('firefly.piggy_bank') }}</th>+ <th style="width:10%;" class="text-end">{{ __('firefly.saved_so_far') }}</th>+ <th class="d-none d-md-table-cell"></th>+ <th class="d-none d-md-table-cell"></th>+ <th class="d-none d-md-table-cell"></th>+ <th style="width:10%;" class="text-end">{{ __('firefly.target_amount') }}</th>+ <th style="width:10%;" class="d-none d-md-table-cell text-end">{{ __('firefly.left_to_save') }}</th>+ <th style="width:15%;" class="d-none d-md-table-cell text-end">{{ __('firefly.suggested_savings_per_month') }}</th>+ </tr>+ </thead>+ @if(count($objectGroup['piggy_banks']) > 0)+ <tbody class="piggy-connected-list" @if(0 !== $objectGroupOrder)data-title="{{ $objectGroup['object_group_title'] }}"@else data-title=""@endif>+ @foreach($objectGroup['piggy_banks'] as $piggy)+ <tr class="piggy-sortable" data-id="{{ $piggy['id'] }}" data-name="{{ $piggy['name'] }}" data-order="{{ $piggy['order'] }}">+ <td class="d-none d-md-table-cell">+ <span class="bi bi-list piggy-handle"></span>+ <span class="loadSpin"></span>+ </td>+ <td class="d-table-cell d-md-none">+ <div class="btn-group btn-group-sm">+ <a href="{{ route('piggy-banks.remove-money-mobile', $piggy['id']) }}" class="btn btn-secondary btn-sm"><span class="bi bi-plus"></span></a>+ <a href="{{ route('piggy-banks.add-money-mobile', $piggy['id']) }}" class="btn btn-secondary btn-sm"><span class="bi bi-dash"></span></a>+ </div>+ </td>+ <td style="width:100px;">+ <div class="btn-group btn-group-sm">+ <a href="{{ route('piggy-banks.edit', $piggy['id']) }}" class="btn btn-secondary btn-sm"><span class="bi bi-pencil"></span></a>+ <a href="{{ route('piggy-banks.delete', $piggy['id']) }}" class="btn btn-danger btn-sm"><span class="bi bi-trash"></span></a>+ </div>+ </td>+ <td>+ <a href="{{ route('piggy-banks.show', $piggy['id']) }}" title="{{ $piggy['name'] }}">{{ $piggy['name'] }}</a>+ @if(count($piggy['attachments']) > 0)+ <span class="fa fa-fw fa-paperclip"></span>+ @endif+ </td>+ <td class="text-end piggySaved">+ <span title="Saved so far" class="text-end">+ {!! \FireflyIII\Support\Facades\Steam::formatAmountBySymbol($piggy['current_amount'],$piggy['currency_symbol'],$piggy['currency_decimal_places']) !!}+ @if($convertToPrimary and $piggy['currency_id'] !== $primaryCurrency->id && null !== $piggy['pc_current_amount'])+ ({!! \FireflyIII\Support\Facades\Steam::formatAmountBySymbol($piggy['pc_current_amount'],$primaryCurrency->symbol,$primaryCurrency->decimal_places) !!})+ @endif+ </span>+ </td>+ <td class="d-none d-md-table-cell" style="width:40px;">+ @if($piggy['current_amount'] > 0)+ <a href="{{ route('piggy-banks.remove-money', $piggy['id']) }}" class="btn btn-secondary btn-sm removeMoney" data-id="{{ $piggy['id'] }}">+ <span data-id="{{ $piggy['id'] }}" class="bi bi-dash"></span></a>+ @endif+ </td>++ <td class="piggyBar d-none d-md-table-cell">+ @if(null !== $piggy['percentage'])+ <div class="progress progress mb-0">+ <div+ @if(100 === $piggy['percentage'])+ class="progress-bar progress-bar-success w-{{ round(max(30, $piggy['percentage'])) }}"+ @elseif(0 === $piggy['percentage'])+ class="progress-bar progress-bar-warning w-{{ round(max(30, $piggy['percentage'])) }}"+ @else+ class="progress-bar progress-bar-info w-{{ round(max(30, $piggy['percentage'])) }}"+ @endif+ role="progressbar" aria-valuenow="{{ $piggy['percentage'] }}" aria-valuemin="0" aria-valuemax="100">+ {{ $piggy['percentage'] }}%+ </div>+ </div>+ @endif+ </td>+++ <td style="width:40px;" class="d-none d-md-table-cell">+ @if($piggy['left_to_save'] > 0 || null === $piggy['left_to_save'])+ <a href="{{ route('piggy-banks.add-money', $piggy['id']) }}" class="btn btn-secondary btn-sm addMoney" data-id="{{ $piggy['id'] }}">+ <span data-id="{{ $piggy['id'] }}" class="b bi-plus"></span></a>+ @endif+ </td>+ <td class="text-end">+ @if(null !== $piggy['target_amount'] && 0 !== $piggy['target_amount'])+ <span title="{{ __('firefly.target_amount') }}">{!! \FireflyIII\Support\Facades\Steam::formatAmountBySymbol($piggy['target_amount'],$piggy['currency_symbol'],$piggy['currency_decimal_places']) !!}</span>+ @if($convertToPrimary && $piggy['currency_id'] !== $primaryCurrency->id && null !== $piggy['pc_target_amount'])+ (<span title="{{ __('firefly.target_amount') }}">{!! \FireflyIII\Support\Facades\Steam::formatAmountBySymbol($piggy['pc_target_amount'],$primaryCurrency->symbol, $primaryCurrency->decimal_places) !!}</span>)+ @endif+ @endif+ </td>+ <td class="text-end d-none d-md-table-cell">+ @if($piggy['left_to_save'] > 0)+ <span title="{{ __('firefly.left_to_save') }}">{!! \FireflyIII\Support\Facades\Steam::formatAmountBySymbol($piggy['left_to_save'],$piggy['currency_symbol'],$piggy['currency_decimal_places']) !!}</span>+ @if($convertToPrimary && $piggy['currency_id'] !== $primaryCurrency->id && null !== $piggy['pc_left_to_save'])+ (<span title="{{ __('firefly.left_to_save') }}">{!! \FireflyIII\Support\Facades\Steam::formatAmountBySymbol($piggy['pc_left_to_save'], $primaryCurrency->symbol,$primaryCurrency->decimal_places) !!}</span>)+ @endif+ @endif+ </td>+ <td class="d-none d-md-table-cell text-end">+ @if(null !== $piggy['target_date'] && null !== $piggy['save_per_month'])+ {!! \FireflyIII\Support\Facades\Steam::formatAmountBySymbol($piggy['save_per_month'], $piggy['currency_symbol'], $piggy['currency_decimal_places']) !!}+ @if($convertToPrimary && $piggy['currency_id'] !== $primaryCurrency->id && null !== $piggy['pc_save_per_month'])+ ({!! \FireflyIII\Support\Facades\Steam::formatAmountBySymbol($piggy['pc_save_per_month'], $primaryCurrency->symbol, $primaryCurrency->decimal_places) !!})+ @endif+ @endif+ </td>+ </tr>+ @endforeach+ <tr>+ <td class="d-none d-md-table-cell"> </td> {{-- handle --}}+ <td class="d-table-cell d-md-none"> </td> {{-- mobile buttons --}}+ <td> </td> {{-- normal buttons --}}+ <td> </td> {{-- title --}}+ <td class="text-end">+ @foreach($objectGroup['sums'] as $sum)+ {!! \FireflyIII\Support\Facades\Steam::formatAmountBySymbol($sum['saved'], $sum['currency_symbol'], $sum['currency_decimal_places']) !!}<br />+ @endforeach+ </td>+ <td class="d-none d-md-table-cell"> </td> {{-- remove money --}}+ <td class="d-none d-md-table-cell"> </td> {{-- progress --}}+ <td class="d-none d-md-table-cell"> </td> {{-- add money --}}+ <td class="text-end">+ @foreach($objectGroup['sums'] as $sum)+ {!! \FireflyIII\Support\Facades\Steam::formatAmountBySymbol($sum['target'], $sum['currency_symbol'], $sum['currency_decimal_places']) !!}<br />+ @endforeach+ </td>+ <td class="text-end d-none d-md-table-cell">+ @foreach($objectGroup['sums'] as $sum)+ {!! \FireflyIII\Support\Facades\Steam::formatAmountBySymbol($sum['left_to_save'], $sum['currency_symbol'], $sum['currency_decimal_places']) !!}<br />+ @endforeach+ </td>+ <td class="d-none d-md-table-cell text-end">+ @foreach($objectGroup['sums'] as $sum)+ {!! \FireflyIII\Support\Facades\Steam::formatAmountBySymbol($sum['save_per_month'], $sum['currency_symbol'], $sum['currency_decimal_places']) !!}<br />+ @endforeach+ </td>+ </tr>+ </tbody>+ @endif+</table>+@endforeachdiff --git a/resources/views/layout/v3/session.blade.php b/resources/views/layout/v3/session.blade.phpindex dacfa9a065..82e60a7d13 100644--- a/resources/views/layout/v3/session.blade.php+++ b/resources/views/layout/v3/session.blade.php@@ -96,6 +96,17 @@</ul><!--begin::End Navbar Links--><ul class="navbar-nav ms-auto">+ <li class="nav-item">+ <span class="nav-link">+ Size:+ <span class="d-inline d-sm-none">xs</span>+ <span class="d-none d-sm-inline d-md-none">sm</span>+ <span class="d-none d-md-inline d-lg-none">md</span>+ <span class="d-none d-lg-inline d-xl-none">lg</span>+ <span class="d-none d-xl-inline d-xxl-none">xl</span>+ <span class="d-none d-xxl-inline">xxl</span>+ </span>+ </li><!--begin::Navbar Search--><li class="nav-item"><a class="nav-link" data-widget="navbar-search" href="{{route('search.index')}}" role="button">diff --git a/resources/views/piggy-banks/index.blade.php b/resources/views/piggy-banks/index.blade.phpnew file mode 100644index 0000000000..c420e925be--- /dev/null+++ b/resources/views/piggy-banks/index.blade.php@@ -0,0 +1,108 @@+@extends('layout.v3.session')+@section('content')+ @if(0 === count($piggyBanks))+ TODO TODO TODO TODO+ {% include 'partials.empty' with {objectType: 'default', type: 'piggies',route: route('piggy-banks.create')} %}+ @endif+ @if(count($piggyBanks) > 0)+ <div class="row">+ <div class="col-lg-12 col-md-12 col-sm-12">+ <div class="card mb-3">+ <div class="card-header">+ <div class="row">+ <div class="col">+ <h3 class="card-title">{{ __('firefly.piggyBanks') }}</h3>+ </div>+ <div class="col">+ <div class="col text-end">+ <div class="dropdown">+ <button class="btn btn-sm btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton1" data-bs-toggle="dropdown" aria-expanded="false">+ <span class="bi bi-list"></span>+ </button>+ <ul class="dropdown-menu" aria-labelledby="dropdownMenuButton1">+ <li><a class="dropdown-item" href="{{ route('piggy-banks.create') }}"><span+ class="bi bi-plus-circle"></span> {{ __('firefly.create_new_piggy_bank') }}+ </a></li>+ </ul>+ </div>+ </div>+ </div>+ </div>+ </div>+ <div class="card-body p-0">+ <x-lists.piggy-banks :piggyBanks="$piggyBanks" />+ </div>+ <div class="card-footer">+ <div class="row">+ <div class="col">+ <div class="col text-end">+ <div class="dropdown">+ <button class="btn btn-sm btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton1" data-bs-toggle="dropdown" aria-expanded="false">+ <span class="bi bi-list"></span>+ </button>+ <ul class="dropdown-menu" aria-labelledby="dropdownMenuButton1">+ <li><a class="dropdown-item" href="{{ route('piggy-banks.create') }}"><span+ class="bi bi-plus-circle"></span> {{ __('firefly.create_new_piggy_bank') }}+ </a></li>+ </ul>+ </div>+ </div>+ </div>+ </div>+ </div>+ </div>+ </div>+ </div>++ <div class="row">+ <div class="col-lg-12 col-md-12 col-sm-12">+ <div class="card mb-3">+ <div class="card-header">+ <h3 class="card-title">{{ __('firefly.account_status') }}</h3>+ </div>+ <div class="card-body p-0">+ <table class="table table-hover" id="accountStatus">+ <thead>+ <tr>+ <th>{{ __('firefly.account') }}</th>+ <th class="text-right hidden-sm hidden-xs">{{ __('firefly.balance') }}</th>+ <th class="text-right">{{ __('firefly.left_for_piggy_banks') }}</th>+ <th class="text-right hidden-sm hidden-xs">{{ __('firefly.sum_of_piggy_banks') }}</th>+ <th class="text-right hidden-sm hidden-xs">{{ __('firefly.saved_so_far') }}</th>+ <th class="text-right hidden-sm hidden-xs">{{ __('firefly.left_to_save') }}</th>+ </tr>+ </thead>+ <tbody>+ @foreach($accounts as $id => $info)+ <tr>+ <td><a href="{{ route('accounts.show', $id) }}" title="{{ $info['name'] }}">{{ $info['name'] }}</a></td>+ <td class="text-right hidden-sm hidden-xs">+ {!! \FireflyIII\Support\Facades\Steam::formatAmountBySymbol($info['current_balance'],$info['currency_symbol'],$info['currency_decimal_places']) !!}+ </td>+ <td class="text-right">+ {!! \FireflyIII\Support\Facades\Steam::formatAmountBySymbol($info['left'],$info['currency_symbol'],$info['currency_decimal_places']) !!}+ </td>+ <td class="text-right hidden-sm hidden-xs">+ {!! \FireflyIII\Support\Facades\Steam::formatAmountBySymbol($info['target'],$info['currency_symbol'],$info['currency_decimal_places']) !!}+ </td>+ <td class="text-right hidden-sm hidden-xs">+ {!! \FireflyIII\Support\Facades\Steam::formatAmountBySymbol($info['saved'],$info['currency_symbol'],$info['currency_decimal_places']) !!}+ </td>+ <td class="text-right hidden-sm hidden-xs">+ {!! \FireflyIII\Support\Facades\Steam::formatAmountBySymbol($info['to_save'],$info['currency_symbol'],$info['currency_decimal_places']) !!}+ </td>+ </tr>+ @endforeach+ </tbody>+ </table>+ </div>+ </div>+ </div>+ </div>+ @endif+@endsection+@section('scripts')+ @vite(['js/pages/piggy-banks/index.js'])+ <script src="v1/js/lib/jquery-ui.min.js?v={{ $FF_BUILD_TIME }}" type="text/javascript" nonce="{{ $JS_NONCE }}"></script>+ <script type="text/javascript" src="v1/js/ff/piggy-banks/index.js?v={{ $FF_BUILD_TIME }}" nonce="{{ $JS_NONCE }}"></script>+@endsectiondiff --git a/resources/views/piggy-banks/index.twig b/resources/views/piggy-banks/old-index.twigsimilarity index 100%rename from resources/views/piggy-banks/index.twigrename to resources/views/piggy-banks/old-index.twig