mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 07:34:43 +00:00
🤖 Auto commit for release 'develop' on 2025-09-07
This commit is contained in:
@@ -139,14 +139,14 @@ class RemoteUserGuard implements Guard
|
||||
/**
|
||||
* @SuppressWarnings("PHPMD.ShortMethodName")
|
||||
*/
|
||||
public function id(): null|int|string
|
||||
public function id(): int|string|null
|
||||
{
|
||||
Log::debug(sprintf('Now at %s', __METHOD__));
|
||||
|
||||
return $this->user?->id;
|
||||
}
|
||||
|
||||
public function setUser(null|Authenticatable|User $user): void // @phpstan-ignore-line
|
||||
public function setUser(Authenticatable|User|null $user): void // @phpstan-ignore-line
|
||||
{
|
||||
Log::debug(sprintf('Now at %s', __METHOD__));
|
||||
if ($user instanceof User) {
|
||||
|
@@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Facades;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
class Navigation extends Facade
|
||||
|
@@ -144,9 +144,10 @@ 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) {
|
||||
@@ -172,9 +173,10 @@ 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'];
|
||||
}
|
||||
@@ -184,14 +186,15 @@ 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)));
|
||||
}
|
||||
@@ -206,19 +209,20 @@ 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'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,9 +240,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,
|
||||
@@ -285,30 +289,30 @@ 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];
|
||||
$balanceDifference = $this->getBalanceDifference($id, $currency);
|
||||
$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($item->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($item->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;
|
||||
$pcBalanceDifference = 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) {
|
||||
@@ -347,7 +351,7 @@ class AccountEnrichment implements EnrichmentInterface
|
||||
'pc_balance_difference' => $pcBalanceDifference,
|
||||
];
|
||||
// end add balances
|
||||
$item->meta = $meta;
|
||||
$item->meta = $meta;
|
||||
|
||||
return $item;
|
||||
});
|
||||
@@ -369,12 +373,13 @@ class AccountEnrichment implements EnrichmentInterface
|
||||
|
||||
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;
|
||||
@@ -426,8 +431,8 @@ class AccountEnrichment implements EnrichmentInterface
|
||||
if (0 === count($startBalance) || 0 === count($endBalance)) {
|
||||
return null;
|
||||
}
|
||||
$start = $startBalance[$currency->code] ?? '0';
|
||||
$end = $endBalance[$currency->code] ?? '0';
|
||||
$start = $startBalance[$currency->code] ?? '0';
|
||||
$end = $endBalance[$currency->code] ?? '0';
|
||||
|
||||
return bcsub($end, $start);
|
||||
}
|
||||
@@ -440,22 +445,25 @@ class AccountEnrichment implements EnrichmentInterface
|
||||
private function sortData(): void
|
||||
{
|
||||
$dbParams = config('firefly.allowed_db_sort_parameters.Account', []);
|
||||
|
||||
/** @var array $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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -55,10 +55,9 @@ class AvailableBudgetEnrichment implements EnrichmentInterface
|
||||
private readonly OperationsRepositoryInterface $opsRepository;
|
||||
private readonly BudgetRepositoryInterface $repository;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//$this->primaryCurrency = Amount::getPrimaryCurrency();
|
||||
// $this->primaryCurrency = Amount::getPrimaryCurrency();
|
||||
$this->convertToPrimary = Amount::convertToPrimary();
|
||||
$this->noBudgetRepository = app(NoBudgetRepositoryInterface::class);
|
||||
$this->opsRepository = app(OperationsRepositoryInterface::class);
|
||||
|
@@ -30,10 +30,8 @@ use FireflyIII\Models\AutoBudget;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Models\Note;
|
||||
use FireflyIII\Models\ObjectGroup;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Models\UserGroup;
|
||||
use FireflyIII\Repositories\Budget\OperationsRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Amount;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Collection;
|
||||
@@ -56,9 +54,7 @@ class BudgetEnrichment implements EnrichmentInterface
|
||||
private array $objectGroups = [];
|
||||
private array $mappedObjects = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
public function __construct() {}
|
||||
|
||||
public function enrich(Collection $collection): Collection
|
||||
{
|
||||
|
@@ -55,8 +55,8 @@ class PiggyBankEnrichment implements EnrichmentInterface
|
||||
private array $mappedObjects = [];
|
||||
private TransactionCurrency $primaryCurrency;
|
||||
private array $amounts = [];
|
||||
private array $accounts= [];
|
||||
private array $objectGroups= [];
|
||||
private array $accounts = [];
|
||||
private array $objectGroups = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
@@ -25,7 +25,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\JsonApi\Enrichments;
|
||||
|
||||
use function Safe\json_decode;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Enums\RecurrenceRepetitionWeekend;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
@@ -53,11 +52,13 @@ use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use function Safe\json_decode;
|
||||
|
||||
class RecurringEnrichment implements EnrichmentInterface
|
||||
{
|
||||
private Collection $collection;
|
||||
private array $ids = [];
|
||||
// private array $transactionTypeIds = [];
|
||||
// private array $transactionTypeIds = [];
|
||||
// private array $transactionTypes = [];
|
||||
private array $notes = [];
|
||||
private array $repetitions = [];
|
||||
@@ -122,10 +123,10 @@ class RecurringEnrichment implements EnrichmentInterface
|
||||
{
|
||||
/** @var Recurrence $recurrence */
|
||||
foreach ($this->collection as $recurrence) {
|
||||
$id = (int)$recurrence->id;
|
||||
// $typeId = (int)$recurrence->transaction_type_id;
|
||||
$this->ids[] = $id;
|
||||
//$this->transactionTypeIds[$id] = $typeId;
|
||||
$id = (int)$recurrence->id;
|
||||
// $typeId = (int)$recurrence->transaction_type_id;
|
||||
$this->ids[] = $id;
|
||||
// $this->transactionTypeIds[$id] = $typeId;
|
||||
}
|
||||
$this->ids = array_unique($this->ids);
|
||||
|
||||
@@ -146,7 +147,7 @@ class RecurringEnrichment implements EnrichmentInterface
|
||||
|
||||
/** @var RecurrenceRepetition $repetition */
|
||||
foreach ($set as $repetition) {
|
||||
$recurrence = $this->collection->filter(fn(Recurrence $item) => (int)$item->id === (int)$repetition->recurrence_id)->first();
|
||||
$recurrence = $this->collection->filter(fn (Recurrence $item) => (int)$item->id === (int)$repetition->recurrence_id)->first();
|
||||
$fromDate = clone ($recurrence->latest_date ?? $recurrence->first_date);
|
||||
$id = (int)$repetition->recurrence_id;
|
||||
$repId = (int)$repetition->id;
|
||||
|
@@ -28,7 +28,6 @@ namespace FireflyIII\Support\JsonApi\Enrichments;
|
||||
use Carbon\Carbon;
|
||||
use Carbon\CarbonInterface;
|
||||
use Carbon\Exceptions\InvalidFormatException;
|
||||
use Carbon\Exceptions\ParseErrorException;
|
||||
use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Models\Note;
|
||||
use FireflyIII\Models\ObjectGroup;
|
||||
@@ -87,11 +86,11 @@ class SubscriptionEnrichment implements EnrichmentInterface
|
||||
$paidDates = $this->paidDates;
|
||||
$payDates = $this->payDates;
|
||||
$this->collection = $this->collection->map(function (Bill $item) use ($notes, $objectGroups, $paidDates, $payDates) {
|
||||
$id = (int)$item->id;
|
||||
$currency = $item->transactionCurrency;
|
||||
$nem = $this->getNextExpectedMatch($payDates[$id] ?? []);
|
||||
$id = (int)$item->id;
|
||||
$currency = $item->transactionCurrency;
|
||||
$nem = $this->getNextExpectedMatch($payDates[$id] ?? []);
|
||||
|
||||
$meta = [
|
||||
$meta = [
|
||||
'notes' => null,
|
||||
'object_group_id' => null,
|
||||
'object_group_title' => null,
|
||||
@@ -102,7 +101,7 @@ class SubscriptionEnrichment implements EnrichmentInterface
|
||||
'nem' => $nem,
|
||||
'nem_diff' => $this->getNextExpectedMatchDiff($nem, $payDates[$id] ?? []),
|
||||
];
|
||||
$amounts = [
|
||||
$amounts = [
|
||||
'amount_min' => Steam::bcround($item->amount_min, $currency->decimal_places),
|
||||
'amount_max' => Steam::bcround($item->amount_max, $currency->decimal_places),
|
||||
'average' => Steam::bcround(bcdiv(bcadd($item->amount_min, $item->amount_max), '2'), $currency->decimal_places),
|
||||
@@ -155,9 +154,10 @@ class SubscriptionEnrichment implements EnrichmentInterface
|
||||
private function collectNotes(): void
|
||||
{
|
||||
$notes = Note::query()->whereIn('noteable_id', $this->subscriptionIds)
|
||||
->whereNotNull('notes.text')
|
||||
->where('notes.text', '!=', '')
|
||||
->where('noteable_type', Bill::class)->get(['notes.noteable_id', 'notes.text'])->toArray();
|
||||
->whereNotNull('notes.text')
|
||||
->where('notes.text', '!=', '')
|
||||
->where('noteable_type', Bill::class)->get(['notes.noteable_id', 'notes.text'])->toArray()
|
||||
;
|
||||
foreach ($notes as $note) {
|
||||
$this->notes[(int)$note['noteable_id']] = (string)$note['text'];
|
||||
}
|
||||
@@ -186,12 +186,13 @@ class SubscriptionEnrichment implements EnrichmentInterface
|
||||
|
||||
private function collectObjectGroups(): void
|
||||
{
|
||||
$set = DB::table('object_groupables')
|
||||
->whereIn('object_groupable_id', $this->subscriptionIds)
|
||||
->where('object_groupable_type', Bill::class)
|
||||
->get(['object_groupable_id', 'object_group_id']);
|
||||
$set = DB::table('object_groupables')
|
||||
->whereIn('object_groupable_id', $this->subscriptionIds)
|
||||
->where('object_groupable_type', Bill::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;
|
||||
@@ -219,13 +220,13 @@ class SubscriptionEnrichment implements EnrichmentInterface
|
||||
// 2023-07-18 this particular date is used to search for the last paid date.
|
||||
// 2023-07-18 the cloned $searchDate is used to grab the correct transactions.
|
||||
/** @var Carbon $start */
|
||||
$start = clone $this->start;
|
||||
$searchStart = clone $start;
|
||||
$start = clone $this->start;
|
||||
$searchStart = clone $start;
|
||||
$start->subDay();
|
||||
|
||||
/** @var Carbon $end */
|
||||
$end = clone $this->end;
|
||||
$searchEnd = clone $end;
|
||||
$end = clone $this->end;
|
||||
$searchEnd = clone $end;
|
||||
|
||||
// move the search dates to the start of the day.
|
||||
$searchStart->startOfDay();
|
||||
@@ -234,13 +235,13 @@ class SubscriptionEnrichment implements EnrichmentInterface
|
||||
Log::debug(sprintf('Search parameters are: start: %s, end: %s', $searchStart->format('Y-m-d H:i:s'), $searchEnd->format('Y-m-d H:i:s')));
|
||||
|
||||
// Get from database when bills were paid.
|
||||
$set = $this->user->transactionJournals()
|
||||
->whereIn('bill_id', $this->subscriptionIds)
|
||||
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
->leftJoin('transaction_currencies AS currency', 'currency.id', '=', 'transactions.transaction_currency_id')
|
||||
->leftJoin('transaction_currencies AS foreign_currency', 'foreign_currency.id', '=', 'transactions.foreign_currency_id')
|
||||
->where('transactions.amount', '>', 0)
|
||||
->before($searchEnd)->after($searchStart)->get(
|
||||
$set = $this->user->transactionJournals()
|
||||
->whereIn('bill_id', $this->subscriptionIds)
|
||||
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
->leftJoin('transaction_currencies AS currency', 'currency.id', '=', 'transactions.transaction_currency_id')
|
||||
->leftJoin('transaction_currencies AS foreign_currency', 'foreign_currency.id', '=', 'transactions.foreign_currency_id')
|
||||
->where('transactions.amount', '>', 0)
|
||||
->before($searchEnd)->after($searchStart)->get(
|
||||
[
|
||||
'transaction_journals.id',
|
||||
'transaction_journals.date',
|
||||
@@ -257,26 +258,27 @@ class SubscriptionEnrichment implements EnrichmentInterface
|
||||
'transactions.amount',
|
||||
'transactions.foreign_amount',
|
||||
]
|
||||
);
|
||||
)
|
||||
;
|
||||
Log::debug(sprintf('Count %d entries in set', $set->count()));
|
||||
|
||||
// for each bill, do a loop.
|
||||
$converter = new ExchangeRateConverter();
|
||||
$converter = new ExchangeRateConverter();
|
||||
|
||||
/** @var Bill $subscription */
|
||||
foreach ($this->collection as $subscription) {
|
||||
// Grab from array the most recent payment. If none exist, fall back to the start date and pretend *that* was the last paid date.
|
||||
Log::debug(sprintf('Grab last paid date from function, return %s if it comes up with nothing.', $start->format('Y-m-d')));
|
||||
$lastPaidDate = $this->lastPaidDate($subscription, $set, $start);
|
||||
$lastPaidDate = $this->lastPaidDate($subscription, $set, $start);
|
||||
Log::debug(sprintf('Result of lastPaidDate is %s', $lastPaidDate->format('Y-m-d')));
|
||||
|
||||
// At this point the "next match" is exactly after the last time the bill was paid.
|
||||
$result = [];
|
||||
$filtered = $set->filter(function (TransactionJournal $journal) use ($subscription) {
|
||||
$result = [];
|
||||
$filtered = $set->filter(function (TransactionJournal $journal) use ($subscription) {
|
||||
return (int)$journal->bill_id === (int)$subscription->id;
|
||||
});
|
||||
foreach ($filtered as $entry) {
|
||||
$array = [
|
||||
$array = [
|
||||
'transaction_group_id' => (string)$entry->transaction_group_id,
|
||||
'transaction_journal_id' => (string)$entry->id,
|
||||
'date' => $entry->date->toAtomString(),
|
||||
@@ -352,7 +354,7 @@ class SubscriptionEnrichment implements EnrichmentInterface
|
||||
return $default;
|
||||
}
|
||||
|
||||
$latest = $filtered->first()->date;
|
||||
$latest = $filtered->first()->date;
|
||||
|
||||
/** @var TransactionJournal $journal */
|
||||
foreach ($filtered as $journal) {
|
||||
@@ -398,12 +400,12 @@ class SubscriptionEnrichment implements EnrichmentInterface
|
||||
|
||||
/** @var Bill $subscription */
|
||||
foreach ($this->collection as $subscription) {
|
||||
$id = (int)$subscription->id;
|
||||
$lastPaidDate = $this->getLastPaidDate($this->paidDates[$id] ?? []);
|
||||
$payDates = $this->calculator->getPayDates($this->start, $this->end, $subscription->date, $subscription->repeat_freq, $subscription->skip, $lastPaidDate);
|
||||
$payDatesFormatted = [];
|
||||
$id = (int)$subscription->id;
|
||||
$lastPaidDate = $this->getLastPaidDate($this->paidDates[$id] ?? []);
|
||||
$payDates = $this->calculator->getPayDates($this->start, $this->end, $subscription->date, $subscription->repeat_freq, $subscription->skip, $lastPaidDate);
|
||||
$payDatesFormatted = [];
|
||||
foreach ($payDates as $string) {
|
||||
$date = Carbon::createFromFormat('!Y-m-d', $string, config('app.timezone'));
|
||||
$date = Carbon::createFromFormat('!Y-m-d', $string, config('app.timezone'));
|
||||
if (!$date instanceof Carbon) {
|
||||
$date = today(config('app.timezone'));
|
||||
}
|
||||
|
@@ -57,7 +57,7 @@ class Preferences
|
||||
;
|
||||
}
|
||||
|
||||
public function get(string $name, null|array|bool|int|string $default = null): ?Preference
|
||||
public function get(string $name, array|bool|int|string|null $default = null): ?Preference
|
||||
{
|
||||
/** @var null|User $user */
|
||||
$user = auth()->user();
|
||||
@@ -71,7 +71,7 @@ class Preferences
|
||||
return $this->getForUser($user, $name, $default);
|
||||
}
|
||||
|
||||
public function getForUser(User $user, string $name, null|array|bool|int|string $default = null): ?Preference
|
||||
public function getForUser(User $user, string $name, array|bool|int|string|null $default = null): ?Preference
|
||||
{
|
||||
// Log::debug(sprintf('getForUser(#%d, "%s")', $user->id, $name));
|
||||
// don't care about user group ID, except for some specific preferences.
|
||||
@@ -135,7 +135,7 @@ class Preferences
|
||||
Cache::put($key, '', 5);
|
||||
}
|
||||
|
||||
public function setForUser(User $user, string $name, null|array|bool|int|string $value): Preference
|
||||
public function setForUser(User $user, string $name, array|bool|int|string|null $value): Preference
|
||||
{
|
||||
$fullName = sprintf('preference%s%s', $user->id, $name);
|
||||
$userGroupId = $this->getUserGroupId($user, $name);
|
||||
@@ -240,7 +240,7 @@ class Preferences
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getEncryptedForUser(User $user, string $name, null|array|bool|int|string $default = null): ?Preference
|
||||
public function getEncryptedForUser(User $user, string $name, array|bool|int|string|null $default = null): ?Preference
|
||||
{
|
||||
$result = $this->getForUser($user, $name, $default);
|
||||
if ('' === $result->data) {
|
||||
@@ -265,7 +265,7 @@ class Preferences
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getFresh(string $name, null|array|bool|int|string $default = null): ?Preference
|
||||
public function getFresh(string $name, array|bool|int|string|null $default = null): ?Preference
|
||||
{
|
||||
/** @var null|User $user */
|
||||
$user = auth()->user();
|
||||
@@ -313,7 +313,7 @@ class Preferences
|
||||
Session::forget('first');
|
||||
}
|
||||
|
||||
public function set(string $name, null|array|bool|int|string $value): Preference
|
||||
public function set(string $name, array|bool|int|string|null $value): Preference
|
||||
{
|
||||
/** @var null|User $user */
|
||||
$user = auth()->user();
|
||||
|
@@ -37,7 +37,7 @@ interface UserGroupInterface
|
||||
|
||||
public function getUserGroup(): ?UserGroup;
|
||||
|
||||
public function setUser(null|Authenticatable|User $user): void;
|
||||
public function setUser(Authenticatable|User|null $user): void;
|
||||
|
||||
public function setUserGroup(UserGroup $userGroup): void;
|
||||
|
||||
|
@@ -61,7 +61,7 @@ trait UserGroupTrait
|
||||
/**
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function setUser(null|Authenticatable|User $user): void
|
||||
public function setUser(Authenticatable|User|null $user): void
|
||||
{
|
||||
if ($user instanceof User) {
|
||||
$this->user = $user;
|
||||
|
@@ -31,6 +31,7 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Steam;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use function Safe\preg_replace;
|
||||
|
||||
/**
|
||||
@@ -105,14 +106,15 @@ trait ConvertsDataTypes
|
||||
$parts = explode(',', $parameter);
|
||||
$sortParameters = [];
|
||||
foreach ($parts as $part) {
|
||||
$part = trim($part);
|
||||
$direction = 'asc';
|
||||
$part = trim($part);
|
||||
$direction = 'asc';
|
||||
if ('-' === $part[0]) {
|
||||
$part = substr($part, 1);
|
||||
$direction = 'desc';
|
||||
}
|
||||
$sortParameters[] = [$part, $direction];
|
||||
}
|
||||
|
||||
return $sortParameters;
|
||||
}
|
||||
|
||||
@@ -434,7 +436,7 @@ 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'));
|
||||
if (null === $entry['current_amount']) {
|
||||
|
@@ -137,7 +137,7 @@ class AccountSearch implements GenericSearchInterface
|
||||
$this->types = $types;
|
||||
}
|
||||
|
||||
public function setUser(null|Authenticatable|User $user): void
|
||||
public function setUser(Authenticatable|User|null $user): void
|
||||
{
|
||||
if ($user instanceof User) {
|
||||
$this->user = $user;
|
||||
|
@@ -116,9 +116,10 @@ class AmountFormat extends AbstractExtension
|
||||
'formatAmountBySymbol',
|
||||
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));
|
||||
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);
|
||||
}
|
||||
|
||||
|
@@ -38,6 +38,7 @@ use Override;
|
||||
use Twig\Extension\AbstractExtension;
|
||||
use Twig\TwigFilter;
|
||||
use Twig\TwigFunction;
|
||||
|
||||
use function Safe\parse_url;
|
||||
|
||||
/**
|
||||
@@ -70,14 +71,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) {
|
||||
@@ -118,15 +119,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';
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -140,7 +141,7 @@ 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/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',
|
||||
@@ -213,7 +214,7 @@ class General extends AbstractExtension
|
||||
{
|
||||
return new TwigFunction(
|
||||
'phpdate',
|
||||
static fn(string $str): string => date($str)
|
||||
static fn (string $str): string => date($str)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -269,7 +270,7 @@ 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(
|
||||
@@ -375,7 +376,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'))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user