@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | /** @var Account $account */ |
61 | 61 | foreach ($accounts as $account) { |
62 | 62 | $accountId = $account->id; |
63 | - $currency = (int) $repository->getMetaValue($account, 'currency_id'); |
|
63 | + $currency = (int)$repository->getMetaValue($account, 'currency_id'); |
|
64 | 64 | /** @noinspection NullPointerExceptionInspection */ |
65 | 65 | $currency = 0 === $currency ? $default->id : $currency; |
66 | 66 | $entry = ['preferredCurrency' => $currency, 'name' => $account->name]; |
@@ -106,11 +106,11 @@ discard block |
||
106 | 106 | */ |
107 | 107 | public function variables(Request $request, AccountRepositoryInterface $repository, CurrencyRepositoryInterface $currencyRepository): Response |
108 | 108 | { |
109 | - $account = $repository->findNull((int) $request->get('account')); |
|
109 | + $account = $repository->findNull((int)$request->get('account')); |
|
110 | 110 | $currencyId = 0; |
111 | 111 | if (null !== $account) { |
112 | 112 | // TODO we can use getAccountCurrency() instead |
113 | - $currencyId = (int) $repository->getMetaValue($account, 'currency_id'); |
|
113 | + $currencyId = (int)$repository->getMetaValue($account, 'currency_id'); |
|
114 | 114 | } |
115 | 115 | /** @var TransactionCurrency $currency */ |
116 | 116 | $currency = $currencyRepository->findNull($currencyId); |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | /** @noinspection NullPointerExceptionInspection */ |
127 | 127 | $lang = $pref->data; |
128 | 128 | $dateRange = $this->getDateRangeConfig(); |
129 | - $uid = substr(hash('sha256', sprintf('%s-%s-%s', (string) config('app.key'), auth()->user()->id, auth()->user()->email)), 0, 12); |
|
129 | + $uid = substr(hash('sha256', sprintf('%s-%s-%s', (string)config('app.key'), auth()->user()->id, auth()->user()->email)), 0, 12); |
|
130 | 130 | |
131 | 131 | $data = [ |
132 | 132 | 'currencyCode' => $currency->code, |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | parent::__construct(); |
72 | 72 | |
73 | 73 | $this->middleware( |
74 | - static function ($request, $next) { |
|
75 | - app('view')->share('title', (string) trans('firefly.profile')); |
|
74 | + static function($request, $next) { |
|
75 | + app('view')->share('title', (string)trans('firefly.profile')); |
|
76 | 76 | app('view')->share('mainTitleIcon', 'fa-user'); |
77 | 77 | |
78 | 78 | return $next($request); |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | |
104 | 104 | $title = auth()->user()->email; |
105 | 105 | $email = auth()->user()->email; |
106 | - $subTitle = (string) trans('firefly.change_your_email'); |
|
106 | + $subTitle = (string)trans('firefly.change_your_email'); |
|
107 | 107 | $subTitleIcon = 'fa-envelope'; |
108 | 108 | |
109 | 109 | return view('profile.change-email', compact('title', 'subTitle', 'subTitleIcon', 'email')); |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | } |
129 | 129 | |
130 | 130 | $title = auth()->user()->email; |
131 | - $subTitle = (string) trans('firefly.change_your_password'); |
|
131 | + $subTitle = (string)trans('firefly.change_your_password'); |
|
132 | 132 | $subTitleIcon = 'fa-key'; |
133 | 133 | |
134 | 134 | return view('profile.change-password', compact('title', 'subTitle', 'subTitleIcon')); |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | $repository->unblockUser($user); |
220 | 220 | |
221 | 221 | // return to login. |
222 | - session()->flash('success', (string) trans('firefly.login_with_new_email')); |
|
222 | + session()->flash('success', (string)trans('firefly.login_with_new_email')); |
|
223 | 223 | |
224 | 224 | return redirect(route('login')); |
225 | 225 | } |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | // @codeCoverageIgnoreEnd |
241 | 241 | } |
242 | 242 | $title = auth()->user()->email; |
243 | - $subTitle = (string) trans('firefly.delete_account'); |
|
243 | + $subTitle = (string)trans('firefly.delete_account'); |
|
244 | 244 | $subTitleIcon = 'fa-trash'; |
245 | 245 | |
246 | 246 | return view('profile.delete-account', compact('title', 'subTitle', 'subTitleIcon')); |
@@ -260,8 +260,8 @@ discard block |
||
260 | 260 | $user = auth()->user(); |
261 | 261 | |
262 | 262 | $repository->setMFACode($user, null); |
263 | - session()->flash('success', (string) trans('firefly.pref_two_factor_auth_disabled')); |
|
264 | - session()->flash('info', (string) trans('firefly.pref_two_factor_auth_remove_it')); |
|
263 | + session()->flash('success', (string)trans('firefly.pref_two_factor_auth_disabled')); |
|
264 | + session()->flash('info', (string)trans('firefly.pref_two_factor_auth_remove_it')); |
|
265 | 265 | |
266 | 266 | return redirect(route('profile.index')); |
267 | 267 | } |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | |
285 | 285 | // If FF3 already has a secret, just set the two factor auth enabled to 1, |
286 | 286 | // and let the user continue with the existing secret. |
287 | - session()->flash('info', (string) trans('firefly.2fa_already_enabled')); |
|
287 | + session()->flash('info', (string)trans('firefly.2fa_already_enabled')); |
|
288 | 288 | |
289 | 289 | return redirect(route('profile.index')); |
290 | 290 | } |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | ->setBlocks(2) // Every code must have 7 blocks |
337 | 337 | ->setChars(6) // Each block must have 16 chars |
338 | 338 | ->toArray(); |
339 | - $codes = implode("\r\n", $recoveryCodes); |
|
339 | + $codes = implode("\r\n", $recoveryCodes); |
|
340 | 340 | |
341 | 341 | app('preferences')->set('mfa_recovery', $recoveryCodes); |
342 | 342 | app('preferences')->mark(); |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | $newEmail = $request->string('email'); |
369 | 369 | $oldEmail = $user->email; |
370 | 370 | if ($newEmail === $user->email) { |
371 | - session()->flash('error', (string) trans('firefly.email_not_changed')); |
|
371 | + session()->flash('error', (string)trans('firefly.email_not_changed')); |
|
372 | 372 | |
373 | 373 | return redirect(route('profile.change-email'))->withInput(); |
374 | 374 | } |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | Auth::guard()->logout(); |
379 | 379 | $request->session()->invalidate(); |
380 | 380 | |
381 | - session()->flash('success', (string) trans('firefly.email_changed')); |
|
381 | + session()->flash('success', (string)trans('firefly.email_changed')); |
|
382 | 382 | |
383 | 383 | return redirect(route('index')); |
384 | 384 | } |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | // force user logout. |
394 | 394 | Auth::guard()->logout(); |
395 | 395 | $request->session()->invalidate(); |
396 | - session()->flash('success', (string) trans('firefly.email_changed')); |
|
396 | + session()->flash('success', (string)trans('firefly.email_changed')); |
|
397 | 397 | |
398 | 398 | return redirect(route('index')); |
399 | 399 | } |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | } |
432 | 432 | |
433 | 433 | $repository->changePassword($user, $request->get('new_password')); |
434 | - session()->flash('success', (string) trans('firefly.password_changed')); |
|
434 | + session()->flash('success', (string)trans('firefly.password_changed')); |
|
435 | 435 | |
436 | 436 | return redirect(route('profile.index')); |
437 | 437 | } |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | $secret = session()->get('two-factor-secret'); |
455 | 455 | $repository->setMFACode($user, $secret); |
456 | 456 | |
457 | - session()->flash('success', (string) trans('firefly.saved_preferences')); |
|
457 | + session()->flash('success', (string)trans('firefly.saved_preferences')); |
|
458 | 458 | app('preferences')->mark(); |
459 | 459 | |
460 | 460 | // also save the code so replay attack is prevented. |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | public function postDeleteAccount(UserRepositoryInterface $repository, DeleteAccountFormRequest $request) |
487 | 487 | { |
488 | 488 | if (!Hash::check($request->get('password'), auth()->user()->password)) { |
489 | - session()->flash('error', (string) trans('firefly.invalid_password')); |
|
489 | + session()->flash('error', (string)trans('firefly.invalid_password')); |
|
490 | 490 | |
491 | 491 | return redirect(route('profile.delete-account')); |
492 | 492 | } |
@@ -512,7 +512,7 @@ discard block |
||
512 | 512 | $user = auth()->user(); |
513 | 513 | $token = $user->generateAccessToken(); |
514 | 514 | app('preferences')->set('access_token', $token); |
515 | - session()->flash('success', (string) trans('firefly.token_regenerated')); |
|
515 | + session()->flash('success', (string)trans('firefly.token_regenerated')); |
|
516 | 516 | |
517 | 517 | return redirect(route('profile.index')); |
518 | 518 | } |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | /** @var string $match */ |
556 | 556 | $match = null; |
557 | 557 | foreach ($set as $entry) { |
558 | - $hashed = hash('sha256', sprintf('%s%s', (string) config('app.key'), $entry->data)); |
|
558 | + $hashed = hash('sha256', sprintf('%s%s', (string)config('app.key'), $entry->data)); |
|
559 | 559 | if ($hashed === $hash) { |
560 | 560 | $match = $entry->data; |
561 | 561 | break; |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | $repository->unblockUser($user); |
571 | 571 | |
572 | 572 | // return to login. |
573 | - session()->flash('success', (string) trans('firefly.login_with_old_email')); |
|
573 | + session()->flash('success', (string)trans('firefly.login_with_old_email')); |
|
574 | 574 | |
575 | 575 | return redirect(route('login')); |
576 | 576 | } |
@@ -165,8 +165,8 @@ |
||
165 | 165 | $user = $event->user; |
166 | 166 | $ipAddress = $event->ipAddress; |
167 | 167 | $token = app('preferences')->getForUser($user, 'email_change_undo_token', 'invalid'); |
168 | - $hashed = hash('sha256', sprintf('%s%s', (string) config('app.key'), $oldEmail)); |
|
169 | - $uri = route('profile.undo-email-change', [$token->data,$hashed]); |
|
168 | + $hashed = hash('sha256', sprintf('%s%s', (string)config('app.key'), $oldEmail)); |
|
169 | + $uri = route('profile.undo-email-change', [$token->data, $hashed]); |
|
170 | 170 | try { |
171 | 171 | Mail::to($oldEmail)->send(new UndoEmailChangeMail($newEmail, $oldEmail, $uri, $ipAddress)); |
172 | 172 | // @codeCoverageIgnoreStart |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | public static function routeBinder(string $value): Account |
132 | 132 | { |
133 | 133 | if (auth()->check()) { |
134 | - $accountId = (int) $value; |
|
134 | + $accountId = (int)$value; |
|
135 | 135 | /** @var User $user */ |
136 | 136 | $user = auth()->user(); |
137 | 137 | /** @var Account $account */ |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | public function setVirtualBalanceAttribute($value): void |
254 | 254 | { |
255 | 255 | $value = (string)$value; |
256 | - if('' === $value) { |
|
256 | + if ('' === $value) { |
|
257 | 257 | $value = null; |
258 | 258 | } |
259 | 259 | $this->attributes['virtual_balance'] = $value; |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | $set = [ |
211 | 211 | 'journal' => $journal, |
212 | 212 | 'name' => $field, |
213 | - 'data' => (string) ($data[$field] ?? ''), |
|
213 | + 'data' => (string)($data[$field] ?? ''), |
|
214 | 214 | ]; |
215 | 215 | |
216 | 216 | Log::debug(sprintf('Going to store meta-field "%s", with value "%s".', $set['name'], $set['data'])); |
@@ -257,11 +257,11 @@ discard block |
||
257 | 257 | $type = $this->typeRepository->findTransactionType(null, $row['type']); |
258 | 258 | $carbon = $row['date'] ?? new Carbon; |
259 | 259 | $order = $row['order'] ?? 0; |
260 | - $currency = $this->currencyRepository->findCurrency((int) $row['currency_id'], $row['currency_code']); |
|
260 | + $currency = $this->currencyRepository->findCurrency((int)$row['currency_id'], $row['currency_code']); |
|
261 | 261 | $foreignCurrency = $this->currencyRepository->findCurrencyNull($row['foreign_currency_id'], $row['foreign_currency_code']); |
262 | - $bill = $this->billRepository->findBill((int) $row['bill_id'], $row['bill_name']); |
|
262 | + $bill = $this->billRepository->findBill((int)$row['bill_id'], $row['bill_name']); |
|
263 | 263 | $billId = TransactionType::WITHDRAWAL === $type->type && null !== $bill ? $bill->id : null; |
264 | - $description = app('steam')->cleanString((string) $row['description']); |
|
264 | + $description = app('steam')->cleanString((string)$row['description']); |
|
265 | 265 | |
266 | 266 | /** Manipulate basic fields */ |
267 | 267 | $carbon->setTimezone(config('app.timezone')); |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | |
281 | 281 | /** create or get source and destination accounts */ |
282 | 282 | $sourceInfo = [ |
283 | - 'id' => (int) $row['source_id'], |
|
283 | + 'id' => (int)$row['source_id'], |
|
284 | 284 | 'name' => $row['source_name'], |
285 | 285 | 'iban' => $row['source_iban'], |
286 | 286 | 'number' => $row['source_number'], |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | ]; |
290 | 290 | |
291 | 291 | $destInfo = [ |
292 | - 'id' => (int) $row['destination_id'], |
|
292 | + 'id' => (int)$row['destination_id'], |
|
293 | 293 | 'name' => $row['destination_name'], |
294 | 294 | 'iban' => $row['destination_iban'], |
295 | 295 | 'number' => $row['destination_number'], |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | $transactionFactory->setForeignCurrency($foreignCurrency); |
335 | 335 | $transactionFactory->setReconciled($row['reconciled'] ?? false); |
336 | 336 | try { |
337 | - $negative = $transactionFactory->createNegative((string) $row['amount'], (string) $row['foreign_amount']); |
|
337 | + $negative = $transactionFactory->createNegative((string)$row['amount'], (string)$row['foreign_amount']); |
|
338 | 338 | } catch (FireflyException $e) { |
339 | 339 | Log::error('Exception creating negative transaction.'); |
340 | 340 | Log::error($e->getMessage()); |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | $transactionFactory->setForeignCurrency($foreignCurrency); |
354 | 354 | $transactionFactory->setReconciled($row['reconciled'] ?? false); |
355 | 355 | try { |
356 | - $transactionFactory->createPositive((string) $row['amount'], (string) $row['foreign_amount']); |
|
356 | + $transactionFactory->createPositive((string)$row['amount'], (string)$row['foreign_amount']); |
|
357 | 357 | } catch (FireflyException $e) { |
358 | 358 | Log::error('Exception creating positive transaction.'); |
359 | 359 | Log::error($e->getMessage()); |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | $json = json_encode($dataRow, JSON_THROW_ON_ERROR, 512); |
548 | 548 | if (false === $json) { |
549 | 549 | // @codeCoverageIgnoreStart |
550 | - $json = json_encode((string) microtime(), JSON_THROW_ON_ERROR, 512); |
|
550 | + $json = json_encode((string)microtime(), JSON_THROW_ON_ERROR, 512); |
|
551 | 551 | Log::error(sprintf('Could not hash the original row! %s', json_last_error_msg()), $dataRow); |
552 | 552 | // @codeCoverageIgnoreEnd |
553 | 553 | } |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | return; |
584 | 584 | } |
585 | 585 | |
586 | - $piggyBank = $this->piggyRepository->findPiggyBank((int) $data['piggy_bank_id'], $data['piggy_bank_name']); |
|
586 | + $piggyBank = $this->piggyRepository->findPiggyBank((int)$data['piggy_bank_id'], $data['piggy_bank_name']); |
|
587 | 587 | |
588 | 588 | if (null !== $piggyBank) { |
589 | 589 | $this->piggyEventFactory->create($journal, $piggyBank); |
@@ -606,7 +606,7 @@ discard block |
||
606 | 606 | $this->accountValidator->setTransactionType($transactionType); |
607 | 607 | |
608 | 608 | // validate source account. |
609 | - $sourceId = isset($data['source_id']) ? (int) $data['source_id'] : null; |
|
609 | + $sourceId = isset($data['source_id']) ? (int)$data['source_id'] : null; |
|
610 | 610 | $sourceName = $data['source_name'] ?? null; |
611 | 611 | $validSource = $this->accountValidator->validateSource($sourceId, $sourceName, null); |
612 | 612 | |
@@ -616,7 +616,7 @@ discard block |
||
616 | 616 | } |
617 | 617 | Log::debug('Source seems valid.'); |
618 | 618 | // validate destination account |
619 | - $destinationId = isset($data['destination_id']) ? (int) $data['destination_id'] : null; |
|
619 | + $destinationId = isset($data['destination_id']) ? (int)$data['destination_id'] : null; |
|
620 | 620 | $destinationName = (string)($data['destination_name'] ?? null); |
621 | 621 | $validDestination = $this->accountValidator->validateDestination($destinationId, $destinationName, null); |
622 | 622 | // do something with result: |
@@ -65,18 +65,18 @@ discard block |
||
65 | 65 | } |
66 | 66 | // first part: get all balances in own currency: |
67 | 67 | $transactions = $account->transactions() |
68 | - ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id') |
|
69 | - ->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59')) |
|
70 | - ->where('transactions.transaction_currency_id', $currency->id) |
|
71 | - ->get(['transactions.amount'])->toArray(); |
|
68 | + ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id') |
|
69 | + ->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59')) |
|
70 | + ->where('transactions.transaction_currency_id', $currency->id) |
|
71 | + ->get(['transactions.amount'])->toArray(); |
|
72 | 72 | $nativeBalance = $this->sumTransactions($transactions, 'amount'); |
73 | 73 | // get all balances in foreign currency: |
74 | 74 | $transactions = $account->transactions() |
75 | - ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id') |
|
76 | - ->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59')) |
|
77 | - ->where('transactions.foreign_currency_id', $currency->id) |
|
78 | - ->where('transactions.transaction_currency_id', '!=', $currency->id) |
|
79 | - ->get(['transactions.foreign_amount'])->toArray(); |
|
75 | + ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id') |
|
76 | + ->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59')) |
|
77 | + ->where('transactions.foreign_currency_id', $currency->id) |
|
78 | + ->where('transactions.transaction_currency_id', '!=', $currency->id) |
|
79 | + ->get(['transactions.foreign_amount'])->toArray(); |
|
80 | 80 | $foreignBalance = $this->sumTransactions($transactions, 'foreign_amount'); |
81 | 81 | |
82 | 82 | // check: |
@@ -122,10 +122,10 @@ discard block |
||
122 | 122 | |
123 | 123 | |
124 | 124 | $transactions = $account->transactions() |
125 | - ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id') |
|
126 | - ->where('transaction_journals.date', '<=', $date->format('Y-m-d')) |
|
127 | - ->where('transactions.transaction_currency_id', $currencyId) |
|
128 | - ->get(['transactions.amount'])->toArray(); |
|
125 | + ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id') |
|
126 | + ->where('transaction_journals.date', '<=', $date->format('Y-m-d')) |
|
127 | + ->where('transactions.transaction_currency_id', $currencyId) |
|
128 | + ->get(['transactions.amount'])->toArray(); |
|
129 | 129 | $nativeBalance = $this->sumTransactions($transactions, 'amount'); |
130 | 130 | |
131 | 131 | // get all balances in foreign currency: |
@@ -209,23 +209,23 @@ discard block |
||
209 | 209 | |
210 | 210 | // query! |
211 | 211 | $set = $account->transactions() |
212 | - ->leftJoin('transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id') |
|
213 | - ->where('transaction_journals.date', '>=', $start->format('Y-m-d 00:00:00')) |
|
214 | - ->where('transaction_journals.date', '<=', $end->format('Y-m-d 23:59:59')) |
|
215 | - ->groupBy('transaction_journals.date') |
|
216 | - ->groupBy('transactions.transaction_currency_id') |
|
217 | - ->groupBy('transactions.foreign_currency_id') |
|
218 | - ->orderBy('transaction_journals.date', 'ASC') |
|
219 | - ->whereNull('transaction_journals.deleted_at') |
|
220 | - ->get( |
|
221 | - [ |
|
222 | - 'transaction_journals.date', |
|
223 | - 'transactions.transaction_currency_id', |
|
224 | - DB::raw('SUM(transactions.amount) AS modified'), |
|
225 | - 'transactions.foreign_currency_id', |
|
226 | - DB::raw('SUM(transactions.foreign_amount) AS modified_foreign'), |
|
227 | - ] |
|
228 | - ); |
|
212 | + ->leftJoin('transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id') |
|
213 | + ->where('transaction_journals.date', '>=', $start->format('Y-m-d 00:00:00')) |
|
214 | + ->where('transaction_journals.date', '<=', $end->format('Y-m-d 23:59:59')) |
|
215 | + ->groupBy('transaction_journals.date') |
|
216 | + ->groupBy('transactions.transaction_currency_id') |
|
217 | + ->groupBy('transactions.foreign_currency_id') |
|
218 | + ->orderBy('transaction_journals.date', 'ASC') |
|
219 | + ->whereNull('transaction_journals.deleted_at') |
|
220 | + ->get( |
|
221 | + [ |
|
222 | + 'transaction_journals.date', |
|
223 | + 'transactions.transaction_currency_id', |
|
224 | + DB::raw('SUM(transactions.amount) AS modified'), |
|
225 | + 'transactions.foreign_currency_id', |
|
226 | + DB::raw('SUM(transactions.foreign_amount) AS modified_foreign'), |
|
227 | + ] |
|
228 | + ); |
|
229 | 229 | |
230 | 230 | $currentBalance = $startBalance; |
231 | 231 | /** @var Transaction $entry */ |
@@ -497,9 +497,9 @@ discard block |
||
497 | 497 | $list = []; |
498 | 498 | |
499 | 499 | $set = auth()->user()->transactions() |
500 | - ->whereIn('transactions.account_id', $accounts) |
|
501 | - ->groupBy(['transactions.account_id', 'transaction_journals.user_id']) |
|
502 | - ->get(['transactions.account_id', DB::raw('MAX(transaction_journals.date) AS max_date')]); |
|
500 | + ->whereIn('transactions.account_id', $accounts) |
|
501 | + ->groupBy(['transactions.account_id', 'transaction_journals.user_id']) |
|
502 | + ->get(['transactions.account_id', DB::raw('MAX(transaction_journals.date) AS max_date')]); |
|
503 | 503 | |
504 | 504 | foreach ($set as $entry) { |
505 | 505 | $list[(int)$entry->account_id] = new Carbon($entry->max_date); |
@@ -64,14 +64,14 @@ discard block |
||
64 | 64 | $currency = $repository->getAccountCurrency($account) ?? app('amount')->getDefaultCurrencyByUser($account->user); |
65 | 65 | } |
66 | 66 | // first part: get all balances in own currency: |
67 | - $transactions = $account->transactions() |
|
67 | + $transactions = $account->transactions() |
|
68 | 68 | ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id') |
69 | 69 | ->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59')) |
70 | 70 | ->where('transactions.transaction_currency_id', $currency->id) |
71 | 71 | ->get(['transactions.amount'])->toArray(); |
72 | 72 | $nativeBalance = $this->sumTransactions($transactions, 'amount'); |
73 | 73 | // get all balances in foreign currency: |
74 | - $transactions = $account->transactions() |
|
74 | + $transactions = $account->transactions() |
|
75 | 75 | ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id') |
76 | 76 | ->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59')) |
77 | 77 | ->where('transactions.foreign_currency_id', $currency->id) |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | $currencyId = (int)$repository->getMetaValue($account, 'currency_id'); |
122 | 122 | |
123 | 123 | |
124 | - $transactions = $account->transactions() |
|
124 | + $transactions = $account->transactions() |
|
125 | 125 | ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id') |
126 | 126 | ->where('transaction_journals.date', '<=', $date->format('Y-m-d')) |
127 | 127 | ->where('transactions.transaction_currency_id', $currencyId) |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | if ($cache->has()) { |
274 | 274 | return $cache->get(); // @codeCoverageIgnore |
275 | 275 | } |
276 | - $query = $account->transactions() |
|
276 | + $query = $account->transactions() |
|
277 | 277 | ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id') |
278 | 278 | ->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59')) |
279 | 279 | ->groupBy('transactions.transaction_currency_id'); |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | */ |
368 | 368 | public function cleanString(string $string): string |
369 | 369 | { |
370 | - $search = [ |
|
370 | + $search = [ |
|
371 | 371 | "\u{0001}", // start of heading |
372 | 372 | "\u{0002}", // start of text |
373 | 373 | "\u{0003}", // end of text |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | */ |
431 | 431 | public function nlCleanString(string $string): string |
432 | 432 | { |
433 | - $search = [ |
|
433 | + $search = [ |
|
434 | 434 | "\u{0001}", // start of heading |
435 | 435 | "\u{0002}", // start of text |
436 | 436 | "\u{0003}", // end of text |