Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Better call to date.
James Cole284222c2eea9
diff --git a/app/Api/V1/Controllers/SummaryController.php b/app/Api/V1/Controllers/SummaryController.phpindex fd24fbc9d2..e19ce39edc 100644--- a/app/Api/V1/Controllers/SummaryController.php+++ b/app/Api/V1/Controllers/SummaryController.php@@ -328,7 +328,7 @@ class SummaryController extends Controllerprivate function getLeftToSpendInfo(Carbon $start, Carbon $end): array{$return = [];- $today = new Carbon;+ $today = today(config('app.timezone'));$available = $this->abRepository->getAvailableBudgetWithCurrency($start, $end);$budgets = $this->budgetRepository->getActiveBudgets();$spent = $this->opsRepository->sumExpenses($start, $end, null, $budgets);diff --git a/app/Console/Commands/Export/ExportData.php b/app/Console/Commands/Export/ExportData.phpindex 859a493443..1644ff6214 100644--- a/app/Console/Commands/Export/ExportData.php+++ b/app/Console/Commands/Export/ExportData.php@@ -230,7 +230,7 @@ class ExportData extends Commandreturn $date;}if ('end' === $field) {- $date = new Carbon;+ $date = today(config('app.timezone'));$date->endOfDay();return $date;diff --git a/app/Factory/TransactionJournalFactory.php b/app/Factory/TransactionJournalFactory.phpindex 92f18e7dd0..449d9b8718 100644--- a/app/Factory/TransactionJournalFactory.php+++ b/app/Factory/TransactionJournalFactory.php@@ -258,7 +258,7 @@ class TransactionJournalFactory/** Some basic fields */$type = $this->typeRepository->findTransactionType(null, $row['type']);- $carbon = $row['date'] ?? new Carbon;+ $carbon = $row['date'] ?? today(config('app.timezone'));$order = $row['order'] ?? 0;$currency = $this->currencyRepository->findCurrency((int) $row['currency_id'], $row['currency_code']);$foreignCurrency = $this->currencyRepository->findCurrencyNull($row['foreign_currency_id'], $row['foreign_currency_code']);diff --git a/app/Http/Controllers/Account/ShowController.php b/app/Http/Controllers/Account/ShowController.phpindex 58cc741bf7..d3abe012e3 100644--- a/app/Http/Controllers/Account/ShowController.php+++ b/app/Http/Controllers/Account/ShowController.php@@ -106,7 +106,7 @@ class ShowController extends Controller}$location = $this->repository->getLocation($account);$attachments = $this->repository->getAttachments($account);- $today = new Carbon;+ $today = today(config('app.timezone'));$subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $account->accountType->type));$page = (int) $request->get('page');$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;@@ -173,8 +173,8 @@ class ShowController extends Controller$isLiability = $this->repository->isLiability($account);$attachments = $this->repository->getAttachments($account);$objectType = config(sprintf('firefly.shortNamesByFullName.%s', $account->accountType->type));- $end = new Carbon;- $today = new Carbon;+ $end = today(config('app.timezone'));+ $today = today(config('app.timezone'));$start = $this->repository->oldestJournalDate($account) ?? Carbon::now()->startOfMonth();$subTitleIcon = config('firefly.subIconsByIdentifier.' . $account->accountType->type);$page = (int) $request->get('page');diff --git a/app/Http/Controllers/Admin/TelemetryController.php b/app/Http/Controllers/Admin/TelemetryController.phpindex 4fb36ae8d4..2a18e2c4f5 100644--- a/app/Http/Controllers/Admin/TelemetryController.php+++ b/app/Http/Controllers/Admin/TelemetryController.php@@ -87,7 +87,7 @@ class TelemetryController extends Controllerpublic function submit(){$job = app(SubmitTelemetryData::class);- $job->setDate(new Carbon);+ $job->setDate(today(config('app.timezone')));$job->setForce(true);$job->handle();session()->flash('info', trans('firefly.telemetry_submission_executed'));diff --git a/app/Http/Controllers/Category/NoCategoryController.php b/app/Http/Controllers/Category/NoCategoryController.phpindex 8f7f5904f3..d8af04fb2d 100644--- a/app/Http/Controllers/Category/NoCategoryController.php+++ b/app/Http/Controllers/Category/NoCategoryController.php@@ -126,7 +126,7 @@ class NoCategoryController extends Controller$subTitle = (string) trans('firefly.all_journals_without_category');$first = $this->journalRepos->firstNull();$start = null === $first ? new Carbon : $first->date;- $end = new Carbon;+ $end = today(config('app.timezone'));Log::debug(sprintf('Start for noCategory() is %s', $start->format('Y-m-d')));Log::debug(sprintf('End for noCategory() is %s', $end->format('Y-m-d')));diff --git a/app/Http/Controllers/Category/ShowController.php b/app/Http/Controllers/Category/ShowController.phpindex 8dc1c3b0cd..d26c36a093 100644--- a/app/Http/Controllers/Category/ShowController.php+++ b/app/Http/Controllers/Category/ShowController.php@@ -129,8 +129,8 @@ class ShowController extends Controller$subTitle = (string) trans('firefly.all_journals_for_category', ['name' => $category->name]);$first = $this->repository->firstUseDate($category);/** @var Carbon $start */- $start = $first ?? new Carbon;- $end = new Carbon;+ $start = $first ?? today(config('app.timezone'));+ $end = today(config('app.timezone'));$path = route('categories.show.all', [$category->id]);$attachments = $this->repository->getAttachments($category);diff --git a/app/Http/Controllers/Chart/CategoryController.php b/app/Http/Controllers/Chart/CategoryController.phpindex 4ed3e8abb5..6fa4efcaab 100644--- a/app/Http/Controllers/Chart/CategoryController.php+++ b/app/Http/Controllers/Chart/CategoryController.php@@ -230,7 +230,7 @@ class CategoryController extends Controller{$carbon = null;try {- $carbon = new Carbon;+ $carbon = today(config('app.timezone'));} catch (Exception $e) {$e->getMessage();}diff --git a/app/Http/Controllers/Chart/PiggyBankController.php b/app/Http/Controllers/Chart/PiggyBankController.phpindex 2d3246195a..2d08fa7aa6 100644--- a/app/Http/Controllers/Chart/PiggyBankController.php+++ b/app/Http/Controllers/Chart/PiggyBankController.php@@ -79,7 +79,7 @@ class PiggyBankController extends Controller$locale =app('steam')->getLocale();// get first event or start date of piggy bank or today- $startDate = $piggyBank->start_date ?? new Carbon;+ $startDate = $piggyBank->start_date ?? today(config('app.timezone'));/** @var PiggyBankEvent $first */$firstEvent = $set->first();@@ -87,7 +87,7 @@ class PiggyBankController extends Controller// which ever is older:$oldest = $startDate->lt($firstDate) ? $startDate : $firstDate;- $today = new Carbon;+ $today = today(config('app.timezone'));// depending on diff, do something with range of chart.$step = $this->calculateStep($oldest, $today);diff --git a/app/Http/Controllers/Export/IndexController.php b/app/Http/Controllers/Export/IndexController.phpindex 59a1596ead..09d67a73f0 100644--- a/app/Http/Controllers/Export/IndexController.php+++ b/app/Http/Controllers/Export/IndexController.php@@ -79,7 +79,7 @@ class IndexController extends Controller$generator->setExportTransactions(true);// get first transaction in DB:- $firstDate = new Carbon;+ $firstDate = today(config('app.timezone'));$firstDate->subYear();$journal = $this->journalRepository->firstNull();if (null !== $journal) {diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.phpindex 60661c61c6..5b33937b6e 100644--- a/app/Http/Controllers/HomeController.php+++ b/app/Http/Controllers/HomeController.php@@ -126,7 +126,7 @@ class HomeController extends Controller$end = session('end', Carbon::now()->endOfMonth());/** @noinspection NullPointerExceptionInspection */$accounts = $repository->getAccountsById($frontPage->data);- $today = new Carbon;+ $today = today(config('app.timezone'));/** @var BillRepositoryInterface $billRepository */$billRepository = app(BillRepositoryInterface::class);diff --git a/app/Http/Controllers/Json/BoxController.php b/app/Http/Controllers/Json/BoxController.phpindex 20b45bee97..d9fe2a5359 100644--- a/app/Http/Controllers/Json/BoxController.php+++ b/app/Http/Controllers/Json/BoxController.php@@ -68,7 +68,7 @@ class BoxController extends Controller$start = session('start', Carbon::now()->startOfMonth());/** @var Carbon $end */$end = session('end', Carbon::now()->endOfMonth());- $today = new Carbon;+ $today = today(config('app.timezone'));$display = 2; // see method docs.$boxTitle = (string) trans('firefly.spent');diff --git a/app/Http/Controllers/PiggyBank/AmountController.php b/app/Http/Controllers/PiggyBank/AmountController.phpindex ed335332a2..8b9716152e 100644--- a/app/Http/Controllers/PiggyBank/AmountController.php+++ b/app/Http/Controllers/PiggyBank/AmountController.php@@ -76,7 +76,7 @@ class AmountController extends Controller*/public function add(PiggyBank $piggyBank){- $leftOnAccount = $this->piggyRepos->leftOnAccount($piggyBank, new Carbon);+ $leftOnAccount = $this->piggyRepos->leftOnAccount($piggyBank, today(config('app.timezone')));$savedSoFar = $this->piggyRepos->getCurrentAmount($piggyBank);$leftToSave = bcsub($piggyBank->targetamount, $savedSoFar);$maxAmount = min($leftOnAccount, $leftToSave);@@ -95,7 +95,7 @@ class AmountController extends Controllerpublic function addMobile(PiggyBank $piggyBank){/** @var Carbon $date */- $date = session('end', new Carbon);+ $date = session('end', today(config('app.timezone')));$leftOnAccount = $this->piggyRepos->leftOnAccount($piggyBank, $date);$savedSoFar = $this->piggyRepos->getCurrentAmount($piggyBank);$leftToSave = bcsub($piggyBank->targetamount, $savedSoFar);diff --git a/app/Http/Controllers/PiggyBank/CreateController.php b/app/Http/Controllers/PiggyBank/CreateController.phpindex a6775a70a9..39a37507ec 100644--- a/app/Http/Controllers/PiggyBank/CreateController.php+++ b/app/Http/Controllers/PiggyBank/CreateController.php@@ -96,7 +96,7 @@ class CreateController extends Controller{$data = $request->getPiggyBankData();if (null === $data['startdate']) {- $data['startdate'] = new Carbon;+ $data['startdate'] = today(config('app.timezone'));}$piggyBank = $this->piggyRepos->store($data);diff --git a/app/Http/Controllers/Recurring/CreateController.php b/app/Http/Controllers/Recurring/CreateController.phpindex e91ba1fbc0..f127b5f3f8 100644--- a/app/Http/Controllers/Recurring/CreateController.php+++ b/app/Http/Controllers/Recurring/CreateController.php@@ -85,7 +85,7 @@ class CreateController extends Controller{$budgets = app('expandedform')->makeSelectListWithEmpty($this->budgets->getActiveBudgets());$defaultCurrency = app('amount')->getDefaultCurrency();- $tomorrow = new Carbon;+ $tomorrow = today(config('app.timezone'));$oldRepetitionType = $request->old('repetition_type');$tomorrow->addDay();@@ -179,7 +179,7 @@ class CreateController extends Controller{$budgets = app('expandedform')->makeSelectListWithEmpty($this->budgets->getActiveBudgets());$defaultCurrency = app('amount')->getDefaultCurrency();- $tomorrow = new Carbon;+ $tomorrow = today(config('app.timezone'));$oldRepetitionType = $request->old('repetition_type');$tomorrow->addDay();diff --git a/app/Http/Controllers/Recurring/IndexController.php b/app/Http/Controllers/Recurring/IndexController.phpindex d628c5fd09..677ff9ce9a 100644--- a/app/Http/Controllers/Recurring/IndexController.php+++ b/app/Http/Controllers/Recurring/IndexController.php@@ -85,8 +85,8 @@ class IndexController extends Controller$page = 0 === (int) $request->get('page') ? 1 : (int) $request->get('page');$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;$collection = $this->recurring->get();- $today = new Carbon;- $year = new Carbon;+ $today = today(config('app.timezone'));+ $year = today(config('app.timezone'));// split collection$total = $collection->count();diff --git a/app/Http/Controllers/Recurring/ShowController.php b/app/Http/Controllers/Recurring/ShowController.phpindex 4833c983b1..c2fa2e609e 100644--- a/app/Http/Controllers/Recurring/ShowController.php+++ b/app/Http/Controllers/Recurring/ShowController.php@@ -84,7 +84,7 @@ class ShowController extends Controller$array = $transformer->transform($recurrence);$groups = $this->recurring->getTransactions($recurrence);- $today = new Carbon;+ $today = today(config('app.timezone'));$array['repeat_until'] = null !== $array['repeat_until'] ? new Carbon($array['repeat_until']) : null;// transform dates back to Carbon objects:diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.phpindex eec0c6fdda..44f9f70f8d 100644--- a/app/Http/Controllers/ReportController.php+++ b/app/Http/Controllers/ReportController.php@@ -263,7 +263,7 @@ class ReportController extends Controllerpublic function index(AccountRepositoryInterface $repository){/** @var Carbon $start */- $start = clone session('first', new Carbon);+ $start = clone session('first', today(config('app.timezone')));$months = $this->helper->listOfMonths($start);$customFiscalYear = app('preferences')->get('customFiscalYear', 0)->data;$accounts = $repository->getAccountsByType(diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.phpindex 4637d7e20f..2ff4259eb0 100644--- a/app/Http/Controllers/TagController.php+++ b/app/Http/Controllers/TagController.php@@ -251,7 +251,7 @@ class TagController extends Controller);$startPeriod = $this->repository->firstUseDate($tag);- $startPeriod = $startPeriod ?? new Carbon;+ $startPeriod = $startPeriod ?? today(config('app.timezone'));$endPeriod = clone $end;$periods = $this->getTagPeriodOverview($tag, $startPeriod, $endPeriod);$path = route('tags.show', [$tag->id, $start->format('Y-m-d'), $end->format('Y-m-d')]);@@ -285,8 +285,8 @@ class TagController extends Controller$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;$periods = [];$subTitle = (string) trans('firefly.all_journals_for_tag', ['tag' => $tag->tag]);- $start = $this->repository->firstUseDate($tag) ?? new Carbon;- $end = $this->repository->lastUseDate($tag) ?? new Carbon;+ $start = $this->repository->firstUseDate($tag) ?? today(config('app.timezone'));+ $end = $this->repository->lastUseDate($tag) ?? today(config('app.timezone'));$attachments = $this->repository->getAttachments($tag);$path = route('tags.show', [$tag->id, 'all']);$location = $this->repository->getLocation($tag);diff --git a/app/Http/Controllers/Transaction/IndexController.php b/app/Http/Controllers/Transaction/IndexController.phpindex 22355d5d6d..4f7c1db0a9 100644--- a/app/Http/Controllers/Transaction/IndexController.php+++ b/app/Http/Controllers/Transaction/IndexController.php@@ -144,7 +144,7 @@ class IndexController extends Controller$first = $repository->firstNull();$start = null === $first ? new Carbon : $first->date;$last = $this->repository->getLast();- $end = $last ? $last->date : new Carbon;+ $end = $last ? $last->date : today(config('app.timezone'));$subTitle = (string) trans('firefly.all_' . $objectType);/** @var GroupCollectorInterface $collector */diff --git a/app/Http/Requests/RecurrenceFormRequest.php b/app/Http/Requests/RecurrenceFormRequest.phpindex 180fe2fe86..cd999e9006 100644--- a/app/Http/Requests/RecurrenceFormRequest.php+++ b/app/Http/Requests/RecurrenceFormRequest.php@@ -144,7 +144,7 @@ class RecurrenceFormRequest extends FormRequest*/public function rules(): array{- $today = new Carbon;+ $today = today(config('app.timezone'));$tomorrow = Carbon::now()->addDay();$rules = [// mandatory info for recurrence.diff --git a/app/Http/Requests/ReportFormRequest.php b/app/Http/Requests/ReportFormRequest.phpindex ef13ed9048..bd0cf2cfa4 100644--- a/app/Http/Requests/ReportFormRequest.php+++ b/app/Http/Requests/ReportFormRequest.php@@ -151,7 +151,7 @@ class ReportFormRequest extends FormRequest*/public function getEndDate(): Carbon{- $date = new Carbon;+ $date = today(config('app.timezone'));$range = $this->get('daterange');$parts = explode(' - ', (string) $range);if (2 === count($parts)) {@@ -179,7 +179,7 @@ class ReportFormRequest extends FormRequest*/public function getStartDate(): Carbon{- $date = new Carbon;+ $date = today(config('app.timezone'));$range = $this->get('daterange');$parts = explode(' - ', (string) $range);if (2 === count($parts)) {diff --git a/app/Jobs/SubmitTelemetryData.php b/app/Jobs/SubmitTelemetryData.phpindex 1d06651b42..71ac5fe04c 100644--- a/app/Jobs/SubmitTelemetryData.php+++ b/app/Jobs/SubmitTelemetryData.php@@ -151,7 +151,7 @@ class SubmitTelemetryData implements ShouldQueue{$telemetry->each(static function (Telemetry $entry) {- $entry->submitted = new Carbon;+ $entry->submitted = today(config('app.timezone'));$entry->save();});diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.phpindex ef81a870b5..d6fb4b5ab1 100644--- a/app/Repositories/Budget/BudgetRepository.php+++ b/app/Repositories/Budget/BudgetRepository.php@@ -307,7 +307,7 @@ class BudgetRepository implements BudgetRepositoryInterface$autoBudget->save();// create initial budget limit.- $today = new Carbon;+ $today = today(config('app.timezone'));$start = app('navigation')->startOfPeriod($today, $autoBudget->period);$end = app('navigation')->endOfPeriod($start, $autoBudget->period);diff --git a/app/Repositories/PiggyBank/ModifiesPiggyBanks.php b/app/Repositories/PiggyBank/ModifiesPiggyBanks.phpindex 5914066a91..81de55e795 100644--- a/app/Repositories/PiggyBank/ModifiesPiggyBanks.php+++ b/app/Repositories/PiggyBank/ModifiesPiggyBanks.php@@ -101,7 +101,7 @@ trait ModifiesPiggyBanks*/public function canAddAmount(PiggyBank $piggyBank, string $amount): bool{- $leftOnAccount = $this->leftOnAccount($piggyBank, new Carbon);+ $leftOnAccount = $this->leftOnAccount($piggyBank, today(config('app.timezone')));$savedSoFar = (string) $this->getRepetition($piggyBank)->currentamount;$leftToSave = bcsub($piggyBank->targetamount, $savedSoFar);$maxAmount = (string) min(round($leftOnAccount, 12), round($leftToSave, 12));diff --git a/app/Services/Currency/FixerIOv2.php b/app/Services/Currency/FixerIOv2.phpindex 9d90712f38..05efb698e9 100644--- a/app/Services/Currency/FixerIOv2.php+++ b/app/Services/Currency/FixerIOv2.php@@ -67,8 +67,8 @@ class FixerIOv2 implements ExchangeRateInterface$exchangeRate->toCurrency()->associate($toCurrency);$exchangeRate->date = $date;$exchangeRate->rate = $rate;- $exchangeRate->updated_at = new Carbon;- $exchangeRate->created_at = new Carbon;+ $exchangeRate->updated_at = today(config('app.timezone'));+ $exchangeRate->created_at = today(config('app.timezone'));// get API key$apiKey = config('firefly.fixer_api_key');diff --git a/app/Services/Currency/RatesApiIOv1.php b/app/Services/Currency/RatesApiIOv1.phpindex e3d6c565c4..903e31ec0b 100644--- a/app/Services/Currency/RatesApiIOv1.php+++ b/app/Services/Currency/RatesApiIOv1.php@@ -67,8 +67,8 @@ class RatesApiIOv1 implements ExchangeRateInterface$exchangeRate->toCurrency()->associate($toCurrency);$exchangeRate->date = $date;$exchangeRate->rate = $rate;- $exchangeRate->updated_at = new Carbon;- $exchangeRate->created_at = new Carbon;+ $exchangeRate->updated_at = today(config('app.timezone'));+ $exchangeRate->created_at = today(config('app.timezone'));// build URI$uri = sprintf(diff --git a/app/Support/Cronjobs/AbstractCronjob.php b/app/Support/Cronjobs/AbstractCronjob.phpindex 5dd9c524c1..b5ab855754 100644--- a/app/Support/Cronjobs/AbstractCronjob.php+++ b/app/Support/Cronjobs/AbstractCronjob.php@@ -49,7 +49,7 @@ abstract class AbstractCronjobpublic function __construct(){$this->force = false;- $this->date = new Carbon;+ $this->date = today(config('app.timezone'));}diff --git a/app/Support/Export/ExportDataGenerator.php b/app/Support/Export/ExportDataGenerator.phpindex 31e4d8ce45..5e9e0308e6 100644--- a/app/Support/Export/ExportDataGenerator.php+++ b/app/Support/Export/ExportDataGenerator.php@@ -84,9 +84,9 @@ class ExportDataGeneratorpublic function __construct(){- $this->start = new Carbon;+ $this->start = today(config('app.timezone'));$this->start->subYear();- $this->end = new Carbon;+ $this->end = today(config('app.timezone'));$this->exportTransactions = false;$this->exportAccounts = false;$this->exportBudgets = false;diff --git a/app/Support/Form/FormSupport.php b/app/Support/Form/FormSupport.phpindex 5979411b9d..b0c0784080 100644--- a/app/Support/Form/FormSupport.php+++ b/app/Support/Form/FormSupport.php@@ -54,7 +54,7 @@ trait FormSupport/** @var Carbon $date */$date = null;try {- $date = new Carbon;+ $date = today(config('app.timezone'));} catch (Exception $e) {$e->getMessage();}diff --git a/app/Support/Http/Controllers/GetConfigurationData.php b/app/Support/Http/Controllers/GetConfigurationData.phpindex 84c7af2337..33577c798f 100644--- a/app/Support/Http/Controllers/GetConfigurationData.php+++ b/app/Support/Http/Controllers/GetConfigurationData.php@@ -101,7 +101,7 @@ trait GetConfigurationData$first = session('first');$title = sprintf('%s - %s', $start->formatLocalized($this->monthAndDayFormat), $end->formatLocalized($this->monthAndDayFormat));$isCustom = true === session('is_custom_range', false);- $today = new Carbon;+ $today = today(config('app.timezone'));$ranges = [// first range is the current range:$title => [$start, $end],diff --git a/app/Support/Http/Controllers/PeriodOverview.php b/app/Support/Http/Controllers/PeriodOverview.phpindex 2fd6f2df6d..7d887c2de2 100644--- a/app/Support/Http/Controllers/PeriodOverview.php+++ b/app/Support/Http/Controllers/PeriodOverview.php@@ -288,7 +288,7 @@ trait PeriodOverview$range = app('preferences')->get('viewRange', '1M')->data;$first = $this->journalRepos->firstNull();$start = null === $first ? new Carbon : $first->date;- $end = $theDate ?? new Carbon;+ $end = $theDate ?? today(config('app.timezone'));Log::debug(sprintf('Start for getNoCategoryPeriodOverview() is %s', $start->format('Y-m-d')));Log::debug(sprintf('End for getNoCategoryPeriodOverview() is %s', $end->format('Y-m-d')));diff --git a/app/Support/Twig/TransactionGroupTwig.php b/app/Support/Twig/TransactionGroupTwig.phpindex ebd237d19d..281d6b698b 100644--- a/app/Support/Twig/TransactionGroupTwig.php+++ b/app/Support/Twig/TransactionGroupTwig.php@@ -71,7 +71,7 @@ class TransactionGroupTwig extends AbstractExtension->whereNull('deleted_at')->first();if (null === $entry) {- return new Carbon;+ return today(config('app.timezone'));}return new Carbon(json_decode($entry->data, false));