mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Various code cleanup.
This commit is contained in:
parent
64831b4c86
commit
c4039b53e6
@ -26,9 +26,9 @@ class StoredTransactionJournal extends Event
|
||||
|
||||
use SerializesModels;
|
||||
|
||||
/** @var TransactionJournal */
|
||||
/** @var TransactionJournal */
|
||||
public $journal;
|
||||
/** @var int */
|
||||
/** @var int */
|
||||
public $piggyBankId;
|
||||
|
||||
/**
|
||||
|
@ -26,7 +26,7 @@ class UpdatedTransactionJournal extends Event
|
||||
|
||||
use SerializesModels;
|
||||
|
||||
/** @var TransactionJournal */
|
||||
/** @var TransactionJournal */
|
||||
public $journal;
|
||||
|
||||
/**
|
||||
|
@ -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
|
||||
|
@ -15,7 +15,6 @@ namespace FireflyIII\Generator\Report;
|
||||
|
||||
use FireflyIII\Models\Transaction;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -26,7 +26,7 @@ use Log;
|
||||
*/
|
||||
class InternalTransferFilter implements FilterInterface
|
||||
{
|
||||
/** @var array */
|
||||
/** @var array */
|
||||
private $accounts = [];
|
||||
|
||||
/**
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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'));
|
||||
|
@ -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;
|
||||
|
@ -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'));
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
];
|
||||
|
@ -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)) {
|
||||
|
@ -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);
|
||||
|
@ -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'));
|
||||
|
||||
|
@ -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'),
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -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]));
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -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'],
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -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');
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
*
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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 = '<span class="text-info">%s</span>';
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -8,7 +8,7 @@
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
/** global: budgetChartUri,budgetLimitID */
|
||||
/** global: budgetChartUri, expenseCategoryUri, expenseAssetUri, expenseExpenseUri */
|
||||
|
||||
$(function () {
|
||||
"use strict";
|
||||
|
@ -13,10 +13,7 @@
|
||||
$(function () {
|
||||
"use strict";
|
||||
|
||||
console.log('Getting charts');
|
||||
columnChart(everything, 'category-everything');
|
||||
|
||||
console.log('Specific: ' + specific);
|
||||
columnChart(specific, 'specific-period');
|
||||
|
||||
});
|
@ -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';
|
||||
|
@ -6,6 +6,8 @@
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
/** global: zoomLevel, latitude, longitude, google, doPlaceMarker */
|
||||
|
||||
/*
|
||||
Some vars as prep for the map:
|
||||
*/
|
||||
|
@ -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);
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -6,7 +6,7 @@
|
||||
</p>
|
||||
|
||||
<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>
|
||||
|
||||
</body>
|
||||
|
@ -3,4 +3,4 @@ Beep boop,
|
||||
|
||||
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.
|
||||
|
Loading…
Reference in New Issue
Block a user