From c4039b53e66c3b000694bf324d3ae005ea5ec21d Mon Sep 17 00:00:00 2001
From: James Cole
Date: Mon, 5 Jun 2017 11:12:50 +0200
Subject: [PATCH] Various code cleanup.
---
app/Events/StoredTransactionJournal.php | 4 +-
app/Events/UpdatedTransactionJournal.php | 2 +-
.../Chart/Basic/ChartJsGenerator.php | 2 +-
app/Generator/Report/Support.php | 1 -
.../Events/UpdatedJournalEventHandler.php | 4 +-
app/Handlers/Events/UserEventHandler.php | 2 +
app/Helpers/Attachments/AttachmentHelper.php | 3 +-
app/Helpers/Collector/JournalCollector.php | 2 +-
app/Helpers/Filter/InternalTransferFilter.php | 2 +-
app/Http/Controllers/AccountController.php | 4 +-
.../Controllers/Chart/AccountController.php | 3 +-
.../Controllers/Chart/CategoryController.php | 14 +--
.../Chart/CategoryReportController.php | 1 -
.../Controllers/Chart/ReportController.php | 4 +-
app/Http/Controllers/JavascriptController.php | 8 +-
.../Controllers/Json/ExchangeController.php | 1 -
app/Http/Controllers/JsonController.php | 1 -
app/Http/Controllers/PiggyBankController.php | 15 ++--
.../Report/OperationsController.php | 3 -
.../Transaction/MassController.php | 1 -
.../Transaction/SingleController.php | 11 ++-
.../Transaction/SplitController.php | 10 +--
.../Controllers/TransactionController.php | 9 +-
app/Http/Requests/AccountFormRequest.php | 26 +++---
app/Http/breadcrumbs.php | 8 +-
app/Import/ImportStorage.php | 1 -
app/Import/ImportValidator.php | 2 -
app/Mail/RegisteredUser.php | 8 +-
app/Mail/RequestedNewPassword.php | 12 +--
app/Models/Transaction.php | 30 +++----
app/Models/TransactionJournal.php | 33 +++----
app/Providers/FireflyServiceProvider.php | 2 +-
app/Providers/JournalServiceProvider.php | 40 ++++-----
.../Account/AccountRepositoryInterface.php | 10 +--
.../Journal/JournalRepository.php | 1 -
app/Repositories/Journal/JournalSupport.php | 86 +++++++++----------
app/Repositories/Journal/JournalUpdate.php | 4 +-
.../PiggyBank/PiggyBankRepository.php | 4 +-
app/Support/Amount.php | 2 +-
.../Models/TransactionJournalTrait.php | 79 ++++++++++++++++-
app/Support/Twig/Transaction.php | 1 -
public/js/ff/budgets/show.js | 2 +-
public/js/ff/categories/show.js | 3 -
public/js/ff/charts.js | 1 -
public/js/ff/tags/show.js | 2 +
public/js/ff/transactions/single/common.js | 12 +--
public/js/ff/transactions/single/create.js | 8 +-
public/js/ff/transactions/single/edit.js | 3 +-
resources/views/emails/footer-html.twig | 2 +-
resources/views/emails/footer-text.twig | 2 +-
50 files changed, 274 insertions(+), 217 deletions(-)
diff --git a/app/Events/StoredTransactionJournal.php b/app/Events/StoredTransactionJournal.php
index d1d6805cd2..e67cfbe2cc 100644
--- a/app/Events/StoredTransactionJournal.php
+++ b/app/Events/StoredTransactionJournal.php
@@ -26,9 +26,9 @@ class StoredTransactionJournal extends Event
use SerializesModels;
- /** @var TransactionJournal */
+ /** @var TransactionJournal */
public $journal;
- /** @var int */
+ /** @var int */
public $piggyBankId;
/**
diff --git a/app/Events/UpdatedTransactionJournal.php b/app/Events/UpdatedTransactionJournal.php
index ce21810bc2..2390a13d75 100644
--- a/app/Events/UpdatedTransactionJournal.php
+++ b/app/Events/UpdatedTransactionJournal.php
@@ -26,7 +26,7 @@ class UpdatedTransactionJournal extends Event
use SerializesModels;
- /** @var TransactionJournal */
+ /** @var TransactionJournal */
public $journal;
/**
diff --git a/app/Generator/Chart/Basic/ChartJsGenerator.php b/app/Generator/Chart/Basic/ChartJsGenerator.php
index b63f9e9c01..4649e0722d 100644
--- a/app/Generator/Chart/Basic/ChartJsGenerator.php
+++ b/app/Generator/Chart/Basic/ChartJsGenerator.php
@@ -112,7 +112,7 @@ class ChartJsGenerator implements GeneratorInterface
// sort by value, keep keys.
asort($data);
- $index = 0;
+ $index = 0;
foreach ($data as $key => $value) {
// make larger than 0
diff --git a/app/Generator/Report/Support.php b/app/Generator/Report/Support.php
index 563e72f12b..674b31f7d6 100644
--- a/app/Generator/Report/Support.php
+++ b/app/Generator/Report/Support.php
@@ -15,7 +15,6 @@ namespace FireflyIII\Generator\Report;
use FireflyIII\Models\Transaction;
use Illuminate\Support\Collection;
-use Log;
/**
diff --git a/app/Handlers/Events/UpdatedJournalEventHandler.php b/app/Handlers/Events/UpdatedJournalEventHandler.php
index e4ea75a008..17303c9134 100644
--- a/app/Handlers/Events/UpdatedJournalEventHandler.php
+++ b/app/Handlers/Events/UpdatedJournalEventHandler.php
@@ -23,7 +23,7 @@ use FireflyIII\Support\Events\BillScanner;
/**
* @codeCoverageIgnore
- *
+ *
* Class UpdatedJournalEventHandler
*
* @package FireflyIII\Handlers\Events
@@ -54,7 +54,7 @@ class UpdatedJournalEventHandler
{
// get all the user's rule groups, with the rules, order by 'order'.
$journal = $updatedJournalEvent->journal;
- $groups = $this->repository->getActiveGroups($journal->user);
+ $groups = $this->repository->getActiveGroups($journal->user);
/** @var RuleGroup $group */
foreach ($groups as $group) {
diff --git a/app/Handlers/Events/UserEventHandler.php b/app/Handlers/Events/UserEventHandler.php
index 4b02a2a455..0259c403e5 100644
--- a/app/Handlers/Events/UserEventHandler.php
+++ b/app/Handlers/Events/UserEventHandler.php
@@ -74,6 +74,7 @@ class UserEventHandler
} catch (Swift_TransportException $e) {
Log::error($e->getMessage());
}
+
// @codeCoverageIgnoreEnd
return true;
@@ -106,6 +107,7 @@ class UserEventHandler
} catch (Swift_TransportException $e) {
Log::error($e->getMessage());
}
+
// @codeCoverageIgnoreEnd
return true;
diff --git a/app/Helpers/Attachments/AttachmentHelper.php b/app/Helpers/Attachments/AttachmentHelper.php
index 3189055bb2..58cf4da50e 100644
--- a/app/Helpers/Attachments/AttachmentHelper.php
+++ b/app/Helpers/Attachments/AttachmentHelper.php
@@ -20,7 +20,7 @@ use Illuminate\Support\Collection;
use Illuminate\Support\MessageBag;
use Storage;
use Symfony\Component\HttpFoundation\File\UploadedFile;
-use Log;
+
/**
* Class AttachmentHelper
*
@@ -202,6 +202,7 @@ class AttachmentHelper implements AttachmentHelperInterface
/**
* @codeCoverageIgnore
+ *
* @param UploadedFile $file
*
* @return bool
diff --git a/app/Helpers/Collector/JournalCollector.php b/app/Helpers/Collector/JournalCollector.php
index fb19073685..2fbc389eab 100644
--- a/app/Helpers/Collector/JournalCollector.php
+++ b/app/Helpers/Collector/JournalCollector.php
@@ -499,7 +499,7 @@ class JournalCollector implements JournalCollectorInterface
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
->leftJoin('account_types', 'accounts.account_type_id', 'account_types.id')
->leftJoin('transaction_currencies', 'transaction_currencies.id', 'transactions.transaction_currency_id')
- ->leftJoin('transaction_currencies as foreign_currencies', 'foreign_currencies.id', 'transactions.foreign_currency_id')
+ ->leftJoin('transaction_currencies as foreign_currencies', 'foreign_currencies.id', 'transactions.foreign_currency_id')
->whereNull('transactions.deleted_at')
->whereNull('transaction_journals.deleted_at')
->where('transaction_journals.user_id', $this->user->id)
diff --git a/app/Helpers/Filter/InternalTransferFilter.php b/app/Helpers/Filter/InternalTransferFilter.php
index 7e8d71588e..24b4b9727c 100644
--- a/app/Helpers/Filter/InternalTransferFilter.php
+++ b/app/Helpers/Filter/InternalTransferFilter.php
@@ -26,7 +26,7 @@ use Log;
*/
class InternalTransferFilter implements FilterInterface
{
- /** @var array */
+ /** @var array */
private $accounts = [];
/**
diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php
index 8e248a1628..362b2fd14b 100644
--- a/app/Http/Controllers/AccountController.php
+++ b/app/Http/Controllers/AccountController.php
@@ -293,8 +293,8 @@ class AccountController extends Controller
$periods = $this->getPeriodOverview($account);
}
- $count = 0;
- $loop = 0;
+ $count = 0;
+ $loop = 0;
// grab journals, but be prepared to jump a period back to get the right ones:
Log::info('Now at loop start.');
while ($count === 0 && $loop < 3) {
diff --git a/app/Http/Controllers/Chart/AccountController.php b/app/Http/Controllers/Chart/AccountController.php
index 38bd1f3345..2a48a2876d 100644
--- a/app/Http/Controllers/Chart/AccountController.php
+++ b/app/Http/Controllers/Chart/AccountController.php
@@ -14,7 +14,6 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Chart;
use Carbon\Carbon;
-use Exception;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
@@ -336,7 +335,7 @@ class AccountController extends Controller
/**
* @param Account $account
- * @param Carbon $start
+ * @param Carbon $start
*
* @return \Illuminate\Http\JsonResponse
* @throws FireflyException
diff --git a/app/Http/Controllers/Chart/CategoryController.php b/app/Http/Controllers/Chart/CategoryController.php
index d330a9b363..e4301ee034 100644
--- a/app/Http/Controllers/Chart/CategoryController.php
+++ b/app/Http/Controllers/Chart/CategoryController.php
@@ -277,10 +277,10 @@ class CategoryController extends Controller
*/
public function specificPeriod(CategoryRepositoryInterface $repository, Category $category, Carbon $date)
{
- $range = Preferences::get('viewRange', '1M')->data;
- $start = Navigation::startOfPeriod($date, $range);
- $end = Navigation::endOfPeriod($date, $range);
- $data = $this->makePeriodChart($repository, $category, $start, $end);
+ $range = Preferences::get('viewRange', '1M')->data;
+ $start = Navigation::startOfPeriod($date, $range);
+ $end = Navigation::endOfPeriod($date, $range);
+ $data = $this->makePeriodChart($repository, $category, $start, $end);
return Response::json($data);
}
@@ -336,9 +336,9 @@ class CategoryController extends Controller
$sum = bcadd($spent, $earned);
$label = trim(Navigation::periodShow($start, '1D'));
- $chartData[0]['entries'][$label] = round(bcmul($spent, '-1'),12);
- $chartData[1]['entries'][$label] = round($earned,12);
- $chartData[2]['entries'][$label] = round($sum,12);
+ $chartData[0]['entries'][$label] = round(bcmul($spent, '-1'), 12);
+ $chartData[1]['entries'][$label] = round($earned, 12);
+ $chartData[2]['entries'][$label] = round($sum, 12);
$start->addDay();
diff --git a/app/Http/Controllers/Chart/CategoryReportController.php b/app/Http/Controllers/Chart/CategoryReportController.php
index 572a8a3432..653996cf5d 100644
--- a/app/Http/Controllers/Chart/CategoryReportController.php
+++ b/app/Http/Controllers/Chart/CategoryReportController.php
@@ -16,7 +16,6 @@ namespace FireflyIII\Http\Controllers\Chart;
use Carbon\Carbon;
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
-use FireflyIII\Generator\Report\Category\MonthReportGenerator;
use FireflyIII\Helpers\Chart\MetaPieChartInterface;
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
use FireflyIII\Helpers\Filter\NegativeAmountFilter;
diff --git a/app/Http/Controllers/Chart/ReportController.php b/app/Http/Controllers/Chart/ReportController.php
index 1452192fe3..3310a0b64b 100644
--- a/app/Http/Controllers/Chart/ReportController.php
+++ b/app/Http/Controllers/Chart/ReportController.php
@@ -104,7 +104,7 @@ class ReportController extends Controller
$cache->addProperty($accounts);
$cache->addProperty($end);
if ($cache->has()) {
- //return Response::json($cache->get()); // @codeCoverageIgnore
+ return Response::json($cache->get()); // @codeCoverageIgnore
}
Log::debug('Going to do operations for accounts ', $accounts->pluck('id')->toArray());
$format = Navigation::preferredCarbonLocalizedFormat($start, $end);
@@ -250,7 +250,7 @@ class ReportController extends Controller
$cache->addProperty($accounts);
$cache->addProperty($end);
if ($cache->has()) {
- // return $cache->get(); // @codeCoverageIgnore
+ return $cache->get(); // @codeCoverageIgnore
}
$currentStart = clone $start;
diff --git a/app/Http/Controllers/JavascriptController.php b/app/Http/Controllers/JavascriptController.php
index e5e7fb0651..1ad10422c2 100644
--- a/app/Http/Controllers/JavascriptController.php
+++ b/app/Http/Controllers/JavascriptController.php
@@ -34,7 +34,7 @@ class JavascriptController extends Controller
* @param AccountRepositoryInterface $repository
* @param CurrencyRepositoryInterface $currencyRepository
*
- * @return $this
+ * @return \Illuminate\Http\Response
*/
public function accounts(AccountRepositoryInterface $repository, CurrencyRepositoryInterface $currencyRepository)
{
@@ -63,7 +63,7 @@ class JavascriptController extends Controller
/**
* @param CurrencyRepositoryInterface $repository
*
- * @return $this
+ * @return \Illuminate\Http\Response
*/
public function currencies(CurrencyRepositoryInterface $repository)
{
@@ -71,8 +71,8 @@ class JavascriptController extends Controller
$data = ['currencies' => [],];
/** @var TransactionCurrency $currency */
foreach ($currencies as $currency) {
- $currencyId = $currency->id;
- $entry = ['name' => $currency->name, 'code' => $currency->code, 'symbol' => $currency->symbol];
+ $currencyId = $currency->id;
+ $entry = ['name' => $currency->name, 'code' => $currency->code, 'symbol' => $currency->symbol];
$data['currencies'][$currencyId] = $entry;
}
diff --git a/app/Http/Controllers/Json/ExchangeController.php b/app/Http/Controllers/Json/ExchangeController.php
index e96cae05e8..79f88acf2c 100644
--- a/app/Http/Controllers/Json/ExchangeController.php
+++ b/app/Http/Controllers/Json/ExchangeController.php
@@ -41,7 +41,6 @@ class ExchangeController extends Controller
/** @var CurrencyRepositoryInterface $repository */
$repository = app(CurrencyRepositoryInterface::class);
$rate = $repository->getExchangeRate($fromCurrency, $toCurrency, $date);
- $amount = null;
if (is_null($rate->id)) {
Log::debug(sprintf('No cached exchange rate in database for %s to %s on %s', $fromCurrency->code, $toCurrency->code, $date->format('Y-m-d')));
$preferred = env('EXCHANGE_RATE_SERVICE', config('firefly.preferred_exchange_service'));
diff --git a/app/Http/Controllers/JsonController.php b/app/Http/Controllers/JsonController.php
index 0313f57040..e86536bc7b 100644
--- a/app/Http/Controllers/JsonController.php
+++ b/app/Http/Controllers/JsonController.php
@@ -20,7 +20,6 @@ use FireflyIII\Helpers\Collector\JournalCollectorInterface;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
-use FireflyIII\Repositories\Account\AccountTaskerInterface;
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
diff --git a/app/Http/Controllers/PiggyBankController.php b/app/Http/Controllers/PiggyBankController.php
index 564ee720ae..f4dc60cee9 100644
--- a/app/Http/Controllers/PiggyBankController.php
+++ b/app/Http/Controllers/PiggyBankController.php
@@ -296,8 +296,8 @@ class PiggyBankController extends Controller
Log::error('Cannot add ' . $amount . ' because canAddAmount returned false.');
Session::flash(
'error', strval(
- trans('firefly.cannot_add_amount_piggy', ['amount' => Amount::formatAnything($currency, $amount, false), 'name' => e($piggyBank->name)])
- )
+ trans('firefly.cannot_add_amount_piggy', ['amount' => Amount::formatAnything($currency, $amount, false), 'name' => e($piggyBank->name)])
+ )
);
return redirect(route('piggy-banks.index'));
@@ -312,12 +312,13 @@ class PiggyBankController extends Controller
*/
public function postRemove(Request $request, PiggyBankRepositoryInterface $repository, PiggyBank $piggyBank)
{
- $amount = $request->get('amount');
+ $amount = $request->get('amount');
$currency = Amount::getDefaultCurrency();
if ($repository->canRemoveAmount($piggyBank, $amount)) {
$repository->removeAmount($piggyBank, $amount);
Session::flash(
- 'success', strval(trans('firefly.removed_amount_from_piggy', ['amount' => Amount::formatAnything($currency, $amount, false), 'name' => $piggyBank->name]))
+ 'success',
+ strval(trans('firefly.removed_amount_from_piggy', ['amount' => Amount::formatAnything($currency, $amount, false), 'name' => $piggyBank->name]))
);
Preferences::mark();
@@ -326,7 +327,11 @@ class PiggyBankController extends Controller
$amount = strval(round($request->get('amount'), 12));
- Session::flash('error', strval(trans('firefly.cannot_remove_from_piggy', ['amount' => Amount::formatAnything($currency, $amount, false), 'name' => e($piggyBank->name)])));
+ Session::flash(
+ 'error', strval(
+ trans('firefly.cannot_remove_from_piggy', ['amount' => Amount::formatAnything($currency, $amount, false), 'name' => e($piggyBank->name)])
+ )
+ );
return redirect(route('piggy-banks.index'));
}
diff --git a/app/Http/Controllers/Report/OperationsController.php b/app/Http/Controllers/Report/OperationsController.php
index 5081ba6554..59643b578d 100644
--- a/app/Http/Controllers/Report/OperationsController.php
+++ b/app/Http/Controllers/Report/OperationsController.php
@@ -15,10 +15,7 @@ namespace FireflyIII\Http\Controllers\Report;
use Carbon\Carbon;
-use FireflyIII\Helpers\Collector\JournalCollectorInterface;
use FireflyIII\Http\Controllers\Controller;
-use FireflyIII\Models\Transaction;
-use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Account\AccountTaskerInterface;
use FireflyIII\Support\CacheProperties;
use Illuminate\Support\Collection;
diff --git a/app/Http/Controllers/Transaction/MassController.php b/app/Http/Controllers/Transaction/MassController.php
index 0551bfafe8..61d2a0fa43 100644
--- a/app/Http/Controllers/Transaction/MassController.php
+++ b/app/Http/Controllers/Transaction/MassController.php
@@ -246,7 +246,6 @@ class MassController extends Controller
'currency_id' => $foreignCurrencyId,
'foreign_amount' => $foreignAmount,
'destination_amount' => $foreignAmount,
- //'foreign_currency_id' => $foreignCurrencyId,
'category' => $category,
'tags' => $tags,
];
diff --git a/app/Http/Controllers/Transaction/SingleController.php b/app/Http/Controllers/Transaction/SingleController.php
index bdd4de6a21..67e2c7cb19 100644
--- a/app/Http/Controllers/Transaction/SingleController.php
+++ b/app/Http/Controllers/Transaction/SingleController.php
@@ -273,7 +273,7 @@ class SingleController extends Controller
];
// amounts for withdrawals and deposits:
- // (amount, native_amount, source_amount, destination_amount)
+ // amount, native_amount, source_amount, destination_amount
if (($journal->isWithdrawal() || $journal->isDeposit()) && !is_null($pTransaction->foreign_amount)) {
$preFilled['amount'] = $pTransaction->foreign_amount;
$preFilled['currency'] = $pTransaction->foreignCurrency;
@@ -365,14 +365,13 @@ class SingleController extends Controller
}
/**
- * @param JournalFormRequest $request
- * @param JournalRepositoryInterface $repository
- * @param JournalUpdateInterface $updater
- * @param TransactionJournal $journal
+ * @param JournalFormRequest $request
+ * @param JournalUpdateInterface $updater
+ * @param TransactionJournal $journal
*
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
- public function update(JournalFormRequest $request, JournalRepositoryInterface $repository, JournalUpdateInterface $updater, TransactionJournal $journal)
+ public function update(JournalFormRequest $request, JournalUpdateInterface $updater, TransactionJournal $journal)
{
// @codeCoverageIgnoreStart
if ($this->isOpeningBalance($journal)) {
diff --git a/app/Http/Controllers/Transaction/SplitController.php b/app/Http/Controllers/Transaction/SplitController.php
index 2514574fe1..fa899d6bff 100644
--- a/app/Http/Controllers/Transaction/SplitController.php
+++ b/app/Http/Controllers/Transaction/SplitController.php
@@ -23,7 +23,6 @@ use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
-use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalTaskerInterface;
use FireflyIII\Repositories\Journal\JournalUpdateInterface;
use Illuminate\Http\Request;
@@ -123,14 +122,13 @@ class SplitController extends Controller
/**
- * @param Request $request
- * @param JournalRepositoryInterface $repository
- * @param JournalUpdateInterface $updater
- * @param TransactionJournal $journal
+ * @param Request $request
+ * @param JournalUpdateInterface $updater
+ * @param TransactionJournal $journal
*
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
- public function update(Request $request, JournalRepositoryInterface $repository, JournalUpdateInterface $updater, TransactionJournal $journal)
+ public function update(Request $request, JournalUpdateInterface $updater, TransactionJournal $journal)
{
if ($this->isOpeningBalance($journal)) {
return $this->redirectToAccount($journal);
diff --git a/app/Http/Controllers/TransactionController.php b/app/Http/Controllers/TransactionController.php
index 5f6f12de2e..2ac6a55db8 100644
--- a/app/Http/Controllers/TransactionController.php
+++ b/app/Http/Controllers/TransactionController.php
@@ -18,7 +18,6 @@ use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
use FireflyIII\Helpers\Filter\InternalTransferFilter;
use FireflyIII\Models\TransactionJournal;
-use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalTaskerInterface;
use FireflyIII\Support\CacheProperties;
@@ -179,10 +178,10 @@ class TransactionController extends Controller
return $this->redirectToAccount($journal);
}
- $events = $tasker->getPiggyBankEvents($journal);
- $transactions = $tasker->getTransactionsOverview($journal);
- $what = strtolower($journal->transaction_type_type ?? $journal->transactionType->type);
- $subTitle = trans('firefly.' . $what) . ' "' . e($journal->description) . '"';
+ $events = $tasker->getPiggyBankEvents($journal);
+ $transactions = $tasker->getTransactionsOverview($journal);
+ $what = strtolower($journal->transaction_type_type ?? $journal->transactionType->type);
+ $subTitle = trans('firefly.' . $what) . ' "' . e($journal->description) . '"';
return view('transactions.show', compact('journal', 'events', 'subTitle', 'what', 'transactions'));
diff --git a/app/Http/Requests/AccountFormRequest.php b/app/Http/Requests/AccountFormRequest.php
index 90b8eb760d..bf24b65418 100644
--- a/app/Http/Requests/AccountFormRequest.php
+++ b/app/Http/Requests/AccountFormRequest.php
@@ -38,19 +38,19 @@ class AccountFormRequest extends Request
public function getAccountData(): array
{
return [
- 'name' => $this->string('name'),
- 'active' => $this->boolean('active'),
- 'accountType' => $this->string('what'),
- 'currency_id' => $this->integer('currency_id'),
- 'virtualBalance' => $this->float('virtualBalance'),
- 'iban' => $this->string('iban'),
- 'BIC' => $this->string('BIC'),
- 'accountNumber' => $this->string('accountNumber'),
- 'accountRole' => $this->string('accountRole'),
- 'openingBalance' => $this->float('openingBalance'),
- 'openingBalanceDate' => $this->date('openingBalanceDate'),
- 'ccType' => $this->string('ccType'),
- 'ccMonthlyPaymentDate' => $this->string('ccMonthlyPaymentDate'),
+ 'name' => $this->string('name'),
+ 'active' => $this->boolean('active'),
+ 'accountType' => $this->string('what'),
+ 'currency_id' => $this->integer('currency_id'),
+ 'virtualBalance' => $this->float('virtualBalance'),
+ 'iban' => $this->string('iban'),
+ 'BIC' => $this->string('BIC'),
+ 'accountNumber' => $this->string('accountNumber'),
+ 'accountRole' => $this->string('accountRole'),
+ 'openingBalance' => $this->float('openingBalance'),
+ 'openingBalanceDate' => $this->date('openingBalanceDate'),
+ 'ccType' => $this->string('ccType'),
+ 'ccMonthlyPaymentDate' => $this->string('ccMonthlyPaymentDate'),
];
}
diff --git a/app/Http/breadcrumbs.php b/app/Http/breadcrumbs.php
index 1b98afd9b4..5668c16162 100644
--- a/app/Http/breadcrumbs.php
+++ b/app/Http/breadcrumbs.php
@@ -81,7 +81,7 @@ Breadcrumbs::register(
if ($moment !== 'all') {
$title = trans(
'firefly.between_dates_breadcrumb', ['start' => $start->formatLocalized(strval(trans('config.month_and_day'))),
- 'end' => $end->formatLocalized(strval(trans('config.month_and_day')))]
+ 'end' => $end->formatLocalized(strval(trans('config.month_and_day')))]
);
$breadcrumbs->push($title, route('accounts.show', [$account->id, $moment, $start, $end]));
}
@@ -726,16 +726,16 @@ Breadcrumbs::register(
Breadcrumbs::register(
'tags.show', function (BreadCrumbGenerator $breadcrumbs, Tag $tag, string $moment, Carbon $start, Carbon $end) {
$breadcrumbs->parent('tags.index');
- $breadcrumbs->push(e($tag->tag), route('tags.show', [$tag->id], $moment));
+ $breadcrumbs->push(e($tag->tag), route('tags.show', [$tag->id, $moment]));
if ($moment === 'all') {
- $breadcrumbs->push(trans('firefly.everything'), route('tags.show', [$tag->id], $moment));
+ $breadcrumbs->push(trans('firefly.everything'), route('tags.show', [$tag->id, $moment]));
}
if ($moment !== 'all') {
$title = trans(
'firefly.between_dates_breadcrumb', ['start' => $start->formatLocalized(strval(trans('config.month_and_day'))),
'end' => $end->formatLocalized(strval(trans('config.month_and_day')))]
);
- $breadcrumbs->push($title, route('tags.show', [$tag->id], $moment));
+ $breadcrumbs->push($title, route('tags.show', [$tag->id, $moment]));
}
}
);
diff --git a/app/Import/ImportStorage.php b/app/Import/ImportStorage.php
index 4f39086965..2d5524fcec 100644
--- a/app/Import/ImportStorage.php
+++ b/app/Import/ImportStorage.php
@@ -291,7 +291,6 @@ class ImportStorage
'user_id' => $entry->user->id,
'transaction_type_id' => $entry->fields['transaction-type']->id,
'bill_id' => $billId,
- // TODO update this transaction currency reference.
'transaction_currency_id' => $entry->fields['currency']->id,
'description' => $entry->fields['description'],
'date' => $entry->fields['date-transaction'],
diff --git a/app/Import/ImportValidator.php b/app/Import/ImportValidator.php
index fd9981ec47..3a3a373b2b 100644
--- a/app/Import/ImportValidator.php
+++ b/app/Import/ImportValidator.php
@@ -74,7 +74,6 @@ class ImportValidator
$entry = $this->setOpposingAccount($entry);
$entry = $this->cleanDescription($entry);
$entry = $this->setTransactionType($entry);
- // TODO update this transaction currency reference.
$entry = $this->setTransactionCurrency($entry);
$newCollection->put($index, $entry);
@@ -384,7 +383,6 @@ class ImportValidator
*/
private function setTransactionCurrency(ImportEntry $entry): ImportEntry
{
- // TODO update this transaction currency reference.
if (is_null($entry->fields['currency'])) {
/** @var CurrencyRepositoryInterface $repository */
$repository = app(CurrencyRepositoryInterface::class);
diff --git a/app/Mail/RegisteredUser.php b/app/Mail/RegisteredUser.php
index 924aa883de..a693fb13e1 100644
--- a/app/Mail/RegisteredUser.php
+++ b/app/Mail/RegisteredUser.php
@@ -12,18 +12,18 @@ class RegisteredUser extends Mailable
/** @var string */
public $address;
/** @var string */
- public $ip;
+ public $userIp;
/**
* Create a new message instance.
*
* @param string $address
- * @param string $ip
+ * @param string $userIp
*/
- public function __construct(string $address, string $ip)
+ public function __construct(string $address, string $userIp)
{
$this->address = $address;
- $this->ip = $ip;
+ $this->userIp = $userIp;
}
/**
diff --git a/app/Mail/RequestedNewPassword.php b/app/Mail/RequestedNewPassword.php
index b97a47c50f..cdda5b9858 100644
--- a/app/Mail/RequestedNewPassword.php
+++ b/app/Mail/RequestedNewPassword.php
@@ -10,20 +10,20 @@ class RequestedNewPassword extends Mailable
{
use Queueable, SerializesModels;
/** @var string */
- public $ip;
- /** @var string */
public $url;
+ /** @var string */
+ public $userIp;
/**
* RequestedNewPassword constructor.
*
* @param string $url
- * @param string $ip
+ * @param string $userIp
*/
- public function __construct(string $url, string $ip)
+ public function __construct(string $url, string $userIp)
{
- $this->url = $url;
- $this->ip = $ip;
+ $this->url = $url;
+ $this->userIp = $userIp;
}
/**
diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php
index 0e9ade0b30..c9b139d485 100644
--- a/app/Models/Transaction.php
+++ b/app/Models/Transaction.php
@@ -32,7 +32,7 @@ class Transaction extends Model
* @var array
*/
protected $casts
- = [
+ = [
'created_at' => 'date',
'updated_at' => 'date',
'deleted_at' => 'date',
@@ -40,18 +40,18 @@ class Transaction extends Model
'encrypted' => 'boolean', // model does not have these fields though
'bill_name_encrypted' => 'boolean',
];
- protected $dates = ['created_at', 'updated_at', 'deleted_at'];
- protected $fillable = ['account_id', 'transaction_journal_id', 'description', 'amount', 'identifier', 'transaction_currency_id', 'foreign_currency_id','foreign_amount'];
- protected $hidden = ['encrypted'];
+ protected $dates = ['created_at', 'updated_at', 'deleted_at'];
+ protected $fillable
+ = ['account_id', 'transaction_journal_id', 'description', 'amount', 'identifier', 'transaction_currency_id', 'foreign_currency_id',
+ 'foreign_amount'];
+ protected $hidden = ['encrypted'];
protected $rules
- = [
+ = [
'account_id' => 'required|exists:accounts,id',
'transaction_journal_id' => 'required|exists:transaction_journals,id',
'transaction_currency_id' => 'required|exists:transaction_currencies,id',
- //'foreign_currency_id' => 'exists:transaction_currencies,id',
'description' => 'between:0,1024',
'amount' => 'required|numeric',
- //'foreign_amount' => 'numeric',
];
/**
@@ -101,6 +101,14 @@ class Transaction extends Model
return $this->belongsToMany('FireflyIII\Models\Category');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
+ public function foreignCurrency()
+ {
+ return $this->belongsTo('FireflyIII\Models\TransactionCurrency', 'foreign_currency_id');
+ }
+
/**
* @param $value
*
@@ -171,14 +179,6 @@ class Transaction extends Model
return $this->belongsTo('FireflyIII\Models\TransactionCurrency');
}
- /**
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
- */
- public function foreignCurrency()
- {
- return $this->belongsTo('FireflyIII\Models\TransactionCurrency','foreign_currency_id');
- }
-
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
diff --git a/app/Models/TransactionJournal.php b/app/Models/TransactionJournal.php
index cc0c00ef45..bfb4de8bdc 100644
--- a/app/Models/TransactionJournal.php
+++ b/app/Models/TransactionJournal.php
@@ -19,6 +19,7 @@ use FireflyIII\Support\CacheProperties;
use FireflyIII\Support\Models\TransactionJournalTrait;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Log;
@@ -66,12 +67,12 @@ class TransactionJournal extends Model
/** @var array */
protected $rules
= [
- 'user_id' => 'required|exists:users,id',
- 'transaction_type_id' => 'required|exists:transaction_types,id',
- 'description' => 'required|between:1,1024',
- 'completed' => 'required|boolean',
- 'date' => 'required|date',
- 'encrypted' => 'required|boolean',
+ 'user_id' => 'required|exists:users,id',
+ 'transaction_type_id' => 'required|exists:transaction_types,id',
+ 'description' => 'required|between:1,1024',
+ 'completed' => 'required|boolean',
+ 'date' => 'required|date',
+ 'encrypted' => 'required|boolean',
];
/**
@@ -114,7 +115,7 @@ class TransactionJournal extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
- public function budgets()
+ public function budgets(): BelongsToMany
{
return $this->belongsToMany('FireflyIII\Models\Budget');
}
@@ -122,7 +123,7 @@ class TransactionJournal extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
- public function categories()
+ public function categories(): BelongsToMany
{
return $this->belongsToMany('FireflyIII\Models\Category');
}
@@ -203,7 +204,7 @@ class TransactionJournal extends Model
/**
* @return bool
*/
- public function isDeposit()
+ public function isDeposit(): bool
{
if (!is_null($this->transaction_type_type)) {
return $this->transaction_type_type == TransactionType::DEPOSIT;
@@ -216,7 +217,7 @@ class TransactionJournal extends Model
*
* @return bool
*/
- public function isOpeningBalance()
+ public function isOpeningBalance(): bool
{
if (!is_null($this->transaction_type_type)) {
return $this->transaction_type_type == TransactionType::OPENING_BALANCE;
@@ -229,7 +230,7 @@ class TransactionJournal extends Model
*
* @return bool
*/
- public function isTransfer()
+ public function isTransfer(): bool
{
if (!is_null($this->transaction_type_type)) {
return $this->transaction_type_type == TransactionType::TRANSFER;
@@ -242,7 +243,7 @@ class TransactionJournal extends Model
*
* @return bool
*/
- public function isWithdrawal()
+ public function isWithdrawal(): bool
{
if (!is_null($this->transaction_type_type)) {
return $this->transaction_type_type == TransactionType::WITHDRAWAL;
@@ -254,7 +255,7 @@ class TransactionJournal extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
- public function piggyBankEvents()
+ public function piggyBankEvents(): HasMany
{
return $this->hasMany('FireflyIII\Models\PiggyBankEvent');
}
@@ -266,7 +267,7 @@ class TransactionJournal extends Model
*
* @return bool
*/
- public function save(array $options = [])
+ public function save(array $options = []): bool
{
$count = $this->tags()->count();
$this->tag_count = $count;
@@ -404,9 +405,9 @@ class TransactionJournal extends Model
}
/**
- * @return \Illuminate\Database\Eloquent\Relations\HasMany
+ * @return HasMany
*/
- public function transactions()
+ public function transactions(): HasMany
{
return $this->hasMany('FireflyIII\Models\Transaction');
}
diff --git a/app/Providers/FireflyServiceProvider.php b/app/Providers/FireflyServiceProvider.php
index c9740f4bcf..f9d3ea1976 100644
--- a/app/Providers/FireflyServiceProvider.php
+++ b/app/Providers/FireflyServiceProvider.php
@@ -52,11 +52,11 @@ use FireflyIII\Support\Twig\Rule;
use FireflyIII\Support\Twig\Transaction;
use FireflyIII\Support\Twig\Translation;
use FireflyIII\Validation\FireflyValidator;
+use Illuminate\Foundation\Application;
use Illuminate\Support\ServiceProvider;
use Twig;
use TwigBridge\Extension\Loader\Functions;
use Validator;
-use Illuminate\Foundation\Application;
/**
* Class FireflyServiceProvider
diff --git a/app/Providers/JournalServiceProvider.php b/app/Providers/JournalServiceProvider.php
index 7c65845e93..7fcabbe606 100644
--- a/app/Providers/JournalServiceProvider.php
+++ b/app/Providers/JournalServiceProvider.php
@@ -95,26 +95,6 @@ class JournalServiceProvider extends ServiceProvider
);
}
- /**
- *
- */
- private function registerUpdater()
- {
- $this->app->bind(
- JournalUpdateInterface::class,
- function (Application $app) {
- /** @var JournalUpdateInterface $tasker */
- $update = app(JournalUpdate::class);
-
- if ($app->auth->check()) {
- $update->setUser(auth()->user());
- }
-
- return $update;
- }
- );
- }
-
/**
*
*/
@@ -134,4 +114,24 @@ class JournalServiceProvider extends ServiceProvider
}
);
}
+
+ /**
+ *
+ */
+ private function registerUpdater()
+ {
+ $this->app->bind(
+ JournalUpdateInterface::class,
+ function (Application $app) {
+ /** @var JournalUpdateInterface $tasker */
+ $update = app(JournalUpdate::class);
+
+ if ($app->auth->check()) {
+ $update->setUser(auth()->user());
+ }
+
+ return $update;
+ }
+ );
+ }
}
diff --git a/app/Repositories/Account/AccountRepositoryInterface.php b/app/Repositories/Account/AccountRepositoryInterface.php
index e444fcada0..a9e04b03d6 100644
--- a/app/Repositories/Account/AccountRepositoryInterface.php
+++ b/app/Repositories/Account/AccountRepositoryInterface.php
@@ -36,11 +36,6 @@ interface AccountRepositoryInterface
*/
public function count(array $types): int;
- /**
- * @return Account
- */
- public function getCashAccount(): Account;
-
/**
* Moved here from account CRUD.
*
@@ -103,6 +98,11 @@ interface AccountRepositoryInterface
*/
public function getActiveAccountsByType(array $types): Collection;
+ /**
+ * @return Account
+ */
+ public function getCashAccount(): Account;
+
/**
* Returns the date of the very last transaction in this account.
*
diff --git a/app/Repositories/Journal/JournalRepository.php b/app/Repositories/Journal/JournalRepository.php
index 85746ec174..d8402430a1 100644
--- a/app/Repositories/Journal/JournalRepository.php
+++ b/app/Repositories/Journal/JournalRepository.php
@@ -15,7 +15,6 @@ namespace FireflyIII\Repositories\Journal;
use FireflyIII\Models\Account;
use FireflyIII\Models\Tag;
-use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
diff --git a/app/Repositories/Journal/JournalSupport.php b/app/Repositories/Journal/JournalSupport.php
index cb930ccf18..1c77c44124 100644
--- a/app/Repositories/Journal/JournalSupport.php
+++ b/app/Repositories/Journal/JournalSupport.php
@@ -170,6 +170,49 @@ class JournalSupport
];
}
+ /**
+ * @param array $data
+ *
+ * @return Transaction
+ */
+ public static function storeTransaction(array $data): Transaction
+ {
+ $fields = [
+ 'transaction_journal_id' => $data['journal']->id,
+ 'account_id' => $data['account']->id,
+ 'amount' => $data['amount'],
+ 'foreign_amount' => $data['foreign_amount'],
+ 'transaction_currency_id' => $data['transaction_currency_id'],
+ 'foreign_currency_id' => $data['foreign_currency_id'],
+ 'description' => $data['description'],
+ 'identifier' => $data['identifier'],
+ ];
+
+
+ if (is_null($data['foreign_currency_id'])) {
+ unset($fields['foreign_currency_id']);
+ }
+ if (is_null($data['foreign_amount'])) {
+ unset($fields['foreign_amount']);
+ }
+
+ /** @var Transaction $transaction */
+ $transaction = Transaction::create($fields);
+
+ Log::debug(sprintf('Transaction stored with ID: %s', $transaction->id));
+
+ if (!is_null($data['category'])) {
+ $transaction->categories()->save($data['category']);
+ }
+
+ if (!is_null($data['budget'])) {
+ $transaction->categories()->save($data['budget']);
+ }
+
+ return $transaction;
+
+ }
+
/**
* @param User $user
* @param array $data
@@ -315,47 +358,4 @@ class JournalSupport
return $data;
}
-
- /**
- * @param array $data
- *
- * @return Transaction
- */
- public static function storeTransaction(array $data): Transaction
- {
- $fields = [
- 'transaction_journal_id' => $data['journal']->id,
- 'account_id' => $data['account']->id,
- 'amount' => $data['amount'],
- 'foreign_amount' => $data['foreign_amount'],
- 'transaction_currency_id' => $data['transaction_currency_id'],
- 'foreign_currency_id' => $data['foreign_currency_id'],
- 'description' => $data['description'],
- 'identifier' => $data['identifier'],
- ];
-
-
- if (is_null($data['foreign_currency_id'])) {
- unset($fields['foreign_currency_id']);
- }
- if (is_null($data['foreign_amount'])) {
- unset($fields['foreign_amount']);
- }
-
- /** @var Transaction $transaction */
- $transaction = Transaction::create($fields);
-
- Log::debug(sprintf('Transaction stored with ID: %s', $transaction->id));
-
- if (!is_null($data['category'])) {
- $transaction->categories()->save($data['category']);
- }
-
- if (!is_null($data['budget'])) {
- $transaction->categories()->save($data['budget']);
- }
-
- return $transaction;
-
- }
}
\ No newline at end of file
diff --git a/app/Repositories/Journal/JournalUpdate.php b/app/Repositories/Journal/JournalUpdate.php
index 0be4ac53a5..ff438369a2 100644
--- a/app/Repositories/Journal/JournalUpdate.php
+++ b/app/Repositories/Journal/JournalUpdate.php
@@ -258,8 +258,7 @@ class JournalUpdate implements JournalUpdateInterface
$transaction->transaction_currency_id = $data['currency_id'];
$transaction->foreign_amount = is_null($data['foreign_amount']) ? null : app('steam')->positive($data['foreign_amount']);
$transaction->foreign_currency_id = $data['foreign_currency_id'];
-
- $transaction->account_id = $account->id;
+ $transaction->account_id = $account->id;
$transaction->save();
}
@@ -284,6 +283,7 @@ class JournalUpdate implements JournalUpdateInterface
$transaction->transaction_currency_id = $data['currency_id'];
$transaction->foreign_amount = is_null($data['foreign_amount']) ? null : bcmul(app('steam')->positive($data['foreign_amount']), '-1');
$transaction->foreign_currency_id = $data['foreign_currency_id'];
+ $transaction->account_id = $account->id;
$transaction->save();
}
diff --git a/app/Repositories/PiggyBank/PiggyBankRepository.php b/app/Repositories/PiggyBank/PiggyBankRepository.php
index b5807a51f9..6c05daa897 100644
--- a/app/Repositories/PiggyBank/PiggyBankRepository.php
+++ b/app/Repositories/PiggyBank/PiggyBankRepository.php
@@ -241,11 +241,11 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
public function getPiggyBanksWithAmount(): Collection
{
$currency = Amount::getDefaultCurrency();
- $set = $this->getPiggyBanks();
+ $set = $this->getPiggyBanks();
foreach ($set as $piggy) {
$currentAmount = $piggy->currentRelevantRep()->currentamount ?? '0';
- $piggy->name = $piggy->name . ' (' . Amount::formatAnything($currency, $currentAmount, false) . ')';
+ $piggy->name = $piggy->name . ' (' . Amount::formatAnything($currency, $currentAmount, false) . ')';
}
return $set;
diff --git a/app/Support/Amount.php b/app/Support/Amount.php
index c75630d0ab..d90a1a2de4 100644
--- a/app/Support/Amount.php
+++ b/app/Support/Amount.php
@@ -292,7 +292,7 @@ class Amount
}
if ($transaction->transaction_type_type === TransactionType::TRANSFER) {
- $amount = app('steam')->positive($amount);
+ $amount = app('steam')->positive($amount);
$coloured = false;
$format = '%s';
}
diff --git a/app/Support/Models/TransactionJournalTrait.php b/app/Support/Models/TransactionJournalTrait.php
index 0961fafbb4..847ead3232 100644
--- a/app/Support/Models/TransactionJournalTrait.php
+++ b/app/Support/Models/TransactionJournalTrait.php
@@ -15,16 +15,21 @@ namespace FireflyIII\Support\Models;
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Transaction;
+use FireflyIII\Models\TransactionJournalMeta;
+use FireflyIII\Rules\Triggers\TransactionType;
use FireflyIII\Support\CacheProperties;
use Illuminate\Database\Eloquent\Builder;
+use Illuminate\Database\Eloquent\Relations\BelongsToMany;
+use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Support\Collection;
/**
* Class TransactionJournalTrait
*
- * @property int $id
- * @method Collection transactions()
- * @method bool isWithdrawal()
+ * @property int $id
+ * @property Carbon $date
+ * @property string $transaction_type_type
+ * @property TransactionType $transactionType
*
* @package FireflyIII\Support\Models
*/
@@ -91,6 +96,16 @@ trait TransactionJournalTrait
return 0;
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
+ */
+ abstract public function budgets(): BelongsToMany;
+
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
+ */
+ abstract public function categories(): BelongsToMany;
+
/**
* @return string
*/
@@ -180,6 +195,19 @@ trait TransactionJournalTrait
return $list;
}
+ /**
+ *
+ * @param string $name
+ *
+ * @return string
+ */
+ abstract public function getMeta(string $name);
+
+ /**
+ * @return bool
+ */
+ abstract public function isDeposit(): bool;
+
/**
* @param Builder $query
* @param string $table
@@ -201,6 +229,29 @@ trait TransactionJournalTrait
return false;
}
+ /**
+ *
+ * @return bool
+ */
+ abstract public function isOpeningBalance(): bool;
+
+ /**
+ *
+ * @return bool
+ */
+ abstract public function isTransfer(): bool;
+
+ /**
+ *
+ * @return bool
+ */
+ abstract public function isWithdrawal(): bool;
+
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\HasMany
+ */
+ abstract public function piggyBankEvents(): HasMany;
+
/**
* @return int
*/
@@ -221,6 +272,23 @@ trait TransactionJournalTrait
return $this->transactions()->where('amount', '>', 0)->first();
}
+ /**
+ * Save the model to the database.
+ *
+ * @param array $options
+ *
+ * @return bool
+ */
+ abstract public function save(array $options = []): bool;
+
+ /**
+ * @param string $name
+ * @param $value
+ *
+ * @return TransactionJournalMeta
+ */
+ abstract public function setMeta(string $name, $value): TransactionJournalMeta;
+
/**
* @return Collection
*/
@@ -281,4 +349,9 @@ trait TransactionJournalTrait
return $typeStr;
}
+
+ /**
+ * @return HasMany
+ */
+ abstract public function transactions(): HasMany;
}
diff --git a/app/Support/Twig/Transaction.php b/app/Support/Twig/Transaction.php
index a8d97c97f8..3774940216 100644
--- a/app/Support/Twig/Transaction.php
+++ b/app/Support/Twig/Transaction.php
@@ -13,7 +13,6 @@ declare(strict_types=1);
namespace FireflyIII\Support\Twig;
-use Amount;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\Transaction as TransactionModel;
use FireflyIII\Models\TransactionType;
diff --git a/public/js/ff/budgets/show.js b/public/js/ff/budgets/show.js
index 9d276150df..1852c5b6cd 100644
--- a/public/js/ff/budgets/show.js
+++ b/public/js/ff/budgets/show.js
@@ -8,7 +8,7 @@
* See the LICENSE file for details.
*/
-/** global: budgetChartUri,budgetLimitID */
+/** global: budgetChartUri, expenseCategoryUri, expenseAssetUri, expenseExpenseUri */
$(function () {
"use strict";
diff --git a/public/js/ff/categories/show.js b/public/js/ff/categories/show.js
index 9efadd8828..ed564154d9 100644
--- a/public/js/ff/categories/show.js
+++ b/public/js/ff/categories/show.js
@@ -13,10 +13,7 @@
$(function () {
"use strict";
- console.log('Getting charts');
columnChart(everything, 'category-everything');
-
- console.log('Specific: ' + specific);
columnChart(specific, 'specific-period');
});
\ No newline at end of file
diff --git a/public/js/ff/charts.js b/public/js/ff/charts.js
index fa0c8f049a..5e5bf17ce0 100644
--- a/public/js/ff/charts.js
+++ b/public/js/ff/charts.js
@@ -186,7 +186,6 @@ function doubleYNonStackedChart(URI, container) {
*/
function columnChart(URI, container) {
"use strict";
- console.log('Going to draw column chart for ' + URI + ' in ' + container);
var colorData = true;
var options = $.extend(true, {}, defaultChartOptions);
var chartType = 'bar';
diff --git a/public/js/ff/tags/show.js b/public/js/ff/tags/show.js
index e7142191a9..0cf25a8a26 100644
--- a/public/js/ff/tags/show.js
+++ b/public/js/ff/tags/show.js
@@ -6,6 +6,8 @@
* See the LICENSE file for details.
*/
+/** global: zoomLevel, latitude, longitude, google, doPlaceMarker */
+
/*
Some vars as prep for the map:
*/
diff --git a/public/js/ff/transactions/single/common.js b/public/js/ff/transactions/single/common.js
index 0fd23dd6ac..d164754235 100644
--- a/public/js/ff/transactions/single/common.js
+++ b/public/js/ff/transactions/single/common.js
@@ -6,6 +6,8 @@
* See the LICENSE file for details.
*/
+/** global: Modernizr, accountInfo, currencyInfo, accountInfo, transferInstructions, what */
+
$(document).ready(function () {
"use strict";
setCommonAutocomplete();
@@ -73,7 +75,6 @@ function selectsForeignCurrency() {
var nativeCurrencyId = parseInt(accountInfo[selectedAccountId].preferredCurrency);
if (foreignCurrencyId !== nativeCurrencyId) {
- console.log('User has selected currency #' + foreignCurrencyId + ' and this is different from native currency #' + nativeCurrencyId);
// the input where the native amount is entered gets the symbol for the native currency:
$('.non-selectable-currency-symbol').text(currencyInfo[nativeCurrencyId].symbol);
@@ -90,7 +91,6 @@ function selectsForeignCurrency() {
}
if (foreignCurrencyId === nativeCurrencyId) {
- console.log('User has selected currency #' + foreignCurrencyId + ' and this is equal to native currency #' + nativeCurrencyId + ' (phew).');
$('#exchange_rate_instruction_holder').hide();
$('#native_amount_holder').hide();
}
@@ -110,7 +110,6 @@ function convertForeignToNative() {
var date = $('#ffInput_date').val();
var amount = $('#ffInput_amount').val();
var uri = 'json/rate/' + foreignCurrencyCode + '/' + nativeCurrencyCode + '/' + date + '?amount=' + amount;
- console.log('Will grab ' + uri);
$.get(uri).done(updateNativeAmount);
}
@@ -119,8 +118,6 @@ function convertForeignToNative() {
* @param data
*/
function updateNativeAmount(data) {
- console.log('Returned data:');
- console.log(data);
$('#ffInput_native_amount').val(data.amount);
}
@@ -158,12 +155,10 @@ function validateCurrencyForTransfer() {
$('#source_amount_holder').show().find('.non-selectable-currency-symbol').text(sourceSymbol);
if (sourceCurrency === destinationCurrency) {
- console.log('Both accounts accept #' + sourceCurrency);
$('#destination_amount_holder').hide();
$('#amount_holder').hide();
return;
}
- console.log('Source accepts #' + sourceCurrency + ', destination #' + destinationCurrency);
$('#ffInput_exchange_rate_instruction').text(getTransferExchangeInstructions());
$('#exchange_rate_instruction_holder').show();
$('input[name="source_amount"]').val($('input[name="amount"]').val());
@@ -191,7 +186,6 @@ function convertSourceToDestination() {
var amount = $('#ffInput_source_amount').val();
$('#ffInput_amount').val(amount);
var uri = 'json/rate/' + sourceCurrencyCode + '/' + destinationCurrencyCode + '/' + date + '?amount=' + amount;
- console.log('Will grab ' + uri);
$.get(uri).done(updateDestinationAmount);
}
@@ -200,7 +194,5 @@ function convertSourceToDestination() {
* @param data
*/
function updateDestinationAmount(data) {
- console.log('Returned data:');
- console.log(data);
$('#ffInput_destination_amount').val(data.amount);
}
\ No newline at end of file
diff --git a/public/js/ff/transactions/single/create.js b/public/js/ff/transactions/single/create.js
index f74263d899..c98759b9b9 100644
--- a/public/js/ff/transactions/single/create.js
+++ b/public/js/ff/transactions/single/create.js
@@ -6,7 +6,7 @@
* See the LICENSE file for details.
*/
-/** global: what,Modernizr, title, breadcrumbs, middleCrumbName, button, piggiesLength, txt, middleCrumbUrl,exchangeRateInstructions */
+/** global: currencyInfo, accountInfo, what,Modernizr, title, breadcrumbs, middleCrumbName, button, piggiesLength, txt, middleCrumbUrl,exchangeRateInstructions, convertForeignToNative, convertSourceToDestination, selectsForeignCurrency, accountInfo */
$(document).ready(function () {
"use strict";
@@ -64,8 +64,6 @@ function updateNativeCurrency() {
var newAccountId = getAccountId();
var nativeCurrencyId = accountInfo[newAccountId].preferredCurrency;
- console.log('User selected account #' + newAccountId + '. Native currency is #' + nativeCurrencyId);
-
$('.currency-option[data-id="' + nativeCurrencyId + '"]').click();
$('[data-toggle="dropdown"]').parent().removeClass('open');
if (what !== 'transfer') {
@@ -107,6 +105,7 @@ function updateForm() {
var srcName = $('#ffInput_source_account_name');
switch (what) {
+
case 'withdrawal':
// show source_id and dest_name
document.getElementById('source_account_id_holder').style.display = 'block';
@@ -178,6 +177,8 @@ function updateForm() {
}
document.getElementById('piggy_bank_id_holder').style.display = showPiggies;
break;
+ default:
+ break;
}
updateNativeCurrency();
}
@@ -232,4 +233,5 @@ function getAccountId() {
if (what === "deposit" || what === "transfer") {
return $('select[name="destination_account_id"]').val();
}
+ return undefined;
}
diff --git a/public/js/ff/transactions/single/edit.js b/public/js/ff/transactions/single/edit.js
index d608568c65..05c2132260 100644
--- a/public/js/ff/transactions/single/edit.js
+++ b/public/js/ff/transactions/single/edit.js
@@ -8,7 +8,7 @@
* See the LICENSE file for details.
*/
-/** global: what, Modernizr */
+/** global: what, Modernizr, selectsForeignCurrency, convertForeignToNative, validateCurrencyForTransfer, convertSourceToDestination, journalData, journal, accountInfo, exchangeRateInstructions, currencyInfo */
$(document).ready(function () {
"use strict";
@@ -79,6 +79,7 @@ function getAccountId() {
}
alert('Cannot handle ' + journal.transaction_type.type);
+ return undefined;
}
/**
diff --git a/resources/views/emails/footer-html.twig b/resources/views/emails/footer-html.twig
index 6f4f219380..935128c2aa 100644
--- a/resources/views/emails/footer-html.twig
+++ b/resources/views/emails/footer-html.twig
@@ -6,7 +6,7 @@
- PS: This message was sent because a request from IP {{ ip }} triggered it.
+ PS: This message was sent because a request from IP {{ ip }} {{ userIp }} triggered it.