Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
more progress
Sander Dorigocf53df569a31
diff --git a/app/Helpers/Functions/helpers.php b/app/Helpers/Functions/helpers.phpindex 1e7e1dbf87..46ffe93e2c 100644--- a/app/Helpers/Functions/helpers.php+++ b/app/Helpers/Functions/helpers.php@@ -30,8 +30,10 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;use FireflyIII\Support\Facades\Amount;use FireflyIII\Support\Facades\AppConfiguration;use FireflyIII\Support\Facades\Steam;+use FireflyIII\Support\Search\OperatorQuerySearch;use Illuminate\Support\Collection;use Illuminate\Support\Facades\Log;+use League\CommonMark\GithubFlavoredMarkdownConverter;use function Safe\mb_ord;use function Safe\preg_match;use function Safe\preg_replace_callback;@@ -53,6 +55,22 @@ if (!function_exists('env_default_when_empty')) {}}+if(!function_exists('parseMarkdown')) {+ function parseMarkdown(string $string): string {+ $converter = new GithubFlavoredMarkdownConverter(['allow_unsafe_links' => false, 'max_nesting_level' => 5, 'html_input' => 'escape']);++ return (string) $converter->convert($string);+ }+}++if(!function_exists('getRootSearchOperator')) {+ function getRootSearchOperator(string $operator): string {+ $result = OperatorQuerySearch::getRootOperator($operator);++ return str_replace('-', 'not_', $result);+ }+}+if(!function_exists('getAppConfiguration')) {function getAppConfiguration(string $name, mixed $default = null): mixed {try {diff --git a/app/Support/Http/Controllers/PeriodOverview.php b/app/Support/Http/Controllers/PeriodOverview.phpindex d0cd6f7c03..9fe656b6af 100644--- a/app/Support/Http/Controllers/PeriodOverview.php+++ b/app/Support/Http/Controllers/PeriodOverview.php@@ -155,6 +155,7 @@ trait PeriodOverview'revenue' => 'earned','transfer' => 'transferred','transfers' => 'transferred',+ 'all' => 'all',];if (!array_key_exists($type, $setTypes)) {throw new FireflyException(sprintf('[c] Cannot deal with type "%s"', $type));diff --git a/config/firefly.php b/config/firefly.phpindex ce28ff1124..832c56aaf9 100644--- a/config/firefly.php+++ b/config/firefly.php@@ -390,6 +390,7 @@ return [AccountTypeEnum::MORTGAGE->value => AccountTypeEnum::MORTGAGE->value,],'transactionTypesByType' => [+ 'all' => ['Withdrawal','Deposit','Transfer'],'expenses' => ['Withdrawal'],'withdrawal' => ['Withdrawal'],'revenue' => ['Deposit'],diff --git a/resources/assets/v3/js/pages/rules/index.js b/resources/assets/v3/js/pages/rules/index.jsnew file mode 100644index 0000000000..217ae6c5fb--- /dev/null+++ b/resources/assets/v3/js/pages/rules/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 124b5f60e1..e387aa6430 100644--- a/resources/assets/v3/vite.config.js+++ b/resources/assets/v3/vite.config.js@@ -53,6 +53,9 @@ export default defineConfig(({command, mode, isSsrBuild, isPreview}) => {// budgets'js/pages/budgets/index.js',+ // rules+ 'js/pages/rules/index.js',+// subscriptions'js/pages/subscriptions/index.js',diff --git a/resources/views/accounts/index.blade.php b/resources/views/accounts/index.blade.phpindex 90f05c75f6..b6d2d6ea37 100644--- a/resources/views/accounts/index.blade.php+++ b/resources/views/accounts/index.blade.php@@ -37,9 +37,10 @@</div>@endif@if(0 === count($accounts) && 1 === $page)- TODO TODO TODO TODO- {% include 'partials.empty' with {objectType: objectType, type: 'accounts',route: route('accounts.create', [objectType])} %}-+ @php+ $shownDemo = true+ @endphp+ <x-empty-page :route="route('accounts.create', [$objectType])" type="accounts" :object-type="$objectType" />@if($inactiveCount > 0)<p class="text-center"><small><em>diff --git a/resources/views/components/lists/periods.blade.php b/resources/views/components/lists/periods.blade.phpindex b188f2056b..703f4f285f 100644--- a/resources/views/components/lists/periods.blade.php+++ b/resources/views/components/lists/periods.blade.php@@ -14,7 +14,7 @@@endif@if(array_key_exists('spent', $period))@foreach($period['spent'] as $spent)- @if($spent['amount'] !== 0)+ @if(is_array($spent) && $spent['amount'] !== 0)<tr><td class="third">{{ __('firefly.spent') }}</td><td class="text-right">@@ -45,7 +45,7 @@@endforeach@endif@foreach($period['transferred'] ?? [] as $entry)- @if($entry['amount'] !== 0)+ @if(is_array($entry) && $entry['amount'] !== 0)<tr><td class="third">{{ __('firefly.transferred') }}</td><td class="text-right">@@ -58,7 +58,7 @@@endforeach@foreach($period['transferred_away'] ?? [] as $entry)- @if($entry['amount'] !== 0)+ @if(is_array($entry) && $entry['amount'] !== 0)<tr><td class="third">{{ __('firefly.transferred_away') }}</td><td class="text-right">diff --git a/resources/views/components/lists/piggy-banks.blade.php b/resources/views/components/lists/piggy-banks.blade.phpindex 2d92587d7b..b820a28bcb 100644--- a/resources/views/components/lists/piggy-banks.blade.php+++ b/resources/views/components/lists/piggy-banks.blade.php@@ -1,6 +1,6 @@@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">+<table class="table table-hover table-sm table-condensed" id="piggy-sortable"><thead><tr><th style="width:50px;" class="d-none d-md-table-cell"> </th>diff --git a/resources/views/components/lists/subscriptions.blade.php b/resources/views/components/lists/subscriptions.blade.phpindex 43b01ec86c..dc0818cde8 100644--- a/resources/views/components/lists/subscriptions.blade.php+++ b/resources/views/components/lists/subscriptions.blade.php@@ -1,7 +1,7 @@@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">+<table class="table table-hover table-sm table-bordered" id="bill-sortable"><thead class="table-secondary"><tr><th class="hidden-sm hidden-xs"> </th>@@ -202,9 +202,10 @@</table>@endforeach-<h5 class="m-3">Totals</h5>@if(count($totals) > 0)+<h5 class="m-3">Totals</h5>+<table class="table table-bordered table-hover mb-3"><tbody>@foreach($totals as $sum)diff --git a/resources/views/rules/index.blade.php b/resources/views/rules/index.blade.phpnew file mode 100644index 0000000000..816a4e4f14--- /dev/null+++ b/resources/views/rules/index.blade.php@@ -0,0 +1,210 @@+@extends('layout.v3.session')+@section('content')+ <div class="row">+ <div class="col-lg-12 col-md-12 col-sm-12">+ <div class="btn-group">+ <a href="{{ route('rule-groups.create') }}" id="new_rule_group" class="btn btn-success">{{ __('firefly.new_rule_group') }}</a>+ <a href="{{ route('rules.create') }}" class="btn btn-success new_rule">{{ __('firefly.new_rule') }}</a>+ </div>+ <p></p>+ </div>+ </div>+@if(1 === count($ruleGroups) && 0 === $ruleGroups[0]->count())+@php+$shownDemo = true+@endphp+<x-empty-page :route="route('rules.create', [$objectType])" type="rules" object-type="default" />+@endif+@foreach($ruleGroups as $ruleGroup)+ <div class="row mb-2">+ <div class="col-lg-12 col-md-12 col-sm-12">+ <div class="card rules-box" data-group="{{ $ruleGroup->id }}">+ <div class="card-header">+ <div class="row">+ <div class="col">+ <h3 class="card-title">+ @if($ruleGroup->active)+ {{ $ruleGroup->title }}+ @else+ <s>{{ $ruleGroup->title }}</s> ({{ strtolower(__('firefly.inactive')) }})+ @endif+ </h3>+ </div>+ <div class="col text-end">+ <div class="dropdown">+ <button class="btn btn-sm btn-secondary-outline dropdown-toggle" type="button" id="card_header_{{ $ruleGroup->id }}" data-bs-toggle="dropdown" aria-expanded="false">+ <span class="bi bi-list"></span>+ </button>+ <ul class="dropdown-menu" aria-labelledby="card_header_{{ $ruleGroup->id }}">+ <li><a class="dropdown-item" href="{{ route('rule-groups.edit',$ruleGroup->id) }}"><span class="fa fa-fw fa-pencil"></span> {{ __('firefly.edit') }}</a></li>+ <li><a class="dropdown-item" href="{{ route('rule-groups.delete',$ruleGroup->id) }}"><span class="fa fa-fw fa-trash"></span> {{ __('firefly.delete') }}</a></li>+ <li><a class="dropdown-item" href="{{ route('rule-groups.select-transactions',$ruleGroup->id) }}"><span+ class="fa fa-fw fa-power-off"></span> {{ trans('firefly.apply_rule_group_selection', ['title' => $ruleGroup->title]) }}+ </a></li>+ @if($ruleGroup->order > 1)+ <li><a href="#" class="dropdown-item move-group" data-direction="up" data-id="{{ $ruleGroup->id }}"><span+ class="fa fa-fw fa-arrow-up"></span> {{ __('firefly.move_rule_group_up') }}</a></li>+ @endif+ @if($ruleGroup->order < count($ruleGroups))+ <li><a href="#" class="dropdown-item move-group" data-direction="down" data-id="{{ $ruleGroup->id }}"><span+ class="fa fa-fw fa-arrow-down"></span> {{ __('firefly.move_rule_group_down') }}+ </a></li>+ @endif+ </ul>+ </div>+ </div>+ </div>+ </div>+ <div class="card-body">+ <p>+ <em>{{ $ruleGroup->description }}</em>+ </p>+ <p>+ <a href="{{ route('rules.create', $ruleGroup->id) }}"+ class="btn btn-success new_rule">{{ __('firefly.new_rule') }}</a>+ </p>++ @if($ruleGroup->rules->count() > 0)+ <table class="table table-sm table-hover table-striped group-rules">+ <thead>+ <tr>+ <th class="five"> </th>+ <th class="ten"> </th>+ <th class="ten"> </th>+ <th class="quarter">{{ __('firefly.rule_name') }}</th>+ <th class="quarter hidden-xs">{{ __('firefly.rule_triggers') }}</th>+ <th class="quarter hidden-xs">{{ __('firefly.rule_actions') }}</th>+ </tr>+ </thead>+ <tbody class="rule-connected-list">+ @foreach($ruleGroup->rules as $rule)+ <tr class="single-rule" data-order="{{ $rule->order }}" data-id="{{ $rule->id }}" data-group-id="{{ $ruleGroup->id }}" data-position="{{ $loop->index }}">+ <td>+ <div class="btn-group btn-group-xs prio_buttons">+ <span class="fa fa-fw fa-bars rule-handle"></span>+ </div>+ </td>+ <td>+ <div class="btn-group btn-group-xs edit_buttons">+ <a title="{{ __('firefly.edit') }}" href="{{ route('rules.edit', $rule->id) }}"+ class="btn btn-default"><span+ class="fa fa-fw fa-pencil"></span></a>+ <a title="{{ __('firefly.delete') }}"+ href="{{ route('rules.delete', $rule->id) }}"+ class="btn btn-danger"><span+ class="fa fa-fw fa-trash"></span></a>+ </div>+ </td>+ <td>+ <div class="btn-group btn-group-xs test_buttons">+ {{-- show which transactions would match --}}+ <a href="{{ route('rules.search',$rule->id) }}" class="btn btn-default {% if false == rule.strict %}test_rule_triggers{% endif %}" data-id="{{ $rule->id }}" title="{{ __('firefly.test_rule_triggers') }}"><span data-id="{{ $rule->id }}" class="fa fa-fw fa-flask"></span></a>+ @if($rule->active)+ {{-- actually execute rule --}}+ <a href="{{ route('rules.select-transactions',$rule->id) }}" class="btn btn-default" title=" {{ trans('firefly.apply_rule_selection', ['title' => $rule->title]) }}"><span class="fa fa-fw fa-power-off "></span></a>+ @endif++ {{-- duplicate rule --}}+ <a href="#" class="btn btn-default duplicate-rule" data-id="{{ $rule->id }}" title=" {{ trans('firefly.duplicate_rule', ['title' => $rule->title]) }}"><span class="fa fa-fw fa-copy"></span></a>+ </div>+ </td>+ <td class="markdown">+ @if($rule->active)+ {{ $rule->title }}+ @else+ <s>{{ $rule->title }}</s> ({{ strtolower(__('firefly.inactive')) }})+ @endif+ @if($rule->stop_processing)+ <span class="fa fa-stop-circle-o"></span>+ @endif+ @if('' !== $rule->description)+ <small class="hidden-xs+ @if(!$rule->active)+ text-muted+ @endif+ "+ ><br/>{{ parseMarkdown($rule->description) }}</small>+ @endif+ <small>(@if($rule->strict)<span class="text-danger">{{ __('firefly.rule_is_strict') }}</span>@else<span class="text-success">{{ __('firefly.rule_is_not_strict') }}</span>@endif​)</small>+ </td>+ <td class="hidden-xs">+ @if($rule->ruleTriggers->count() > 0)+ <ul class="small rule-trigger-list" data-count="{{ $rule->ruleTriggers->count() }}" data-id="{{ $rule->id }}">+ @foreach($rule->ruleTriggers as $trigger)+ @if('user_action' === $trigger->trigger_type)+ <li+ @if(!$rule->active)+ class="text-muted"+ @endif+ data-id="{{ $trigger->id }}">+ {{ trans(('firefly.rule_trigger_' . getRootSearchOperator($trigger->trigger_type)), ['trigger_value' => $trigger->trigger_value]) }}+ @if($trigger->stop_processing)+ <span class="fa fa-stop-circle-o"></span>+ @endif+ </li>+ @endif+ @endforeach+ </ul>+ <ul class="small rule-triggers-show hidden pointer" data-id="{{ $rule->id }}">+ <li data-id="{{ $rule->id }}">{{ __('firefly.show_triggers') }}</li>+ </ul>+ @endif+ </td>+ <td class="hidden-xs">+ @if($rule->ruleActions->count() > 0)+ <ul class="small rule-action-list" data-count="{{ $rule->ruleActions->count() }}" data-id="{{ $rule->id }}">+ @foreach($rule->ruleActions as $action)+ <li+ @if(!$rule->active)+ class="text-muted"+ @endif+ data-id="{{ $action->id }}">{{ trans(('firefly.rule_action_' . $action->action_type), ['action_value' => $action->action_value]) }}+ @if($action->stop_processing)+ <span class="fa fa-stop-circle-o"></span>+ @endif+ </li>+ @endforeach+ </ul>+ <ul class="small rule-actions-show hidden pointer" data-id="{{ $rule->id }}">+ <li>{{ __('firefly.show_actions') }}</li>+ </ul>+ @endif+ </td>+ </tr>+ @endforeach+ </tbody>+ </table>+ @else+ <p>+ <em>{{ __('firefly.no_rules_in_group') }}</em>+ </p>+ @endif+ <p>+ <br/>+ <a href="{{ route('rules.create', $ruleGroup->id) }}"+ class="btn btn-success new_rule">{{ __('firefly.new_rule') }}</a>+ </p>+ </div>+ </div>+ </div>+ </div>+@endforeach++ {% include 'rules.partials.test-trigger-modal' %}++ <div class="row">+ <div class="col-lg-12 col-md-12 col-sm-12">+ <a href="{{ route('rule-groups.create') }}" class="btn btn-success">{{ __('firefly.new_rule_group') }}</a>+ </div>+ </div>++@endsection+@section('scripts')+ @vite(['js/pages/rules/index.js'])+ <script type="text/javascript" nonce="{{ $JS_NONCE }}">+ var moveRuleGroupUrl = '{{ route('rule-groups.move') }}';+ var duplicateRuleUrl = '{{ route('rules.duplicate') }}';+ </script>+ <script type="text/javascript" src="v1/js/lib/jquery-ui.min.js?v={{ $FF_BUILD_TIME }}" nonce="{{ $JS_NONCE }}"></script>+ <script type="text/javascript" src="v1/js/ff/rules/index.js?v={{ $FF_BUILD_TIME }}" nonce="{{ $JS_NONCE }}"></script>+@endsectiondiff --git a/resources/views/rules/index.twig b/resources/views/rules/old-index.twigsimilarity index 100%rename from resources/views/rules/index.twigrename to resources/views/rules/old-index.twig