Skip to content

Firefly III: a personal finances manager

Fix date issues.

James Cole7196ac3ec982
diff --cc app/Helpers/Collector/GroupCollector.php
index bcf955b721,4540f41a32..b3bfbf4e75
--- a/app/Helpers/Collector/GroupCollector.php
+++ b/app/Helpers/Collector/GroupCollector.php
@@@ -553,9 -552,9 +553,14 @@@ class GroupCollector implements GroupCo
$result['tags'] = [];
$result['attachments'] = [];
try {
-- $result['date'] = new Carbon($result['date']);
-- $result['created_at'] = new Carbon($result['created_at']);
-- $result['updated_at'] = new Carbon($result['updated_at']);
++ $result['date'] = new Carbon($result['date'], 'UTC');
++ $result['created_at'] = new Carbon($result['created_at'], 'UTC');
++ $result['updated_at'] = new Carbon($result['updated_at'], 'UTC');
++
++ // this is going to happen a lot:
++ $result['date']->setTimezone(env('TZ'));
++ $result['created_at']->setTimezone(env('TZ'));
++ $result['updated_at']->setTimezone(env('TZ'));
} catch (Exception $e) {
Log::error($e->getMessage());
}
diff --cc app/Http/Controllers/Account/ShowController.php
index b2f5f973ff,b2f5f973ff..68841905b2
--- a/app/Http/Controllers/Account/ShowController.php
+++ b/app/Http/Controllers/Account/ShowController.php
@@@ -46,10 -46,10 +46,8 @@@ class ShowController extends Controlle
{
use UserNavigation, PeriodOverview;
-- /** @var CurrencyRepositoryInterface The currency repository */
-- private $currencyRepos;
-- /** @var AccountRepositoryInterface The account repository */
-- private $repository;
++ private CurrencyRepositoryInterface $currencyRepos;
++ private AccountRepositoryInterface $repository;
/**
* ShowController constructor.
diff --cc app/Http/Controllers/BillController.php
index a11e77bfae,2c12d48479..ee674fa8ab
--- a/app/Http/Controllers/BillController.php
+++ b/app/Http/Controllers/BillController.php
@@@ -211,16 -211,14 +211,20 @@@ class BillController extends Controlle
/** @var Collection $bills */
$bills = $unfiltered->map(
function (Bill $bill) use ($transformer, $defaultCurrency) {
-- $return = $transformer->transform($bill);
- $nextExpectedMatch = new Carbon($return['next_expected_match']);
- $return['next_expected_match_diff'] = $nextExpectedMatch->isToday() ? trans('firefly.today') : $nextExpectedMatch->diffForHumans(today(), Carbon::DIFF_RELATIVE_TO_NOW);
-- $currency = $bill->transactionCurrency ?? $defaultCurrency;
-- $return['currency_id'] = $currency->id;
-- $return['currency_name'] = $currency->name;
-- $return['currency_symbol'] = $currency->symbol;
-- $return['currency_code'] = $currency->code;
-- $return['currency_decimal_places'] = $currency->decimal_places;
-- $return['attachments'] = $this->billRepository->getAttachments($bill);
++ $return = $transformer->transform($bill);
++ $nextExpectedMatch = new Carbon($return['next_expected_match']);
++ $return['next_expected_match_diff'] = $nextExpectedMatch->isToday()
++ ? trans('firefly.today')
++ : $nextExpectedMatch->diffForHumans(
++ today(), Carbon::DIFF_RELATIVE_TO_NOW
++ );
++ $currency = $bill->transactionCurrency ?? $defaultCurrency;
++ $return['currency_id'] = $currency->id;
++ $return['currency_name'] = $currency->name;
++ $return['currency_symbol'] = $currency->symbol;
++ $return['currency_code'] = $currency->code;
++ $return['currency_decimal_places'] = $currency->decimal_places;
++ $return['attachments'] = $this->billRepository->getAttachments($bill);
return $return;
}
diff --cc app/Models/TransactionJournal.php
index 637d68e2b0,637d68e2b0..74e548e7c7
--- a/app/Models/TransactionJournal.php
+++ b/app/Models/TransactionJournal.php
@@@ -121,18 -121,18 +121,6 @@@ use Symfony\Component\HttpKernel\Except
* @property-read int|null $transaction_journal_meta_count
* @property-read int|null $transactions_count
* @method static EloquentBuilder|TransactionJournal whereTransactionGroupId($value)
-- * @property int $user_id
-- * @property int|null $transaction_group_id
-- * @property int|null $transaction_currency_id
-- * @property \Illuminate\Support\Carbon|null $interest_date
-- * @property \Illuminate\Support\Carbon|null $book_date
-- * @property \Illuminate\Support\Carbon|null $process_date
-- * @property int $order
-- * @property bool $encrypted
-- * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Budget[] $budgets
-- * @property-read \FireflyIII\Models\TransactionGroup|null $transactionGroup
-- * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\TransactionJournalMeta[] $transactionJournalMeta
-- * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Transaction[] $transactions
*/
class TransactionJournal extends Model
{