mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-19 19:01:58 +00:00
Replace direct calls to Carbon class.
This commit is contained in:
@@ -350,11 +350,11 @@ class BasicController extends Controller
|
||||
{
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
$date = Carbon::now()->startOfDay();
|
||||
$date = today(config('app.timezone'))->startOfDay();
|
||||
// start and end in the future? use $end
|
||||
if ($this->notInDateRange($date, $start, $end)) {
|
||||
/** @var Carbon $date */
|
||||
$date = session('end', Carbon::now()->endOfMonth());
|
||||
$date = session('end', today(config('app.timezone'))->endOfMonth());
|
||||
}
|
||||
|
||||
/** @var NetWorthInterface $netWorthHelper */
|
||||
|
@@ -42,8 +42,8 @@ class ExportRequest extends FormRequest
|
||||
public function getAll(): array
|
||||
{
|
||||
$result = [
|
||||
'start' => $this->getCarbonDate('start') ?? Carbon::now()->subYear(),
|
||||
'end' => $this->getCarbonDate('end') ?? Carbon::now(),
|
||||
'start' => $this->getCarbonDate('start') ?? today(config('app.timezone'))->subYear(),
|
||||
'end' => $this->getCarbonDate('end') ?? today(config('app.timezone')),
|
||||
'type' => $this->convertString('type'),
|
||||
];
|
||||
$parts = explode(',', $this->convertString('accounts'));
|
||||
|
@@ -56,7 +56,7 @@ class CronRequest extends FormRequest
|
||||
{
|
||||
$data = [
|
||||
'force' => false,
|
||||
'date' => Carbon::now(),
|
||||
'date' => today(config('app.timezone')),
|
||||
];
|
||||
if ($this->has('force')) {
|
||||
$data['force'] = $this->boolean('force');
|
||||
|
@@ -191,7 +191,7 @@ class ExportData extends Command
|
||||
*/
|
||||
private function getDateParameter(string $field): Carbon
|
||||
{
|
||||
$date = Carbon::now()->subYear();
|
||||
$date = today(config('app.timezone'))->subYear();
|
||||
$error = false;
|
||||
if (null !== $this->option($field)) {
|
||||
try {
|
||||
@@ -209,7 +209,7 @@ class ExportData extends Command
|
||||
|
||||
if (true === $error && 'start' === $field) {
|
||||
$journal = $this->journalRepository->firstNull();
|
||||
$date = null === $journal ? Carbon::now()->subYear() : $journal->date;
|
||||
$date = null === $journal ? today(config('app.timezone'))->subYear() : $journal->date;
|
||||
$date->startOfDay();
|
||||
}
|
||||
|
||||
|
@@ -282,7 +282,7 @@ class ApplyRules extends Command
|
||||
private function verifyInputDates(): void
|
||||
{
|
||||
// parse start date.
|
||||
$inputStart = Carbon::now()->startOfMonth();
|
||||
$inputStart = today(config('app.timezone'))->startOfMonth();
|
||||
$startString = $this->option('start_date');
|
||||
if (null === $startString) {
|
||||
/** @var JournalRepositoryInterface $repository */
|
||||
@@ -298,7 +298,7 @@ class ApplyRules extends Command
|
||||
}
|
||||
|
||||
// parse end date
|
||||
$inputEnd = Carbon::now();
|
||||
$inputEnd = today(config('app.timezone'));
|
||||
$endString = $this->option('end_date');
|
||||
if (null !== $endString && '' !== $endString) {
|
||||
$inputEnd = Carbon::createFromFormat('Y-m-d', $endString);
|
||||
|
@@ -45,7 +45,7 @@ class PiggyBankEventHandler
|
||||
if (null !== $event->transactionGroup) {
|
||||
$journal = $event->transactionGroup->transactionJournals()->first();
|
||||
}
|
||||
$date = $journal?->date ?? Carbon::now();
|
||||
$date = $journal?->date ?? today(config('app.timezone'));
|
||||
|
||||
// sanity check: event must not already exist for this journal and piggy bank.
|
||||
if (null !== $journal) {
|
||||
|
@@ -123,7 +123,7 @@ class ReportHelper implements ReportHelperInterface
|
||||
$fiscalHelper = app(FiscalHelperInterface::class);
|
||||
$start = clone $date;
|
||||
$start->startOfMonth();
|
||||
$end = Carbon::now();
|
||||
$end = today(config('app.timezone'));
|
||||
$end->endOfMonth();
|
||||
$months = [];
|
||||
|
||||
|
@@ -93,9 +93,9 @@ class IndexController extends Controller
|
||||
$accounts = $collection->slice(($page - 1) * $pageSize, $pageSize);
|
||||
unset($collection);
|
||||
/** @var Carbon $start */
|
||||
$start = clone session('start', Carbon::now()->startOfMonth());
|
||||
$start = clone session('start', today(config('app.timezone'))->startOfMonth());
|
||||
/** @var Carbon $end */
|
||||
$end = clone session('end', Carbon::now()->endOfMonth());
|
||||
$end = clone session('end', today(config('app.timezone'))->endOfMonth());
|
||||
$start->subDay();
|
||||
|
||||
$ids = $accounts->pluck('id')->toArray();
|
||||
@@ -156,9 +156,9 @@ class IndexController extends Controller
|
||||
|
||||
unset($collection);
|
||||
/** @var Carbon $start */
|
||||
$start = clone session('start', Carbon::now()->startOfMonth());
|
||||
$start = clone session('start', today(config('app.timezone'))->startOfMonth());
|
||||
/** @var Carbon $end */
|
||||
$end = clone session('end', Carbon::now()->endOfMonth());
|
||||
$end = clone session('end', today(config('app.timezone'))->endOfMonth());
|
||||
$start->subDay();
|
||||
|
||||
$ids = $accounts->pluck('id')->toArray();
|
||||
|
@@ -100,7 +100,7 @@ class ReconcileController extends Controller
|
||||
$currency = $this->accountRepos->getAccountCurrency($account) ?? app('amount')->getDefaultCurrency();
|
||||
|
||||
// no start or end:
|
||||
$range = app('preferences')->get('viewRange', '1M')->data;
|
||||
$range = app('navigation')->getViewRange(false);
|
||||
|
||||
// get start and end
|
||||
|
||||
|
@@ -182,7 +182,7 @@ class ShowController extends Controller
|
||||
$objectType = config(sprintf('firefly.shortNamesByFullName.%s', $account->accountType->type));
|
||||
$end = today(config('app.timezone'));
|
||||
$today = today(config('app.timezone'));
|
||||
$start = $this->repository->oldestJournalDate($account) ?? Carbon::now()->startOfMonth();
|
||||
$start = $this->repository->oldestJournalDate($account) ?? today(config('app.timezone'))->startOfMonth();
|
||||
$subTitleIcon = config('firefly.subIconsByIdentifier.'.$account->accountType->type);
|
||||
$page = (int)$request->get('page');
|
||||
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||
|
@@ -159,7 +159,7 @@ class ShowController extends Controller
|
||||
public function show(Request $request, Budget $budget)
|
||||
{
|
||||
/** @var Carbon $allStart */
|
||||
$allStart = session('first', Carbon::now()->startOfYear());
|
||||
$allStart = session('first', today(config('app.timezone'))->startOfYear());
|
||||
$allEnd = today();
|
||||
$page = (int)$request->get('page');
|
||||
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||
@@ -221,7 +221,7 @@ class ShowController extends Controller
|
||||
$groups = $collector->getPaginatedGroups();
|
||||
$groups->setPath(route('budgets.show', [$budget->id, $budgetLimit->id]));
|
||||
/** @var Carbon $start */
|
||||
$start = session('first', Carbon::now()->startOfYear());
|
||||
$start = session('first', today(config('app.timezone'))->startOfYear());
|
||||
$end = today(config('app.timezone'));
|
||||
$attachments = $this->repository->getAttachments($budget);
|
||||
$limits = $this->getLimits($budget, $start, $end);
|
||||
|
@@ -88,14 +88,14 @@ class ShowController extends Controller
|
||||
public function show(Request $request, Category $category, Carbon $start = null, Carbon $end = null)
|
||||
{
|
||||
/** @var Carbon $start */
|
||||
$start = $start ?? session('start', Carbon::now()->startOfMonth());
|
||||
$start = $start ?? session('start', today(config('app.timezone'))->startOfMonth());
|
||||
/** @var Carbon $end */
|
||||
$end = $end ?? session('end', Carbon::now()->endOfMonth());
|
||||
$end = $end ?? session('end', today(config('app.timezone'))->endOfMonth());
|
||||
$subTitleIcon = 'fa-bookmark';
|
||||
$page = (int)$request->get('page');
|
||||
$attachments = $this->repository->getAttachments($category);
|
||||
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||
$oldest = $this->repository->firstUseDate($category) ?? Carbon::now()->startOfYear();
|
||||
$oldest = $this->repository->firstUseDate($category) ?? today(config('app.timezone'))->startOfYear();
|
||||
$periods = $this->getCategoryPeriodOverview($category, $oldest, $end);
|
||||
$path = route('categories.show', [$category->id, $start->format('Y-m-d'), $end->format('Y-m-d')]);
|
||||
$subTitle = trans(
|
||||
|
@@ -90,9 +90,9 @@ class AccountController extends Controller
|
||||
public function expenseAccounts(): JsonResponse
|
||||
{
|
||||
/** @var Carbon $start */
|
||||
$start = clone session('start', Carbon::now()->startOfMonth());
|
||||
$start = clone session('start', today(config('app.timezone'))->startOfMonth());
|
||||
/** @var Carbon $end */
|
||||
$end = clone session('end', Carbon::now()->endOfMonth());
|
||||
$end = clone session('end', today(config('app.timezone'))->endOfMonth());
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
@@ -184,8 +184,8 @@ class AccountController extends Controller
|
||||
*/
|
||||
public function expenseBudgetAll(AccountRepositoryInterface $repository, Account $account): JsonResponse
|
||||
{
|
||||
$start = $repository->oldestJournalDate($account) ?? Carbon::now()->startOfMonth();
|
||||
$end = Carbon::now();
|
||||
$start = $repository->oldestJournalDate($account) ?? today(config('app.timezone'))->startOfMonth();
|
||||
$end = today(config('app.timezone'));
|
||||
|
||||
return $this->expenseBudget($account, $start, $end);
|
||||
}
|
||||
@@ -259,8 +259,8 @@ class AccountController extends Controller
|
||||
*/
|
||||
public function expenseCategoryAll(AccountRepositoryInterface $repository, Account $account): JsonResponse
|
||||
{
|
||||
$start = $repository->oldestJournalDate($account) ?? Carbon::now()->startOfMonth();
|
||||
$end = Carbon::now();
|
||||
$start = $repository->oldestJournalDate($account) ?? today(config('app.timezone'))->startOfMonth();
|
||||
$end = today(config('app.timezone'));
|
||||
|
||||
return $this->expenseCategory($account, $start, $end);
|
||||
}
|
||||
@@ -334,8 +334,8 @@ class AccountController extends Controller
|
||||
*/
|
||||
public function frontpage(AccountRepositoryInterface $repository): JsonResponse
|
||||
{
|
||||
$start = clone session('start', Carbon::now()->startOfMonth());
|
||||
$end = clone session('end', Carbon::now()->endOfMonth());
|
||||
$start = clone session('start', today(config('app.timezone'))->startOfMonth());
|
||||
$end = clone session('end', today(config('app.timezone'))->endOfMonth());
|
||||
$defaultSet = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET])->pluck('id')->toArray();
|
||||
Log::debug('Default set is ', $defaultSet);
|
||||
$frontPage = app('preferences')->get('frontPageAccounts', $defaultSet);
|
||||
@@ -360,8 +360,8 @@ class AccountController extends Controller
|
||||
*/
|
||||
public function incomeCategoryAll(AccountRepositoryInterface $repository, Account $account): JsonResponse
|
||||
{
|
||||
$start = $repository->oldestJournalDate($account) ?? Carbon::now()->startOfMonth();
|
||||
$end = Carbon::now();
|
||||
$start = $repository->oldestJournalDate($account) ?? today(config('app.timezone'))->startOfMonth();
|
||||
$end = today(config('app.timezone'));
|
||||
|
||||
return $this->incomeCategory($account, $start, $end);
|
||||
}
|
||||
@@ -540,9 +540,9 @@ class AccountController extends Controller
|
||||
public function revenueAccounts(): JsonResponse
|
||||
{
|
||||
/** @var Carbon $start */
|
||||
$start = clone session('start', Carbon::now()->startOfMonth());
|
||||
$start = clone session('start', today(config('app.timezone'))->startOfMonth());
|
||||
/** @var Carbon $end */
|
||||
$end = clone session('end', Carbon::now()->endOfMonth());
|
||||
$end = clone session('end', today(config('app.timezone'))->endOfMonth());
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
|
@@ -62,8 +62,8 @@ class BillController extends Controller
|
||||
*/
|
||||
public function frontpage(BillRepositoryInterface $repository): JsonResponse
|
||||
{
|
||||
$start = session('start', Carbon::now()->startOfMonth());
|
||||
$end = session('end', Carbon::now()->endOfMonth());
|
||||
$start = session('start', today(config('app.timezone'))->startOfMonth());
|
||||
$end = session('end', today(config('app.timezone'))->endOfMonth());
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
|
@@ -214,7 +214,7 @@ class BudgetController extends Controller
|
||||
$cache->addProperty($budget->id);
|
||||
$cache->addProperty($budgetLimitId);
|
||||
$cache->addProperty('chart.budget.expense-asset');
|
||||
$start = session('first', Carbon::now()->startOfYear());
|
||||
$start = session('first', today(config('app.timezone'))->startOfYear());
|
||||
$end = today();
|
||||
|
||||
if (null !== $budgetLimit) {
|
||||
@@ -282,7 +282,7 @@ class BudgetController extends Controller
|
||||
$cache->addProperty($budget->id);
|
||||
$cache->addProperty($budgetLimitId);
|
||||
$cache->addProperty('chart.budget.expense-category');
|
||||
$start = session('first', Carbon::now()->startOfYear());
|
||||
$start = session('first', today(config('app.timezone'))->startOfYear());
|
||||
$end = today();
|
||||
if (null !== $budgetLimit) {
|
||||
$start = $budgetLimit->start_date;
|
||||
@@ -346,7 +346,7 @@ class BudgetController extends Controller
|
||||
$cache->addProperty($budget->id);
|
||||
$cache->addProperty($budgetLimitId);
|
||||
$cache->addProperty('chart.budget.expense-expense');
|
||||
$start = session('first', Carbon::now()->startOfYear());
|
||||
$start = session('first', today(config('app.timezone'))->startOfYear());
|
||||
$end = today();
|
||||
if (null !== $budgetLimit) {
|
||||
$start = $budgetLimit->start_date;
|
||||
@@ -402,8 +402,8 @@ class BudgetController extends Controller
|
||||
*/
|
||||
public function frontpage(): JsonResponse
|
||||
{
|
||||
$start = session('start', Carbon::now()->startOfMonth());
|
||||
$end = session('end', Carbon::now()->endOfMonth());
|
||||
$start = session('start', today(config('app.timezone'))->startOfMonth());
|
||||
$end = session('end', today(config('app.timezone'))->endOfMonth());
|
||||
|
||||
// chart properties for cache:
|
||||
$cache = new CacheProperties();
|
||||
|
@@ -120,7 +120,7 @@ class DebugController extends Controller
|
||||
public function index(Request $request)
|
||||
{
|
||||
// basic scope information:
|
||||
$now = Carbon::now()->format('Y-m-d H:i:s e');
|
||||
$now = today(config('app.timezone'))->format('Y-m-d H:i:s e');
|
||||
$buildNr = '(unknown)';
|
||||
$buildDate = '(unknown)';
|
||||
$expectedDBversion = config('firefly.db_version');
|
||||
|
@@ -119,9 +119,9 @@ class HomeController extends Controller
|
||||
$transactions = [];
|
||||
$frontPage = app('preferences')->getFresh('frontPageAccounts', $repository->getAccountsByType([AccountType::ASSET])->pluck('id')->toArray());
|
||||
/** @var Carbon $start */
|
||||
$start = session('start', Carbon::now()->startOfMonth());
|
||||
$start = session('start', today(config('app.timezone'))->startOfMonth());
|
||||
/** @var Carbon $end */
|
||||
$end = session('end', Carbon::now()->endOfMonth());
|
||||
$end = session('end', today(config('app.timezone'))->endOfMonth());
|
||||
$accounts = $repository->getAccountsById($frontPage->data);
|
||||
$today = today(config('app.timezone'));
|
||||
|
||||
|
@@ -157,9 +157,9 @@ class JavascriptController extends Controller
|
||||
public function variablesV2(Request $request): Response
|
||||
{
|
||||
/** @var Carbon $start */
|
||||
$start = clone session('start', Carbon::now()->startOfMonth());
|
||||
$start = clone session('start', today(config('app.timezone'))->startOfMonth());
|
||||
/** @var Carbon $end */
|
||||
$end = clone session('end', Carbon::now()->endOfMonth());
|
||||
$end = clone session('end', today(config('app.timezone'))->endOfMonth());
|
||||
|
||||
$data = [
|
||||
'start' => $start->format('Y-m-d'),
|
||||
|
@@ -60,9 +60,9 @@ class BoxController extends Controller
|
||||
/** @var AvailableBudgetRepositoryInterface $abRepository */
|
||||
$abRepository = app(AvailableBudgetRepositoryInterface::class);
|
||||
/** @var Carbon $start */
|
||||
$start = session('start', Carbon::now()->startOfMonth());
|
||||
$start = session('start', today(config('app.timezone'))->startOfMonth());
|
||||
/** @var Carbon $end */
|
||||
$end = session('end', Carbon::now()->endOfMonth());
|
||||
$end = session('end', today(config('app.timezone'))->endOfMonth());
|
||||
$today = today(config('app.timezone'));
|
||||
$display = 2; // see method docs.
|
||||
$boxTitle = (string)trans('firefly.spent');
|
||||
@@ -135,9 +135,9 @@ class BoxController extends Controller
|
||||
{
|
||||
// Cache result, return cache if present.
|
||||
/** @var Carbon $start */
|
||||
$start = session('start', Carbon::now()->startOfMonth());
|
||||
$start = session('start', today(config('app.timezone'))->startOfMonth());
|
||||
/** @var Carbon $end */
|
||||
$end = session('end', Carbon::now()->endOfMonth());
|
||||
$end = session('end', today(config('app.timezone'))->endOfMonth());
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
@@ -216,12 +216,12 @@ class BoxController extends Controller
|
||||
*/
|
||||
public function netWorth(): JsonResponse
|
||||
{
|
||||
$date = Carbon::now()->endOfDay();
|
||||
$date = today(config('app.timezone'))->endOfDay();
|
||||
|
||||
// start and end in the future? use $end
|
||||
if ($this->notInSessionRange($date)) {
|
||||
/** @var Carbon $date */
|
||||
$date = session('end', Carbon::now()->endOfMonth());
|
||||
$date = session('end', today(config('app.timezone'))->endOfMonth());
|
||||
}
|
||||
|
||||
/** @var NetWorthInterface $netWorthHelper */
|
||||
|
@@ -152,7 +152,7 @@ class RecurrenceController extends Controller
|
||||
{
|
||||
$request->validate(['date' => ['required', 'date'],]);
|
||||
$string = $request->get('date') ?? date('Y-m-d');
|
||||
$today = Carbon::now()->startOfDay();
|
||||
$today = today(config('app.timezone'))->startOfDay();
|
||||
$date = Carbon::createFromFormat('Y-m-d', $string)->startOfDay();
|
||||
$preSelected = (string)$request->get('pre_select');
|
||||
$locale = app('steam')->getLocale();
|
||||
|
@@ -87,7 +87,7 @@ class IndexController extends Controller
|
||||
$collection = $this->piggyRepos->getPiggyBanks();
|
||||
$accounts = [];
|
||||
/** @var Carbon $end */
|
||||
$end = session('end', Carbon::now()->endOfMonth());
|
||||
$end = session('end', today(config('app.timezone'))->endOfMonth());
|
||||
|
||||
// transform piggies using the transformer:
|
||||
$parameters = new ParameterBag();
|
||||
|
@@ -71,7 +71,7 @@ class ShowController extends Controller
|
||||
public function show(PiggyBank $piggyBank)
|
||||
{
|
||||
/** @var Carbon $end */
|
||||
$end = session('end', Carbon::now()->endOfMonth());
|
||||
$end = session('end', today(config('app.timezone'))->endOfMonth());
|
||||
// transform piggies using the transformer:
|
||||
$parameters = new ParameterBag();
|
||||
$parameters->set('end', $end);
|
||||
|
@@ -68,7 +68,7 @@ class TriggerController extends Controller
|
||||
/** @var TransactionJournal $journal */
|
||||
foreach ($group->transactionJournals as $journal) {
|
||||
Log::debug(sprintf('Set date of journal #%d to today!', $journal->id));
|
||||
$journal->date = Carbon::today();
|
||||
$journal->date = today(config('app.timezone'));
|
||||
$journal->save();
|
||||
}
|
||||
}
|
||||
|
@@ -118,8 +118,8 @@ class SelectController extends Controller
|
||||
return redirect(route('rules.index'));
|
||||
}
|
||||
// does the user have shared accounts?
|
||||
$first = session('first', Carbon::now()->subYear())->format('Y-m-d');
|
||||
$today = Carbon::now()->format('Y-m-d');
|
||||
$first = session('first', today(config('app.timezone'))->subYear())->format('Y-m-d');
|
||||
$today = today(config('app.timezone'))->format('Y-m-d');
|
||||
$subTitle = (string)trans('firefly.apply_rule_selection', ['title' => $rule->title]);
|
||||
|
||||
return view('rules.rule.select-transactions', compact('first', 'today', 'rule', 'subTitle'));
|
||||
|
@@ -110,7 +110,7 @@ class ExecutionController extends Controller
|
||||
public function selectTransactions(RuleGroup $ruleGroup)
|
||||
{
|
||||
$first = session('first')->format('Y-m-d');
|
||||
$today = Carbon::now()->format('Y-m-d');
|
||||
$today = today(config('app.timezone'))->format('Y-m-d');
|
||||
$subTitle = (string)trans('firefly.apply_rule_group_selection', ['title' => $ruleGroup->title]);
|
||||
|
||||
return view('rules.rule-group.select-transactions', compact('first', 'today', 'ruleGroup', 'subTitle'));
|
||||
|
@@ -194,7 +194,7 @@ class RecurrenceFormRequest extends FormRequest
|
||||
public function rules(): array
|
||||
{
|
||||
$today = today(config('app.timezone'));
|
||||
$tomorrow = Carbon::now()->addDay();
|
||||
$tomorrow = today(config('app.timezone'))->addDay();
|
||||
$rules = [
|
||||
// mandatory info for recurrence.
|
||||
'title' => 'required|between:1,255|uniqueObjectForUser:recurrences,title',
|
||||
|
@@ -47,7 +47,7 @@ class SelectTransactionsRequest extends FormRequest
|
||||
/** @var Carbon $sessionFirst */
|
||||
$sessionFirst = clone session('first');
|
||||
$first = $sessionFirst->subDay()->format('Y-m-d');
|
||||
$today = Carbon::now()->addDay()->format('Y-m-d');
|
||||
$today = today(config('app.timezone'))->addDay()->format('Y-m-d');
|
||||
|
||||
return [
|
||||
'start' => 'required|date|after:'.$first,
|
||||
|
@@ -357,7 +357,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
return $savePerMonth;
|
||||
}
|
||||
if (null !== $piggyBank->targetdate && $repetition->currentamount < $piggyBank->targetamount) {
|
||||
$now = Carbon::now();
|
||||
$now = today(config('app.timezone'));
|
||||
$startDate = null !== $piggyBank->startdate && $piggyBank->startdate->gte($now) ? $piggyBank->startdate : $now;
|
||||
$diffInMonths = $startDate->diffInMonths($piggyBank->targetdate, false);
|
||||
$remainingAmount = bcsub($piggyBank->targetamount, $repetition->currentamount);
|
||||
|
@@ -534,7 +534,7 @@ class RecurringRepository implements RecurringRepositoryInterface
|
||||
}
|
||||
if ('yearly' === $repetition->repetition_type) {
|
||||
//
|
||||
$today = Carbon::now()->endOfYear();
|
||||
$today = today(config('app.timezone'))->endOfYear();
|
||||
$repDate = Carbon::createFromFormat('Y-m-d', $repetition->repetition_moment);
|
||||
$diffInYears = $today->diffInYears($repDate);
|
||||
$repDate->addYears($diffInYears); // technically not necessary.
|
||||
|
@@ -282,7 +282,7 @@ class UserRepository implements UserRepositoryInterface
|
||||
*/
|
||||
public function inviteUser(User $user, string $email): InvitedUser
|
||||
{
|
||||
$now = Carbon::now();
|
||||
$now = today(config('app.timezone'));
|
||||
$now->addDays(2);
|
||||
$invitee = new InvitedUser();
|
||||
$invitee->user()->associate($user);
|
||||
@@ -463,7 +463,7 @@ class UserRepository implements UserRepositoryInterface
|
||||
*/
|
||||
public function validateInviteCode(string $code): bool
|
||||
{
|
||||
$now = Carbon::now();
|
||||
$now = today(config('app.timezone'));
|
||||
$invitee = InvitedUser::where('invite_code', $code)->where('expires', '>', $now->format('Y-m-d H:i:s'))->where('redeemed', 0)->first();
|
||||
return null !== $invitee;
|
||||
}
|
||||
|
@@ -74,7 +74,7 @@ class UpdateRequest implements UpdateRequestInterface
|
||||
// always fall back to current version:
|
||||
$return = [
|
||||
'version' => config('firefly.version'),
|
||||
'date' => Carbon::today()->startOfDay(),
|
||||
'date' => today(config('app.timezone'))->startOfDay(),
|
||||
'level' => 'error',
|
||||
'message' => (string)trans('firefly.unknown_error'),
|
||||
];
|
||||
@@ -171,7 +171,7 @@ class UpdateRequest implements UpdateRequestInterface
|
||||
// a newer version is available!
|
||||
/** @var Carbon $released */
|
||||
$released = $information['date'];
|
||||
$today = Carbon::today()->startOfDay();
|
||||
$today = today(config('app.timezone'))->startOfDay();
|
||||
$diff = $today->diffInDays($released);
|
||||
$expectedDiff = config('firefly.update_minimum_age') ?? 6;
|
||||
// it's still very fresh, and user wants a stable release:
|
||||
|
@@ -65,7 +65,7 @@ class GroupCloneService
|
||||
{
|
||||
$newJournal = $journal->replicate();
|
||||
$newJournal->transaction_group_id = $newGroup->id;
|
||||
$newJournal->date = Carbon::now();
|
||||
$newJournal->date = today(config('app.timezone'));
|
||||
$newJournal->save();
|
||||
|
||||
foreach ($journal->transactions as $transaction) {
|
||||
|
@@ -48,20 +48,20 @@ class Date implements BinderInterface
|
||||
$fiscalHelper = app(FiscalHelperInterface::class);
|
||||
|
||||
$magicWords = [
|
||||
'currentMonthStart' => Carbon::now()->startOfMonth(),
|
||||
'currentMonthEnd' => Carbon::now()->endOfMonth(),
|
||||
'currentYearStart' => Carbon::now()->startOfYear(),
|
||||
'currentYearEnd' => Carbon::now()->endOfYear(),
|
||||
'currentMonthStart' => today(config('app.timezone'))->startOfMonth(),
|
||||
'currentMonthEnd' => today(config('app.timezone'))->endOfMonth(),
|
||||
'currentYearStart' => today(config('app.timezone'))->startOfYear(),
|
||||
'currentYearEnd' => today(config('app.timezone'))->endOfYear(),
|
||||
|
||||
'previousMonthStart' => Carbon::now()->startOfMonth()->subDay()->startOfMonth(),
|
||||
'previousMonthEnd' => Carbon::now()->startOfMonth()->subDay()->endOfMonth(),
|
||||
'previousYearStart' => Carbon::now()->startOfYear()->subDay()->startOfYear(),
|
||||
'previousYearEnd' => Carbon::now()->startOfYear()->subDay()->endOfYear(),
|
||||
'previousMonthStart' => today(config('app.timezone'))->startOfMonth()->subDay()->startOfMonth(),
|
||||
'previousMonthEnd' => today(config('app.timezone'))->startOfMonth()->subDay()->endOfMonth(),
|
||||
'previousYearStart' => today(config('app.timezone'))->startOfYear()->subDay()->startOfYear(),
|
||||
'previousYearEnd' => today(config('app.timezone'))->startOfYear()->subDay()->endOfYear(),
|
||||
|
||||
'currentFiscalYearStart' => $fiscalHelper->startOfFiscalYear(Carbon::now()),
|
||||
'currentFiscalYearEnd' => $fiscalHelper->endOfFiscalYear(Carbon::now()),
|
||||
'previousFiscalYearStart' => $fiscalHelper->startOfFiscalYear(Carbon::now())->subYear(),
|
||||
'previousFiscalYearEnd' => $fiscalHelper->endOfFiscalYear(Carbon::now())->subYear(),
|
||||
'currentFiscalYearStart' => $fiscalHelper->startOfFiscalYear(today(config('app.timezone'))),
|
||||
'currentFiscalYearEnd' => $fiscalHelper->endOfFiscalYear(today(config('app.timezone'))),
|
||||
'previousFiscalYearStart' => $fiscalHelper->startOfFiscalYear(today(config('app.timezone')))->subYear(),
|
||||
'previousFiscalYearEnd' => $fiscalHelper->endOfFiscalYear(today(config('app.timezone')))->subYear(),
|
||||
];
|
||||
if (array_key_exists($value, $magicWords)) {
|
||||
$return = $magicWords[$value];
|
||||
|
@@ -43,7 +43,7 @@ class AutoBudgetCronjob extends AbstractCronjob
|
||||
$config = app('fireflyconfig')->get('last_ab_job', 0);
|
||||
$lastTime = (int)$config->data;
|
||||
$diff = time() - $lastTime;
|
||||
$diffForHumans = Carbon::now()->diffForHumans(Carbon::createFromTimestamp($lastTime), null, true);
|
||||
$diffForHumans = today(config('app.timezone'))->diffForHumans(Carbon::createFromTimestamp($lastTime), null, true);
|
||||
if (0 === $lastTime) {
|
||||
Log::info('Auto budget cron-job has never fired before.');
|
||||
}
|
||||
|
@@ -48,7 +48,7 @@ class BillWarningCronjob extends AbstractCronjob
|
||||
$config = app('fireflyconfig')->get('last_bw_job', 0);
|
||||
$lastTime = (int)$config->data;
|
||||
$diff = time() - $lastTime;
|
||||
$diffForHumans = Carbon::now()->diffForHumans(Carbon::createFromTimestamp($lastTime), null, true);
|
||||
$diffForHumans = today(config('app.timezone'))->diffForHumans(Carbon::createFromTimestamp($lastTime), null, true);
|
||||
|
||||
if (0 === $lastTime) {
|
||||
Log::info('The bill warning cron-job has never fired before.');
|
||||
|
@@ -43,7 +43,7 @@ class ExchangeRatesCronjob extends AbstractCronjob
|
||||
$config = app('fireflyconfig')->get('last_cer_job', 0);
|
||||
$lastTime = (int)$config->data;
|
||||
$diff = time() - $lastTime;
|
||||
$diffForHumans = Carbon::now()->diffForHumans(Carbon::createFromTimestamp($lastTime), null, true);
|
||||
$diffForHumans = today(config('app.timezone'))->diffForHumans(Carbon::createFromTimestamp($lastTime), null, true);
|
||||
if (0 === $lastTime) {
|
||||
Log::info('Exchange rates cron-job has never fired before.');
|
||||
}
|
||||
|
@@ -48,7 +48,7 @@ class RecurringCronjob extends AbstractCronjob
|
||||
$config = app('fireflyconfig')->get('last_rt_job', 0);
|
||||
$lastTime = (int)$config->data;
|
||||
$diff = time() - $lastTime;
|
||||
$diffForHumans = Carbon::now()->diffForHumans(Carbon::createFromTimestamp($lastTime), null, true);
|
||||
$diffForHumans = today(config('app.timezone'))->diffForHumans(Carbon::createFromTimestamp($lastTime), null, true);
|
||||
|
||||
if (0 === $lastTime) {
|
||||
Log::info('Recurring transactions cron-job has never fired before.');
|
||||
|
@@ -158,7 +158,7 @@ trait ConvertsExchangeRates
|
||||
private function convertAmount(string $amount, TransactionCurrency $from, TransactionCurrency $to, ?Carbon $date = null): string
|
||||
{
|
||||
Log::debug(sprintf('Converting %s from %s to %s', $amount, $from->code, $to->code));
|
||||
$date = $date ?? Carbon::now();
|
||||
$date = $date ?? today(config('app.timezone'));
|
||||
$rate = $this->getRate($from, $to, $date);
|
||||
|
||||
return bcmul($amount, $rate);
|
||||
|
@@ -45,7 +45,7 @@ trait DateCalculation
|
||||
public function activeDaysLeft(Carbon $start, Carbon $end): int
|
||||
{
|
||||
$difference = $start->diffInDays($end) + 1;
|
||||
$today = Carbon::now()->startOfDay();
|
||||
$today = today(config('app.timezone'))->startOfDay();
|
||||
|
||||
if ($start->lte($today) && $end->gte($today)) {
|
||||
$difference = $today->diffInDays($end);
|
||||
@@ -67,7 +67,7 @@ trait DateCalculation
|
||||
protected function activeDaysPassed(Carbon $start, Carbon $end): int
|
||||
{
|
||||
$difference = $start->diffInDays($end) + 1;
|
||||
$today = Carbon::now()->startOfDay();
|
||||
$today = today(config('app.timezone'))->startOfDay();
|
||||
|
||||
if ($start->lte($today) && $end->gte($today)) {
|
||||
$difference = $start->diffInDays($today) + 1;
|
||||
|
@@ -140,22 +140,22 @@ trait GetConfigurationData
|
||||
}
|
||||
|
||||
// last seven days:
|
||||
$seven = Carbon::now()->subDays(7);
|
||||
$seven = today(config('app.timezone'))->subDays(7);
|
||||
$index = (string)trans('firefly.last_seven_days');
|
||||
$ranges[$index] = [$seven, new Carbon()];
|
||||
|
||||
// last 30 days:
|
||||
$thirty = Carbon::now()->subDays(30);
|
||||
$thirty = today(config('app.timezone'))->subDays(30);
|
||||
$index = (string)trans('firefly.last_thirty_days');
|
||||
$ranges[$index] = [$thirty, new Carbon()];
|
||||
|
||||
// month to date:
|
||||
$monthBegin = Carbon::now()->startOfMonth();
|
||||
$monthBegin = today(config('app.timezone'))->startOfMonth();
|
||||
$index = (string)trans('firefly.month_to_date');
|
||||
$ranges[$index] = [$monthBegin, new Carbon()];
|
||||
|
||||
// year to date:
|
||||
$yearBegin = Carbon::now()->startOfYear();
|
||||
$yearBegin = today(config('app.timezone'))->startOfYear();
|
||||
$index = (string)trans('firefly.year_to_date');
|
||||
$ranges[$index] = [$yearBegin, new Carbon()];
|
||||
|
||||
|
@@ -145,9 +145,9 @@ trait RequestInformation
|
||||
final protected function notInSessionRange(Carbon $date): bool // Validate a preference
|
||||
{
|
||||
/** @var Carbon $start */
|
||||
$start = session('start', Carbon::now()->startOfMonth());
|
||||
$start = session('start', today(config('app.timezone'))->startOfMonth());
|
||||
/** @var Carbon $end */
|
||||
$end = session('end', Carbon::now()->endOfMonth());
|
||||
$end = session('end', today(config('app.timezone'))->endOfMonth());
|
||||
$result = false;
|
||||
if ($start->greaterThanOrEqualTo($date) && $end->greaterThanOrEqualTo($date)) {
|
||||
$result = true;
|
||||
@@ -175,7 +175,7 @@ trait RequestInformation
|
||||
$attributes['startDate'] = Carbon::createFromFormat('Ymd', $attributes['startDate'])->startOfDay();
|
||||
} catch (InvalidArgumentException $e) {
|
||||
Log::debug(sprintf('Not important error message: %s', $e->getMessage()));
|
||||
$date = Carbon::now()->startOfMonth();
|
||||
$date = today(config('app.timezone'))->startOfMonth();
|
||||
$attributes['startDate'] = $date;
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ trait RequestInformation
|
||||
$attributes['endDate'] = Carbon::createFromFormat('Ymd', $attributes['endDate'])->endOfDay();
|
||||
} catch (InvalidArgumentException $e) {
|
||||
Log::debug(sprintf('Not important error message: %s', $e->getMessage()));
|
||||
$date = Carbon::now()->startOfMonth();
|
||||
$date = today(config('app.timezone'))->startOfMonth();
|
||||
$attributes['endDate'] = $date;
|
||||
}
|
||||
|
||||
|
@@ -255,9 +255,9 @@ class Navigation
|
||||
// and end added to $theCurrentEnd
|
||||
if ('custom' === $repeatFreq) {
|
||||
/** @var Carbon $tStart */
|
||||
$tStart = session('start', Carbon::now()->startOfMonth());
|
||||
$tStart = session('start', today(config('app.timezone'))->startOfMonth());
|
||||
/** @var Carbon $tEnd */
|
||||
$tEnd = session('end', Carbon::now()->endOfMonth());
|
||||
$tEnd = session('end', today(config('app.timezone'))->endOfMonth());
|
||||
$diffInDays = $tStart->diffInDays($tEnd);
|
||||
$currentEnd->addDays($diffInDays);
|
||||
|
||||
@@ -428,6 +428,35 @@ class Navigation
|
||||
return $date->format('Y-m-d');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the user's view range and if necessary, corrects the dynamic view
|
||||
* range to a normal range.
|
||||
* @param bool $correct
|
||||
* @return string
|
||||
*/
|
||||
public function getViewRange(bool $correct): string
|
||||
{
|
||||
$range = (string)app('preferences')->get('viewRange', '1M')?->data ?? '1M';
|
||||
if (!$correct) {
|
||||
return $range;
|
||||
}
|
||||
switch ($range) {
|
||||
default:
|
||||
return $range;
|
||||
case 'last7':
|
||||
return '1W';
|
||||
case 'last30':
|
||||
case 'MTD':
|
||||
return '1M';
|
||||
case 'last90':
|
||||
case 'QTD':
|
||||
return '3M';
|
||||
case 'last365':
|
||||
case 'YTD':
|
||||
return '1Y';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If the date difference between start and end is less than a month, method returns trans(config.month_and_day). If the difference is less than a year,
|
||||
* method returns "config.month". If the date difference is larger, method returns "config.year".
|
||||
@@ -573,9 +602,9 @@ class Navigation
|
||||
// this is then subtracted from $theDate (* $subtract).
|
||||
if ('custom' === $repeatFreq) {
|
||||
/** @var Carbon $tStart */
|
||||
$tStart = session('start', Carbon::now()->startOfMonth());
|
||||
$tStart = session('start', today(config('app.timezone'))->startOfMonth());
|
||||
/** @var Carbon $tEnd */
|
||||
$tEnd = session('end', Carbon::now()->endOfMonth());
|
||||
$tEnd = session('end', today(config('app.timezone'))->endOfMonth());
|
||||
$diffInDays = $tStart->diffInDays($tEnd);
|
||||
$date->subDays($diffInDays * $subtract);
|
||||
|
||||
@@ -621,6 +650,7 @@ class Navigation
|
||||
*/
|
||||
public function updateEndDate(string $range, Carbon $start): Carbon
|
||||
{
|
||||
Log::debug(sprintf('updateEndDate("%s", "%s")', $range, $start->format('Y-m-d')));
|
||||
$functionMap = [
|
||||
'1D' => 'endOfDay',
|
||||
'1W' => 'endOfWeek',
|
||||
@@ -664,6 +694,9 @@ class Navigation
|
||||
'MTD',
|
||||
];
|
||||
if (in_array($range, $list, true)) {
|
||||
$end = Carbon::now(config('app.timezone'));
|
||||
$end->endOfDay();
|
||||
Log::debug(sprintf('updateEndDate returns "%s"', $end->format('Y-m-d')));
|
||||
return $end;
|
||||
}
|
||||
|
||||
@@ -680,6 +713,7 @@ class Navigation
|
||||
*/
|
||||
public function updateStartDate(string $range, Carbon $start): Carbon
|
||||
{
|
||||
Log::debug(sprintf('updateStartDate("%s", "%s")', $range, $start->format('Y-m-d')));
|
||||
$functionMap = [
|
||||
'1D' => 'startOfDay',
|
||||
'1W' => 'startOfWeek',
|
||||
|
@@ -128,7 +128,7 @@ class ParseDateString
|
||||
*/
|
||||
protected function parseKeyword(string $keyword): Carbon
|
||||
{
|
||||
$today = Carbon::today()->startOfDay();
|
||||
$today = today(config('app.timezone'))->startOfDay();
|
||||
|
||||
return match ($keyword) {
|
||||
default => $today,
|
||||
@@ -164,7 +164,7 @@ class ParseDateString
|
||||
{
|
||||
Log::debug(sprintf('Now in parseRelativeDate("%s")', $date));
|
||||
$parts = explode(' ', $date);
|
||||
$today = Carbon::today()->startOfDay();
|
||||
$today = today(config('app.timezone'))->startOfDay();
|
||||
$functions = [
|
||||
[
|
||||
'd' => 'subDays',
|
||||
|
@@ -67,7 +67,7 @@ class General extends AbstractExtension
|
||||
return '0';
|
||||
}
|
||||
/** @var Carbon $date */
|
||||
$date = session('end', Carbon::now()->endOfMonth());
|
||||
$date = session('end', today(config('app.timezone'))->endOfMonth());
|
||||
|
||||
return app('steam')->balance($account, $date);
|
||||
}
|
||||
|
Reference in New Issue
Block a user