Merge pull request #11545 from firefly-iii/release-1768729993

🤖 Automatically merge the PR into the develop branch.
This commit is contained in:
github-actions[bot]
2026-01-18 10:53:20 +01:00
committed by GitHub
7 changed files with 33 additions and 24 deletions

View File

@@ -1,4 +1,5 @@
<?php
/*
* SubscriptionNeedsExtensionOrRenewal.php
* Copyright (c) 2026 james@firefly-iii.org

View File

@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
/*
* SubscriptionIsOverdueForPayment.php
* Copyright (c) 2026 james@firefly-iii.org

View File

@@ -56,12 +56,12 @@ class WarnAboutBills implements ShouldQueue
*/
public function __construct(?Carbon $date)
{
$newDate = new Carbon();
$newDate = new Carbon();
$newDate->startOfDay();
$this->date = $newDate;
$this->date = $newDate;
if ($date instanceof Carbon) {
$newDate = clone $date;
$newDate = clone $date;
$newDate->startOfDay();
$this->date = $newDate;
}
@@ -148,7 +148,7 @@ class WarnAboutBills implements ShouldQueue
public function setDate(Carbon $date): void
{
$newDate = clone $date;
$newDate = clone $date;
$newDate->startOfDay();
$this->date = $newDate;
}
@@ -170,7 +170,7 @@ class WarnAboutBills implements ShouldQueue
$enrichment->setEnd($end);
/** @var Bill $single */
$single = $enrichment->enrichSingle($bill);
$single = $enrichment->enrichSingle($bill);
return [
'pay_dates' => $single->meta['pay_dates'] ?? [],
@@ -180,7 +180,7 @@ class WarnAboutBills implements ShouldQueue
private function needsOverdueAlert(array $dates): bool
{
$count = count($dates['pay_dates']) - count($dates['paid_dates']);
$count = count($dates['pay_dates']) - count($dates['paid_dates']);
if (0 === $count || 0 === count($dates['pay_dates'])) {
return false;
}
@@ -188,7 +188,7 @@ class WarnAboutBills implements ShouldQueue
$earliest = new Carbon($dates['pay_dates'][0]);
$earliest->startOfDay();
Log::debug(sprintf('Earliest expected pay date is %s', $earliest->toAtomString()));
$diff = $earliest->diffInDays($this->date);
$diff = $earliest->diffInDays($this->date);
Log::debug(sprintf('Difference in days is %s', $diff));
return $diff >= 6; // FIXME hard coded value.

View File

@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
/*
* NotifiesAboutExtensionOrRenewal.php
* Copyright (c) 2026 james@firefly-iii.org
@@ -35,8 +37,9 @@ class NotifiesAboutExtensionOrRenewal implements ShouldQueue
{
Log::debug(sprintf('Now in %s', __METHOD__));
$subscription = $event->subscription;
/** @var bool $preference */
$preference = Preferences::getForUser($subscription->user, 'notification_bill_reminder', true)->data;
$preference = Preferences::getForUser($subscription->user, 'notification_bill_reminder', true)->data;
if (true === $preference) {
Log::debug('Subscription reminder is true!');
@@ -63,5 +66,4 @@ class NotifiesAboutExtensionOrRenewal implements ShouldQueue
}
Log::debug('User has disabled subscription reminders.');
}
}

View File

@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
/*
* NotifiesAboutOverdueSubscription.php
* Copyright (c) 2026 james@firefly-iii.org
@@ -36,15 +38,15 @@ class NotifiesAboutOverdueSubscriptions implements ShouldQueue
{
Log::debug(sprintf('Now in %s', __METHOD__));
// make sure user does not get the warning twice.
$overdue = $event->overdue;
$user = $event->user;
$toBeWarned = [];
$overdue = $event->overdue;
$user = $event->user;
$toBeWarned = [];
Log::debug(sprintf('%d subscriptions to warn about.', count($overdue)));
foreach ($overdue as $item) {
/** @var Bill $bill */
$bill = $item['bill'];
$key = sprintf('bill_overdue_%s_%s', $bill->id, substr(hash('sha256', json_encode($item['dates']['pay_dates'], JSON_THROW_ON_ERROR)), 0, 10));
$pref = Preferences::getForUser($bill->user, $key, false);
$bill = $item['bill'];
$key = sprintf('bill_overdue_%s_%s', $bill->id, substr(hash('sha256', json_encode($item['dates']['pay_dates'], JSON_THROW_ON_ERROR)), 0, 10));
$pref = Preferences::getForUser($bill->user, $key, false);
if (true === $pref->data) {
Log::debug(sprintf('User #%d has already been warned about overdue subscription #%d.', $bill->user->id, $bill->id));
@@ -96,5 +98,4 @@ class NotifiesAboutOverdueSubscriptions implements ShouldQueue
}
}

View File

@@ -108,19 +108,21 @@ class AccountBalanceCalculator
->orderBy('transaction_journals.id', 'DESC')
->orderBy('transaction_journals.description', 'DESC')
->orderBy('transactions.amount', 'DESC')
->where('transactions.account_id', $accountId);
->where('transactions.account_id', $accountId)
;
$query->where('transaction_journals.date', '<', $notBefore);
$first = $query->first(['transactions.id', 'transactions.balance_dirty', 'transactions.transaction_currency_id', 'transaction_journals.date', 'transactions.account_id', 'transactions.amount', 'transactions.balance_after']);
if(null === $first) {
if (null === $first) {
Log::debug(sprintf('Found no transactions for currency #%d and account #%d, return 0.', $currencyId, $accountId));
return '0';
}
$balance = (string)($first->balance_after ?? '0');
Log::debug(sprintf('getLatestBalance: found balance: %s in transaction #%d on moment %s', Steam::bcround($balance,2), $first->id ?? 0, $notBefore->format('Y-m-d H:i:s')));
Log::debug(sprintf('getLatestBalance: found balance: %s in transaction #%d on moment %s', Steam::bcround($balance, 2), $first->id ?? 0, $notBefore->format('Y-m-d H:i:s')));
return $balance;
}
@@ -133,7 +135,7 @@ class AccountBalanceCalculator
Log::debug(sprintf('start of optimizedCalculation with date "%s"', $notBefore?->format('Y-m-d H:i:s')));
if ($accounts->count() > 0) {
Log::debug(sprintf('Limited to %d account(s): %s', $accounts->count(), join(', ', $accounts->pluck('id')->toArray())));
Log::debug(sprintf('Limited to %d account(s): %s', $accounts->count(), implode(', ', $accounts->pluck('id')->toArray())));
}
// collect all transactions and the change they make.
$balances = [];
@@ -146,7 +148,8 @@ class AccountBalanceCalculator
->orderBy('transaction_journals.order', 'desc')
->orderBy('transaction_journals.id', 'asc')
->orderBy('transaction_journals.description', 'asc')
->orderBy('transactions.amount', 'asc');
->orderBy('transactions.amount', 'asc')
;
if ($accounts->count() > 0) {
$query->whereIn('transactions.account_id', $accounts->pluck('id')->toArray());
}
@@ -171,7 +174,7 @@ class AccountBalanceCalculator
$before = $balances[$entry->account_id][$entry->transaction_currency_id][0];
$after = bcadd($before, (string)$entry->amount);
Log::debug(sprintf('Before:%s, after:%s', Steam::bcround($before,2), Steam::bcround($after, 2)));
Log::debug(sprintf('Before:%s, after:%s', Steam::bcround($before, 2), Steam::bcround($after, 2)));
if (true === $entry->balance_dirty || $accounts->count() > 0) {
// update the transaction:

View File

@@ -78,8 +78,8 @@ return [
'running_balance_column' => (bool)envNonEmpty('USE_RUNNING_BALANCE', true), // this is only the default value, is not used.
// see cer.php for exchange rates feature flag.
],
'version' => 'develop/2026-01-17',
'build_time' => 1768662564,
'version' => 'develop/2026-01-18',
'build_time' => 1768729886,
'api_version' => '2.1.0', // field is no longer used.
'db_version' => 28, // field is no longer used.