Compare commits

...

22 Commits

Author SHA1 Message Date
James Cole
b3a9e6569e Fix #10854 2025-09-04 06:26:28 +02:00
James Cole
f174f124ef Fix # 2025-09-04 06:26:12 +02:00
James Cole
8745377f31 Fix #10833 2025-09-04 06:22:18 +02:00
James Cole
cf76e93f31 Remove primary currency from views, add some debug for #10854 2025-09-04 06:22:04 +02:00
James Cole
19e36f6f6e Share primary currency to all pages. 2025-09-03 21:02:13 +02:00
James Cole
2a7bb6f048 Fix #10853 2025-09-03 20:34:40 +02:00
James Cole
536eacbc0c Fix sort params 2025-09-03 20:34:28 +02:00
James Cole
af78158d0b Fix minor issues. 2025-09-02 18:38:34 +02:00
github-actions[bot]
fb97910a34 Merge pull request #10848 from firefly-iii/release-1756787147
🤖 Automatically merge the PR into the develop branch.
2025-09-02 06:25:54 +02:00
JC5
66b4d14129 🤖 Auto commit for release 'develop' on 2025-09-02 2025-09-02 06:25:47 +02:00
James Cole
fd53047dbc Merge branch 'develop' of github.com:firefly-iii/firefly-iii into develop 2025-09-02 06:03:17 +02:00
James Cole
5f6fc1bab4 Fix #10846 2025-09-02 06:03:11 +02:00
github-actions[bot]
cd0b64bd24 Merge pull request #10845 from firefly-iii/release-1756752249
🤖 Automatically merge the PR into the develop branch.
2025-09-01 20:44:18 +02:00
JC5
91b26bce0e 🤖 Auto commit for release 'develop' on 2025-09-01 2025-09-01 20:44:09 +02:00
James Cole
26a8bd921d Fix columns, improve views. 2025-09-01 20:39:40 +02:00
github-actions[bot]
ad77d55c16 Merge pull request #10844 from firefly-iii/release-1756729274
🤖 Automatically merge the PR into the develop branch.
2025-09-01 14:21:21 +02:00
JC5
445a383dd0 🤖 Auto commit for release 'develop' on 2025-09-01 2025-09-01 14:21:14 +02:00
Sander Dorigo
1666af939e Fix null 2025-09-01 14:03:21 +02:00
github-actions[bot]
35447f5eee Merge pull request #10843 from firefly-iii/release-1756727799
🤖 Automatically merge the PR into the develop branch.
2025-09-01 13:56:46 +02:00
JC5
7c6fcb5731 🤖 Auto commit for release 'develop' on 2025-09-01 2025-09-01 13:56:39 +02:00
Sander Dorigo
fabd9bf765 Merge branch 'develop' of https://github.com/firefly-iii/firefly-iii into develop 2025-09-01 13:38:39 +02:00
Sander Dorigo
6352d26633 fix argument 2025-09-01 13:38:32 +02:00
28 changed files with 451 additions and 286 deletions

View File

@@ -67,7 +67,6 @@ abstract class Controller extends BaseController
protected array $accepts = ['application/json', 'application/vnd.api+json'];
/** @var array<int, string> */
protected array $allowedSort;
protected bool $convertToPrimary = false;
protected TransactionCurrency $primaryCurrency;
protected ParameterBag $parameters;
@@ -78,7 +77,6 @@ abstract class Controller extends BaseController
public function __construct()
{
// get global parameters
$this->allowedSort = config('firefly.allowed_sort_parameters');
$this->middleware(
function ($request, $next) {
$this->parameters = $this->getParameters();
@@ -150,13 +148,7 @@ abstract class Controller extends BaseController
}
if (null !== $value) {
$value = (int)$value;
if ($value < 1) {
$value = 1;
}
if ($value > 2 ** 16) {
$value = 2 ** 16;
}
$value = min(max(1, $value), 2 ** 16);
$bag->set($integer, $value);
}
if (null === $value
@@ -173,39 +165,8 @@ abstract class Controller extends BaseController
}
// sort fields:
return $this->getSortParameters($bag);
}
private function getSortParameters(ParameterBag $bag): ParameterBag
{
$sortParameters = [];
try {
$param = (string)request()->query->get('sort');
} catch (BadRequestException $e) {
Log::error('Request field "sort" contains a non-scalar value. Value set to NULL.');
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
$param = '';
}
if ('' === $param) {
return $bag;
}
$parts = explode(',', $param);
foreach ($parts as $part) {
$part = trim($part);
$direction = 'asc';
if ('-' === $part[0]) {
$part = substr($part, 1);
$direction = 'desc';
}
if (in_array($part, $this->allowedSort, true)) {
$sortParameters[] = [$part, $direction];
}
}
$bag->set('sort', $sortParameters);
return $bag;
//return $this->getSortParameters($bag);
}
/**

View File

@@ -86,13 +86,18 @@ class ShowController extends Controller
$count = $collection->count();
// continue sort:
// TODO if the user sorts on DB dependent field there must be no slice before enrichment, only after.
// TODO still need to figure out how to do this easily.
$accounts = $collection->slice(($this->parameters->get('page') - 1) * $params['limit'], $params['limit']);
// enrich
/** @var User $admin */
$admin = auth()->user();
$enrichment = new AccountEnrichment();
$enrichment->setSort($params['sort']);
$enrichment->setDate($this->parameters->get('date'));
$enrichment->setStart($this->parameters->get('start'));
$enrichment->setEnd($this->parameters->get('end'));
$enrichment->setUser($admin);
$accounts = $enrichment->enrich($accounts);
@@ -116,7 +121,7 @@ class ShowController extends Controller
*
* Show single instance.
*/
public function show(Account $account): JsonResponse
public function show(ShowRequest $request, Account $account): JsonResponse
{
// get list of accounts. Count it and split it.
$this->repository->resetAccountOrder();
@@ -128,6 +133,8 @@ class ShowController extends Controller
$admin = auth()->user();
$enrichment = new AccountEnrichment();
$enrichment->setDate($this->parameters->get('date'));
$enrichment->setStart($this->parameters->get('start'));
$enrichment->setEnd($this->parameters->get('end'));
$enrichment->setUser($admin);
$account = $enrichment->enrichSingle($account);

View File

@@ -24,7 +24,9 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests\Models\Account;
use Carbon\Carbon;
use FireflyIII\Models\Account;
use FireflyIII\Models\Preference;
use FireflyIII\Rules\IsValidSortInstruction;
use FireflyIII\Support\Facades\Preferences;
use FireflyIII\Support\Http\Api\AccountFilter;
use FireflyIII\Support\Request\ConvertsDataTypes;
@@ -55,7 +57,7 @@ class ShowRequest extends FormRequest
return [
'type' => $this->convertString('type', 'all'),
'limit' => $limit,
'sort' => $this->convertString('sort', 'order'),
'sort' => $this->convertSortParameters('sort',Account::class),
'page' => $page,
];
}
@@ -68,7 +70,7 @@ class ShowRequest extends FormRequest
'date' => 'date',
'start' => 'date|present_with:end|before_or_equal:end|before:2038-01-17|after:1970-01-02',
'end' => 'date|present_with:start|after_or_equal:start|before:2038-01-17|after:1970-01-02',
'sort' => 'in:active,iban,name,order,-active,-iban,-name,-order', // TODO improve me.
'sort' => ['nullable', new IsValidSortInstruction(Account::class)],
'type' => sprintf('in:%s', $keys),
'limit' => 'numeric|min:1|max:131337',
'page' => 'numeric|min:1|max:131337',
@@ -83,6 +85,8 @@ class ShowRequest extends FormRequest
return;
}
$data = $validator->getData();
if (array_key_exists('date', $data) && array_key_exists('start', $data) && array_key_exists('end', $data)) {
// assume valid dates, before we got here.
$start = Carbon::parse($data['start'], config('app.timezone'))->startOfDay();

View File

@@ -70,6 +70,7 @@ class NotificationController extends Controller
}
$forcedAvailability['ntfy'] = '' !== $ntfyTopic;
$forcedAvailability['pushover'] = '' !== $pushoverAppToken && '' !== $pushoverUserToken;
$forcedAvailability['slack'] = '' !== $slackUrl;
return view(
'settings.notifications.index',

View File

@@ -77,7 +77,6 @@ class CreateController extends Controller
$periods[$current] = (string) trans('firefly.repeat_freq_'.$current);
}
$subTitle = (string) trans('firefly.create_new_bill');
$primaryCurrency = $this->primaryCurrency;
// put previous url in session if not redirect from store (not "create another").
if (true !== session('bills.create.fromStore')) {
@@ -85,7 +84,7 @@ class CreateController extends Controller
}
$request->session()->forget('bills.create.fromStore');
return view('bills.create', compact('periods', 'subTitle', 'primaryCurrency'));
return view('bills.create', compact('periods', 'subTitle'));
}
/**

View File

@@ -88,7 +88,6 @@ class EditController extends Controller
$bill->amount_min = app('steam')->bcround($bill->amount_min, $bill->transactionCurrency->decimal_places);
$bill->amount_max = app('steam')->bcround($bill->amount_max, $bill->transactionCurrency->decimal_places);
$rules = $this->repository->getRulesForBill($bill);
$primaryCurrency = $this->primaryCurrency;
// code to handle active-checkboxes
$hasOldInput = null !== $request->old('_token');
@@ -105,7 +104,7 @@ class EditController extends Controller
$request->session()->flash('preFilled', $preFilled);
$request->session()->forget('bills.edit.fromUpdate');
return view('bills.edit', compact('subTitle', 'periods', 'rules', 'bill', 'primaryCurrency', 'preFilled'));
return view('bills.edit', compact('subTitle', 'periods', 'rules', 'bill', 'preFilled'));
}
/**

View File

@@ -135,7 +135,6 @@ class IndexController extends Controller
// get all inactive budgets, and simply list them:
$inactive = $this->repository->getInactiveBudgets();
$primaryCurrency = $this->primaryCurrency;
return view(
'budgets.index',
@@ -148,7 +147,6 @@ class IndexController extends Controller
'budgets',
'currencies',
'periodTitle',
'primaryCurrency',
'activeDaysPassed',
'activeDaysLeft',
'inactive',

View File

@@ -140,6 +140,7 @@ abstract class Controller extends BaseController
View::share('language', $language);
View::share('locale', $locale);
View::share('convertToPrimary', $this->convertToPrimary);
View::share('primaryCurrency', $this->primaryCurrency);
View::share('shownDemo', $shownDemo);
View::share('current_route_name', $page);
View::share('original_route_name', Route::currentRouteName());

View File

@@ -84,7 +84,6 @@ class CreateController extends Controller
{
$budgets = app('expandedform')->makeSelectListWithEmpty($this->budgetRepos->getActiveBudgets());
$bills = app('expandedform')->makeSelectListWithEmpty($this->billRepository->getActiveBills());
$primaryCurrency = $this->primaryCurrency;
$tomorrow = today(config('app.timezone'));
$oldRepetitionType = $request->old('repetition_type');
$tomorrow->addDay();
@@ -116,7 +115,7 @@ class CreateController extends Controller
return view(
'recurring.create',
compact('tomorrow', 'oldRepetitionType', 'bills', 'weekendResponses', 'preFilled', 'repetitionEnds', 'primaryCurrency', 'budgets')
compact('tomorrow', 'oldRepetitionType', 'bills', 'weekendResponses', 'preFilled', 'repetitionEnds', 'budgets')
);
}
@@ -129,7 +128,6 @@ class CreateController extends Controller
{
$budgets = app('expandedform')->makeSelectListWithEmpty($this->budgetRepos->getActiveBudgets());
$bills = app('expandedform')->makeSelectListWithEmpty($this->billRepository->getActiveBills());
$primaryCurrency = $this->primaryCurrency;
$tomorrow = today(config('app.timezone'));
$oldRepetitionType = $request->old('repetition_type');
$tomorrow->addDay();
@@ -208,10 +206,7 @@ class CreateController extends Controller
}
$request->session()->flash('preFilled', $preFilled);
return view(
'recurring.create',
compact('tomorrow', 'oldRepetitionType', 'bills', 'weekendResponses', 'preFilled', 'repetitionEnds', 'primaryCurrency', 'budgets')
);
return view('recurring.create', compact('tomorrow', 'oldRepetitionType', 'bills', 'weekendResponses', 'preFilled', 'repetitionEnds', 'budgets'));
}
/**

View File

@@ -117,7 +117,6 @@ class CreateController extends Controller
$optionalFields = app('preferences')->get('transaction_journal_optional_fields', [])->data;
$allowedOpposingTypes = config('firefly.allowed_opposing_types');
$accountToTypes = config('firefly.account_to_transaction');
$primaryCurrency = $this->primaryCurrency;
$previousUrl = $this->rememberPreviousUrl('transactions.create.url');
$parts = parse_url((string) $previousUrl);
$search = sprintf('?%s', $parts['query'] ?? '');
@@ -145,26 +144,6 @@ class CreateController extends Controller
session()->put('preFilled', $preFilled);
return view(
'transactions.create',
compact(
'subTitleIcon',
'cash',
'longitude',
'latitude',
'zoomLevel',
'objectType',
'optionalDateFields',
'subTitle',
'primaryCurrency',
'previousUrl',
'optionalFields',
'preFilled',
'allowedOpposingTypes',
'accountToTypes',
'sourceId',
'destinationId'
)
);
return view('transactions.create', compact('subTitleIcon', 'cash', 'longitude', 'latitude', 'zoomLevel', 'objectType', 'optionalDateFields', 'subTitle', 'previousUrl', 'optionalFields', 'preFilled', 'allowedOpposingTypes', 'accountToTypes', 'sourceId', 'destinationId'));
}
}

View File

@@ -84,7 +84,6 @@ class EditController extends Controller
$title = $transactionGroup->transactionJournals()->count() > 1 ? $transactionGroup->title : $transactionGroup->transactionJournals()->first()->description;
$subTitle = (string) trans('firefly.edit_transaction_title', ['description' => $title]);
$subTitleIcon = 'fa-plus';
$primaryCurrency = $this->primaryCurrency;
$cash = $repository->getCashAccount();
$previousUrl = $this->rememberPreviousUrl('transactions.edit.url');
$parts = parse_url((string) $previousUrl);
@@ -114,26 +113,7 @@ class EditController extends Controller
$latitude = config('firefly.default_location.latitude');
$zoomLevel = config('firefly.default_location.zoom_level');
return view(
'transactions.edit',
compact(
'cash',
'allowedSourceDests',
'expectedSourceTypes',
'optionalDateFields',
'longitude',
'latitude',
'zoomLevel',
'optionalFields',
'subTitle',
'subTitleIcon',
'transactionGroup',
'allowedOpposingTypes',
'accountToTypes',
'primaryCurrency',
'previousUrl'
)
);
return view('transactions.edit', compact('cash', 'allowedSourceDests', 'expectedSourceTypes', 'optionalDateFields', 'longitude', 'latitude', 'zoomLevel', 'optionalFields', 'subTitle', 'subTitleIcon', 'transactionGroup', 'allowedOpposingTypes', 'accountToTypes', 'previousUrl'));
}
public function unreconcile(TransactionJournal $journal): JsonResponse

View File

@@ -92,6 +92,7 @@ class ShowController extends Controller
$collector = app(GroupCollectorInterface::class);
$collector->setUser($admin)->setTransactionGroup($transactionGroup)->withAPIInformation();
/** @var TransactionGroup $selectedGroup */
$selectedGroup = $collector->getGroups()->first();
if (null === $selectedGroup) {
throw new NotFoundHttpException();
@@ -103,9 +104,6 @@ class ShowController extends Controller
$selectedGroup = $enrichment->enrichSingle($selectedGroup);
/** @var null|TransactionJournal $first */
$first = $transactionGroup->transactionJournals()->first(['transaction_journals.*']);
$splits = $transactionGroup->transactionJournals()->count();
$splits = count($selectedGroup['transactions']);
$keys = array_keys($selectedGroup['transactions']);
$first = $selectedGroup['transactions'][array_shift($keys)];

View File

@@ -484,14 +484,19 @@ class AccountRepository implements AccountRepositoryInterface, UserGroupInterfac
$query->accountTypeIn($types);
}
// add sort parameters. At this point they're filtered to allowed fields to sort by:
// add sort parameters
$allowed = config('firefly.allowed_db_sort_parameters.Account', []);
$sorted = 0;
if (0 !== count($sort)) {
foreach ($sort as $param) {
$query->orderBy($param[0], $param[1]);
if(in_array($param[0], $allowed, true)) {
$query->orderBy($param[0], $param[1]);
++$sorted;
}
}
}
if (0 === count($sort)) {
if (0 === $sorted) {
if (0 !== count($res)) {
$query->orderBy('accounts.order', 'ASC');
}

View File

@@ -377,7 +377,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface,
/** @var TransactionJournal $journal */
$journal = $this->user->transactionJournals()->find($journalId);
return $journal->tags()->get();
return $journal->tags()->whereNull('deleted_at')->get();
}
/**

View File

@@ -0,0 +1,64 @@
<?php
/*
* IsValidSortInstruction.php
* Copyright (c) 2025 james@firefly-iii.org
*
* 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/>.
*/
namespace FireflyIII\Rules;
use Closure;
use Illuminate\Contracts\Validation\ValidationRule;
class IsValidSortInstruction implements ValidationRule
{
private string $class;
public function __construct(string $class)
{
$this->class = $class;
}
public function validate(string $attribute, mixed $value, Closure $fail): void
{
$shortClass = str_replace('FireflyIII\\Models\\', '', $this->class);
if (!is_string($value)) {
$fail('validation.invalid_sort_instruction')->translate(['object' => $shortClass]);
return;
}
$validParameters = config(sprintf('firefly.allowed_sort_parameters.%s', $shortClass));
if (!is_array($validParameters)) {
$fail('validation.no_sort_instructions')->translate(['object' => $shortClass]);
return;
}
$parts = explode(',', $value);
foreach ($parts as $i => $part) {
$part = trim($part);
if (strlen($part) < 2) {
$fail('validation.invalid_sort_instruction_index')->translate(['index' => $i, 'object' => $shortClass]);
return;
}
if ('-' === $part[0]) {
$part = substr($part, 1);
}
if (!in_array($part, $validParameters, true)) {
$fail('validation.invalid_sort_instruction_index')->translate(['index' => $i, 'object' => $shortClass]);
return;
}
}
}
}

View File

@@ -176,7 +176,7 @@ class Amount
public function getSystemCurrency(): TransactionCurrency
{
return TransactionCurrency::where('code', 'EUR')->first();
return TransactionCurrency::whereNull('deleted_at')->where('code', 'EUR')->first();
}
/**

View File

@@ -67,10 +67,15 @@ class AccountEnrichment implements EnrichmentInterface
private UserGroup $userGroup;
private array $lastActivities = [];
private ?Carbon $date = null;
private ?Carbon $start = null;
private ?Carbon $end = null;
private bool $convertToPrimary;
private array $balances = [];
private array $startBalances = [];
private array $endBalances = [];
private array $objectGroups = [];
private array $mappedObjects = [];
private array $sort = [];
/**
* TODO The account enricher must do conversion from and to the primary currency.
@@ -111,6 +116,7 @@ class AccountEnrichment implements EnrichmentInterface
$this->collectObjectGroups();
$this->collectBalances();
$this->appendCollectedData();
$this->sortData();
return $this->collection;
}
@@ -138,10 +144,9 @@ class AccountEnrichment implements EnrichmentInterface
private function collectMetaData(): void
{
$set = AccountMeta::whereIn('name', ['is_multi_currency', 'include_net_worth', 'currency_id', 'account_role', 'account_number', 'BIC', 'liability_direction', 'interest', 'interest_period', 'current_debt'])
->whereIn('account_id', $this->ids)
->get(['account_meta.id', 'account_meta.account_id', 'account_meta.name', 'account_meta.data'])->toArray()
;
$set = AccountMeta::whereIn('name', ['is_multi_currency', 'include_net_worth', 'currency_id', 'account_role', 'account_number', 'BIC', 'liability_direction', 'interest', 'interest_period', 'current_debt'])
->whereIn('account_id', $this->ids)
->get(['account_meta.id', 'account_meta.account_id', 'account_meta.name', 'account_meta.data'])->toArray();
/** @var array $entry */
foreach ($set as $entry) {
@@ -167,10 +172,9 @@ class AccountEnrichment implements EnrichmentInterface
private function collectNotes(): void
{
$notes = Note::query()->whereIn('noteable_id', $this->ids)
->whereNotNull('notes.text')
->where('notes.text', '!=', '')
->where('noteable_type', Account::class)->get(['notes.noteable_id', 'notes.text'])->toArray()
;
->whereNotNull('notes.text')
->where('notes.text', '!=', '')
->where('noteable_type', Account::class)->get(['notes.noteable_id', 'notes.text'])->toArray();
foreach ($notes as $note) {
$this->notes[(int)$note['noteable_id']] = (string)$note['text'];
}
@@ -180,15 +184,14 @@ class AccountEnrichment implements EnrichmentInterface
private function collectLocations(): void
{
$locations = Location::query()->whereIn('locatable_id', $this->ids)
->where('locatable_type', Account::class)->get(['locations.locatable_id', 'locations.latitude', 'locations.longitude', 'locations.zoom_level'])->toArray()
;
->where('locatable_type', Account::class)->get(['locations.locatable_id', 'locations.latitude', 'locations.longitude', 'locations.zoom_level'])->toArray();
foreach ($locations as $location) {
$this->locations[(int)$location['locatable_id']]
= [
'latitude' => (float)$location['latitude'],
'longitude' => (float)$location['longitude'],
'zoom_level' => (int)$location['zoom_level'],
];
'latitude' => (float)$location['latitude'],
'longitude' => (float)$location['longitude'],
'zoom_level' => (int)$location['zoom_level'],
];
}
Log::debug(sprintf('Enrich with %d locations(s)', count($this->locations)));
}
@@ -203,20 +206,19 @@ class AccountEnrichment implements EnrichmentInterface
->setUserGroup($this->userGroup)
->setAccounts($this->collection)
->withAccountInformation()
->setTypes([TransactionTypeEnum::OPENING_BALANCE->value])
;
$journals = $collector->getExtractedJournals();
->setTypes([TransactionTypeEnum::OPENING_BALANCE->value]);
$journals = $collector->getExtractedJournals();
foreach ($journals as $journal) {
$this->openingBalances[(int)$journal['source_account_id']]
= [
'amount' => Steam::negative($journal['amount']),
'date' => $journal['date'],
];
'amount' => Steam::negative($journal['amount']),
'date' => $journal['date'],
];
$this->openingBalances[(int)$journal['destination_account_id']]
= [
'amount' => Steam::positive($journal['amount']),
'date' => $journal['date'],
];
'amount' => Steam::positive($journal['amount']),
'date' => $journal['date'],
];
}
}
@@ -234,9 +236,9 @@ class AccountEnrichment implements EnrichmentInterface
private function appendCollectedData(): void
{
$this->collection = $this->collection->map(function (Account $item) {
$id = (int)$item->id;
$item->full_account_type = $this->accountTypes[(int)$item->account_type_id] ?? null;
$meta = [
$id = (int)$item->id;
$item->full_account_type = $this->accountTypes[(int)$item->account_type_id] ?? null;
$meta = [
'currency' => null,
'location' => [
'latitude' => null,
@@ -256,7 +258,7 @@ class AccountEnrichment implements EnrichmentInterface
// add object group if available
if (array_key_exists($id, $this->mappedObjects)) {
$key = $this->mappedObjects[$id];
$meta['object_group_id'] = (string) $this->objectGroups[$key]['id'];
$meta['object_group_id'] = (string)$this->objectGroups[$key]['id'];
$meta['object_group_title'] = $this->objectGroups[$key]['title'];
$meta['object_group_order'] = $this->objectGroups[$key]['order'];
}
@@ -283,43 +285,47 @@ class AccountEnrichment implements EnrichmentInterface
// add balances
// get currencies:
$currency = $this->primaryCurrency; // assume primary currency
$currency = $this->primaryCurrency; // assume primary currency
if (null !== $meta['currency']) {
$currency = $meta['currency'];
}
// get the current balance:
$date = $this->getDate();
$date = $this->getDate();
// $finalBalance = Steam::finalAccountBalance($item, $date, $this->primaryCurrency, $this->convertToPrimary);
$finalBalance = $this->balances[$id];
$finalBalance = $this->balances[$id];
$balanceDifference = $this->getBalanceDifference($id, $currency);
Log::debug(sprintf('Call finalAccountBalance(%s) with date/time "%s"', var_export($this->convertToPrimary, true), $date->toIso8601String()), $finalBalance);
// collect current balances:
$currentBalance = Steam::bcround($finalBalance[$currency->code] ?? '0', $currency->decimal_places);
$openingBalance = Steam::bcround($meta['opening_balance_amount'] ?? '0', $currency->decimal_places);
$virtualBalance = Steam::bcround($account->virtual_balance ?? '0', $currency->decimal_places);
$debtAmount = $meta['current_debt'] ?? null;
$currentBalance = Steam::bcround($finalBalance[$currency->code] ?? '0', $currency->decimal_places);
$openingBalance = Steam::bcround($meta['opening_balance_amount'] ?? '0', $currency->decimal_places);
$virtualBalance = Steam::bcround($account->virtual_balance ?? '0', $currency->decimal_places);
$debtAmount = $meta['current_debt'] ?? null;
// set some pc_ default values to NULL:
$pcCurrentBalance = null;
$pcOpeningBalance = null;
$pcVirtualBalance = null;
$pcDebtAmount = null;
$pcCurrentBalance = null;
$pcOpeningBalance = null;
$pcVirtualBalance = null;
$pcDebtAmount = null;
$pcBalanceDifference = null;
// convert to primary currency if needed:
if ($this->convertToPrimary && $currency->id !== $this->primaryCurrency->id) {
Log::debug(sprintf('Convert to primary, from %s to %s', $currency->code, $this->primaryCurrency->code));
$converter = new ExchangeRateConverter();
$pcCurrentBalance = $converter->convert($currency, $this->primaryCurrency, $date, $currentBalance);
$pcOpeningBalance = $converter->convert($currency, $this->primaryCurrency, $date, $openingBalance);
$pcVirtualBalance = $converter->convert($currency, $this->primaryCurrency, $date, $virtualBalance);
$pcDebtAmount = null === $debtAmount ? null : $converter->convert($currency, $this->primaryCurrency, $date, $debtAmount);
$converter = new ExchangeRateConverter();
$pcCurrentBalance = $converter->convert($currency, $this->primaryCurrency, $date, $currentBalance);
$pcOpeningBalance = $converter->convert($currency, $this->primaryCurrency, $date, $openingBalance);
$pcVirtualBalance = $converter->convert($currency, $this->primaryCurrency, $date, $virtualBalance);
$pcBalanceDifference = null === $balanceDifference ? null : $converter->convert($currency, $this->primaryCurrency, $date, $balanceDifference);
$pcDebtAmount = null === $debtAmount ? null : $converter->convert($currency, $this->primaryCurrency, $date, $debtAmount);
}
if ($this->convertToPrimary && $currency->id === $this->primaryCurrency->id) {
$pcCurrentBalance = $currentBalance;
$pcOpeningBalance = $openingBalance;
$pcVirtualBalance = $virtualBalance;
$pcDebtAmount = $debtAmount;
$pcCurrentBalance = $currentBalance;
$pcOpeningBalance = $openingBalance;
$pcVirtualBalance = $virtualBalance;
$pcBalanceDifference = $balanceDifference;
$pcDebtAmount = $debtAmount;
}
// set opening balance(s) to NULL if the date is null
@@ -329,17 +335,19 @@ class AccountEnrichment implements EnrichmentInterface
}
$meta['current_balance_date'] = $this->getDate();
$meta['balances'] = [
'current_balance' => $currentBalance,
'pc_current_balance' => $pcCurrentBalance,
'opening_balance' => $openingBalance,
'pc_opening_balance' => $pcOpeningBalance,
'virtual_balance' => $virtualBalance,
'pc_virtual_balance' => $pcVirtualBalance,
'debt_amount' => $debtAmount,
'pc_debt_amount' => $pcDebtAmount,
'current_balance' => $currentBalance,
'pc_current_balance' => $pcCurrentBalance,
'opening_balance' => $openingBalance,
'pc_opening_balance' => $pcOpeningBalance,
'virtual_balance' => $virtualBalance,
'pc_virtual_balance' => $pcVirtualBalance,
'debt_amount' => $debtAmount,
'pc_debt_amount' => $pcDebtAmount,
'balance_difference' => $balanceDifference,
'pc_balance_difference' => $pcBalanceDifference,
];
// end add balances
$item->meta = $meta;
$item->meta = $meta;
return $item;
});
@@ -353,17 +361,20 @@ class AccountEnrichment implements EnrichmentInterface
private function collectBalances(): void
{
$this->balances = Steam::accountsBalancesOptimized($this->collection, $this->getDate(), $this->primaryCurrency, $this->convertToPrimary);
if (null !== $this->start && null !== $this->end) {
$this->startBalances = Steam::accountsBalancesOptimized($this->collection, $this->start, $this->primaryCurrency, $this->convertToPrimary);
$this->endBalances = Steam::accountsBalancesOptimized($this->collection, $this->end, $this->primaryCurrency, $this->convertToPrimary);
}
}
private function collectObjectGroups(): void
{
$set = DB::table('object_groupables')
->whereIn('object_groupable_id', $this->ids)
->where('object_groupable_type', Account::class)
->get(['object_groupable_id', 'object_group_id'])
;
$set = DB::table('object_groupables')
->whereIn('object_groupable_id', $this->ids)
->where('object_groupable_type', Account::class)
->get(['object_groupable_id', 'object_group_id']);
$ids = array_unique($set->pluck('object_group_id')->toArray());
$ids = array_unique($set->pluck('object_group_id')->toArray());
foreach ($set as $entry) {
$this->mappedObjects[(int)$entry->object_groupable_id] = (int)$entry->object_group_id;
@@ -394,4 +405,57 @@ class AccountEnrichment implements EnrichmentInterface
return $this->date;
}
public function setStart(?Carbon $start): void
{
$this->start = $start;
}
public function setEnd(?Carbon $end): void
{
$this->end = $end;
}
private function getBalanceDifference(int $id, TransactionCurrency $currency): ?string
{
if (null === $this->start || null === $this->end) {
return null;
}
$startBalance = $this->startBalances[$id] ?? [];
$endBalance = $this->endBalances[$id] ?? [];
if (0 === count($startBalance) || 0 === count($endBalance)) {
return null;
}
$start = $startBalance[$currency->code] ?? '0';
$end = $endBalance[$currency->code] ?? '0';
return bcsub($end, $start);
}
public function setSort(array $sort): void
{
$this->sort = $sort;
}
private function sortData(): void
{
$dbParams = config('firefly.allowed_db_sort_parameters.Account', []);
/** @var array<string,string> $parameter */
foreach ($this->sort as $parameter) {
if (in_array($parameter[0], $dbParams, true)) {
continue;
}
switch ($parameter[0]) {
default:
throw new FireflyException(sprintf('Account enrichment cannot sort on field "%s"', $parameter[0]));
case 'current_balance':
case 'pc_current_balance':
$this->collection = $this->collection->sortBy(static function (Account $account) use ($parameter) {
return $account->meta['balances'][$parameter[0]] ?? '0';
}, SORT_NUMERIC, 'desc' === $parameter[1]);
break;
}
}
}
}

View File

@@ -31,7 +31,6 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Support\Facades\Steam;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
use function Safe\preg_replace;
/**
@@ -99,6 +98,24 @@ trait ConvertsDataTypes
return Steam::filterSpaces($string);
}
public function convertSortParameters(string $field, string $class): array
{
// assume this all works, because the validator would have caught any errors.
$parameter = (string)request()->query->get($field);
$parts = explode(',', $parameter);
$sortParameters = [];
foreach ($parts as $part) {
$part = trim($part);
$direction = 'asc';
if ('-' === $part[0]) {
$part = substr($part, 1);
$direction = 'desc';
}
$sortParameters[] = [$part, $direction];
}
return $sortParameters;
}
public function clearString(?string $string): ?string
{
$string = $this->clearStringKeepNewlines($string);
@@ -129,7 +146,7 @@ trait ConvertsDataTypes
// clear zalgo text (TODO also in API v2)
$string = preg_replace('/(\pM{2})\pM+/u', '\1', $string);
return trim((string) $string);
return trim((string)$string);
}
public function convertIban(string $field): string
@@ -147,7 +164,7 @@ trait ConvertsDataTypes
return $default;
}
return (string) $this->clearString((string) $entry);
return (string)$this->clearString((string)$entry);
}
/**
@@ -161,7 +178,7 @@ trait ConvertsDataTypes
*/
public function convertInteger(string $field): int
{
return (int) $this->get($field);
return (int)$this->get($field);
}
/**
@@ -186,7 +203,7 @@ trait ConvertsDataTypes
$collection = new Collection();
if (is_array($set)) {
foreach ($set as $accountId) {
$account = $repository->find((int) $accountId);
$account = $repository->find((int)$accountId);
if (null !== $account) {
$collection->push($account);
}
@@ -201,7 +218,7 @@ trait ConvertsDataTypes
*/
public function stringWithNewlines(string $field): string
{
return (string) $this->clearStringKeepNewlines((string) ($this->get($field) ?? ''));
return (string)$this->clearStringKeepNewlines((string)($this->get($field) ?? ''));
}
/**
@@ -245,14 +262,14 @@ trait ConvertsDataTypes
protected function convertDateTime(?string $string): ?Carbon
{
$value = $this->get((string) $string);
$value = $this->get((string)$string);
if (null === $value) {
return null;
}
if ('' === $value) {
return null;
}
if (10 === strlen((string) $value)) {
if (10 === strlen((string)$value)) {
// probably a date format.
try {
$carbon = Carbon::createFromFormat('Y-m-d', $value, config('app.timezone'));
@@ -300,7 +317,7 @@ trait ConvertsDataTypes
return null;
}
return (float) $res;
return (float)$res;
}
protected function dateFromValue(?string $string): ?Carbon
@@ -338,7 +355,7 @@ trait ConvertsDataTypes
return null;
}
return (float) $string;
return (float)$string;
}
/**
@@ -375,10 +392,10 @@ trait ConvertsDataTypes
{
$result = null;
Log::debug(sprintf('Date string is "%s"', (string) $this->get($field)));
Log::debug(sprintf('Date string is "%s"', (string)$this->get($field)));
try {
$result = '' !== (string) $this->get($field) ? new Carbon((string) $this->get($field), config('app.timezone')) : null;
$result = '' !== (string)$this->get($field) ? new Carbon((string)$this->get($field), config('app.timezone')) : null;
} catch (InvalidFormatException) {
// @ignoreException
Log::debug(sprintf('Exception when parsing date "%s".', $this->get($field)));
@@ -399,12 +416,12 @@ trait ConvertsDataTypes
return null;
}
$value = (string) $this->get($field);
$value = (string)$this->get($field);
if ('' === $value) {
return null;
}
return (int) $value;
return (int)$value;
}
protected function parseAccounts(mixed $array): array
@@ -417,9 +434,9 @@ trait ConvertsDataTypes
if (!is_array($entry)) {
continue;
}
$amount = null;
$amount = null;
if (array_key_exists('current_amount', $entry)) {
$amount = $this->clearString((string) ($entry['current_amount'] ?? '0'));
$amount = $this->clearString((string)($entry['current_amount'] ?? '0'));
if (null === $entry['current_amount']) {
$amount = null;
}
@@ -428,7 +445,7 @@ trait ConvertsDataTypes
$amount = null;
}
$return[] = [
'account_id' => $this->integerFromValue((string) ($entry['account_id'] ?? '0')),
'account_id' => $this->integerFromValue((string)($entry['account_id'] ?? '0')),
'current_amount' => $amount,
];
}
@@ -448,6 +465,6 @@ trait ConvertsDataTypes
return null;
}
return (int) $string;
return (int)$string;
}
}

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Support\Twig;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Account as AccountModel;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
@@ -52,9 +53,9 @@ class AmountFormat extends AbstractExtension
return new TwigFilter(
'formatAmount',
static function (string $string): string {
$currency = app('amount')->getPrimaryCurrency();
$currency = Amount::getPrimaryCurrency();
return app('amount')->formatAnything($currency, $string, true);
return Amount::formatAnything($currency, $string, true);
},
['is_safe' => ['html']]
);
@@ -65,9 +66,9 @@ class AmountFormat extends AbstractExtension
return new TwigFilter(
'formatAmountPlain',
static function (string $string): string {
$currency = app('amount')->getPrimaryCurrency();
$currency = Amount::getPrimaryCurrency();
return app('amount')->formatAnything($currency, $string, false);
return Amount::formatAnything($currency, $string, false);
},
['is_safe' => ['html']]
);
@@ -98,9 +99,9 @@ class AmountFormat extends AbstractExtension
/** @var AccountRepositoryInterface $accountRepos */
$accountRepos = app(AccountRepositoryInterface::class);
$currency = $accountRepos->getAccountCurrency($account) ?? app('amount')->getPrimaryCurrency();
$currency = $accountRepos->getAccountCurrency($account) ?? Amount::getPrimaryCurrency();
return app('amount')->formatAnything($currency, $amount, $coloured);
return Amount::formatAnything($currency, $amount, $coloured);
},
['is_safe' => ['html']]
);
@@ -113,14 +114,21 @@ class AmountFormat extends AbstractExtension
{
return new TwigFunction(
'formatAmountBySymbol',
static function (string $amount, string $symbol, ?int $decimalPlaces = null, ?bool $coloured = null): string {
static function (string $amount, ?string $symbol, ?int $decimalPlaces = null, ?bool $coloured = null): string {
if(null === $symbol) {
$message = sprintf('formatAmountBySymbol("%s", %s, %d, %s) was called without a symbol. Please browse to /flush to clear your cache.', $amount,var_export($symbol, true), $decimalPlaces, var_export($coloured, true));
Log::error($message);
throw new FireflyException($message);
}
$decimalPlaces ??= 2;
$coloured ??= true;
$currency = new TransactionCurrency();
$currency->symbol = $symbol;
$currency->decimal_places = $decimalPlaces;
return app('amount')->formatAnything($currency, $amount, $coloured);
return Amount::formatAnything($currency, $amount, $coloured);
},
['is_safe' => ['html']]
);
@@ -136,7 +144,7 @@ class AmountFormat extends AbstractExtension
static function (TransactionCurrency $currency, string $amount, ?bool $coloured = null): string {
$coloured ??= true;
return app('amount')->formatAnything($currency, $amount, $coloured);
return Amount::formatAnything($currency, $amount, $coloured);
},
['is_safe' => ['html']]
);
@@ -161,7 +169,7 @@ class AmountFormat extends AbstractExtension
Log::error(sprintf('Fallback currency is "%s".', $currency->code));
}
return app('amount')->formatAnything($currency, $amount, $coloured);
return Amount::formatAnything($currency, $amount, $coloured);
},
['is_safe' => ['html']]
);

View File

@@ -32,13 +32,12 @@ use FireflyIII\Support\Facades\Amount;
use FireflyIII\Support\Facades\Steam;
use FireflyIII\Support\Search\OperatorQuerySearch;
use Illuminate\Support\Facades\Log;
use League\CommonMark\GithubFlavoredMarkdownConverter;
use Illuminate\Support\Facades\Route;
use League\CommonMark\GithubFlavoredMarkdownConverter;
use Override;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
use Twig\TwigFunction;
use Override;
use function Safe\parse_url;
/**
@@ -71,14 +70,14 @@ class General extends AbstractExtension
}
/** @var Carbon $date */
$date = session('end', today(config('app.timezone'))->endOfMonth());
$date = session('end', today(config('app.timezone'))->endOfMonth());
Log::debug(sprintf('twig balance: Call finalAccountBalance with date/time "%s"', $date->toIso8601String()));
$info = Steam::finalAccountBalance($account, $date);
$currency = Steam::getAccountCurrency($account);
$primary = Amount::getPrimaryCurrency();
$convertToPrimary = Amount::convertToPrimary();
$usePrimary = $convertToPrimary && $primary->id !== $currency->id;
$currency ??= $primary;
$currency ??= $primary;
$strings = [];
foreach ($info as $key => $balance) {
if ('balance' === $key) {
@@ -119,15 +118,15 @@ class General extends AbstractExtension
static function (int $size): string {
// less than one GB, more than one MB
if ($size < (1024 * 1024 * 2014) && $size >= (1024 * 1024)) {
return round($size / (1024 * 1024), 2).' MB';
return round($size / (1024 * 1024), 2) . ' MB';
}
// less than one MB
if ($size < (1024 * 1024)) {
return round($size / 1024, 2).' KB';
return round($size / 1024, 2) . ' KB';
}
return $size.' bytes';
return $size . ' bytes';
}
);
}
@@ -141,9 +140,9 @@ class General extends AbstractExtension
{
return new TwigFilter(
'mimeIcon',
static fn (string $string): string => match ($string) {
static fn(string $string): string => match ($string) {
'application/pdf' => 'fa-file-pdf-o',
'image/png', 'image/jpeg', 'image/svg+xml', 'image/heic', 'image/heic-sequence', 'application/vnd.oasis.opendocument.image' => 'fa-file-image-o',
'image/webp', 'image/png', 'image/jpeg', 'image/svg+xml', 'image/heic', 'image/heic-sequence', 'application/vnd.oasis.opendocument.image' => 'fa-file-image-o',
'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', 'application/x-iwork-pages-sffpages', 'application/vnd.sun.xml.writer', 'application/vnd.sun.xml.writer.template', 'application/vnd.sun.xml.writer.global', 'application/vnd.stardivision.writer', 'application/vnd.stardivision.writer-global', 'application/vnd.oasis.opendocument.text', 'application/vnd.oasis.opendocument.text-template', 'application/vnd.oasis.opendocument.text-web', 'application/vnd.oasis.opendocument.text-master' => 'fa-file-word-o',
'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', 'application/vnd.sun.xml.calc', 'application/vnd.sun.xml.calc.template', 'application/vnd.stardivision.calc', 'application/vnd.oasis.opendocument.spreadsheet', 'application/vnd.oasis.opendocument.spreadsheet-template' => 'fa-file-excel-o',
'application/vnd.ms-powerpoint', 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'application/vnd.openxmlformats-officedocument.presentationml.template', 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', 'application/vnd.sun.xml.impress', 'application/vnd.sun.xml.impress.template', 'application/vnd.stardivision.impress', 'application/vnd.oasis.opendocument.presentation', 'application/vnd.oasis.opendocument.presentation-template' => 'fa-file-powerpoint-o',
@@ -168,7 +167,7 @@ class General extends AbstractExtension
]
);
return (string) $converter->convert($text);
return (string)$converter->convert($text);
},
['is_safe' => ['html']]
);
@@ -182,8 +181,8 @@ class General extends AbstractExtension
return new TwigFilter(
'phphost',
static function (string $string): string {
$proto = (string) parse_url($string, PHP_URL_SCHEME);
$host = (string) parse_url($string, PHP_URL_HOST);
$proto = (string)parse_url($string, PHP_URL_SCHEME);
$host = (string)parse_url($string, PHP_URL_HOST);
return e(sprintf('%s://%s', $proto, $host));
}
@@ -214,7 +213,7 @@ class General extends AbstractExtension
{
return new TwigFunction(
'phpdate',
static fn (string $str): string => date($str)
static fn(string $str): string => date($str)
);
}
@@ -270,12 +269,12 @@ class General extends AbstractExtension
'activeRoutePartialObjectType',
static function ($context): string {
[, $route, $objectType] = func_get_args();
$activeObjectType = $context['objectType'] ?? false;
$activeObjectType = $context['objectType'] ?? false;
if ($objectType === $activeObjectType
&& false !== stripos(
(string) Route::getCurrentRoute()->getName(),
(string) $route
(string)Route::getCurrentRoute()->getName(),
(string)$route
)) {
return 'active';
}
@@ -376,7 +375,7 @@ class General extends AbstractExtension
{
return new TwigFunction(
'carbonize',
static fn (string $date): Carbon => new Carbon($date, config('app.timezone'))
static fn(string $date): Carbon => new Carbon($date, config('app.timezone'))
);
}
}

View File

@@ -66,13 +66,13 @@ class AccountTransformer extends AbstractTransformer
}
// get account type:
$accountType = (string) config(sprintf('firefly.shortNamesByFullName.%s', $account->full_account_type));
$liabilityType = (string) config(sprintf('firefly.shortLiabilityNameByFullName.%s', $account->full_account_type));
$accountType = (string)config(sprintf('firefly.shortNamesByFullName.%s', $account->full_account_type));
$liabilityType = (string)config(sprintf('firefly.shortLiabilityNameByFullName.%s', $account->full_account_type));
$liabilityType = '' === $liabilityType ? null : strtolower($liabilityType);
$liabilityDirection = $account->meta['liability_direction'] ?? null;
$accountRole = $this->getAccountRole($account, $accountType);
$hasCurrencySettings = null !== $account->meta['currency'];
$includeNetWorth = 1 === (int) ($account->meta['include_net_worth'] ?? 0);
$includeNetWorth = 1 === (int)($account->meta['include_net_worth'] ?? 0);
$longitude = $account->meta['location']['longitude'] ?? null;
$latitude = $account->meta['location']['latitude'] ?? null;
$zoomLevel = $account->meta['location']['zoom_level'] ?? null;
@@ -95,7 +95,7 @@ class AccountTransformer extends AbstractTransformer
[$interest, $interestPeriod] = $this->getInterest($account, $accountType);
return [
'id' => (string) $account->id,
'id' => (string)$account->id,
'created_at' => $account->created_at->toAtomString(),
'updated_at' => $account->updated_at->toAtomString(),
'active' => $account->active,
@@ -112,13 +112,13 @@ class AccountTransformer extends AbstractTransformer
'object_has_currency_setting' => $hasCurrencySettings,
// currency is object specific or primary, already determined above.
'currency_id' => (string) $currency['id'],
'currency_id' => (string)$currency['id'],
'currency_name' => $currency['name'],
'currency_code' => $currency['code'],
'currency_symbol' => $currency['symbol'],
'currency_decimal_places' => $currency['decimal_places'],
'primary_currency_id' => (string) $this->primary->id,
'primary_currency_id' => (string)$this->primary->id,
'primary_currency_name' => $this->primary->name,
'primary_currency_code' => $this->primary->code,
'primary_currency_symbol' => $this->primary->symbol,
@@ -137,6 +137,9 @@ class AccountTransformer extends AbstractTransformer
'debt_amount' => $account->meta['balances']['debt_amount'],
'pc_debt_amount' => $account->meta['balances']['pc_debt_amount'],
'balance_difference' => $account->meta['balances']['balance_difference'],
'pc_balance_difference' => $account->meta['balances']['pc_balance_difference'],
'current_balance_date' => $account->meta['current_balance_date']->toAtomString(),
'notes' => $account->meta['notes'] ?? null,
'monthly_payment_date' => $monthlyPaymentDate,
@@ -166,7 +169,7 @@ class AccountTransformer extends AbstractTransformer
private function getAccountRole(Account $account, string $accountType): ?string
{
$accountRole = $account->meta['account_role'] ?? null;
if ('asset' !== $accountType || '' === (string) $accountRole) {
if ('asset' !== $accountType || '' === (string)$accountRole) {
return null;
}
@@ -202,7 +205,7 @@ class AccountTransformer extends AbstractTransformer
}
$monthlyPaymentDate = $object->toAtomString();
}
if (10 !== strlen((string) $monthlyPaymentDate)) {
if (10 !== strlen((string)$monthlyPaymentDate)) {
$monthlyPaymentDate = Carbon::parse($monthlyPaymentDate, config('app.timezone'))->toAtomString();
}
}

View File

@@ -78,8 +78,8 @@ return [
'running_balance_column' => env('USE_RUNNING_BALANCE', false),
// see cer.php for exchange rates feature flag.
],
'version' => 'develop/2025-09-01',
'build_time' => 1756723186,
'version' => 'develop/2025-09-02',
'build_time' => 1756787029,
'api_version' => '2.1.0', // field is no longer used.
'db_version' => 26,
@@ -182,12 +182,12 @@ return [
'darkMode' => 'browser',
'list_length' => 10, // to be removed if v1 is cancelled.
'default_preferences' => [
'frontpageAccounts' => [],
'listPageSize' => 50,
'currencyPreference' => 'EUR',
'language' => 'en_US',
'locale' => 'equal',
'convertToPrimary' => false,
'frontpageAccounts' => [],
'listPageSize' => 50,
'currencyPreference' => 'EUR',
'language' => 'en_US',
'locale' => 'equal',
'convertToPrimary' => false,
],
'default_currency' => 'EUR',
'default_language' => envNonEmpty('DEFAULT_LANGUAGE', 'en_US'),
@@ -232,6 +232,13 @@ return [
'image/png',
'image/heic',
'image/heic-sequence',
'image/webp',
'image/gif',
'image/tiff',
'image/bmp',
'image/x-icon',
'image/vnd.microsoft.icon',
// PDF
'application/pdf',
@@ -400,7 +407,7 @@ return [
],
'rule-actions' => [
'rule-actions' => [
'set_category' => SetCategory::class,
'clear_category' => ClearCategory::class,
'set_budget' => SetBudget::class,
@@ -434,7 +441,7 @@ return [
// 'set_foreign_amount' => SetForeignAmount::class,
// 'set_foreign_currency' => SetForeignCurrency::class,
],
'context-rule-actions' => [
'context-rule-actions' => [
'set_category',
'set_budget',
'add_tag',
@@ -453,13 +460,13 @@ return [
'convert_transfer',
],
'test-triggers' => [
'test-triggers' => [
'limit' => 10,
'range' => 200,
],
// expected source types for each transaction type, in order of preference.
'expected_source_types' => [
'expected_source_types' => [
'source' => [
TransactionTypeEnum::WITHDRAWAL->value => [AccountTypeEnum::ASSET->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value],
TransactionTypeEnum::DEPOSIT->value => [AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::REVENUE->value, AccountTypeEnum::CASH->value],
@@ -504,7 +511,7 @@ return [
TransactionTypeEnum::LIABILITY_CREDIT->value => [AccountTypeEnum::LIABILITY_CREDIT->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value],
],
],
'allowed_opposing_types' => [
'allowed_opposing_types' => [
'source' => [
AccountTypeEnum::ASSET->value => [
AccountTypeEnum::ASSET->value,
@@ -594,7 +601,7 @@ return [
],
],
// depending on the account type, return the allowed transaction types:
'allowed_transaction_types' => [
'allowed_transaction_types' => [
'source' => [
AccountTypeEnum::ASSET->value => [
TransactionTypeEnum::WITHDRAWAL->value,
@@ -663,7 +670,7 @@ return [
],
// having the source + dest will tell you the transaction type.
'account_to_transaction' => [
'account_to_transaction' => [
AccountTypeEnum::ASSET->value => [
AccountTypeEnum::ASSET->value => TransactionTypeEnum::TRANSFER->value,
AccountTypeEnum::CASH->value => TransactionTypeEnum::WITHDRAWAL->value,
@@ -728,7 +735,7 @@ return [
],
// allowed source -> destination accounts.
'source_dests' => [
'source_dests' => [
TransactionTypeEnum::WITHDRAWAL->value => [
AccountTypeEnum::ASSET->value => [AccountTypeEnum::EXPENSE->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::CASH->value],
AccountTypeEnum::LOAN->value => [AccountTypeEnum::EXPENSE->value, AccountTypeEnum::CASH->value],
@@ -767,7 +774,7 @@ return [
],
],
// if you add fields to this array, don't forget to update the export routine (ExportDataGenerator).
'journal_meta_fields' => [
'journal_meta_fields' => [
// sepa
'sepa_cc',
'sepa_ct_op',
@@ -801,31 +808,47 @@ return [
'recurrence_count',
'recurrence_date',
],
'webhooks' => [
'webhooks' => [
'max_attempts' => env('WEBHOOK_MAX_ATTEMPTS', 3),
],
'can_have_virtual_amounts' => [AccountTypeEnum::ASSET->value],
'can_have_opening_balance' => [AccountTypeEnum::ASSET->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value],
'dynamic_creation_allowed' => [
'can_have_virtual_amounts' => [AccountTypeEnum::ASSET->value],
'can_have_opening_balance' => [AccountTypeEnum::ASSET->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value],
'dynamic_creation_allowed' => [
AccountTypeEnum::EXPENSE->value,
AccountTypeEnum::REVENUE->value,
AccountTypeEnum::INITIAL_BALANCE->value,
AccountTypeEnum::RECONCILIATION->value,
AccountTypeEnum::LIABILITY_CREDIT->value,
],
'valid_asset_fields' => ['account_role', 'account_number', 'currency_id', 'BIC', 'include_net_worth'],
'valid_cc_fields' => ['account_role', 'cc_monthly_payment_date', 'cc_type', 'account_number', 'currency_id', 'BIC', 'include_net_worth'],
'valid_account_fields' => ['account_number', 'currency_id', 'BIC', 'interest', 'interest_period', 'include_net_worth', 'liability_direction'],
'valid_asset_fields' => ['account_role', 'account_number', 'currency_id', 'BIC', 'include_net_worth'],
'valid_cc_fields' => ['account_role', 'cc_monthly_payment_date', 'cc_type', 'account_number', 'currency_id', 'BIC', 'include_net_worth'],
'valid_account_fields' => ['account_number', 'currency_id', 'BIC', 'interest', 'interest_period', 'include_net_worth', 'liability_direction'],
// dynamic date ranges are as follows:
'dynamic_date_ranges' => ['last7', 'last30', 'last90', 'last365', 'MTD', 'QTD', 'YTD'],
'dynamic_date_ranges' => ['last7', 'last30', 'last90', 'last365', 'MTD', 'QTD', 'YTD'],
'allowed_sort_parameters' => [
'Account' => ['id', 'order', 'name', 'iban', 'active', 'account_type_id',
'current_balance',
'pc_current_balance',
'opening_balance',
'pc_opening_balance',
'virtual_balance',
'pc_virtual_balance',
'debt_amount',
'pc_debt_amount',
'balance_difference',
'pc_balance_difference',
],
],
'allowed_db_sort_parameters' => [
'Account' => ['id', 'order', 'name', 'iban', 'active', 'account_type_id'],
],
// only used in v1
'allowed_sort_parameters' => ['order', 'name', 'iban'],
// preselected account lists possibilities:
'preselected_accounts' => ['all', 'assets', 'liabilities'],
'preselected_accounts' => ['all', 'assets', 'liabilities'],
// allowed to store a piggy bank in:
'piggy_bank_account_types' => [AccountTypeEnum::ASSET->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value],
'piggy_bank_account_types' => [AccountTypeEnum::ASSET->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value],
];

6
package-lock.json generated
View File

@@ -11546,9 +11546,9 @@
}
},
"node_modules/vite": {
"version": "7.1.3",
"resolved": "https://registry.npmjs.org/vite/-/vite-7.1.3.tgz",
"integrity": "sha512-OOUi5zjkDxYrKhTV3V7iKsoS37VUM7v40+HuwEmcrsf11Cdx9y3DIr2Px6liIcZFwt3XSRpQvFpL3WVy7ApkGw==",
"version": "7.1.4",
"resolved": "https://registry.npmjs.org/vite/-/vite-7.1.4.tgz",
"integrity": "sha512-X5QFK4SGynAeeIt+A7ZWnApdUyHYm+pzv/8/A57LqSGcI88U6R6ipOs3uCesdc6yl7nl+zNO0t8LmqAdXcQihw==",
"dev": true,
"license": "MIT",
"dependencies": {

View File

@@ -378,8 +378,8 @@ let index = function () {
date: format(today,'yyyy-MM-dd'),
type: type,
page: this.page,
// startPeriod: start,
// endPeriod: end
start: start,
end: end
};
if (!this.tableColumns.balance_difference.enabled) {
@@ -403,17 +403,26 @@ let index = function () {
role: current.attributes.account_role,
iban: null === current.attributes.iban ? '' : current.attributes.iban.match(/.{1,4}/g).join(' '),
account_number: null === current.attributes.account_number ? '' : current.attributes.account_number,
current_balance: current.attributes.current_balance,
currency_code: current.attributes.currency_code,
last_activity: null === current.attributes.last_activity ? '' : format(new Date(current.attributes.last_activity), i18next.t('config.month_and_day_fns')),
liability_type: current.attributes.liability_type,
liability_direction: current.attributes.liability_direction,
interest: current.attributes.interest,
interest_period: current.attributes.interest_period,
// balance: current.attributes.balance,
// pc_balance: current.attributes.pc_balance,
// balances: current.attributes.balances,
// currency info
currency_code: current.attributes.currency_code,
primary_currency_code: current.attributes.primary_currency_code,
// balances.
current_balance: current.attributes.current_balance,
pc_current_balance: current.attributes.pc_current_balance,
balance_difference: current.attributes.balance_difference,
pc_balance_difference: current.attributes.pc_balance_difference,
debt_amount: current.attributes.debt_amount,
pc_debt_amount: current.attributes.debt_amount,
};
console.log(account);
// get group info:
let groupId = current.attributes.object_group_id;
if(!this.pageOptions.groupedAccounts) {

View File

@@ -24,6 +24,9 @@
declare(strict_types=1);
return [
'invalid_sort_instruction' => 'The sort instruction is invalid for an object of type ":object".',
'invalid_sort_instruction_index' => 'The sort instruction at index #:index is invalid for an object of type ":object".',
'no_sort_instructions' => 'There are no sort instructions defined for an object of type ":object".',
'webhook_budget_info' => 'Cannot deliver budget information for transaction related webhooks.',
'webhook_account_info' => 'Cannot deliver account information for budget related webhooks.',
'webhook_transaction_info' => 'Cannot deliver transaction information for budget related webhooks.',

View File

@@ -42,6 +42,7 @@
</div>
</div>
@endif
@if($debug)
<div class="row">
<div class="col">
@@ -49,6 +50,19 @@
<p>
{!! trans('errors.error_location', ['file' => $exception->getFile(), 'line' => $exception->getLine(), 'code' => $exception->getCode() ]) !!}
</p>
<h4>
{{ trans('errors.github_help') }}
</h4>
<p>
{!! trans('errors.github_instructions') !!}
</p>
<ol>
<li>{{ trans('errors.use_search') }}</li>
<li>{!! trans('errors.include_info', ['link' => route('debug') ]) !!}</li>
<li>{{ trans('errors.tell_more') }}</li>
<li>{{ trans('errors.include_logs') }}</li>
<li>{{ trans('errors.what_did_you_do') }}</li>
</ol>
<h4>
{{ trans('errors.stacktrace') }}
</h4>

View File

@@ -440,10 +440,9 @@
<td style="width:40%;">{{ 'tags'|_ }}</td>
<td>
{% for tag in journal.tags %}
<h4 style="display: inline;"><a class="label label-success"
href="{{ route('tags.show', [tag.id]) }}">
<span class="fa fa-fw fa-tag"></span>{{ tag.tag }}</a>
</h4>
{% if null != tag.id %}
<h4 style="display: inline;"><a class="label label-success" href="{{ route('tags.show', [tag.id]) }}"><span class="fa fa-fw fa-tag"></span>{{ tag.tag }}</a></h4>
{% endif %}
{% endfor %}
</td>
</tr>

View File

@@ -263,39 +263,74 @@
</td>
<td x-show="tableColumns.current_balance.visible && tableColumns.current_balance.enabled">
<span x-show="parseFloat(account.current_balance) < 0.0" class="text-danger"
x-text="formatMoney(account.current_balance, account.currency_code)"></span>
x-text="formatMoney(account.current_balance, account.primary_currency_code)"></span>
<span x-show="parseFloat(account.current_balance) === 0.0" class="text-muted"
x-text="formatMoney(account.current_balance, account.currency_code)"></span>
x-text="formatMoney(account.current_balance, account.primary_currency_code)"></span>
<span x-show="parseFloat(account.current_balance) > 0.0" class="text-success"
x-text="formatMoney(account.current_balance, account.currency_code)"></span>
x-text="formatMoney(account.current_balance, account.primary_currency_code)"></span>
<template x-if="null !== account.pc_current_balance">
<span>PC current balance TODO.</span>
<span>(
<span x-show="parseFloat(account.pc_current_balance) < 0.0" class="text-danger"
x-text="formatMoney(account.pc_current_balance, account.primary_currency_code)"></span>
<span x-show="parseFloat(account.pc_current_balance) === 0.0" class="text-muted"
x-text="formatMoney(account.pc_current_balance, account.primary_currency_code)"></span>
<span x-show="parseFloat(account.pc_current_balance) > 0.0" class="text-success"
x-text="formatMoney(account.pc_current_balance, account.primary_currency_code)"></span>
)
</span>
</template>
</td>
<td x-show="tableColumns.amount_due.visible && tableColumns.amount_due.enabled">
<!--
<template x-if="null !== account.current_debt">
<span class="text-info"
x-text="formatMoney(account.current_debt, account.currency_code)"></span>
<template x-if="null !== account.debt_amount">
<span>
<span x-show="null != account.debt_amount && account.debt_amount < 0" class="text-danger"
x-text="formatMoney(account.debt_amount, account.currency_code)"></span>
<span x-show="null != account.debt_amount && account.debt_amount == 0" class="text-muted"
x-text="formatMoney(account.debt_amount, account.currency_code)"></span>
<span x-show="null != account.debt_amount && account.debt_amount > 0" class="text-success"
x-text="formatMoney(account.debt_amount, account.currency_code)"></span>
</span>
<template x-if="null !== account.pc_debt_amount">
<span>(
<span x-show="parseFloat(account.pc_debt_amount) < 0.0" class="text-danger"
x-text="formatMoney(account.pc_debt_amount, account.primary_currency_code)"></span>
<span x-show="parseFloat(account.pc_debt_amount) === 0.0" class="text-muted"
x-text="formatMoney(account.pc_debt_amount, account.primary_currency_code)"></span>
<span x-show="parseFloat(account.pc_debt_amount) > 0.0" class="text-success"
x-text="formatMoney(account.pc_debt_amount, account.primary_currency_code)"></span>
)
</span>
</template>
</template>
-->
FIXME
</td>
<td x-show="tableColumns.last_activity.visible && tableColumns.last_activity.enabled">
<span x-text="account.last_activity"></span>
</td>
<td x-show="tableColumns.balance_difference.visible && tableColumns.balance_difference.enabled">
<template x-if="null !== account.balance">
<template x-for="balance in account.balance">
<template x-if="null !== account.balance_difference">
<span>
<span x-show="null != balance.balance_difference && balance.balance_difference < 0" class="text-danger"
x-text="formatMoney(balance.balance_difference, balance.currency_code)"></span>
<span x-show="null != balance.balance_difference && balance.balance_difference == 0" class="text-muted"
x-text="formatMoney(balance.balance_difference, balance.currency_code)"></span>
<span x-show="null != balance.balance_difference && balance.balance_difference > 0" class="text-success"
x-text="formatMoney(balance.balance_difference, balance.currency_code)"></span>
<span x-show="null != account.balance_difference && account.balance_difference < 0" class="text-danger"
x-text="formatMoney(account.balance_difference, account.currency_code)"></span>
<span x-show="null != account.balance_difference && account.balance_difference == 0" class="text-muted"
x-text="formatMoney(account.balance_difference, account.currency_code)"></span>
<span x-show="null != account.balance_difference && account.balance_difference > 0" class="text-success"
x-text="formatMoney(account.balance_difference, account.currency_code)"></span>
</span>
</template>
<template x-if="null !== account.pc_balance_difference">
<span>(
<span x-show="parseFloat(account.pc_balance_difference) < 0.0" class="text-danger"
x-text="formatMoney(account.pc_balance_difference, account.primary_currency_code)"></span>
<span x-show="parseFloat(account.pc_balance_difference) === 0.0" class="text-muted"
x-text="formatMoney(account.pc_balance_difference, account.primary_currency_code)"></span>
<span x-show="parseFloat(account.pc_balance_difference) > 0.0" class="text-success"
x-text="formatMoney(account.pc_balance_difference, account.primary_currency_code)"></span>
)
</span>
</template>
</template>
</td>
<td x-show="tableColumns.menu.visible && tableColumns.menu.enabled">