Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Fix and clean up subscriptions.
James Colea0f510f38ab1
diff --git a/app/Http/Controllers/Budget/IndexController.php b/app/Http/Controllers/Budget/IndexController.phpindex 674f77fbee..507187db73 100644--- a/app/Http/Controllers/Budget/IndexController.php+++ b/app/Http/Controllers/Budget/IndexController.php@@ -73,7 +73,7 @@ final class IndexController extends Controller$this->middleware(function ($request, $next) {app('view')->share('title', (string) trans('firefly.budgets'));- app('view')->share('mainTitleIcon', 'fa-pie-chart');+ app('view')->share('mainTitleIcon', 'bi-pie-chart');$this->repository = app(BudgetRepositoryInterface::class);$this->opsRepository = app(OperationsRepositoryInterface::class);$this->abRepository = app(AvailableBudgetRepositoryInterface::class);diff --git a/app/View/Components/Lists/Accounts.php b/app/View/Components/Lists/Accounts.phpindex 6927ca564a..5a033ad930 100644--- a/app/View/Components/Lists/Accounts.php+++ b/app/View/Components/Lists/Accounts.php@@ -1,6 +1,6 @@<?php-namespace FireflyIII\View\Components\lists;+namespace FireflyIII\View\Components\Lists;use Closure;use Illuminate\Contracts\View\View;@@ -12,6 +12,7 @@ class Accounts extends Component{public LengthAwarePaginator $accounts;public string $objectType = '';+/*** Create a new component instance.*/diff --git a/app/View/Components/Lists/Subscriptions.php b/app/View/Components/Lists/Subscriptions.phpnew file mode 100644index 0000000000..e182531b45--- /dev/null+++ b/app/View/Components/Lists/Subscriptions.php@@ -0,0 +1,32 @@+<?php++namespace FireflyIII\View\Components\Lists;++use Closure;+use Illuminate\Contracts\View\View;+use Illuminate\Pagination\LengthAwarePaginator;+use Illuminate\View\Component;++class Subscriptions extends Component+{+ public array $bills;+ public array $sums;+ public array $totals;+ /**+ * Create a new component instance.+ */+ public function __construct(array $bills, array $sums, array $totals)+ {+ $this->bills = $bills;+ $this->sums = $sums;+ $this->totals = $totals;+ }++ /**+ * Get the view / contents that represent the component.+ */+ public function render(): View|Closure|string+ {+ return view('components.lists.subscriptions');+ }+}diff --git a/resources/assets/v3/js/pages/subscriptions/index.js b/resources/assets/v3/js/pages/subscriptions/index.jsnew file mode 100644index 0000000000..217ae6c5fb--- /dev/null+++ b/resources/assets/v3/js/pages/subscriptions/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/sass/app.scss b/resources/assets/v3/sass/app.scssindex 5edaebb5c7..1c5b0e0483 100644--- a/resources/assets/v3/sass/app.scss+++ b/resources/assets/v3/sass/app.scss@@ -62,6 +62,10 @@ body.waiting * {cursor: progress;}+/* some borders and lines */+.top-light-border {border-top:1px #aaa solid;}+.top-dark-border {border-top:1px #777 solid;}+.bottom-light-border {border-bottom:1px #aaa solid;}diff --git a/resources/assets/v3/vite.config.js b/resources/assets/v3/vite.config.jsindex da1c7b24de..e927689562 100644--- a/resources/assets/v3/vite.config.js+++ b/resources/assets/v3/vite.config.js@@ -52,6 +52,9 @@ export default defineConfig(({command, mode, isSsrBuild, isPreview}) => {// budgets'js/pages/budgets/index.js',++ // subscriptions+ 'js/pages/subscriptions/index.js',],buildDirectory: '../../../../public/build',// publicDirectory: '../../../public',diff --git a/resources/views/bills/index.blade.php b/resources/views/bills/index.blade.phpindex 973dddc27a..8d50e96b14 100644--- a/resources/views/bills/index.blade.php+++ b/resources/views/bills/index.blade.php@@ -1,46 +1,58 @@-{% extends './layout/default' %}--{% block breadcrumbs %}- {{ Breadcrumbs.render(Route.getCurrentRoute.getName) }}-{% endblock %}--{% block content %}- {% if total == 0 %}+@extends('layout.v3.session')+@section('content')+ @if(0 === $total)+ TODO TODO TODO{% include 'partials.empty' with {objectType: 'default', type: 'bills',route: route('subscriptions.create')} %}- {% else %}+ @endif+ @if($total > 0)<div class="row"><div class="col-lg-12 col-sm-12 col-md-12">- <div class="box">- <div class="box-header with-border">- <h3 class="box-title">{{ title }}</h3>- <div class="box-tools pull-right">- <div class="btn-group">- <button class="btn btn-box-tool dropdown-toggle" data-toggle="dropdown"><span class="fa fa-ellipsis-v"></span></button>- <ul class="dropdown-menu" role="menu">- <li><a href="{{ route('subscriptions.create') }}"><span class="fa fa-plus fa-fw"></span> {{ 'new_bill'|_ }}</a></li>- </ul>+ <div class="card mb-2">+ <div class="card-header">+ <div class="row">+ <div class="col">+ <h3 class="card-title">{{ $title }}</h3>+ </div>+ <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('subscriptions.create') }}"><span+ class="bi bi-plus-circle"></span> {{ __('firefly.create_new_bill') }}+ </a></li>+ </ul>+ </div></div></div></div>- <div class="box-body no-padding">- <div class="m-1">- <a class="btn btn-success" href="{{ route('subscriptions.create') }}"><span class="fa fa-plus fa-fw"></span> {{ 'create_new_bill'|_ }}</a>- </div>- {% include 'list/bills' %}+ <div class="card-body p-0">+ <x-lists.subscriptions :bills="$bills" :sums="$sums" :totals="$totals" /></div>- <div class="box-footer">- <a class="btn btn-success" href="{{ route('subscriptions.create') }}"><span class="fa fa-plus fa-fw"></span> {{ 'create_new_bill'|_ }}</a>+ <div class="card-footer">+ <div class="row">+ <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('subscriptions.create') }}"><span+ class="bi bi-plus-circle"></span> {{ __('firefly.create_new_bill') }}+ </a></li>+ </ul>+ </div>+ </div>+ </div></div></div></div></div>- {% endif %}-{% endblock %}--{% block styles %}-{% endblock %}--{% block scripts %}- <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/bills/index.js?v={{ FF_BUILD_TIME }}" nonce="{{ JS_NONCE }}"></script>-{% endblock %}+@endif+@endsection+@section('scripts')+ @vite(['js/pages/subscriptions/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/bills/index.js?v={{ $FF_BUILD_TIME }}" nonce="{{ $JS_NONCE }}"></script>+@endsectiondiff --git a/resources/views/components/lists/subscriptions.blade.php b/resources/views/components/lists/subscriptions.blade.phpnew file mode 100644index 0000000000..43b01ec86c--- /dev/null+++ b/resources/views/components/lists/subscriptions.blade.php@@ -0,0 +1,236 @@+@foreach($bills as $objectGroupOrder => $objectGroup)+<h5 class="m-3">{{ $objectGroup['object_group_title'] }}</h5>++<table class="table table-hover table-bordered mb-3" id="bill-sortable">+ <thead class="table-secondary">+ <tr>+ <th class="hidden-sm hidden-xs"> </th>+ <th class="hidden-sm hidden-xs"> </th>+ <th>{{ __('list.name') }}</th>+ <th class="hidden-sm hidden-md hidden-xs">{{ __('list.linked_to_rules') }}</th>+ <th class="text-right">{{ trans('list.matchingAmount') }}</th>+ <th class="hidden-sm hidden-xs">{{ trans('list.paid_current_period') }}</th>+ <th class="hidden-sm hidden-xs">{{ trans('list.next_expected_match') }}</th>+ <th class="hidden-sm hidden-xs">{{ trans('list.repeat_freq') }}</th>+ </tr>+ </thead>+ @if(count($objectGroup['bills']) > 0)+ <tbody class="bill-connected-list" data-title="{{ $objectGroup['object_group_title'] }}">+ @foreach($objectGroup['bills'] as $entry)+ <tr class="bill-sortable" data-id="{{ $entry['id'] }}" data-name="{{ $entry['name'] }}" data-order="{{ $entry['order'] }}" data-position="{{ $loop->index }}">+ <td class="hidden-sm hidden-xs">+ <span class="bi bi-list bill-handle"></span>+ </td>+ <td class="hidden-sm hidden-xs">+ <div class="btn-group btn-group-sm edit_tr_buttons"><a href="{{ route('subscriptions.edit',$entry['id']) }}"+ class="btn btn-secondary"><span+ class="bi bi-pencil"></span></a><a+ href="{{ route('subscriptions.delete',$entry['id']) }}" class="btn btn-danger"><span+ class="bi bi-trash"></span></a></div>+ </td>+ <td>+ @if(!$entry['active'])+ <span class="bi bi-ban"></span>+ @endif+ <a href="{{ route('subscriptions.show',$entry['id']) }}" title="{{ $entry['name'] }}">{{ $entry['name'] }}</a>+ {{-- count attachments --}}+ @if(count($entry['attachments']) > 0)+ <span class="bi bi-paperclip"></span>+ @endif++ </td>+ <td class="hidden-sm hidden-md hidden-xs rules">+ @if(count($entry['rules']) > 0)+ <ul class="list-unstyled">+ @foreach($entry['rules'] as $rule)+ <li>+ <a href="{{ route('rules.edit', [$rule['id']]) }}">+ {{ $rule['title'] }}+ </a>+ @if(!$rule['active'])({{ strtolower(__('firefly.list_inactive_rule')) }})@endif+ </li>+ @endforeach+ </ul>+ @endif+ </td>+ <td class="text-right">+ <span class="mr-2" title="{{ e(\FireflyIII\Support\Facades\Steam::formatAmountBySymbol($entry['amount_min'], $entry['currency_symbol'], $entry['currency_decimal_places'], false)) }} -- {{ e(\FireflyIII\Support\Facades\Steam::formatAmountBySymbol($entry['amount_max'], $entry['currency_symbol'], $entry['currency_decimal_places'], false)) }}">+ ~ {!! \FireflyIII\Support\Facades\Steam::formatAmountBySymbol(($entry['amount_max'] + $entry['amount_min'])/2, $entry['currency_symbol'], $entry['currency_decimal_places']) !!}++ @if('0' !== $entry['pc_amount_max'] && null !== $entry['pc_amount_max'])+ (~ {{ \FireflyIII\Support\Facades\Steam::formatAmountBySymbol(($entry['pc_amount_max'] + $entry['pc_amount_min'])/2, $primaryCurrency->symbol, $primaryCurrency->decimal_places) }})+ @endif+ </span>+ </td>++ {{--+ paidDates = 0 (bill not paid in period)+ pay_dates = 0 (bill not expected to be paid in this period)+ bill is active.+ --}}+ @if(0 === count($entry['paid_dates']) && 0 === count($entry['pay_dates']) && $entry['active'])+ <td class="paid_in_period text-muted">+ {{ trans('firefly.not_expected_period') }}+ </td>+ <td class="expected_in_period hidden-sm hidden-xs">+ @if($entry['next_expected_match'])+ {{ new \Carbon\Carbon($entry['next_expected_match'])->isoFormat($monthAndDayFormat) }}+ @endif+ </td>+ @endif++ {{--+ paid_dates = 0 (bill not paid in period)+ pay_dates > 0 (bill IS expected to be paid in this period)+ bill is active+ first pay date is in the past.+ --}}+ @if(0 === count($entry['paid_dates']) && count($entry['pay_dates']) > 0 && $entry['active'])+ @if($entry['next_expected_match_diff'] === __('firefly.not_expected_period')) {{-- terrible code, you should sue me for this. --}}+ <td class="paid_in_period text-muted">+ {{ $entry['next_expected_match_diff'] }}+ </td>+ @else+ <td class="paid_in_period text-warning">+ {{ $entry['next_expected_match_diff'] }}+ <!-- {{ __('firefly.bill_expected_date', ['date' => $entry['next_expected_match_diff']]) }} -->+ </td>+ @endif+ <td class="expected_in_period hidden-sm hidden-xs">+ @foreach($entry['pay_dates'] as $date)+ {{ new \Carbon\Carbon($date)->isoFormat($monthAndDayFormat) }}<br>+ @endforeach++ </td>+ @endif++ {{--+ paid_dates >= 0 (bill is paid X times).+ Don't care about pay_dates.+ --}}++ @if(count($entry['paid_dates']) > 0 && $entry['active'])+ <td class="paid_in_period text-success">+ @foreach($entry['paid_dates'] as $currentPaid)+ <a href="{{ route('transactions.show', $currentPaid['transaction_group_id']) }}">+ {{ new \Carbon\Carbon($currentPaid['date'])->isoFormat($monthAndDayFormat) }}+ </a>+ <br/>+ @endforeach+ </td>+ <td class="expected_in_period hidden-sm hidden-xs">+ @if($entry['next_expected_match'])+ {{ new \Carbon\Carbon($entry['next_expected_match'])->isoFormat($monthAndDayFormat) }}+ @else+ <span class="text-muted">{{ $entry['next_expected_match_diff'] }}</span>+ @endif+ </td>+ @endif+ {{-- bill is not active --}}+ @if(!$entry['active'])+ <td class="paid_in_period text-muted">+ ~+ </td>+ <td class="expected_in_period text-muted hidden-sm hidden-xs">~</td>+ @endif+ <td class="hidden-sm hidden-xs">+ {{ __('firefly.repeat_freq_' . $entry['repeat_freq']) }}+ @if($entry['skip'] > 0)+ {{ __('firefly.skips_over') }} {{ $entry['skip'] }}+ @endif+ @if(null !== $entry['end_date'])+ <br>+ @if(new \Carbon\Carbon($entry['end_date'])->lte($today))+ <span class="text-danger">{{ trans('firefly.bill_end_index_line', ['date' => new \Carbon\Carbon($entry['end_date'])->isoFormat($monthAndDayFormat)]) }}</span>+ @else+ {{ trans('firefly.bill_end_index_line', ['date' => new \Carbon\Carbon($entry['end_date'])->isoFormat($monthAndDayFormat)]) }}+ @endif+ @endif+ @if($entry['extension_date'])+ <br>+ @if(new \Carbon\Carbon($entry['extension_date'])->lte($today))+ <span class="text-danger">{{ trans('firefly.bill_extension_index_line', ['date' => new \Carbon\Carbon($entry['extension_date'])->isoFormat($monthAndDayFormat)]) }}</span>+ @else+ {{ trans('firefly.bill_extension_index_line', ['date' => new \Carbon\Carbon($entry['extension_date'])->isoFormat($monthAndDayFormat)]) }}+ @endif+ @endif+ </td>+ </tr>+ @endforeach+ @foreach($sums[$objectGroupOrder] as $sum)+ @if('0' !== $sum['avg'])+ <tr>+ <td class="hidden-sm hidden-xs" colspan="2"> </td> <!-- handle -->+ <td colspan="2" class="text-right"> <!-- title -->+ <small>{{ __('firefly.sum') }} ({{ $sum['currency_name'] }}) ({{ __('firefly.active_exp_bills_only') }})</small>+ </td>+ <td class="text-right"> <!-- amount -->+ {!! \FireflyIII\Support\Facades\Steam::formatAmountBySymbol($sum['avg'], $sum['currency_symbol'], $sum['currency_decimal_places']) !!}+ </td>+ <td class="hidden-sm hidden-xs" colspan="3"> </td> <!-- handle -->+ </tr>+ @endif+ @if('0' !== $sum['total_left_to_pay'])+ <tr>+ <td class="hidden-sm hidden-xs" colspan="2"> </td> <!-- handle -->+ <td colspan="2" class="text-right"> <!-- title -->+ <small>{{ __('firefly.sum') }} ({{ $sum['currency_name'] }}) ({{ __('firefly.left_to_pay_active_bills') }})</small>+ </td>+ <td class="text-right"> <!-- amount -->+ {!! \FireflyIII\Support\Facades\Steam::formatAmountBySymbol($sum['total_left_to_pay'], $sum['currency_symbol'], $sum['currency_decimal_places']) !!}+ </td>+ <td class="hidden-sm hidden-xs" colspan="3"> </td> <!-- handle -->+ </tr>+ @endif+ @if('0' !== $sum['per_period'])+ <tr>+ <td class="hidden-sm hidden-xs" colspan="2"> </td> <!-- handle -->+ <td colspan="2" class="text-right"> <!-- title -->+ <small>{{ __('firefly.per_period_sum_' . $sum['period']) }} ({{ $sum['currency_name'] }})+ ({{ __('firefly.active_bills_only') }})</small>+ </td>+ <td class="text-right"> <!-- amount -->+ {!! \FireflyIII\Support\Facades\Steam::formatAmountBySymbol($sum['per_period'], $sum['currency_symbol'], $sum['currency_decimal_places']) !!}+ </td>+ <td class="hidden-sm hidden-xs" colspan="3"> </td> <!-- handle -->+ </tr>+ @endif+ @endforeach+ </tbody>+ @endif++</table>+@endforeach++<h5 class="m-3">Totals</h5>+@if(count($totals) > 0)++<table class="table table-bordered table-hover mb-3">+ <tbody>+ @foreach($totals as $sum)+ @if('0' !== $sum['avg'])+ <tr>+ <td class="text-right"> <!-- title -->+ <small>{{ __('firefly.sum') }} ({{ $sum['currency_name'] }}) ({{ __('firefly.active_exp_bills_only_total') }})</small>+ </td>+ <td class="text-right"> <!-- amount -->+ {!! \FireflyIII\Support\Facades\Steam::formatAmountBySymbol($sum['avg'], $sum['currency_symbol'], $sum['currency_decimal_places']) !!}+ </td>+ </tr>+ @endif+ @if('0' !== $sum['per_period'])+ <tr>+ <td class="text-right"> <!-- title -->+ <small>{{ __('firefly.per_period_sum_' . $sum['period']) }} ({{ $sum['currency_name'] }})+ ({{ __('firefly.active_bills_only_total') }})</small>+ </td>+ <td class="text-right"> <!-- amount -->+ {!! \FireflyIII\Support\Facades\Steam::formatAmountBySymbol($sum['per_period'], $sum['currency_symbol'], $sum['currency_decimal_places']) !!}+ </td>+ </tr>+ @endif+ @endforeach+ </tbody>++</table>+@endif