Skip to content

Firefly III: a personal finances manager

Fix #11660

James Colefb035ba594bd
diff --git a/app/Listeners/Model/TransactionGroup/SupportsGroupProcessingTrait.php b/app/Listeners/Model/TransactionGroup/SupportsGroupProcessingTrait.php
index 595b67b07b..c1dd68273e 100644
--- a/app/Listeners/Model/TransactionGroup/SupportsGroupProcessingTrait.php
+++ b/app/Listeners/Model/TransactionGroup/SupportsGroupProcessingTrait.php
@@ -29,12 +29,17 @@ trait SupportsGroupProcessingTrait
protected function processRules(Collection $set, string $type): void
{
Log::debug(sprintf('Will now processRules("%s") for %d journal(s)', $type, $set->count()));
- $array = $set->pluck('id')->toArray();
+
+ if (0 === $set->count()) {
+ return;
+ }
+
+ $array = $set->pluck('id')->toArray();
/** @var TransactionJournal $first */
- $first = $set->first();
- $journalIds = implode(',', $array);
- $user = $first->user;
+ $first = $set->first();
+ $journalIds = implode(',', $array);
+ $user = $first->user;
Log::debug(sprintf('Add local operator for journal(s): %s', $journalIds));
// collect rules:
@@ -44,12 +49,12 @@ trait SupportsGroupProcessingTrait
// add the groups to the rule engine.
// it should run the rules in the group and cancel the group if necessary.
Log::debug(sprintf('Fire processRules with ALL %s rule groups.', $type));
- $groups = $ruleGroupRepository->getRuleGroupsWithRules($type);
+ $groups = $ruleGroupRepository->getRuleGroupsWithRules($type);
// create and fire rule engine.
- $newRuleEngine = app(RuleEngineInterface::class);
+ $newRuleEngine = app(RuleEngineInterface::class);
$newRuleEngine->setUser($user);
- $newRuleEngine->addOperator(['type' => 'journal_id', 'value' => $journalIds]);
+ $newRuleEngine->addOperator(['type' => 'journal_id', 'value' => $journalIds]);
$newRuleEngine->setRuleGroups($groups);
$newRuleEngine->fire();
Log::debug(sprintf('Done with processRules("%s") for %d journal(s)', $type, $set->count()));
@@ -63,10 +68,16 @@ trait SupportsGroupProcessingTrait
return;
}
- // find the earliest date in the set, based on date and _internal_previous_date
- $earliest = $objects->transactionJournals->pluck('date')->sort()->first();
- $fromInternalDate = $this->getFromInternalDate($objects->transactionJournals->pluck('id')->toArray());
- $earliest = $fromInternalDate->lt($earliest) ? $fromInternalDate : $earliest;
+ if (0 === $objects->accounts->count()) {
+ return;
+ }
+ $earliest = today()->subDays(2);
+ if ($objects->transactionJournals->count() > 0) {
+ // find the earliest date in the set, based on date and _internal_previous_date
+ $earliest = $objects->transactionJournals->pluck('date')->sort()->first();
+ $fromInternalDate = $this->getFromInternalDate($objects->transactionJournals->pluck('id')->toArray());
+ $earliest = $fromInternalDate->lt($earliest) ? $fromInternalDate : $earliest;
+ }
Log::debug(sprintf('Found earliest date: %s', $earliest->toW3cString()));
Log::debug('Found accounts to process', $objects->accounts->pluck('id')->toArray());
@@ -78,6 +89,7 @@ trait SupportsGroupProcessingTrait
{
if (!auth()->check()) {
Log::debug('Will NOT remove period statistics for all objects, because no user detected.');
+ return;
}
Log::debug('Will now remove period statistics for all objects.');
@@ -122,9 +134,13 @@ trait SupportsGroupProcessingTrait
{
Log::debug(sprintf('Will now create webhook messages for %d group(s)', $groups->count()));
+ if (0 === $groups->count()) {
+ return;
+ }
+
/** @var TransactionGroup $first */
- $first = $groups->first();
- $user = $first->user;
+ $first = $groups->first();
+ $user = $first->user;
/** @var MessageGeneratorInterface $engine */
$engine = app(MessageGeneratorInterface::class);
diff --git a/app/Repositories/PeriodStatistic/PeriodStatisticRepository.php b/app/Repositories/PeriodStatistic/PeriodStatisticRepository.php
index 71aa913bf4..78c57b4544 100644
--- a/app/Repositories/PeriodStatistic/PeriodStatisticRepository.php
+++ b/app/Repositories/PeriodStatistic/PeriodStatisticRepository.php
@@ -95,6 +95,10 @@ class PeriodStatisticRepository implements PeriodStatisticRepositoryInterface, U
#[Override]
public function deleteStatisticsForPrefix(string $prefix, Collection $dates): void
{
+ if(null === $this->userGroup) {
+ Log::warning(('No user group, so cannot continue.'));
+ return;
+ }
$count = $this->userGroup
->periodStatistics()
->where(function (Builder $q) use ($dates): void {
diff --git a/changelog.md b/changelog.md
index 2f82690e7b..41088a301d 100644
--- a/changelog.md
+++ b/changelog.md
@@ -31,6 +31,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- [Issue 11601](https://github.com/firefly-iii/firefly-iii/issues/11601) (Only ungrouped piggy banks are listed when creating a transaction) reported by @jgmm81
- [Issue 11620](https://github.com/firefly-iii/firefly-iii/issues/11620) (Add database indexes to improve reporting query performance) reported by @Zakmaf
- [PR 11632](https://github.com/firefly-iii/firefly-iii/pull/11632) (fix v2 layout dashboard transactions load) reported by @mateuszkulapl
+- #11660
- Confirming your new email address would result in an error.
### API
diff --git a/resources/views/list/groups.twig b/resources/views/list/groups.twig
index 88f7d59662..043bfcadc6 100644
--- a/resources/views/list/groups.twig
+++ b/resources/views/list/groups.twig
@@ -180,7 +180,12 @@
{% elseif transaction.transaction_type_type == 'Transfer' %}
<span class="text-info money-transfer">
{# amount of transfer #}
+ {% if transaction.source_account_id == account.id %}
+ {{ formatAmountBySymbol(transaction.amount, transaction.currency_symbol, transaction.currency_decimal_places, false) }}
+ {% endif %}
+ {% if transaction.source_account_id != account.id %}
{{ formatAmountBySymbol(transaction.amount*-1, transaction.currency_symbol, transaction.currency_decimal_places, false) }}
+ {% endif %}
{# foreign amount of transfer #}
{% if null != transaction.foreign_amount %}
@@ -267,7 +272,7 @@
{% endif %}
</td>
{% if (fireflyiiiconfig('use_running_balance', true)) %}
- <td>
+ <td style="{{ style|raw }};text-align:right">
{# RUNNING BALANCE #}
{% if (null == transaction.balance_dirty or false == transaction.balance_dirty) and null != transaction.destination_balance_after and null != transaction.source_balance_after %}
{% if transaction.transaction_type_type == 'Deposit' %}