Various code cleanup.

This commit is contained in:
James Cole 2017-06-05 11:12:50 +02:00
parent 64831b4c86
commit c4039b53e6
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
50 changed files with 274 additions and 217 deletions

View File

@ -26,9 +26,9 @@ class StoredTransactionJournal extends Event
use SerializesModels; use SerializesModels;
/** @var TransactionJournal */ /** @var TransactionJournal */
public $journal; public $journal;
/** @var int */ /** @var int */
public $piggyBankId; public $piggyBankId;
/** /**

View File

@ -26,7 +26,7 @@ class UpdatedTransactionJournal extends Event
use SerializesModels; use SerializesModels;
/** @var TransactionJournal */ /** @var TransactionJournal */
public $journal; public $journal;
/** /**

View File

@ -112,7 +112,7 @@ class ChartJsGenerator implements GeneratorInterface
// sort by value, keep keys. // sort by value, keep keys.
asort($data); asort($data);
$index = 0; $index = 0;
foreach ($data as $key => $value) { foreach ($data as $key => $value) {
// make larger than 0 // make larger than 0

View File

@ -15,7 +15,6 @@ namespace FireflyIII\Generator\Report;
use FireflyIII\Models\Transaction; use FireflyIII\Models\Transaction;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Log;
/** /**

View File

@ -23,7 +23,7 @@ use FireflyIII\Support\Events\BillScanner;
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* *
* Class UpdatedJournalEventHandler * Class UpdatedJournalEventHandler
* *
* @package FireflyIII\Handlers\Events * @package FireflyIII\Handlers\Events
@ -54,7 +54,7 @@ class UpdatedJournalEventHandler
{ {
// get all the user's rule groups, with the rules, order by 'order'. // get all the user's rule groups, with the rules, order by 'order'.
$journal = $updatedJournalEvent->journal; $journal = $updatedJournalEvent->journal;
$groups = $this->repository->getActiveGroups($journal->user); $groups = $this->repository->getActiveGroups($journal->user);
/** @var RuleGroup $group */ /** @var RuleGroup $group */
foreach ($groups as $group) { foreach ($groups as $group) {

View File

@ -74,6 +74,7 @@ class UserEventHandler
} catch (Swift_TransportException $e) { } catch (Swift_TransportException $e) {
Log::error($e->getMessage()); Log::error($e->getMessage());
} }
// @codeCoverageIgnoreEnd // @codeCoverageIgnoreEnd
return true; return true;
@ -106,6 +107,7 @@ class UserEventHandler
} catch (Swift_TransportException $e) { } catch (Swift_TransportException $e) {
Log::error($e->getMessage()); Log::error($e->getMessage());
} }
// @codeCoverageIgnoreEnd // @codeCoverageIgnoreEnd
return true; return true;

View File

@ -20,7 +20,7 @@ use Illuminate\Support\Collection;
use Illuminate\Support\MessageBag; use Illuminate\Support\MessageBag;
use Storage; use Storage;
use Symfony\Component\HttpFoundation\File\UploadedFile; use Symfony\Component\HttpFoundation\File\UploadedFile;
use Log;
/** /**
* Class AttachmentHelper * Class AttachmentHelper
* *
@ -202,6 +202,7 @@ class AttachmentHelper implements AttachmentHelperInterface
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
*
* @param UploadedFile $file * @param UploadedFile $file
* *
* @return bool * @return bool

View File

@ -499,7 +499,7 @@ class JournalCollector implements JournalCollectorInterface
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id') ->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
->leftJoin('account_types', 'accounts.account_type_id', 'account_types.id') ->leftJoin('account_types', 'accounts.account_type_id', 'account_types.id')
->leftJoin('transaction_currencies', 'transaction_currencies.id', 'transactions.transaction_currency_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('transactions.deleted_at')
->whereNull('transaction_journals.deleted_at') ->whereNull('transaction_journals.deleted_at')
->where('transaction_journals.user_id', $this->user->id) ->where('transaction_journals.user_id', $this->user->id)

View File

@ -26,7 +26,7 @@ use Log;
*/ */
class InternalTransferFilter implements FilterInterface class InternalTransferFilter implements FilterInterface
{ {
/** @var array */ /** @var array */
private $accounts = []; private $accounts = [];
/** /**

View File

@ -293,8 +293,8 @@ class AccountController extends Controller
$periods = $this->getPeriodOverview($account); $periods = $this->getPeriodOverview($account);
} }
$count = 0; $count = 0;
$loop = 0; $loop = 0;
// grab journals, but be prepared to jump a period back to get the right ones: // grab journals, but be prepared to jump a period back to get the right ones:
Log::info('Now at loop start.'); Log::info('Now at loop start.');
while ($count === 0 && $loop < 3) { while ($count === 0 && $loop < 3) {

View File

@ -14,7 +14,6 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Chart; namespace FireflyIII\Http\Controllers\Chart;
use Carbon\Carbon; use Carbon\Carbon;
use Exception;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Generator\Chart\Basic\GeneratorInterface; use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
use FireflyIII\Helpers\Collector\JournalCollectorInterface; use FireflyIII\Helpers\Collector\JournalCollectorInterface;
@ -336,7 +335,7 @@ class AccountController extends Controller
/** /**
* @param Account $account * @param Account $account
* @param Carbon $start * @param Carbon $start
* *
* @return \Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
* @throws FireflyException * @throws FireflyException

View File

@ -277,10 +277,10 @@ class CategoryController extends Controller
*/ */
public function specificPeriod(CategoryRepositoryInterface $repository, Category $category, Carbon $date) public function specificPeriod(CategoryRepositoryInterface $repository, Category $category, Carbon $date)
{ {
$range = Preferences::get('viewRange', '1M')->data; $range = Preferences::get('viewRange', '1M')->data;
$start = Navigation::startOfPeriod($date, $range); $start = Navigation::startOfPeriod($date, $range);
$end = Navigation::endOfPeriod($date, $range); $end = Navigation::endOfPeriod($date, $range);
$data = $this->makePeriodChart($repository, $category, $start, $end); $data = $this->makePeriodChart($repository, $category, $start, $end);
return Response::json($data); return Response::json($data);
} }
@ -336,9 +336,9 @@ class CategoryController extends Controller
$sum = bcadd($spent, $earned); $sum = bcadd($spent, $earned);
$label = trim(Navigation::periodShow($start, '1D')); $label = trim(Navigation::periodShow($start, '1D'));
$chartData[0]['entries'][$label] = round(bcmul($spent, '-1'),12); $chartData[0]['entries'][$label] = round(bcmul($spent, '-1'), 12);
$chartData[1]['entries'][$label] = round($earned,12); $chartData[1]['entries'][$label] = round($earned, 12);
$chartData[2]['entries'][$label] = round($sum,12); $chartData[2]['entries'][$label] = round($sum, 12);
$start->addDay(); $start->addDay();

View File

@ -16,7 +16,6 @@ namespace FireflyIII\Http\Controllers\Chart;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Generator\Chart\Basic\GeneratorInterface; use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
use FireflyIII\Generator\Report\Category\MonthReportGenerator;
use FireflyIII\Helpers\Chart\MetaPieChartInterface; use FireflyIII\Helpers\Chart\MetaPieChartInterface;
use FireflyIII\Helpers\Collector\JournalCollectorInterface; use FireflyIII\Helpers\Collector\JournalCollectorInterface;
use FireflyIII\Helpers\Filter\NegativeAmountFilter; use FireflyIII\Helpers\Filter\NegativeAmountFilter;

View File

@ -104,7 +104,7 @@ class ReportController extends Controller
$cache->addProperty($accounts); $cache->addProperty($accounts);
$cache->addProperty($end); $cache->addProperty($end);
if ($cache->has()) { 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()); Log::debug('Going to do operations for accounts ', $accounts->pluck('id')->toArray());
$format = Navigation::preferredCarbonLocalizedFormat($start, $end); $format = Navigation::preferredCarbonLocalizedFormat($start, $end);
@ -250,7 +250,7 @@ class ReportController extends Controller
$cache->addProperty($accounts); $cache->addProperty($accounts);
$cache->addProperty($end); $cache->addProperty($end);
if ($cache->has()) { if ($cache->has()) {
// return $cache->get(); // @codeCoverageIgnore return $cache->get(); // @codeCoverageIgnore
} }
$currentStart = clone $start; $currentStart = clone $start;

View File

@ -34,7 +34,7 @@ class JavascriptController extends Controller
* @param AccountRepositoryInterface $repository * @param AccountRepositoryInterface $repository
* @param CurrencyRepositoryInterface $currencyRepository * @param CurrencyRepositoryInterface $currencyRepository
* *
* @return $this * @return \Illuminate\Http\Response
*/ */
public function accounts(AccountRepositoryInterface $repository, CurrencyRepositoryInterface $currencyRepository) public function accounts(AccountRepositoryInterface $repository, CurrencyRepositoryInterface $currencyRepository)
{ {
@ -63,7 +63,7 @@ class JavascriptController extends Controller
/** /**
* @param CurrencyRepositoryInterface $repository * @param CurrencyRepositoryInterface $repository
* *
* @return $this * @return \Illuminate\Http\Response
*/ */
public function currencies(CurrencyRepositoryInterface $repository) public function currencies(CurrencyRepositoryInterface $repository)
{ {
@ -71,8 +71,8 @@ class JavascriptController extends Controller
$data = ['currencies' => [],]; $data = ['currencies' => [],];
/** @var TransactionCurrency $currency */ /** @var TransactionCurrency $currency */
foreach ($currencies as $currency) { foreach ($currencies as $currency) {
$currencyId = $currency->id; $currencyId = $currency->id;
$entry = ['name' => $currency->name, 'code' => $currency->code, 'symbol' => $currency->symbol]; $entry = ['name' => $currency->name, 'code' => $currency->code, 'symbol' => $currency->symbol];
$data['currencies'][$currencyId] = $entry; $data['currencies'][$currencyId] = $entry;
} }

View File

@ -41,7 +41,6 @@ class ExchangeController extends Controller
/** @var CurrencyRepositoryInterface $repository */ /** @var CurrencyRepositoryInterface $repository */
$repository = app(CurrencyRepositoryInterface::class); $repository = app(CurrencyRepositoryInterface::class);
$rate = $repository->getExchangeRate($fromCurrency, $toCurrency, $date); $rate = $repository->getExchangeRate($fromCurrency, $toCurrency, $date);
$amount = null;
if (is_null($rate->id)) { 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'))); 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')); $preferred = env('EXCHANGE_RATE_SERVICE', config('firefly.preferred_exchange_service'));

View File

@ -20,7 +20,6 @@ use FireflyIII\Helpers\Collector\JournalCollectorInterface;
use FireflyIII\Models\AccountType; use FireflyIII\Models\AccountType;
use FireflyIII\Models\TransactionType; use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Account\AccountTaskerInterface;
use FireflyIII\Repositories\Bill\BillRepositoryInterface; use FireflyIII\Repositories\Bill\BillRepositoryInterface;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface; use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Repositories\Category\CategoryRepositoryInterface; use FireflyIII\Repositories\Category\CategoryRepositoryInterface;

View File

@ -296,8 +296,8 @@ class PiggyBankController extends Controller
Log::error('Cannot add ' . $amount . ' because canAddAmount returned false.'); Log::error('Cannot add ' . $amount . ' because canAddAmount returned false.');
Session::flash( Session::flash(
'error', strval( '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')); return redirect(route('piggy-banks.index'));
@ -312,12 +312,13 @@ class PiggyBankController extends Controller
*/ */
public function postRemove(Request $request, PiggyBankRepositoryInterface $repository, PiggyBank $piggyBank) public function postRemove(Request $request, PiggyBankRepositoryInterface $repository, PiggyBank $piggyBank)
{ {
$amount = $request->get('amount'); $amount = $request->get('amount');
$currency = Amount::getDefaultCurrency(); $currency = Amount::getDefaultCurrency();
if ($repository->canRemoveAmount($piggyBank, $amount)) { if ($repository->canRemoveAmount($piggyBank, $amount)) {
$repository->removeAmount($piggyBank, $amount); $repository->removeAmount($piggyBank, $amount);
Session::flash( 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(); Preferences::mark();
@ -326,7 +327,11 @@ class PiggyBankController extends Controller
$amount = strval(round($request->get('amount'), 12)); $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')); return redirect(route('piggy-banks.index'));
} }

View File

@ -15,10 +15,7 @@ namespace FireflyIII\Http\Controllers\Report;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Account\AccountTaskerInterface; use FireflyIII\Repositories\Account\AccountTaskerInterface;
use FireflyIII\Support\CacheProperties; use FireflyIII\Support\CacheProperties;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;

View File

@ -246,7 +246,6 @@ class MassController extends Controller
'currency_id' => $foreignCurrencyId, 'currency_id' => $foreignCurrencyId,
'foreign_amount' => $foreignAmount, 'foreign_amount' => $foreignAmount,
'destination_amount' => $foreignAmount, 'destination_amount' => $foreignAmount,
//'foreign_currency_id' => $foreignCurrencyId,
'category' => $category, 'category' => $category,
'tags' => $tags, 'tags' => $tags,
]; ];

View File

@ -273,7 +273,7 @@ class SingleController extends Controller
]; ];
// amounts for withdrawals and deposits: // 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)) { if (($journal->isWithdrawal() || $journal->isDeposit()) && !is_null($pTransaction->foreign_amount)) {
$preFilled['amount'] = $pTransaction->foreign_amount; $preFilled['amount'] = $pTransaction->foreign_amount;
$preFilled['currency'] = $pTransaction->foreignCurrency; $preFilled['currency'] = $pTransaction->foreignCurrency;
@ -365,14 +365,13 @@ class SingleController extends Controller
} }
/** /**
* @param JournalFormRequest $request * @param JournalFormRequest $request
* @param JournalRepositoryInterface $repository * @param JournalUpdateInterface $updater
* @param JournalUpdateInterface $updater * @param TransactionJournal $journal
* @param TransactionJournal $journal
* *
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @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 // @codeCoverageIgnoreStart
if ($this->isOpeningBalance($journal)) { if ($this->isOpeningBalance($journal)) {

View File

@ -23,7 +23,6 @@ use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface; use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface; use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalTaskerInterface; use FireflyIII\Repositories\Journal\JournalTaskerInterface;
use FireflyIII\Repositories\Journal\JournalUpdateInterface; use FireflyIII\Repositories\Journal\JournalUpdateInterface;
use Illuminate\Http\Request; use Illuminate\Http\Request;
@ -123,14 +122,13 @@ class SplitController extends Controller
/** /**
* @param Request $request * @param Request $request
* @param JournalRepositoryInterface $repository * @param JournalUpdateInterface $updater
* @param JournalUpdateInterface $updater * @param TransactionJournal $journal
* @param TransactionJournal $journal
* *
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @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)) { if ($this->isOpeningBalance($journal)) {
return $this->redirectToAccount($journal); return $this->redirectToAccount($journal);

View File

@ -18,7 +18,6 @@ use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Collector\JournalCollectorInterface; use FireflyIII\Helpers\Collector\JournalCollectorInterface;
use FireflyIII\Helpers\Filter\InternalTransferFilter; use FireflyIII\Helpers\Filter\InternalTransferFilter;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface; use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalTaskerInterface; use FireflyIII\Repositories\Journal\JournalTaskerInterface;
use FireflyIII\Support\CacheProperties; use FireflyIII\Support\CacheProperties;
@ -179,10 +178,10 @@ class TransactionController extends Controller
return $this->redirectToAccount($journal); return $this->redirectToAccount($journal);
} }
$events = $tasker->getPiggyBankEvents($journal); $events = $tasker->getPiggyBankEvents($journal);
$transactions = $tasker->getTransactionsOverview($journal); $transactions = $tasker->getTransactionsOverview($journal);
$what = strtolower($journal->transaction_type_type ?? $journal->transactionType->type); $what = strtolower($journal->transaction_type_type ?? $journal->transactionType->type);
$subTitle = trans('firefly.' . $what) . ' "' . e($journal->description) . '"'; $subTitle = trans('firefly.' . $what) . ' "' . e($journal->description) . '"';
return view('transactions.show', compact('journal', 'events', 'subTitle', 'what', 'transactions')); return view('transactions.show', compact('journal', 'events', 'subTitle', 'what', 'transactions'));

View File

@ -38,19 +38,19 @@ class AccountFormRequest extends Request
public function getAccountData(): array public function getAccountData(): array
{ {
return [ return [
'name' => $this->string('name'), 'name' => $this->string('name'),
'active' => $this->boolean('active'), 'active' => $this->boolean('active'),
'accountType' => $this->string('what'), 'accountType' => $this->string('what'),
'currency_id' => $this->integer('currency_id'), 'currency_id' => $this->integer('currency_id'),
'virtualBalance' => $this->float('virtualBalance'), 'virtualBalance' => $this->float('virtualBalance'),
'iban' => $this->string('iban'), 'iban' => $this->string('iban'),
'BIC' => $this->string('BIC'), 'BIC' => $this->string('BIC'),
'accountNumber' => $this->string('accountNumber'), 'accountNumber' => $this->string('accountNumber'),
'accountRole' => $this->string('accountRole'), 'accountRole' => $this->string('accountRole'),
'openingBalance' => $this->float('openingBalance'), 'openingBalance' => $this->float('openingBalance'),
'openingBalanceDate' => $this->date('openingBalanceDate'), 'openingBalanceDate' => $this->date('openingBalanceDate'),
'ccType' => $this->string('ccType'), 'ccType' => $this->string('ccType'),
'ccMonthlyPaymentDate' => $this->string('ccMonthlyPaymentDate'), 'ccMonthlyPaymentDate' => $this->string('ccMonthlyPaymentDate'),
]; ];
} }

View File

@ -81,7 +81,7 @@ Breadcrumbs::register(
if ($moment !== 'all') { if ($moment !== 'all') {
$title = trans( $title = trans(
'firefly.between_dates_breadcrumb', ['start' => $start->formatLocalized(strval(trans('config.month_and_day'))), '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])); $breadcrumbs->push($title, route('accounts.show', [$account->id, $moment, $start, $end]));
} }
@ -726,16 +726,16 @@ Breadcrumbs::register(
Breadcrumbs::register( Breadcrumbs::register(
'tags.show', function (BreadCrumbGenerator $breadcrumbs, Tag $tag, string $moment, Carbon $start, Carbon $end) { 'tags.show', function (BreadCrumbGenerator $breadcrumbs, Tag $tag, string $moment, Carbon $start, Carbon $end) {
$breadcrumbs->parent('tags.index'); $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') { 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') { if ($moment !== 'all') {
$title = trans( $title = trans(
'firefly.between_dates_breadcrumb', ['start' => $start->formatLocalized(strval(trans('config.month_and_day'))), '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('tags.show', [$tag->id], $moment)); $breadcrumbs->push($title, route('tags.show', [$tag->id, $moment]));
} }
} }
); );

View File

@ -291,7 +291,6 @@ class ImportStorage
'user_id' => $entry->user->id, 'user_id' => $entry->user->id,
'transaction_type_id' => $entry->fields['transaction-type']->id, 'transaction_type_id' => $entry->fields['transaction-type']->id,
'bill_id' => $billId, 'bill_id' => $billId,
// TODO update this transaction currency reference.
'transaction_currency_id' => $entry->fields['currency']->id, 'transaction_currency_id' => $entry->fields['currency']->id,
'description' => $entry->fields['description'], 'description' => $entry->fields['description'],
'date' => $entry->fields['date-transaction'], 'date' => $entry->fields['date-transaction'],

View File

@ -74,7 +74,6 @@ class ImportValidator
$entry = $this->setOpposingAccount($entry); $entry = $this->setOpposingAccount($entry);
$entry = $this->cleanDescription($entry); $entry = $this->cleanDescription($entry);
$entry = $this->setTransactionType($entry); $entry = $this->setTransactionType($entry);
// TODO update this transaction currency reference.
$entry = $this->setTransactionCurrency($entry); $entry = $this->setTransactionCurrency($entry);
$newCollection->put($index, $entry); $newCollection->put($index, $entry);
@ -384,7 +383,6 @@ class ImportValidator
*/ */
private function setTransactionCurrency(ImportEntry $entry): ImportEntry private function setTransactionCurrency(ImportEntry $entry): ImportEntry
{ {
// TODO update this transaction currency reference.
if (is_null($entry->fields['currency'])) { if (is_null($entry->fields['currency'])) {
/** @var CurrencyRepositoryInterface $repository */ /** @var CurrencyRepositoryInterface $repository */
$repository = app(CurrencyRepositoryInterface::class); $repository = app(CurrencyRepositoryInterface::class);

View File

@ -12,18 +12,18 @@ class RegisteredUser extends Mailable
/** @var string */ /** @var string */
public $address; public $address;
/** @var string */ /** @var string */
public $ip; public $userIp;
/** /**
* Create a new message instance. * Create a new message instance.
* *
* @param string $address * @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->address = $address;
$this->ip = $ip; $this->userIp = $userIp;
} }
/** /**

View File

@ -10,20 +10,20 @@ class RequestedNewPassword extends Mailable
{ {
use Queueable, SerializesModels; use Queueable, SerializesModels;
/** @var string */ /** @var string */
public $ip;
/** @var string */
public $url; public $url;
/** @var string */
public $userIp;
/** /**
* RequestedNewPassword constructor. * RequestedNewPassword constructor.
* *
* @param string $url * @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->url = $url;
$this->ip = $ip; $this->userIp = $userIp;
} }
/** /**

View File

@ -32,7 +32,7 @@ class Transaction extends Model
* @var array * @var array
*/ */
protected $casts protected $casts
= [ = [
'created_at' => 'date', 'created_at' => 'date',
'updated_at' => 'date', 'updated_at' => 'date',
'deleted_at' => 'date', 'deleted_at' => 'date',
@ -40,18 +40,18 @@ class Transaction extends Model
'encrypted' => 'boolean', // model does not have these fields though 'encrypted' => 'boolean', // model does not have these fields though
'bill_name_encrypted' => 'boolean', 'bill_name_encrypted' => 'boolean',
]; ];
protected $dates = ['created_at', 'updated_at', 'deleted_at']; 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 $fillable
protected $hidden = ['encrypted']; = ['account_id', 'transaction_journal_id', 'description', 'amount', 'identifier', 'transaction_currency_id', 'foreign_currency_id',
'foreign_amount'];
protected $hidden = ['encrypted'];
protected $rules protected $rules
= [ = [
'account_id' => 'required|exists:accounts,id', 'account_id' => 'required|exists:accounts,id',
'transaction_journal_id' => 'required|exists:transaction_journals,id', 'transaction_journal_id' => 'required|exists:transaction_journals,id',
'transaction_currency_id' => 'required|exists:transaction_currencies,id', 'transaction_currency_id' => 'required|exists:transaction_currencies,id',
//'foreign_currency_id' => 'exists:transaction_currencies,id',
'description' => 'between:0,1024', 'description' => 'between:0,1024',
'amount' => 'required|numeric', 'amount' => 'required|numeric',
//'foreign_amount' => 'numeric',
]; ];
/** /**
@ -101,6 +101,14 @@ class Transaction extends Model
return $this->belongsToMany('FireflyIII\Models\Category'); 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 * @param $value
* *
@ -171,14 +179,6 @@ class Transaction extends Model
return $this->belongsTo('FireflyIII\Models\TransactionCurrency'); 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 * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/ */

View File

@ -19,6 +19,7 @@ use FireflyIII\Support\CacheProperties;
use FireflyIII\Support\Models\TransactionJournalTrait; use FireflyIII\Support\Models\TransactionJournalTrait;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder; use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Log; use Log;
@ -66,12 +67,12 @@ class TransactionJournal extends Model
/** @var array */ /** @var array */
protected $rules protected $rules
= [ = [
'user_id' => 'required|exists:users,id', 'user_id' => 'required|exists:users,id',
'transaction_type_id' => 'required|exists:transaction_types,id', 'transaction_type_id' => 'required|exists:transaction_types,id',
'description' => 'required|between:1,1024', 'description' => 'required|between:1,1024',
'completed' => 'required|boolean', 'completed' => 'required|boolean',
'date' => 'required|date', 'date' => 'required|date',
'encrypted' => 'required|boolean', 'encrypted' => 'required|boolean',
]; ];
/** /**
@ -114,7 +115,7 @@ class TransactionJournal extends Model
/** /**
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/ */
public function budgets() public function budgets(): BelongsToMany
{ {
return $this->belongsToMany('FireflyIII\Models\Budget'); return $this->belongsToMany('FireflyIII\Models\Budget');
} }
@ -122,7 +123,7 @@ class TransactionJournal extends Model
/** /**
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/ */
public function categories() public function categories(): BelongsToMany
{ {
return $this->belongsToMany('FireflyIII\Models\Category'); return $this->belongsToMany('FireflyIII\Models\Category');
} }
@ -203,7 +204,7 @@ class TransactionJournal extends Model
/** /**
* @return bool * @return bool
*/ */
public function isDeposit() public function isDeposit(): bool
{ {
if (!is_null($this->transaction_type_type)) { if (!is_null($this->transaction_type_type)) {
return $this->transaction_type_type == TransactionType::DEPOSIT; return $this->transaction_type_type == TransactionType::DEPOSIT;
@ -216,7 +217,7 @@ class TransactionJournal extends Model
* *
* @return bool * @return bool
*/ */
public function isOpeningBalance() public function isOpeningBalance(): bool
{ {
if (!is_null($this->transaction_type_type)) { if (!is_null($this->transaction_type_type)) {
return $this->transaction_type_type == TransactionType::OPENING_BALANCE; return $this->transaction_type_type == TransactionType::OPENING_BALANCE;
@ -229,7 +230,7 @@ class TransactionJournal extends Model
* *
* @return bool * @return bool
*/ */
public function isTransfer() public function isTransfer(): bool
{ {
if (!is_null($this->transaction_type_type)) { if (!is_null($this->transaction_type_type)) {
return $this->transaction_type_type == TransactionType::TRANSFER; return $this->transaction_type_type == TransactionType::TRANSFER;
@ -242,7 +243,7 @@ class TransactionJournal extends Model
* *
* @return bool * @return bool
*/ */
public function isWithdrawal() public function isWithdrawal(): bool
{ {
if (!is_null($this->transaction_type_type)) { if (!is_null($this->transaction_type_type)) {
return $this->transaction_type_type == TransactionType::WITHDRAWAL; return $this->transaction_type_type == TransactionType::WITHDRAWAL;
@ -254,7 +255,7 @@ class TransactionJournal extends Model
/** /**
* @return \Illuminate\Database\Eloquent\Relations\HasMany * @return \Illuminate\Database\Eloquent\Relations\HasMany
*/ */
public function piggyBankEvents() public function piggyBankEvents(): HasMany
{ {
return $this->hasMany('FireflyIII\Models\PiggyBankEvent'); return $this->hasMany('FireflyIII\Models\PiggyBankEvent');
} }
@ -266,7 +267,7 @@ class TransactionJournal extends Model
* *
* @return bool * @return bool
*/ */
public function save(array $options = []) public function save(array $options = []): bool
{ {
$count = $this->tags()->count(); $count = $this->tags()->count();
$this->tag_count = $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'); return $this->hasMany('FireflyIII\Models\Transaction');
} }

View File

@ -52,11 +52,11 @@ use FireflyIII\Support\Twig\Rule;
use FireflyIII\Support\Twig\Transaction; use FireflyIII\Support\Twig\Transaction;
use FireflyIII\Support\Twig\Translation; use FireflyIII\Support\Twig\Translation;
use FireflyIII\Validation\FireflyValidator; use FireflyIII\Validation\FireflyValidator;
use Illuminate\Foundation\Application;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
use Twig; use Twig;
use TwigBridge\Extension\Loader\Functions; use TwigBridge\Extension\Loader\Functions;
use Validator; use Validator;
use Illuminate\Foundation\Application;
/** /**
* Class FireflyServiceProvider * Class FireflyServiceProvider

View File

@ -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;
}
);
}
} }

View File

@ -36,11 +36,6 @@ interface AccountRepositoryInterface
*/ */
public function count(array $types): int; public function count(array $types): int;
/**
* @return Account
*/
public function getCashAccount(): Account;
/** /**
* Moved here from account CRUD. * Moved here from account CRUD.
* *
@ -103,6 +98,11 @@ interface AccountRepositoryInterface
*/ */
public function getActiveAccountsByType(array $types): Collection; public function getActiveAccountsByType(array $types): Collection;
/**
* @return Account
*/
public function getCashAccount(): Account;
/** /**
* Returns the date of the very last transaction in this account. * Returns the date of the very last transaction in this account.
* *

View File

@ -15,7 +15,6 @@ namespace FireflyIII\Repositories\Journal;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Models\Tag; use FireflyIII\Models\Tag;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType; use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Tag\TagRepositoryInterface; use FireflyIII\Repositories\Tag\TagRepositoryInterface;

View File

@ -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 User $user
* @param array $data * @param array $data
@ -315,47 +358,4 @@ class JournalSupport
return $data; 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;
}
} }

View File

@ -258,8 +258,7 @@ class JournalUpdate implements JournalUpdateInterface
$transaction->transaction_currency_id = $data['currency_id']; $transaction->transaction_currency_id = $data['currency_id'];
$transaction->foreign_amount = is_null($data['foreign_amount']) ? null : app('steam')->positive($data['foreign_amount']); $transaction->foreign_amount = is_null($data['foreign_amount']) ? null : app('steam')->positive($data['foreign_amount']);
$transaction->foreign_currency_id = $data['foreign_currency_id']; $transaction->foreign_currency_id = $data['foreign_currency_id'];
$transaction->account_id = $account->id;
$transaction->account_id = $account->id;
$transaction->save(); $transaction->save();
} }
@ -284,6 +283,7 @@ class JournalUpdate implements JournalUpdateInterface
$transaction->transaction_currency_id = $data['currency_id']; $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_amount = is_null($data['foreign_amount']) ? null : bcmul(app('steam')->positive($data['foreign_amount']), '-1');
$transaction->foreign_currency_id = $data['foreign_currency_id']; $transaction->foreign_currency_id = $data['foreign_currency_id'];
$transaction->account_id = $account->id;
$transaction->save(); $transaction->save();
} }

View File

@ -241,11 +241,11 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
public function getPiggyBanksWithAmount(): Collection public function getPiggyBanksWithAmount(): Collection
{ {
$currency = Amount::getDefaultCurrency(); $currency = Amount::getDefaultCurrency();
$set = $this->getPiggyBanks(); $set = $this->getPiggyBanks();
foreach ($set as $piggy) { foreach ($set as $piggy) {
$currentAmount = $piggy->currentRelevantRep()->currentamount ?? '0'; $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; return $set;

View File

@ -292,7 +292,7 @@ class Amount
} }
if ($transaction->transaction_type_type === TransactionType::TRANSFER) { if ($transaction->transaction_type_type === TransactionType::TRANSFER) {
$amount = app('steam')->positive($amount); $amount = app('steam')->positive($amount);
$coloured = false; $coloured = false;
$format = '<span class="text-info">%s</span>'; $format = '<span class="text-info">%s</span>';
} }

View File

@ -15,16 +15,21 @@ namespace FireflyIII\Support\Models;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Transaction; use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournalMeta;
use FireflyIII\Rules\Triggers\TransactionType;
use FireflyIII\Support\CacheProperties; use FireflyIII\Support\CacheProperties;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
* Class TransactionJournalTrait * Class TransactionJournalTrait
* *
* @property int $id * @property int $id
* @method Collection transactions() * @property Carbon $date
* @method bool isWithdrawal() * @property string $transaction_type_type
* @property TransactionType $transactionType
* *
* @package FireflyIII\Support\Models * @package FireflyIII\Support\Models
*/ */
@ -91,6 +96,16 @@ trait TransactionJournalTrait
return 0; 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 * @return string
*/ */
@ -180,6 +195,19 @@ trait TransactionJournalTrait
return $list; return $list;
} }
/**
*
* @param string $name
*
* @return string
*/
abstract public function getMeta(string $name);
/**
* @return bool
*/
abstract public function isDeposit(): bool;
/** /**
* @param Builder $query * @param Builder $query
* @param string $table * @param string $table
@ -201,6 +229,29 @@ trait TransactionJournalTrait
return false; 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 * @return int
*/ */
@ -221,6 +272,23 @@ trait TransactionJournalTrait
return $this->transactions()->where('amount', '>', 0)->first(); 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 * @return Collection
*/ */
@ -281,4 +349,9 @@ trait TransactionJournalTrait
return $typeStr; return $typeStr;
} }
/**
* @return HasMany
*/
abstract public function transactions(): HasMany;
} }

View File

@ -13,7 +13,6 @@ declare(strict_types=1);
namespace FireflyIII\Support\Twig; namespace FireflyIII\Support\Twig;
use Amount;
use FireflyIII\Models\AccountType; use FireflyIII\Models\AccountType;
use FireflyIII\Models\Transaction as TransactionModel; use FireflyIII\Models\Transaction as TransactionModel;
use FireflyIII\Models\TransactionType; use FireflyIII\Models\TransactionType;

View File

@ -8,7 +8,7 @@
* See the LICENSE file for details. * See the LICENSE file for details.
*/ */
/** global: budgetChartUri,budgetLimitID */ /** global: budgetChartUri, expenseCategoryUri, expenseAssetUri, expenseExpenseUri */
$(function () { $(function () {
"use strict"; "use strict";

View File

@ -13,10 +13,7 @@
$(function () { $(function () {
"use strict"; "use strict";
console.log('Getting charts');
columnChart(everything, 'category-everything'); columnChart(everything, 'category-everything');
console.log('Specific: ' + specific);
columnChart(specific, 'specific-period'); columnChart(specific, 'specific-period');
}); });

View File

@ -186,7 +186,6 @@ function doubleYNonStackedChart(URI, container) {
*/ */
function columnChart(URI, container) { function columnChart(URI, container) {
"use strict"; "use strict";
console.log('Going to draw column chart for ' + URI + ' in ' + container);
var colorData = true; var colorData = true;
var options = $.extend(true, {}, defaultChartOptions); var options = $.extend(true, {}, defaultChartOptions);
var chartType = 'bar'; var chartType = 'bar';

View File

@ -6,6 +6,8 @@
* See the LICENSE file for details. * See the LICENSE file for details.
*/ */
/** global: zoomLevel, latitude, longitude, google, doPlaceMarker */
/* /*
Some vars as prep for the map: Some vars as prep for the map:
*/ */

View File

@ -6,6 +6,8 @@
* See the LICENSE file for details. * See the LICENSE file for details.
*/ */
/** global: Modernizr, accountInfo, currencyInfo, accountInfo, transferInstructions, what */
$(document).ready(function () { $(document).ready(function () {
"use strict"; "use strict";
setCommonAutocomplete(); setCommonAutocomplete();
@ -73,7 +75,6 @@ function selectsForeignCurrency() {
var nativeCurrencyId = parseInt(accountInfo[selectedAccountId].preferredCurrency); var nativeCurrencyId = parseInt(accountInfo[selectedAccountId].preferredCurrency);
if (foreignCurrencyId !== nativeCurrencyId) { 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: // the input where the native amount is entered gets the symbol for the native currency:
$('.non-selectable-currency-symbol').text(currencyInfo[nativeCurrencyId].symbol); $('.non-selectable-currency-symbol').text(currencyInfo[nativeCurrencyId].symbol);
@ -90,7 +91,6 @@ function selectsForeignCurrency() {
} }
if (foreignCurrencyId === nativeCurrencyId) { if (foreignCurrencyId === nativeCurrencyId) {
console.log('User has selected currency #' + foreignCurrencyId + ' and this is equal to native currency #' + nativeCurrencyId + ' (phew).');
$('#exchange_rate_instruction_holder').hide(); $('#exchange_rate_instruction_holder').hide();
$('#native_amount_holder').hide(); $('#native_amount_holder').hide();
} }
@ -110,7 +110,6 @@ function convertForeignToNative() {
var date = $('#ffInput_date').val(); var date = $('#ffInput_date').val();
var amount = $('#ffInput_amount').val(); var amount = $('#ffInput_amount').val();
var uri = 'json/rate/' + foreignCurrencyCode + '/' + nativeCurrencyCode + '/' + date + '?amount=' + amount; var uri = 'json/rate/' + foreignCurrencyCode + '/' + nativeCurrencyCode + '/' + date + '?amount=' + amount;
console.log('Will grab ' + uri);
$.get(uri).done(updateNativeAmount); $.get(uri).done(updateNativeAmount);
} }
@ -119,8 +118,6 @@ function convertForeignToNative() {
* @param data * @param data
*/ */
function updateNativeAmount(data) { function updateNativeAmount(data) {
console.log('Returned data:');
console.log(data);
$('#ffInput_native_amount').val(data.amount); $('#ffInput_native_amount').val(data.amount);
} }
@ -158,12 +155,10 @@ function validateCurrencyForTransfer() {
$('#source_amount_holder').show().find('.non-selectable-currency-symbol').text(sourceSymbol); $('#source_amount_holder').show().find('.non-selectable-currency-symbol').text(sourceSymbol);
if (sourceCurrency === destinationCurrency) { if (sourceCurrency === destinationCurrency) {
console.log('Both accounts accept #' + sourceCurrency);
$('#destination_amount_holder').hide(); $('#destination_amount_holder').hide();
$('#amount_holder').hide(); $('#amount_holder').hide();
return; return;
} }
console.log('Source accepts #' + sourceCurrency + ', destination #' + destinationCurrency);
$('#ffInput_exchange_rate_instruction').text(getTransferExchangeInstructions()); $('#ffInput_exchange_rate_instruction').text(getTransferExchangeInstructions());
$('#exchange_rate_instruction_holder').show(); $('#exchange_rate_instruction_holder').show();
$('input[name="source_amount"]').val($('input[name="amount"]').val()); $('input[name="source_amount"]').val($('input[name="amount"]').val());
@ -191,7 +186,6 @@ function convertSourceToDestination() {
var amount = $('#ffInput_source_amount').val(); var amount = $('#ffInput_source_amount').val();
$('#ffInput_amount').val(amount); $('#ffInput_amount').val(amount);
var uri = 'json/rate/' + sourceCurrencyCode + '/' + destinationCurrencyCode + '/' + date + '?amount=' + amount; var uri = 'json/rate/' + sourceCurrencyCode + '/' + destinationCurrencyCode + '/' + date + '?amount=' + amount;
console.log('Will grab ' + uri);
$.get(uri).done(updateDestinationAmount); $.get(uri).done(updateDestinationAmount);
} }
@ -200,7 +194,5 @@ function convertSourceToDestination() {
* @param data * @param data
*/ */
function updateDestinationAmount(data) { function updateDestinationAmount(data) {
console.log('Returned data:');
console.log(data);
$('#ffInput_destination_amount').val(data.amount); $('#ffInput_destination_amount').val(data.amount);
} }

View File

@ -6,7 +6,7 @@
* See the LICENSE file for details. * 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 () { $(document).ready(function () {
"use strict"; "use strict";
@ -64,8 +64,6 @@ function updateNativeCurrency() {
var newAccountId = getAccountId(); var newAccountId = getAccountId();
var nativeCurrencyId = accountInfo[newAccountId].preferredCurrency; var nativeCurrencyId = accountInfo[newAccountId].preferredCurrency;
console.log('User selected account #' + newAccountId + '. Native currency is #' + nativeCurrencyId);
$('.currency-option[data-id="' + nativeCurrencyId + '"]').click(); $('.currency-option[data-id="' + nativeCurrencyId + '"]').click();
$('[data-toggle="dropdown"]').parent().removeClass('open'); $('[data-toggle="dropdown"]').parent().removeClass('open');
if (what !== 'transfer') { if (what !== 'transfer') {
@ -107,6 +105,7 @@ function updateForm() {
var srcName = $('#ffInput_source_account_name'); var srcName = $('#ffInput_source_account_name');
switch (what) { switch (what) {
case 'withdrawal': case 'withdrawal':
// show source_id and dest_name // show source_id and dest_name
document.getElementById('source_account_id_holder').style.display = 'block'; document.getElementById('source_account_id_holder').style.display = 'block';
@ -178,6 +177,8 @@ function updateForm() {
} }
document.getElementById('piggy_bank_id_holder').style.display = showPiggies; document.getElementById('piggy_bank_id_holder').style.display = showPiggies;
break; break;
default:
break;
} }
updateNativeCurrency(); updateNativeCurrency();
} }
@ -232,4 +233,5 @@ function getAccountId() {
if (what === "deposit" || what === "transfer") { if (what === "deposit" || what === "transfer") {
return $('select[name="destination_account_id"]').val(); return $('select[name="destination_account_id"]').val();
} }
return undefined;
} }

View File

@ -8,7 +8,7 @@
* See the LICENSE file for details. * See the LICENSE file for details.
*/ */
/** global: what, Modernizr */ /** global: what, Modernizr, selectsForeignCurrency, convertForeignToNative, validateCurrencyForTransfer, convertSourceToDestination, journalData, journal, accountInfo, exchangeRateInstructions, currencyInfo */
$(document).ready(function () { $(document).ready(function () {
"use strict"; "use strict";
@ -79,6 +79,7 @@ function getAccountId() {
} }
alert('Cannot handle ' + journal.transaction_type.type); alert('Cannot handle ' + journal.transaction_type.type);
return undefined;
} }
/** /**

View File

@ -6,7 +6,7 @@
</p> </p>
<p style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:11px;color:#aaa;"> <p style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:11px;color:#aaa;">
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.
</p> </p>
</body> </body>

View File

@ -3,4 +3,4 @@ Beep boop,
The Firefly III Mail Robot The Firefly III Mail Robot
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.