mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Code cleanup.
This commit is contained in:
parent
65ce277a20
commit
a6dbd912c6
@ -4,6 +4,7 @@ Firefly III
|
||||
[](https://travis-ci.org/JC5/firefly-iii)
|
||||
[](http://stillmaintained.com/JC5/firefly-iii)
|
||||
[](https://coveralls.io/r/JC5/firefly-iii?branch=master)
|
||||
[](https://insight.sensiolabs.com/projects/d44c7012-5f50-41ad-add8-8445330e4102)
|
||||
|
||||
[](https://packagist.org/packages/grumpydictator/firefly-iii)
|
||||
[](https://packagist.org/packages/grumpydictator/firefly-iii)
|
||||
|
@ -199,9 +199,9 @@ class PiggyBankController extends BaseController
|
||||
*/
|
||||
Event::fire('piggy_bank.addMoney', [$piggyBank, $amount]); // new and used.
|
||||
|
||||
Session::flash('success', 'Added ' . mf($amount, false) . ' to "' . e($piggyBank->name) . '".');
|
||||
Session::flash('success', 'Added ' . Amount::format($amount, false) . ' to "' . e($piggyBank->name) . '".');
|
||||
} else {
|
||||
Session::flash('error', 'Could not add ' . mf($amount, false) . ' to "' . e($piggyBank->name) . '".');
|
||||
Session::flash('error', 'Could not add ' . Amount::format($amount, false) . ' to "' . e($piggyBank->name) . '".');
|
||||
}
|
||||
|
||||
return Redirect::route('piggy_banks.index');
|
||||
@ -228,9 +228,9 @@ class PiggyBankController extends BaseController
|
||||
*/
|
||||
Event::fire('piggy_bank.removeMoney', [$piggyBank, $amount]); // new and used.
|
||||
|
||||
Session::flash('success', 'Removed ' . mf($amount, false) . ' from "' . e($piggyBank->name) . '".');
|
||||
Session::flash('success', 'Removed ' . Amount::format($amount, false) . ' from "' . e($piggyBank->name) . '".');
|
||||
} else {
|
||||
Session::flash('error', 'Could not remove ' . mf($amount, false) . ' from "' . e($piggyBank->name) . '".');
|
||||
Session::flash('error', 'Could not remove ' . Amount::format($amount, false) . ' from "' . e($piggyBank->name) . '".');
|
||||
}
|
||||
|
||||
return Redirect::route('piggy_banks.index');
|
||||
|
@ -69,7 +69,7 @@ class TransactionController extends BaseController
|
||||
$set = $this->_repository->getByIds($unique);
|
||||
$set->each(
|
||||
function (TransactionJournal $journal) {
|
||||
$journal->amount = mf($journal->getAmount());
|
||||
$journal->amount = Amount::format($journal->getAmount());
|
||||
}
|
||||
);
|
||||
|
||||
@ -308,7 +308,7 @@ class TransactionController extends BaseController
|
||||
$result = $this->_repository->searchRelated($search, $journal);
|
||||
$result->each(
|
||||
function (TransactionJournal $j) {
|
||||
$j->amount = mf($j->getAmount());
|
||||
$j->amount = Amount::format($j->getAmount());
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -7,11 +7,11 @@ use FireflyIII\Database\CommonDatabaseCallsInterface;
|
||||
use FireflyIII\Database\CUDInterface;
|
||||
use FireflyIII\Database\SwitchUser;
|
||||
use FireflyIII\Exception\NotImplementedException;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\MessageBag;
|
||||
|
||||
use Illuminate\Database\Query\Builder as QueryBuilder;
|
||||
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
||||
/**
|
||||
* Class Account
|
||||
*
|
||||
@ -223,20 +223,21 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte
|
||||
public function destroy(Eloquent $model)
|
||||
{
|
||||
|
||||
// delete piggy banks
|
||||
// delete journals:
|
||||
$journals = \TransactionJournal::whereIn(
|
||||
'id', function (Builder $query) use ($model) {
|
||||
'id', function (QueryBuilder $query) use ($model) {
|
||||
$query->select('transaction_journal_id')
|
||||
->from('transactions')->whereIn(
|
||||
'account_id', function (Builder $query) use ($model) {
|
||||
'account_id', function (QueryBuilder $query) use ($model) {
|
||||
$query
|
||||
->select('id')
|
||||
->from('accounts')
|
||||
->where(
|
||||
function (Builder $q) use ($model) {
|
||||
function (QueryBuilder $q) use ($model) {
|
||||
$q->where('id', $model->id);
|
||||
$q->orWhere(
|
||||
function (Builder $q) use ($model) {
|
||||
function (QueryBuilder $q) use ($model) {
|
||||
$q->where('accounts.name', 'LIKE', '%' . $model->name . '%');
|
||||
// TODO magic number!
|
||||
$q->where('accounts.account_type_id', 3);
|
||||
@ -274,10 +275,10 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte
|
||||
|
||||
// delete accounts:
|
||||
\Account::where(
|
||||
function (Builder $q) use ($model) {
|
||||
function (EloquentBuilder $q) use ($model) {
|
||||
$q->where('id', $model->id);
|
||||
$q->orWhere(
|
||||
function (Builder $q) use ($model) {
|
||||
function (EloquentBuilder $q) use ($model) {
|
||||
$q->where('accounts.name', 'LIKE', '%' . $model->name . '%');
|
||||
// TODO magic number!
|
||||
$q->where('accounts.account_type_id', 3);
|
||||
|
@ -10,7 +10,7 @@ use FireflyIII\Exception\NotImplementedException;
|
||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\MessageBag;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
|
||||
/**
|
||||
* Class Budget
|
||||
@ -336,7 +336,6 @@ class Budget implements CUDInterface, CommonDatabaseCallsInterface, BudgetInterf
|
||||
$limit->repeat_freq = 'monthly';
|
||||
$limit->repeats = 0;
|
||||
$result = $limit->save();
|
||||
\Log::info('Created new limit? ' . boolstr($result));
|
||||
\Log::info('ID: ' . $limit->id);
|
||||
/*
|
||||
* A newly stored limit also created a limit repetition.
|
||||
|
@ -35,7 +35,6 @@ class TransactionCurrency implements TransactionCurrencyInterface, CommonDatabas
|
||||
public function store(array $data)
|
||||
{
|
||||
$currency = new \TransactionCurrency($data);
|
||||
\Log::debug('Is valid? ' . boolstr($currency->isValid()));
|
||||
$currency->save();
|
||||
|
||||
return $currency;
|
||||
@ -52,7 +51,6 @@ class TransactionCurrency implements TransactionCurrencyInterface, CommonDatabas
|
||||
$model->symbol = $data['symbol'];
|
||||
$model->code = $data['code'];
|
||||
$model->name = $data['name'];
|
||||
\Log::debug('Is valid? ' . boolstr($model->isValid()));
|
||||
$model->save();
|
||||
|
||||
return true;
|
||||
|
@ -7,6 +7,7 @@ use FireflyIII\Shared\Toolkit\Form;
|
||||
use FireflyIII\Shared\Toolkit\Navigation;
|
||||
use FireflyIII\Shared\Toolkit\Reminders;
|
||||
use FireflyIII\Shared\Toolkit\Steam;
|
||||
use FireflyIII\Shared\Toolkit\Amount;
|
||||
use FireflyIII\Shared\Validation\FireflyValidator;
|
||||
use Illuminate\Foundation\AliasLoader;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
@ -82,6 +83,11 @@ class FF3ServiceProvider extends ServiceProvider
|
||||
return new Steam;
|
||||
}
|
||||
);
|
||||
$this->app->bind(
|
||||
'amount', function () {
|
||||
return new Amount;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public function registerInterfaces()
|
||||
@ -114,6 +120,7 @@ class FF3ServiceProvider extends ServiceProvider
|
||||
$loader->alias('Navigation', 'FireflyIII\Shared\Facade\Navigation');
|
||||
$loader->alias('FFForm', 'FireflyIII\Shared\Facade\FFForm');
|
||||
$loader->alias('Steam', 'FireflyIII\Shared\Facade\Steam');
|
||||
$loader->alias('Amount', 'FireflyIII\Shared\Facade\Amount');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ class Form
|
||||
$html .= \Form::input('text', $name, $value, $options);
|
||||
break;
|
||||
case 'amount':
|
||||
$html .= '<div class="input-group"><div class="input-group-addon">' . getCurrencySymbol() . '</div>';
|
||||
$html .= '<div class="input-group"><div class="input-group-addon">' . \Amount::getCurrencySymbol() . '</div>';
|
||||
$html .= \Form::input('number', $name, $value, $options);
|
||||
$html .= '</div>';
|
||||
break;
|
||||
|
@ -6,7 +6,7 @@ use Carbon\Carbon;
|
||||
use FireflyIII\Database\Account\Account as AccountRepository;
|
||||
use FireflyIII\Database\SwitchUser;
|
||||
use FireflyIII\Database\TransactionJournal\TransactionJournal as JournalRepository;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Illuminate\Database\Query\JoinClause;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
|
@ -3,9 +3,9 @@
|
||||
namespace FireflyIII\Report;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Query\JoinClause;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
/**
|
||||
* Class ReportQuery
|
||||
|
@ -4,7 +4,7 @@ namespace FireflyIII\Search;
|
||||
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
||||
|
||||
/**
|
||||
* Class Search
|
||||
@ -21,7 +21,7 @@ class Search
|
||||
public function searchAccounts(array $words)
|
||||
{
|
||||
return \Auth::user()->accounts()->with('accounttype')->where(
|
||||
function (Builder $q) use ($words) {
|
||||
function (EloquentBuilder $q) use ($words) {
|
||||
foreach ($words as $word) {
|
||||
$q->orWhere('name', 'LIKE', '%' . e($word) . '%');
|
||||
}
|
||||
@ -97,7 +97,7 @@ class Search
|
||||
public function searchTransactions(array $words)
|
||||
{
|
||||
return \Auth::user()->transactionjournals()->withRelevantData()->where(
|
||||
function (Builder $q) use ($words) {
|
||||
function (EloquentBuilder $q) use ($words) {
|
||||
foreach ($words as $word) {
|
||||
$q->orWhere('description', 'LIKE', '%' . e($word) . '%');
|
||||
}
|
||||
|
24
app/lib/FireflyIII/Shared/Facade/Amount.php
Normal file
24
app/lib/FireflyIII/Shared/Facade/Amount.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace FireflyIII\Shared\Facade;
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
/**
|
||||
* Class Amount
|
||||
*
|
||||
* @package FireflyIII\Shared\Facade
|
||||
*/
|
||||
class Amount extends Facade
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected static function getFacadeAccessor()
|
||||
{
|
||||
return 'amount';
|
||||
}
|
||||
|
||||
}
|
148
app/lib/FireflyIII/Shared/Toolkit/Amount.php
Normal file
148
app/lib/FireflyIII/Shared/Toolkit/Amount.php
Normal file
@ -0,0 +1,148 @@
|
||||
<?php
|
||||
|
||||
namespace FireflyIII\Shared\Toolkit;
|
||||
|
||||
/**
|
||||
* Class Amount
|
||||
*
|
||||
* @package FireflyIII\Shared\Toolkit
|
||||
*/
|
||||
class Amount
|
||||
{
|
||||
|
||||
/**
|
||||
* @param $amount
|
||||
* @param bool $coloured
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function format($amount, $coloured = true)
|
||||
{
|
||||
$currencySymbol = $this->getCurrencySymbol();
|
||||
|
||||
return $this->formatWithSymbol($currencySymbol, $amount, $coloured);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCurrencySymbol()
|
||||
{
|
||||
if (defined('FFCURRENCYSYMBOL')) {
|
||||
return FFCURRENCYSYMBOL;
|
||||
}
|
||||
if (\Cache::has('FFCURRENCYSYMBOL')) {
|
||||
define('FFCURRENCYSYMBOL', \Cache::get('FFCURRENCYSYMBOL'));
|
||||
|
||||
return FFCURRENCYSYMBOL;
|
||||
}
|
||||
|
||||
/** @var \FireflyIII\Database\TransactionCurrency\TransactionCurrency $currencies */
|
||||
$currencies = \App::make('FireflyIII\Database\TransactionCurrency\TransactionCurrency');
|
||||
|
||||
/** @var \FireflyIII\Shared\Preferences\Preferences $preferences */
|
||||
$preferences = \App::make('FireflyIII\Shared\Preferences\Preferences');
|
||||
|
||||
$currencyPreference = $preferences->get('currencyPreference', 'EUR');
|
||||
$currency = $currencies->findByCode($currencyPreference->data);
|
||||
|
||||
\Cache::forever('FFCURRENCYSYMBOL', $currency->symbol);
|
||||
|
||||
define('FFCURRENCYSYMBOL', $currency->symbol);
|
||||
|
||||
return $currency->symbol;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $symbol
|
||||
* @param float $amount
|
||||
* @param bool $coloured
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function formatWithSymbol($symbol, $amount, $coloured = true)
|
||||
{
|
||||
$amount = floatval($amount);
|
||||
$amount = round($amount, 2);
|
||||
$string = number_format($amount, 2, ',', '.');
|
||||
|
||||
if ($coloured === true) {
|
||||
if ($amount === 0.0) {
|
||||
return '<span style="color:#999">' . $symbol . ' ' . $string . '</span>';
|
||||
}
|
||||
if ($amount > 0) {
|
||||
return '<span class="text-success">' . $symbol . ' ' . $string . '</span>';
|
||||
}
|
||||
|
||||
return '<span class="text-danger">' . $symbol . ' ' . $string . '</span>';
|
||||
}
|
||||
|
||||
// €
|
||||
return $symbol . ' ' . $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \TransactionJournal $journal
|
||||
* @param float $amount
|
||||
* @param bool $coloured
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function formatJournal(\TransactionJournal $journal, $amount, $coloured = true)
|
||||
{
|
||||
$symbol = $journal->transactionCurrency->symbol;
|
||||
|
||||
return $this->formatWithSymbol($symbol, $amount, $coloured);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Transaction $transaction
|
||||
* @param bool $coloured
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function formatTransaction(\Transaction $transaction, $coloured = true)
|
||||
{
|
||||
$symbol = $transaction->transactionJournal->transactionCurrency->symbol;
|
||||
$amount = floatval($transaction->amount);
|
||||
|
||||
return $this->formatWithSymbol($symbol, $amount, $coloured);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCurrencyCode()
|
||||
{
|
||||
if (defined('FFCURRENCYCODE')) {
|
||||
return FFCURRENCYCODE;
|
||||
}
|
||||
if (\Cache::has('FFCURRENCYCODE')) {
|
||||
define('FFCURRENCYCODE', \Cache::get('FFCURRENCYCODE'));
|
||||
|
||||
return FFCURRENCYCODE;
|
||||
}
|
||||
|
||||
/** @var \FireflyIII\Database\TransactionCurrency\TransactionCurrency $currencies */
|
||||
$currencies = \App::make('FireflyIII\Database\TransactionCurrency\TransactionCurrency');
|
||||
|
||||
/** @var \FireflyIII\Shared\Preferences\Preferences $preferences */
|
||||
$preferences = \App::make('FireflyIII\Shared\Preferences\Preferences');
|
||||
|
||||
$currencyPreference = $preferences->get('currencyPreference', 'EUR');
|
||||
$currency = $currencies->findByCode($currencyPreference->data);
|
||||
|
||||
\Cache::forever('FFCURRENCYCODE', $currency->code);
|
||||
|
||||
define('FFCURRENCYCODE', $currency->code);
|
||||
|
||||
return $currency->code;
|
||||
}
|
||||
|
||||
}
|
@ -25,7 +25,7 @@ class Steam
|
||||
*/
|
||||
public function balance(\Account $account, Carbon $date = null)
|
||||
{
|
||||
$date = is_null($date) ? Carbon::now() : $date;
|
||||
$date = is_null($date) ? Carbon::now() : $date;
|
||||
$balance = floatval(
|
||||
$account->transactions()->leftJoin(
|
||||
'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id'
|
||||
@ -35,6 +35,23 @@ class Steam
|
||||
return $balance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $boolean
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function boolString($boolean)
|
||||
{
|
||||
if ($boolean === true) {
|
||||
return 'BOOLEAN TRUE';
|
||||
}
|
||||
if ($boolean === false) {
|
||||
return 'BOOLEAN FALSE';
|
||||
}
|
||||
|
||||
return 'NO BOOLEAN: ' . $boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \PiggyBank $piggyBank
|
||||
* @param \PiggyBankRepetition $repetition
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
|
||||
/**
|
||||
* Class Reminder
|
||||
*/
|
||||
@ -31,13 +33,13 @@ class Reminder extends Eloquent
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $query
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param EloquentBuilder $query
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function scopeDateIs($query, Carbon $start, Carbon $end)
|
||||
public function scopeDateIs(EloquentBuilder $query, Carbon $start, Carbon $end)
|
||||
{
|
||||
return $query->where('startdate', $start->format('Y-m-d 00:00:00'))->where('enddate', $end->format('Y-m-d 00:00:00'));
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
@ -27,19 +27,19 @@ class Transaction extends Eloquent
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder $query
|
||||
* @param EloquentBuilder $query
|
||||
* @param Account $account
|
||||
*/
|
||||
public function scopeAccountIs(Builder $query, Account $account)
|
||||
public function scopeAccountIs(EloquentBuilder $query, Account $account)
|
||||
{
|
||||
$query->where('transactions.account_id', $account->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder $query
|
||||
* @param EloquentBuilder $query
|
||||
* @param Carbon $date
|
||||
*/
|
||||
public function scopeAfter(Builder $query, Carbon $date)
|
||||
public function scopeAfter(EloquentBuilder $query, Carbon $date)
|
||||
{
|
||||
if (is_null($this->joinedJournals)) {
|
||||
$query->leftJoin(
|
||||
@ -51,10 +51,10 @@ class Transaction extends Eloquent
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder $query
|
||||
* @param EloquentBuilder $query
|
||||
* @param Carbon $date
|
||||
*/
|
||||
public function scopeBefore(Builder $query, Carbon $date)
|
||||
public function scopeBefore(EloquentBuilder $query, Carbon $date)
|
||||
{
|
||||
if (is_null($this->joinedJournals)) {
|
||||
$query->leftJoin(
|
||||
@ -66,28 +66,28 @@ class Transaction extends Eloquent
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder $query
|
||||
* @param EloquentBuilder $query
|
||||
* @param $amount
|
||||
*/
|
||||
public function scopeLessThan(Builder $query, $amount)
|
||||
public function scopeLessThan(EloquentBuilder $query, $amount)
|
||||
{
|
||||
$query->where('amount', '<', $amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder $query
|
||||
* @param EloquentBuilder $query
|
||||
* @param $amount
|
||||
*/
|
||||
public function scopeMoreThan(Builder $query, $amount)
|
||||
public function scopeMoreThan(EloquentBuilder $query, $amount)
|
||||
{
|
||||
$query->where('amount', '>', $amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder $query
|
||||
* @param EloquentBuilder $query
|
||||
* @param array $types
|
||||
*/
|
||||
public function scopeTransactionTypes(Builder $query, array $types)
|
||||
public function scopeTransactionTypes(EloquentBuilder $query, array $types)
|
||||
{
|
||||
if (is_null($this->joinedJournals)) {
|
||||
$query->leftJoin(
|
||||
|
@ -1,10 +1,11 @@
|
||||
<?php
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
/**
|
||||
* Class TransactionJournal
|
||||
@ -13,15 +14,23 @@ class TransactionJournal extends Eloquent
|
||||
{
|
||||
use SoftDeletingTrait, ValidatingTrait;
|
||||
|
||||
protected $fillable
|
||||
= ['transaction_type_id', 'transaction_currency_id', 'user_id',
|
||||
'description', 'date', 'completed'];
|
||||
protected $rules
|
||||
= ['transaction_type_id' => 'required|exists:transaction_types,id',
|
||||
'transaction_currency_id' => 'required|exists:transaction_currencies,id',
|
||||
'description' => 'required|between:1,255',
|
||||
'date' => 'required|date',
|
||||
'completed' => 'required|between:0,1'];
|
||||
protected $fillable
|
||||
= ['transaction_type_id', 'transaction_currency_id', 'user_id',
|
||||
'description', 'date', 'completed'];
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function bill()
|
||||
{
|
||||
return $this->belongsTo('Bill');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
@ -43,7 +52,6 @@ class TransactionJournal extends Eloquent
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* TODO remove this method in favour of something in the FireflyIII libraries.
|
||||
*
|
||||
@ -83,18 +91,10 @@ class TransactionJournal extends Eloquent
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
* @param EloquentBuilder $query
|
||||
* @param Account $account
|
||||
*/
|
||||
public function bill()
|
||||
{
|
||||
return $this->belongsTo('Bill');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder $query
|
||||
* @param Account $account
|
||||
*/
|
||||
public function scopeAccountIs($query, \Account $account)
|
||||
public function scopeAccountIs(EloquentBuilder $query, \Account $account)
|
||||
{
|
||||
if (!isset($this->joinedTransactions)) {
|
||||
$query->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id');
|
||||
@ -104,32 +104,32 @@ class TransactionJournal extends Eloquent
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $query
|
||||
* @param Carbon $date
|
||||
* @param EloquentBuilder $query
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function scopeAfter($query, Carbon $date)
|
||||
public function scopeAfter(EloquentBuilder $query, Carbon $date)
|
||||
{
|
||||
return $query->where('transaction_journals.date', '>=', $date->format('Y-m-d 00:00:00'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $query
|
||||
* @param Carbon $date
|
||||
* @param EloquentBuilder $query
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function scopeBefore($query, Carbon $date)
|
||||
public function scopeBefore(EloquentBuilder $query, Carbon $date)
|
||||
{
|
||||
return $query->where('transaction_journals.date', '<=', $date->format('Y-m-d 00:00:00'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder $query
|
||||
* @param $amount
|
||||
* @param EloquentBuilder $query
|
||||
* @param $amount
|
||||
*/
|
||||
public function scopeLessThan($query, $amount)
|
||||
public function scopeLessThan(EloquentBuilder $query, $amount)
|
||||
{
|
||||
if (is_null($this->joinedTransactions)) {
|
||||
$query->leftJoin(
|
||||
@ -142,10 +142,10 @@ class TransactionJournal extends Eloquent
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder $query
|
||||
* @param $amount
|
||||
* @param EloquentBuilder $query
|
||||
* @param $amount
|
||||
*/
|
||||
public function scopeMoreThan($query, $amount)
|
||||
public function scopeMoreThan(EloquentBuilder $query, $amount)
|
||||
{
|
||||
if (is_null($this->joinedTransactions)) {
|
||||
$query->leftJoin(
|
||||
@ -158,21 +158,21 @@ class TransactionJournal extends Eloquent
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $query
|
||||
* @param Carbon $date
|
||||
* @param EloquentBuilder $query
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function scopeOnDate($query, Carbon $date)
|
||||
public function scopeOnDate(EloquentBuilder $query, Carbon $date)
|
||||
{
|
||||
return $query->where('date', '=', $date->format('Y-m-d'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder $query
|
||||
* @param array $types
|
||||
* @param EloquentBuilder $query
|
||||
* @param array $types
|
||||
*/
|
||||
public function scopeTransactionTypes($query, array $types)
|
||||
public function scopeTransactionTypes(EloquentBuilder $query, array $types)
|
||||
{
|
||||
if (is_null($this->joinedTransactionTypes)) {
|
||||
$query->leftJoin(
|
||||
@ -187,14 +187,14 @@ class TransactionJournal extends Eloquent
|
||||
* Automatically includes the 'with' parameters to get relevant related
|
||||
* objects.
|
||||
*
|
||||
* @param $query
|
||||
* @param EloquentBuilder $query
|
||||
*/
|
||||
public function scopeWithRelevantData($query)
|
||||
public function scopeWithRelevantData(EloquentBuilder $query)
|
||||
{
|
||||
$query->with(
|
||||
['transactions' => function (HasMany $q) {
|
||||
['transactions' => function (HasMany $q) {
|
||||
$q->orderBy('amount', 'ASC');
|
||||
}, 'transactiontype', 'budgets','categories', 'transactions.account.accounttype', 'bill', 'budgets', 'categories']
|
||||
}, 'transactiontype', 'budgets', 'categories', 'transactions.account.accounttype', 'bill', 'budgets', 'categories']
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
@section('scripts')
|
||||
<script type="text/javascript">
|
||||
var what = '{{{$what}}}';
|
||||
var currencyCode = '{{getCurrencyCode()}}';
|
||||
var currencyCode = '{{Amount::getCurrencyCode()}}';
|
||||
</script>
|
||||
|
||||
<!-- load the libraries and scripts necessary for Google Charts: -->
|
||||
|
@ -52,7 +52,7 @@
|
||||
<script type="text/javascript">
|
||||
var accountID = {{{$account->id}}};
|
||||
var view = '{{{$range}}}';
|
||||
var currencyCode = '{{getCurrencyCode()}}';
|
||||
var currencyCode = '{{Amount::getCurrencyCode()}}';
|
||||
</script>
|
||||
<!-- load the libraries and scripts necessary for Google Charts: -->
|
||||
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
|
||||
|
@ -42,7 +42,7 @@
|
||||
@foreach(explode(',',$bill->match) as $word)
|
||||
<span class="label label-info">{{{$word}}}</span>
|
||||
@endforeach
|
||||
between {{mf($bill->amount_min)}} and {{mf($bill->amount_max)}}.
|
||||
between {{Amount::format($bill->amount_min)}} and {{Amount::format($bill->amount_max)}}.
|
||||
Repeats {{$bill->repeat_freq}}.</td>
|
||||
|
||||
</tr>
|
||||
@ -106,7 +106,7 @@
|
||||
@section('scripts')
|
||||
<script type="text/javascript">
|
||||
var billID = {{{$bill->id}}};
|
||||
var currencyCode = '{{getCurrencyCode()}}';
|
||||
var currencyCode = '{{Amount::getCurrencyCode()}}';
|
||||
</script>
|
||||
<!-- load the libraries and scripts necessary for Google Charts: -->
|
||||
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
|
||||
|
@ -10,11 +10,11 @@
|
||||
<div class="panel-body">
|
||||
<div class="row">
|
||||
<div class="col-lg-6 col-md-4 col-sm-3">
|
||||
<small>Budgeted: <span id="budgetedAmount" data-value="300">{{mf(300)}}</span></small>
|
||||
<small>Budgeted: <span id="budgetedAmount" data-value="300">{{Amount::format(300)}}</span></small>
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-4 col-sm-3" style="text-align:right;">
|
||||
<small>Income {{\Session::get('start', \Carbon\Carbon::now()->startOfMonth())->format('F Y')}}:
|
||||
<a href="#" class="updateIncome"><span id="totalAmount" data-value="{{$amount}}">{{mf($amount)}}</span></a></small>
|
||||
<a href="#" class="updateIncome"><span id="totalAmount" data-value="{{$amount}}">{{Amount::format($amount)}}</span></a></small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-6 col-md-4 col-sm-3">
|
||||
<small>Spent: {{mf($spent)}}</small>
|
||||
<small>Spent: {{Amount::format($spent)}}</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
@ -100,21 +100,21 @@
|
||||
<!-- budget-info-X holds the input and the euro-sign: -->
|
||||
<span id="budget-info-{{$budget->id}}">
|
||||
@if($budget->currentRep->amount > $budget->spent)
|
||||
<span class="text-success">{{getCurrencySymbol()}}</span> <input type="number" min="0" max="{{$budgetMaximum}}" data-id="{{$budget->id}}" step="1" value="{{$budget->currentRep->amount}}" style="width:90px;color:#3c763d;" />
|
||||
<span class="text-success">{{Amount::getCurrencySymbol()}}</span> <input type="number" min="0" max="{{$budgetMaximum}}" data-id="{{$budget->id}}" step="1" value="{{$budget->currentRep->amount}}" style="width:90px;color:#3c763d;" />
|
||||
@else
|
||||
<span class="text-danger">{{getCurrencySymbol()}}</span> <input type="number" min="0" max="{{$budgetMaximum}}" data-id="{{$budget->id}}" step="1" value="{{$budget->currentRep->amount}}" style="width:90px;color:#a94442;" />
|
||||
<span class="text-danger">{{Amount::getCurrencySymbol()}}</span> <input type="number" min="0" max="{{$budgetMaximum}}" data-id="{{$budget->id}}" step="1" value="{{$budget->currentRep->amount}}" style="width:90px;color:#a94442;" />
|
||||
@endif
|
||||
</span>
|
||||
@else
|
||||
<span id="budget-description-{{$budget->id}}"><em>No budget</em></span>
|
||||
<span id="budget-info-{{$budget->id}}">
|
||||
<span class="text-success" style="display:none;">{{getCurrencySymbol()}}</span> <input data-id="{{$budget->id}}" type="number" min="0" max="{{$budgetMaximum}}" step="1" value="0" style="width:50px;color:#3c763d;display:none;" />
|
||||
<span class="text-success" style="display:none;">{{Amount::getCurrencySymbol()}}</span> <input data-id="{{$budget->id}}" type="number" min="0" max="{{$budgetMaximum}}" step="1" value="0" style="width:50px;color:#3c763d;display:none;" />
|
||||
</span>
|
||||
@endif
|
||||
</span>
|
||||
</p>
|
||||
<p>
|
||||
<span id="spent-{{$budget->id}}" data-value="{{$budget->spent}}">Spent: {{mf($budget->spent)}}</span>
|
||||
<span id="spent-{{$budget->id}}" data-value="{{$budget->spent}}">Spent: {{Amount::format($budget->spent)}}</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -29,10 +29,10 @@
|
||||
<div class="panel-body">
|
||||
<div class="row">
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
Amount: {{mf($rep->amount)}}
|
||||
Amount: {{Amount::format($rep->amount)}}
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
Spent: {{mf($rep->spentInRepetition())}}
|
||||
Spent: {{Amount::format($rep->spentInRepetition())}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
@ -29,7 +29,7 @@
|
||||
@stop
|
||||
@section('scripts')
|
||||
<script type="text/javascript">
|
||||
var currencyCode = '{{getCurrencyCode()}}';
|
||||
var currencyCode = '{{Amount::getCurrencyCode()}}';
|
||||
</script>
|
||||
<!-- load the libraries and scripts necessary for Google Charts: -->
|
||||
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
|
||||
|
@ -32,7 +32,7 @@
|
||||
<script type="text/javascript">
|
||||
var componentID = {{$category->id}};
|
||||
var year = {{Session::get('start',\Carbon\Carbon::now()->startOfMonth())->format('Y')}};
|
||||
var currencyCode = '{{getCurrencyCode()}}';
|
||||
var currencyCode = '{{Amount::getCurrencyCode()}}';
|
||||
</script>
|
||||
<!-- load the libraries and scripts necessary for Google Charts: -->
|
||||
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
|
||||
|
@ -114,7 +114,7 @@
|
||||
@stop
|
||||
@section('scripts')
|
||||
<script type="text/javascript">
|
||||
var currencyCode = '{{getCurrencyCode()}}';
|
||||
var currencyCode = '{{Amount::getCurrencyCode()}}';
|
||||
</script>
|
||||
<!-- load the libraries and scripts necessary for Google Charts: -->
|
||||
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
|
||||
|
@ -17,7 +17,7 @@
|
||||
</td>
|
||||
<td><a href="{{route('accounts.show',$account->id)}}">{{{$account->name}}}</a></td>
|
||||
<td>{{{$account->accountRole}}}</td>
|
||||
<td>{{mf(Steam::balance($account))}}</td>
|
||||
<td>{{Amount::format(Steam::balance($account))}}</td>
|
||||
<td>
|
||||
@if($account->active)
|
||||
<i class="fa fa-fw fa-check"></i>
|
||||
|
@ -27,9 +27,9 @@
|
||||
@endforeach
|
||||
</td>
|
||||
<td>
|
||||
{{mf($entry->amount_min)}}
|
||||
{{Amount::format($entry->amount_min)}}
|
||||
—
|
||||
{{mf($entry->amount_max)}}
|
||||
{{Amount::format($entry->amount_max)}}
|
||||
</td>
|
||||
<td>
|
||||
<?php $lastMatch = $entry->lastFoundMatch();?>
|
||||
|
@ -58,13 +58,13 @@
|
||||
</td>
|
||||
<td>
|
||||
@if($journal->transactiontype->type == 'Withdrawal')
|
||||
<span class="text-danger">{{mft($journal->transactions[1],false)}}</span>
|
||||
<span class="text-danger">{{Amount::formatTransaction($journal->transactions[1],false)}}</span>
|
||||
@endif
|
||||
@if($journal->transactiontype->type == 'Deposit')
|
||||
<span class="text-success">{{mft($journal->transactions[1],false)}}</span>
|
||||
<span class="text-success">{{Amount::formatTransaction($journal->transactions[1],false)}}</span>
|
||||
@endif
|
||||
@if($journal->transactiontype->type == 'Transfer')
|
||||
<span class="text-info">{{mft($journal->transactions[1],false)}}</span>
|
||||
<span class="text-info">{{Amount::formatTransaction($journal->transactions[1],false)}}</span>
|
||||
@endif
|
||||
</td>
|
||||
<td>
|
||||
|
@ -9,13 +9,13 @@
|
||||
<td>
|
||||
<?php $tableSum += floatval($journal->transactions[1]->amount);?>
|
||||
@if($journal->transactiontype->type == 'Withdrawal')
|
||||
<span class="text-danger">{{mft($journal->transactions[1],false)}}</span>
|
||||
<span class="text-danger">{{Amount::formatTransaction($journal->transactions[1],false)}}</span>
|
||||
@endif
|
||||
@if($journal->transactiontype->type == 'Deposit')
|
||||
<span class="text-success">{{mft($journal->transactions[1],false)}}</span>
|
||||
<span class="text-success">{{Amount::formatTransaction($journal->transactions[1],false)}}</span>
|
||||
@endif
|
||||
@if($journal->transactiontype->type == 'Transfer')
|
||||
<span class="text-info">{{mft($journal->transactions[1],false)}}</span>
|
||||
<span class="text-info">{{Amount::formatTransaction($journal->transactions[1],false)}}</span>
|
||||
@endif
|
||||
</td>
|
||||
<td>
|
||||
@ -33,7 +33,7 @@
|
||||
@if(isset($displaySum) && $displaySum === true)
|
||||
<tr>
|
||||
<td><em>Sum</em></td>
|
||||
<td colspan="3">{{mf($tableSum)}}</td>
|
||||
<td colspan="3">{{Amount::format($tableSum)}}</td>
|
||||
|
||||
</tr>
|
||||
@endif
|
||||
|
@ -18,13 +18,13 @@
|
||||
@if(isset($account))
|
||||
@foreach($journal->transactions as $index => $t)
|
||||
@if($t->account_id == $account->id)
|
||||
{{mft($t)}}
|
||||
{{Amount::formatTransaction($t)}}
|
||||
@endif
|
||||
@endforeach
|
||||
@else
|
||||
@foreach($journal->transactions as $index => $t)
|
||||
@if($index == 0)
|
||||
{{mft($t)}}
|
||||
{{Amount::formatTransaction($t)}}
|
||||
@endif
|
||||
@endforeach
|
||||
@endif
|
||||
|
@ -23,9 +23,9 @@
|
||||
|
||||
<td>
|
||||
@if($event->amount < 0)
|
||||
<span class="text-danger">Removed {{mf($event->amount*-1,false)}}</span>
|
||||
<span class="text-danger">Removed {{Amount::format($event->amount*-1,false)}}</span>
|
||||
@else
|
||||
<span class="text-success">Added {{mf($event->amount,false)}}</span>
|
||||
<span class="text-success">Added {{Amount::format($event->amount,false)}}</span>
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -8,7 +8,7 @@
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>
|
||||
The maximum amount you can add is {{mf($maxAmount)}}
|
||||
The maximum amount you can add is {{Amount::format($maxAmount)}}
|
||||
</p>
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon">€</div>
|
||||
|
@ -50,7 +50,7 @@
|
||||
</div>
|
||||
<!-- One block -->
|
||||
<div class="col-lg-1 col-md-4 col-sm-4 col-xs-4">
|
||||
{{mf($piggyBank->savedSoFar,true)}}
|
||||
{{Amount::format($piggyBank->savedSoFar,true)}}
|
||||
</div>
|
||||
<!-- One block -->
|
||||
<div class="col-lg-7 col-md-12 col-sm-12 col-xs-12">
|
||||
@ -68,12 +68,12 @@
|
||||
</div>
|
||||
<!-- One block -->
|
||||
<div class="col-lg-1 col-md-6 col-sm-6 col-xs-6">
|
||||
{{mf($piggyBank->targetamount,true)}}
|
||||
{{Amount::format($piggyBank->targetamount,true)}}
|
||||
</div>
|
||||
<!-- One block -->
|
||||
<div class="col-lg-1 col-md-6 col-sm-6 col-xs-6">
|
||||
@if($piggyBank->leftToSave > 0)
|
||||
{{mf($piggyBank->leftToSave)}}
|
||||
{{Amount::format($piggyBank->leftToSave)}}
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
@ -109,11 +109,11 @@
|
||||
@foreach($accounts as $id => $info)
|
||||
<tr>
|
||||
<td><a href="{{route('accounts.show',$id)}}">{{{$info['name']}}}</a></td>
|
||||
<td>{{mf($info['balance'])}}</td>
|
||||
<td>{{mf($info['leftForPiggyBanks'])}}</td>
|
||||
<td>{{mf($info['sumOfTargets'])}}</td>
|
||||
<td>{{mf($info['sumOfSaved'])}}</td>
|
||||
<td>{{mf($info['leftToSave'])}}</td>
|
||||
<td>{{Amount::format($info['balance'])}}</td>
|
||||
<td>{{Amount::format($info['leftForPiggyBanks'])}}</td>
|
||||
<td>{{Amount::format($info['sumOfTargets'])}}</td>
|
||||
<td>{{Amount::format($info['sumOfSaved'])}}</td>
|
||||
<td>{{Amount::format($info['leftToSave'])}}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</table>
|
||||
|
@ -8,7 +8,7 @@
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>
|
||||
The maximum amount you can remove is {{mf($piggyBank->currentRelevantRep()->currentamount)}}
|
||||
The maximum amount you can remove is {{Amount::format($piggyBank->currentRelevantRep()->currentamount)}}
|
||||
</p>
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon">€</div>
|
||||
|
@ -40,15 +40,15 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Target amount</td>
|
||||
<td>{{mf($piggyBank->targetamount)}}</td>
|
||||
<td>{{Amount::format($piggyBank->targetamount)}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Saved so far</td>
|
||||
<td>{{mf($piggyBank->currentRelevantRep()->currentamount)}}</td>
|
||||
<td>{{Amount::format($piggyBank->currentRelevantRep()->currentamount)}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Left to save</td>
|
||||
<td>{{mf($piggyBank->targetamount-$piggyBank->currentRelevantRep()->currentamount)}}</td>
|
||||
<td>{{Amount::format($piggyBank->targetamount-$piggyBank->currentRelevantRep()->currentamount)}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Start date</td>
|
||||
@ -95,7 +95,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Expected amount per reminder</td>
|
||||
<td>{{mf($amountPerReminder)}}</td>
|
||||
<td>{{Amount::format($amountPerReminder)}}</td>
|
||||
</tr>
|
||||
@endif
|
||||
</table>
|
||||
|
@ -14,8 +14,8 @@
|
||||
<p>
|
||||
@if(get_class($reminder->remindersable) == 'Piggybank')
|
||||
Somewhere between {{$reminder->startdate->format('j F Y')}} and {{$reminder->enddate->format('j F Y')}} you
|
||||
should deposit {{mf($amount)}} in piggy bank <a href="{{route('piggy_banks.show',$reminder->remindersable_id)}}">{{{$reminder->remindersable->name}}}</a>
|
||||
in order to make your goal of saving {{mf($reminder->remindersable->targetamount)}} on {{$reminder->remindersable->targetdate->format('j F Y')}}
|
||||
should deposit {{Amount::format($amount)}} in piggy bank <a href="{{route('piggy_banks.show',$reminder->remindersable_id)}}">{{{$reminder->remindersable->name}}}</a>
|
||||
in order to make your goal of saving {{Amount::format($reminder->remindersable->targetamount)}} on {{$reminder->remindersable->targetdate->format('j F Y')}}
|
||||
|
||||
@endif
|
||||
</p>
|
||||
|
@ -17,7 +17,7 @@
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<a href="{{route('repeated.show',$entry->id)}}" title="{{{$entry->name}}}">{{{$entry->name}}}</a>
|
||||
({{mf($entry->targetamount)}})
|
||||
({{Amount::format($entry->targetamount)}})
|
||||
|
||||
<!-- ACTIONS MENU -->
|
||||
<div class="pull-right">
|
||||
@ -37,11 +37,11 @@
|
||||
<div class="progress progress-striped">
|
||||
<div class="progress-bar" role="progressbar" aria-valuenow="{{Steam::percentage($entry,$entry->currentRep)}}" aria-valuemin="0" aria-valuemax="100" style="width: {{Steam::percentage($entry,$entry->currentRep)}}%; min-width:15px;">
|
||||
@if(Steam::percentage($entry,$entry->currentRep) > 30)
|
||||
{{mf($entry->currentRep->currentamount,false)}}
|
||||
{{Amount::format($entry->currentRep->currentamount,false)}}
|
||||
@endif
|
||||
</div>
|
||||
@if(Steam::percentage($entry,$entry->currentRep) <= 30)
|
||||
<small>{{mf($entry->currentRep->currentamount,false)}}</small>
|
||||
<small>{{Amount::format($entry->currentRep->currentamount,false)}}</small>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
@ -21,7 +21,7 @@
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<p>
|
||||
Target amount: {{mf($repeatedExpense->targetamount)}}. Currently saved: {{mf($rep->currentamount)}}.
|
||||
Target amount: {{Amount::format($repeatedExpense->targetamount)}}. Currently saved: {{Amount::format($rep->currentamount)}}.
|
||||
</p>
|
||||
<div class="row">
|
||||
@foreach($rep->bars as $bar)
|
||||
@ -41,7 +41,7 @@
|
||||
@endif
|
||||
@endif
|
||||
@if($bar->percentage() > 50 && $bar->percentage() < 100)
|
||||
{{mf($rep->currentamount,false)}}
|
||||
{{Amount::format($rep->currentamount,false)}}
|
||||
@endif
|
||||
</div>
|
||||
<div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="{{100-$bar->percentage()}}" aria-valuemin="0" aria-valuemax="100" style="width: {{100-$bar->percentage()}}%;"></div>
|
||||
|
@ -13,9 +13,9 @@
|
||||
@foreach($accounts as $account)
|
||||
<tr>
|
||||
<td><a href="{{route('accounts.show',$account->id)}}">{{{$account->name}}}</a></td>
|
||||
<td>{{mf($account->startBalance)}}</td>
|
||||
<td>{{mf($account->endBalance)}}</td>
|
||||
<td>{{mf($account->startBalance - $account->endBalance,false)}}</td>
|
||||
<td>{{Amount::format($account->startBalance)}}</td>
|
||||
<td>{{Amount::format($account->endBalance)}}</td>
|
||||
<td>{{Amount::format($account->startBalance - $account->endBalance,false)}}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</table>
|
||||
@ -47,15 +47,15 @@
|
||||
<i class="fa fa-fw fa-question-circle" data-toggle="tooltip" data-placement="top" title="The calculation used here is slightly different from the row below. The numbers should match."></i>
|
||||
@endif
|
||||
</td>
|
||||
<td>{{mf($budget['amount'])}}</td>
|
||||
<td>{{Amount::format($budget['amount'])}}</td>
|
||||
<?php $spent = 0;?>
|
||||
@foreach($accounts as $account)
|
||||
@if(isset($account->budgetInformation[$id]))
|
||||
<td>
|
||||
@if($id == 0)
|
||||
<a href="#">{{mf($account->budgetInformation[$id]['amount'])}}</a>
|
||||
<a href="#">{{Amount::format($account->budgetInformation[$id]['amount'])}}</a>
|
||||
@else
|
||||
{{mf($account->budgetInformation[$id]['amount'])}}
|
||||
{{Amount::format($account->budgetInformation[$id]['amount'])}}
|
||||
@endif
|
||||
</td>
|
||||
<?php
|
||||
@ -63,11 +63,11 @@
|
||||
$accountSums[$account->id] += floatval($account->budgetInformation[$id]['amount']);
|
||||
?>
|
||||
@else
|
||||
<td>{{mf(0)}}</td>
|
||||
<td>{{Amount::format(0)}}</td>
|
||||
@endif
|
||||
@endforeach
|
||||
<td>{{mf($budget['amount'] + $budget['spent'])}}</td>
|
||||
<td>{{mf($budget['amount'] + $spent)}}</td>
|
||||
<td>{{Amount::format($budget['amount'] + $budget['spent'])}}</td>
|
||||
<td>{{Amount::format($budget['amount'] + $spent)}}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
<tr>
|
||||
@ -77,10 +77,10 @@
|
||||
@foreach($accounts as $account)
|
||||
@if(isset($account->budgetInformation[0]))
|
||||
<td>
|
||||
<a href="#">{{mf($account->budgetInformation[0]['amount'])}}</a>
|
||||
<a href="#">{{Amount::format($account->budgetInformation[0]['amount'])}}</a>
|
||||
</td>
|
||||
@else
|
||||
<td>{{mf(0)}}</td>
|
||||
<td>{{Amount::format(0)}}</td>
|
||||
@endif
|
||||
@endforeach
|
||||
<td colspan="2"> </td>
|
||||
@ -89,7 +89,7 @@
|
||||
<td colspan="2">Balanced by transfers</td>
|
||||
@foreach($accounts as $account)
|
||||
<td>
|
||||
<a href="#">{{mf($account->balancedAmount)}}</a>
|
||||
<a href="#">{{Amount::format($account->balancedAmount)}}</a>
|
||||
</td>
|
||||
@endforeach
|
||||
<td colspan="2"> </td>
|
||||
@ -98,14 +98,14 @@
|
||||
<tr>
|
||||
<td colspan="2">Balancing transfers</td>
|
||||
@foreach($accounts as $account)
|
||||
<td>{{mf(0)}}</td>
|
||||
<td>{{Amount::format(0)}}</td>
|
||||
@endforeach
|
||||
<td colspan="2"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">Income</td>
|
||||
@foreach($accounts as $account)
|
||||
<td>{{mf(0)}}</td>
|
||||
<td>{{Amount::format(0)}}</td>
|
||||
@endforeach
|
||||
<td colspan="2"> </td>
|
||||
</tr>
|
||||
@ -118,10 +118,10 @@
|
||||
?>
|
||||
@if(isset($account->budgetInformation[0]))
|
||||
<td>
|
||||
<a href="#">{{mf($account->budgetInformation[0]['amount'] + $account->balancedAmount)}}</a>
|
||||
<a href="#">{{Amount::format($account->budgetInformation[0]['amount'] + $account->balancedAmount)}}</a>
|
||||
</td>
|
||||
@else
|
||||
<td>{{mf(0)}}</td>
|
||||
<td>{{Amount::format(0)}}</td>
|
||||
@endif
|
||||
@endforeach
|
||||
<td colspan="2"> </td>
|
||||
@ -129,14 +129,14 @@
|
||||
<tr>
|
||||
<td colspan="2"><em>Sum</em></td>
|
||||
@foreach($accounts as $account)
|
||||
<td>{{mf($accountSums[$account->id])}}</td>
|
||||
<td>{{Amount::format($accountSums[$account->id])}}</td>
|
||||
@endforeach
|
||||
<td colspan="2"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">Expected balance</td>
|
||||
@foreach($accounts as $account)
|
||||
<td>{{mf($account->startBalance + $accountSums[$account->id])}}</td>
|
||||
<td>{{Amount::format($account->startBalance + $accountSums[$account->id])}}</td>
|
||||
@endforeach
|
||||
<td colspan="2"> </td>
|
||||
</tr>
|
||||
|
@ -21,12 +21,12 @@
|
||||
@else
|
||||
<td><em>{{{$expense['name']}}}</em></td>
|
||||
@endif
|
||||
<td>{{mf($expense['amount'])}}</td>
|
||||
<td>{{Amount::format($expense['amount'])}}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
<tr>
|
||||
<td><em>Sum</em></td>
|
||||
<td>{{mf($sum)}}</td>
|
||||
<td>{{Amount::format($sum)}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
@ -43,15 +43,15 @@
|
||||
<table class="table table-bordered">
|
||||
<tr>
|
||||
<td>In</td>
|
||||
<td>{{mf($in)}}</td>
|
||||
<td>{{Amount::format($in)}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Out</td>
|
||||
<td>{{mf($sum)}}</td>
|
||||
<td>{{Amount::format($sum)}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Difference</td>
|
||||
<td>{{mf($in - $sum)}}</td>
|
||||
<td>{{Amount::format($in - $sum)}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
@ -87,16 +87,16 @@
|
||||
<em>{{{$budget['name']}}}</em>
|
||||
@endif
|
||||
</td>
|
||||
<td>{{mf($budget['amount'])}}</td>
|
||||
<td>{{mf($budget['spent'],false)}}</td>
|
||||
<td>{{mf($budget['amount'] + $budget['spent'])}}</td>
|
||||
<td>{{Amount::format($budget['amount'])}}</td>
|
||||
<td>{{Amount::format($budget['spent'],false)}}</td>
|
||||
<td>{{Amount::format($budget['amount'] + $budget['spent'])}}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
<tr>
|
||||
<td><em>Sum</em></td>
|
||||
<td>{{mf($sumEnvelope)}}</td>
|
||||
<td>{{mf($sumSpent)}}</td>
|
||||
<td>{{mf($sumLeft)}}</td>
|
||||
<td>{{Amount::format($sumEnvelope)}}</td>
|
||||
<td>{{Amount::format($sumSpent)}}</td>
|
||||
<td>{{Amount::format($sumLeft)}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
@ -120,12 +120,12 @@
|
||||
<em>{{{$category['name']}}}</em>
|
||||
@endif
|
||||
</td>
|
||||
<td>{{mf($category['amount'],false)}}</td>
|
||||
<td>{{Amount::format($category['amount'],false)}}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
<tr>
|
||||
<td><em>Sum</em></td>
|
||||
<td>{{mf($sum)}}</td>
|
||||
<td>{{Amount::format($sum)}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
@ -149,16 +149,16 @@
|
||||
?>
|
||||
<tr>
|
||||
<td><a href="{{route('accounts.show',$id)}}">{{{$account['name']}}}</a></td>
|
||||
<td>{{mf($account['startBalance'])}}</td>
|
||||
<td>{{mf($account['endBalance'])}}</td>
|
||||
<td>{{mf($account['difference'])}}</td>
|
||||
<td>{{Amount::format($account['startBalance'])}}</td>
|
||||
<td>{{Amount::format($account['endBalance'])}}</td>
|
||||
<td>{{Amount::format($account['difference'])}}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
<tr>
|
||||
<td><em>Sum</em></td>
|
||||
<td>{{mf($sumStart)}}</td>
|
||||
<td>{{mf($sumEnd)}}</td>
|
||||
<td>{{mf($sumDiff)}}</td>
|
||||
<td>{{Amount::format($sumStart)}}</td>
|
||||
<td>{{Amount::format($sumEnd)}}</td>
|
||||
<td>{{Amount::format($sumDiff)}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
@ -49,16 +49,16 @@
|
||||
<small><em>shared</em></small>
|
||||
@endif
|
||||
</td>
|
||||
<td>{{mf($balance['start'])}}</td>
|
||||
<td>{{mf($balance['end'])}}</td>
|
||||
<td>{{mf($balance['end']-$balance['start'])}}</td>
|
||||
<td>{{Amount::format($balance['start'])}}</td>
|
||||
<td>{{Amount::format($balance['end'])}}</td>
|
||||
<td>{{Amount::format($balance['end']-$balance['start'])}}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
<tr>
|
||||
<td><em>Sum of sums</em></td>
|
||||
<td>{{mf($start)}}</td>
|
||||
<td>{{mf($end)}}</td>
|
||||
<td>{{mf($diff)}}</td>
|
||||
<td>{{Amount::format($start)}}</td>
|
||||
<td>{{Amount::format($end)}}</td>
|
||||
<td>{{Amount::format($diff)}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
@ -83,15 +83,15 @@
|
||||
<table class="table table-bordered table-striped">
|
||||
<tr>
|
||||
<td>In</td>
|
||||
<td>{{mf($incomeSum)}}</td>
|
||||
<td>{{Amount::format($incomeSum)}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Out</td>
|
||||
<td>{{mf($expenseSum*-1)}}</td>
|
||||
<td>{{Amount::format($expenseSum*-1)}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Difference</td>
|
||||
<td>{{mf($incomeSum - $expenseSum)}}</td>
|
||||
<td>{{Amount::format($incomeSum - $expenseSum)}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
@ -107,12 +107,12 @@
|
||||
<?php $sum += floatval($income->sum)*-1;?>
|
||||
<tr>
|
||||
<td><a href="{{route('accounts.show',$income->account_id)}}">{{{$income->name}}}</a></td>
|
||||
<td>{{mf(floatval($income->sum)*-1)}}</td>
|
||||
<td>{{Amount::format(floatval($income->sum)*-1)}}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
<tr>
|
||||
<td><em>Sum</em></td>
|
||||
<td>{{mf($sum)}}</td>
|
||||
<td>{{Amount::format($sum)}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
@ -126,7 +126,7 @@
|
||||
@foreach($groupedExpenses as $id => $expense)
|
||||
<tr>
|
||||
<td><a href="{{route('accounts.show',$id)}}">{{{$expense['name']}}}</a></td>
|
||||
<td>{{mf(floatval($expense['amount'])*-1)}}</td>
|
||||
<td>{{Amount::format(floatval($expense['amount'])*-1)}}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</table>
|
||||
@ -156,7 +156,7 @@
|
||||
|
||||
<script type="text/javascript">
|
||||
var year = '{{$year}}';
|
||||
var currencyCode = '{{getCurrencyCode()}}';
|
||||
var currencyCode = '{{Amount::getCurrencyCode()}}';
|
||||
</script>
|
||||
|
||||
{{HTML::script('assets/javascript/firefly/reports.js')}}
|
||||
|
@ -74,7 +74,7 @@
|
||||
<tr>
|
||||
<td><input type="checkbox" checked="checked" data-relatedto="{{$journal->id}}" data-id="{{$jrnl->id}}" class="unrelate-checkbox" /></td>
|
||||
<td><a href="#">{{{$jrnl->description}}}</a></td>
|
||||
<td>{{mfj($jrnl, $jrnl->getAmount())}}</td>
|
||||
<td>{{Amount::formatJournal($jrnl, $jrnl->getAmount())}}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</table>
|
||||
@ -97,11 +97,11 @@
|
||||
<table class="table table-striped table-bordered">
|
||||
<tr>
|
||||
<td>Amount</td>
|
||||
<td>{{mft($t)}}</td>
|
||||
<td>{{Amount::formatTransaction($t)}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>New balance</td>
|
||||
<td>{{mf($t->before)}} → {{mf($t->after)}}</td>
|
||||
<td>{{Amount::format($t->before)}} → {{Amount::format($t->after)}}</td>
|
||||
</tr>
|
||||
@if(!is_null($t->description))
|
||||
<tr>
|
||||
|
@ -1,166 +1 @@
|
||||
<?php
|
||||
if (!function_exists('mf')) {
|
||||
/**
|
||||
* @param $amount
|
||||
* @param bool $coloured
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function mf($amount, $coloured = true)
|
||||
{
|
||||
$currencySymbol = getCurrencySymbol();
|
||||
|
||||
return mfc($currencySymbol, $amount, $coloured);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('mft')) {
|
||||
/**
|
||||
* @param \Transaction $transaction
|
||||
* @param bool $coloured
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function mft(\Transaction $transaction, $coloured = true)
|
||||
{
|
||||
$symbol = $transaction->transactionJournal->transactionCurrency->symbol;
|
||||
$amount = floatval($transaction->amount);
|
||||
|
||||
return mfc($symbol, $amount, $coloured);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('mfj')) {
|
||||
/**
|
||||
* @param \TransactionJournal $journal
|
||||
* @param float $amount
|
||||
* @param bool $coloured
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function mfj(\TransactionJournal $journal, $amount, $coloured = true)
|
||||
{
|
||||
$symbol = $journal->transactionCurrency->symbol;
|
||||
|
||||
return mfc($symbol, $amount, $coloured);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('mfc')) {
|
||||
/**
|
||||
* @param string $symbol
|
||||
* @param float $amount
|
||||
* @param bool $coloured
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function mfc($symbol, $amount, $coloured = true)
|
||||
{
|
||||
$amount = floatval($amount);
|
||||
$amount = round($amount, 2);
|
||||
$string = number_format($amount, 2, ',', '.');
|
||||
|
||||
if ($coloured === true) {
|
||||
if ($amount === 0.0) {
|
||||
return '<span style="color:#999">' . $symbol . ' ' . $string . '</span>';
|
||||
}
|
||||
if ($amount > 0) {
|
||||
return '<span class="text-success">' . $symbol . ' ' . $string . '</span>';
|
||||
}
|
||||
|
||||
return '<span class="text-danger">' . $symbol . ' ' . $string . '</span>';
|
||||
}
|
||||
|
||||
// €
|
||||
return $symbol . ' ' . $string;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('getCurrencySymbol')) {
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function getCurrencySymbol()
|
||||
{
|
||||
if (defined('FFCURRENCYSYMBOL')) {
|
||||
return FFCURRENCYSYMBOL;
|
||||
}
|
||||
if (Cache::has('FFCURRENCYSYMBOL')) {
|
||||
define('FFCURRENCYSYMBOL', Cache::get('FFCURRENCYSYMBOL'));
|
||||
|
||||
return FFCURRENCYSYMBOL;
|
||||
}
|
||||
|
||||
/** @var \FireflyIII\Database\TransactionCurrency\TransactionCurrency $currencies */
|
||||
$currencies = App::make('FireflyIII\Database\TransactionCurrency\TransactionCurrency');
|
||||
|
||||
/** @var \FireflyIII\Shared\Preferences\Preferences $preferences */
|
||||
$preferences = App::make('FireflyIII\Shared\Preferences\Preferences');
|
||||
|
||||
$currencyPreference = $preferences->get('currencyPreference', 'EUR');
|
||||
$currency = $currencies->findByCode($currencyPreference->data);
|
||||
|
||||
Cache::forever('FFCURRENCYSYMBOL', $currency->symbol);
|
||||
|
||||
define('FFCURRENCYSYMBOL', $currency->symbol);
|
||||
|
||||
return $currency->symbol;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('getCurrencyCode')) {
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function getCurrencyCode()
|
||||
{
|
||||
if (defined('FFCURRENCYCODE')) {
|
||||
return FFCURRENCYCODE;
|
||||
}
|
||||
if (Cache::has('FFCURRENCYCODE')) {
|
||||
define('FFCURRENCYCODE', Cache::get('FFCURRENCYCODE'));
|
||||
|
||||
return FFCURRENCYCODE;
|
||||
}
|
||||
|
||||
/** @var \FireflyIII\Database\TransactionCurrency\TransactionCurrency $currencies */
|
||||
$currencies = App::make('FireflyIII\Database\TransactionCurrency\TransactionCurrency');
|
||||
|
||||
/** @var \FireflyIII\Shared\Preferences\Preferences $preferences */
|
||||
$preferences = App::make('FireflyIII\Shared\Preferences\Preferences');
|
||||
|
||||
$currencyPreference = $preferences->get('currencyPreference', 'EUR');
|
||||
$currency = $currencies->findByCode($currencyPreference->data);
|
||||
|
||||
Cache::forever('FFCURRENCYCODE', $currency->code);
|
||||
|
||||
define('FFCURRENCYCODE', $currency->code);
|
||||
|
||||
return $currency->code;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('boolstr')) {
|
||||
/**
|
||||
* @param $boolean
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function boolstr($boolean)
|
||||
{
|
||||
if (is_bool($boolean) && $boolean === true) {
|
||||
return 'BOOLEAN TRUE';
|
||||
}
|
||||
if (is_bool($boolean) && $boolean === false) {
|
||||
return 'BOOLEAN FALSE';
|
||||
}
|
||||
|
||||
return 'NO BOOLEAN: ' . $boolean;
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ class ReminderControllerCest
|
||||
['reminders.*']
|
||||
);
|
||||
|
||||
$I->wantTo('act on reminder ' . boolstr(is_null($reminder)));
|
||||
$I->wantTo('act on a reminder');
|
||||
$I->amOnPage('/reminders/' . $reminder->id . '/act');
|
||||
$I->see('Money for Nieuwe spullen');
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user