Merge branch 'release/3.4.4'

This commit is contained in:
James Cole
2015-06-07 18:24:40 +02:00
147 changed files with 4054 additions and 2068 deletions

View File

@@ -2,4 +2,4 @@
tools: tools:
external_code_coverage: external_code_coverage:
timeout: 1800 # Timeout in seconds. timeout: 1800 # Timeout in seconds.
runs: 2 runs: 2

View File

@@ -19,4 +19,4 @@ after_script:
- CODECLIMATE_REPO_TOKEN=26489f9e854fcdf7e7660ba29c1455694685465b1f90329a79f7d2bf448acb61 ./vendor/bin/test-reporter --stdout > codeclimate.json - CODECLIMATE_REPO_TOKEN=26489f9e854fcdf7e7660ba29c1455694685465b1f90329a79f7d2bf448acb61 ./vendor/bin/test-reporter --stdout > codeclimate.json
- "curl -X POST -d @codeclimate.json -H 'Content-Type: application/json' -H 'User-Agent: Code Climate (PHP Test Reporter v0.1.1)' https://codeclimate.com/test_reports" - "curl -X POST -d @codeclimate.json -H 'Content-Type: application/json' -H 'User-Agent: Code Climate (PHP Test Reporter v0.1.1)' https://codeclimate.com/test_reports"
- wget https://scrutinizer-ci.com/ocular.phar - wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml - php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml

View File

@@ -1,4 +1,4 @@
# Firefly III (v3.4.3) # Firefly III (v3.4.4)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/JC5/firefly-iii/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/JC5/firefly-iii/?branch=master) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/JC5/firefly-iii/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/JC5/firefly-iii/?branch=master)
[![Code Coverage](https://scrutinizer-ci.com/g/JC5/firefly-iii/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/JC5/firefly-iii/?branch=master) [![Code Coverage](https://scrutinizer-ci.com/g/JC5/firefly-iii/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/JC5/firefly-iii/?branch=master)

View File

@@ -4,7 +4,6 @@ use Auth;
use FireflyIII\Events\JournalCreated; use FireflyIII\Events\JournalCreated;
use FireflyIII\Models\PiggyBank; use FireflyIII\Models\PiggyBank;
use FireflyIII\Models\PiggyBankEvent; use FireflyIII\Models\PiggyBankEvent;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
/** /**
@@ -53,17 +52,9 @@ class ConnectJournalToPiggyBank
return false; return false;
} }
$amount = $journal->amount; $amount = $journal->correct_amount;
/** @var Transaction $transaction */ bcscale(2);
foreach ($journal->transactions()->get() as $transaction) { $repetition->currentamount = bcadd($repetition->currentamount, $amount);
if ($transaction->account_id == $piggyBank->account_id) {
if ($transaction->amount < 0) {
$amount = $transaction->amount * -1;
}
}
}
$repetition->currentamount += $amount;
$repetition->save(); $repetition->save();
PiggyBankEvent::create(['piggy_bank_id' => $piggyBank->id, 'transaction_journal_id' => $journal->id, 'date' => $journal->date, 'amount' => $amount]); PiggyBankEvent::create(['piggy_bank_id' => $piggyBank->id, 'transaction_journal_id' => $journal->id, 'date' => $journal->date, 'amount' => $amount]);

View File

@@ -64,6 +64,7 @@ class BalanceLine
if ($this->getRole() == self::ROLE_DIFFROLE) { if ($this->getRole() == self::ROLE_DIFFROLE) {
return trans('firefly.leftUnbalanced'); return trans('firefly.leftUnbalanced');
} }
return ''; return '';
} }

View File

@@ -41,7 +41,7 @@ class Bill
public function getBills() public function getBills()
{ {
$this->bills->sortBy( $this->bills->sortBy(
function(BillLine $bill) { function (BillLine $bill) {
$active = intval($bill->getBill()->active) == 0 ? 1 : 0; $active = intval($bill->getBill()->active) == 0 ? 1 : 0;
$name = $bill->getBill()->name; $name = $bill->getBill()->name;

View File

@@ -55,7 +55,7 @@ class Category
public function getCategories() public function getCategories()
{ {
$this->categories->sortByDesc( $this->categories->sortByDesc(
function(CategoryModel $category) { function (CategoryModel $category) {
return $category->spent; return $category->spent;
} }
); );

View File

@@ -67,7 +67,7 @@ class Expense
public function getExpenses() public function getExpenses()
{ {
$this->expenses->sortByDesc( $this->expenses->sortByDesc(
function(stdClass $object) { function (stdClass $object) {
return $object->amount; return $object->amount;
} }
); );

View File

@@ -68,7 +68,7 @@ class Income
public function getIncomes() public function getIncomes()
{ {
$this->incomes->sortByDesc( $this->incomes->sortByDesc(
function(stdClass $object) { function (stdClass $object) {
return $object->amount; return $object->amount;
} }
); );

View File

@@ -66,10 +66,11 @@ class ReportHelper implements ReportHelperInterface
// remove cash account, if any: // remove cash account, if any:
$accounts = $accounts->filter( $accounts = $accounts->filter(
function(Account $account) { function (Account $account) {
if ($account->accountType->type != 'Cash account') { if ($account->accountType->type != 'Cash account') {
return $account; return $account;
} }
return null; return null;
} }
); );

View File

@@ -5,9 +5,9 @@ namespace FireflyIII\Helpers\Report;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Helpers\Collection\Account as AccountCollection; use FireflyIII\Helpers\Collection\Account as AccountCollection;
use FireflyIII\Helpers\Collection\Balance; use FireflyIII\Helpers\Collection\Balance;
use FireflyIII\Helpers\Collection\Bill as BillCollection;
use FireflyIII\Helpers\Collection\Budget as BudgetCollection; use FireflyIII\Helpers\Collection\Budget as BudgetCollection;
use FireflyIII\Helpers\Collection\Category as CategoryCollection; use FireflyIII\Helpers\Collection\Category as CategoryCollection;
use FireflyIII\Helpers\Collection\Bill as BillCollection;
use FireflyIII\Helpers\Collection\Expense; use FireflyIII\Helpers\Collection\Expense;
use FireflyIII\Helpers\Collection\Income; use FireflyIII\Helpers\Collection\Income;

View File

@@ -35,15 +35,15 @@ class ReportQuery implements ReportQueryInterface
$query = $this->queryJournalsWithTransactions($start, $end); $query = $this->queryJournalsWithTransactions($start, $end);
if ($includeShared === false) { if ($includeShared === false) {
$query->where( $query->where(
function(Builder $query) { function (Builder $query) {
$query->where( $query->where(
function(Builder $q) { // only get withdrawals not from a shared account function (Builder $q) { // only get withdrawals not from a shared account
$q->where('transaction_types.type', 'Withdrawal'); $q->where('transaction_types.type', 'Withdrawal');
$q->where('acm_from.data', '!=', '"sharedAsset"'); $q->where('acm_from.data', '!=', '"sharedAsset"');
} }
); );
$query->orWhere( $query->orWhere(
function(Builder $q) { // and transfers from a shared account. function (Builder $q) { // and transfers from a shared account.
$q->where('transaction_types.type', 'Transfer'); $q->where('transaction_types.type', 'Transfer');
$q->where('acm_to.data', '=', '"sharedAsset"'); $q->where('acm_to.data', '=', '"sharedAsset"');
} }
@@ -61,17 +61,18 @@ class ReportQuery implements ReportQueryInterface
); );
$data->each( $data->each(
function(TransactionJournal $journal) { function (TransactionJournal $journal) {
if (intval($journal->account_encrypted) == 1) { if (intval($journal->account_encrypted) == 1) {
$journal->name = Crypt::decrypt($journal->name); $journal->name = Crypt::decrypt($journal->name);
} }
} }
); );
$data = $data->filter( $data = $data->filter(
function(TransactionJournal $journal) { function (TransactionJournal $journal) {
if ($journal->amount != 0) { if ($journal->amount != 0) {
return $journal; return $journal;
} }
return null; return null;
} }
); );
@@ -91,26 +92,26 @@ class ReportQuery implements ReportQueryInterface
public function getAllAccounts(Carbon $start, Carbon $end, $includeShared = false) public function getAllAccounts(Carbon $start, Carbon $end, $includeShared = false)
{ {
$query = Auth::user()->accounts()->orderBy('accounts.name', 'ASC') $query = Auth::user()->accounts()->orderBy('accounts.name', 'ASC')
->accountTypeIn(['Default account', 'Asset account', 'Cash account']); ->accountTypeIn(['Default account', 'Asset account', 'Cash account']);
if ($includeShared === false) { if ($includeShared === false) {
$query->leftJoin( $query->leftJoin(
'account_meta', function(JoinClause $join) { 'account_meta', function (JoinClause $join) {
$join->on('account_meta.account_id', '=', 'accounts.id')->where('account_meta.name', '=', 'accountRole'); $join->on('account_meta.account_id', '=', 'accounts.id')->where('account_meta.name', '=', 'accountRole');
} }
) )
->orderBy('accounts.name', 'ASC') ->orderBy('accounts.name', 'ASC')
->where( ->where(
function(Builder $query) { function (Builder $query) {
$query->where('account_meta.data', '!=', '"sharedAsset"'); $query->where('account_meta.data', '!=', '"sharedAsset"');
$query->orWhereNull('account_meta.data'); $query->orWhereNull('account_meta.data');
} }
); );
} }
$set = $query->get(['accounts.*']); $set = $query->get(['accounts.*']);
$set->each( $set->each(
function(Account $account) use ($start, $end) { function (Account $account) use ($start, $end) {
/** /**
* The balance for today always incorporates transactions * The balance for today always incorporates transactions
* made on today. So to get todays "start" balance, we sub one * made on today. So to get todays "start" balance, we sub one
@@ -151,15 +152,15 @@ class ReportQuery implements ReportQueryInterface
// only get deposits not to a shared account // only get deposits not to a shared account
// and transfers to a shared account. // and transfers to a shared account.
$query->where( $query->where(
function(Builder $query) { function (Builder $query) {
$query->where( $query->where(
function(Builder $q) { function (Builder $q) {
$q->where('transaction_types.type', 'Deposit'); $q->where('transaction_types.type', 'Deposit');
$q->where('acm_to.data', '!=', '"sharedAsset"'); $q->where('acm_to.data', '!=', '"sharedAsset"');
} }
); );
$query->orWhere( $query->orWhere(
function(Builder $q) { function (Builder $q) {
$q->where('transaction_types.type', 'Transfer'); $q->where('transaction_types.type', 'Transfer');
$q->where('acm_from.data', '=', '"sharedAsset"'); $q->where('acm_from.data', '=', '"sharedAsset"');
} }
@@ -178,17 +179,18 @@ class ReportQuery implements ReportQueryInterface
); );
$data->each( $data->each(
function(TransactionJournal $journal) { function (TransactionJournal $journal) {
if (intval($journal->account_encrypted) == 1) { if (intval($journal->account_encrypted) == 1) {
$journal->name = Crypt::decrypt($journal->name); $journal->name = Crypt::decrypt($journal->name);
} }
} }
); );
$data = $data->filter( $data = $data->filter(
function(TransactionJournal $journal) { function (TransactionJournal $journal) {
if ($journal->amount != 0) { if ($journal->amount != 0) {
return $journal; return $journal;
} }
return null; return null;
} }
); );
@@ -210,16 +212,16 @@ class ReportQuery implements ReportQueryInterface
{ {
return floatval( return floatval(
Auth::user()->transactionjournals() Auth::user()->transactionjournals()
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id') ->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id') ->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
->transactionTypes(['Withdrawal']) ->transactionTypes(['Withdrawal'])
->where('transactions.account_id', $account->id) ->where('transactions.account_id', $account->id)
->before($end) ->before($end)
->after($start) ->after($start)
->where('budget_transaction_journal.budget_id', $budget->id) ->where('budget_transaction_journal.budget_id', $budget->id)
->get(['transaction_journals.*'])->sum('amount') ->get(['transaction_journals.*'])->sum('amount')
) * -1; ) * -1;
} }
/** /**
@@ -254,28 +256,28 @@ class ReportQuery implements ReportQueryInterface
{ {
$query = TransactionJournal:: $query = TransactionJournal::
leftJoin( leftJoin(
'transactions as t_from', function(JoinClause $join) { 'transactions as t_from', function (JoinClause $join) {
$join->on('t_from.transaction_journal_id', '=', 'transaction_journals.id')->where('t_from.amount', '<', 0); $join->on('t_from.transaction_journal_id', '=', 'transaction_journals.id')->where('t_from.amount', '<', 0);
} }
) )
->leftJoin('accounts as ac_from', 't_from.account_id', '=', 'ac_from.id') ->leftJoin('accounts as ac_from', 't_from.account_id', '=', 'ac_from.id')
->leftJoin( ->leftJoin(
'account_meta as acm_from', function(JoinClause $join) { 'account_meta as acm_from', function (JoinClause $join) {
$join->on('ac_from.id', '=', 'acm_from.account_id')->where('acm_from.name', '=', 'accountRole'); $join->on('ac_from.id', '=', 'acm_from.account_id')->where('acm_from.name', '=', 'accountRole');
} }
) )
->leftJoin( ->leftJoin(
'transactions as t_to', function(JoinClause $join) { 'transactions as t_to', function (JoinClause $join) {
$join->on('t_to.transaction_journal_id', '=', 'transaction_journals.id')->where('t_to.amount', '>', 0); $join->on('t_to.transaction_journal_id', '=', 'transaction_journals.id')->where('t_to.amount', '>', 0);
} }
) )
->leftJoin('accounts as ac_to', 't_to.account_id', '=', 'ac_to.id') ->leftJoin('accounts as ac_to', 't_to.account_id', '=', 'ac_to.id')
->leftJoin( ->leftJoin(
'account_meta as acm_to', function(JoinClause $join) { 'account_meta as acm_to', function (JoinClause $join) {
$join->on('ac_to.id', '=', 'acm_to.account_id')->where('acm_to.name', '=', 'accountRole'); $join->on('ac_to.id', '=', 'acm_to.account_id')->where('acm_to.name', '=', 'accountRole');
} }
) )
->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id'); ->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id');
$query->before($end)->after($start)->where('transaction_journals.user_id', Auth::user()->id); $query->before($end)->after($start)->where('transaction_journals.user_id', Auth::user()->id);
return $query; return $query;

View File

@@ -7,6 +7,7 @@ use FireflyIII\Http\Requests\AccountFormRequest;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use Input; use Input;
use Preferences;
use Redirect; use Redirect;
use Session; use Session;
use Steam; use Steam;
@@ -86,6 +87,7 @@ class AccountController extends Controller
$repository->destroy($account); $repository->destroy($account);
Session::flash('success', trans('firefly.' . $typeName . '_deleted', ['name' => $name])); Session::flash('success', trans('firefly.' . $typeName . '_deleted', ['name' => $name]));
Preferences::mark();
return Redirect::to(Session::get('accounts.delete.url')); return Redirect::to(Session::get('accounts.delete.url'));
} }
@@ -154,7 +156,7 @@ class AccountController extends Controller
$start = clone Session::get('start', Carbon::now()->startOfMonth()); $start = clone Session::get('start', Carbon::now()->startOfMonth());
$start->subDay(); $start->subDay();
$accounts->each( $accounts->each(
function(Account $account) use ($start, $repository) { function (Account $account) use ($start, $repository) {
$account->lastActivityDate = $repository->getLastActivity($account); $account->lastActivityDate = $repository->getLastActivity($account);
$account->startBalance = Steam::balance($account, $start); $account->startBalance = Steam::balance($account, $start);
$account->endBalance = Steam::balance($account, clone Session::get('end', Carbon::now()->endOfMonth())); $account->endBalance = Steam::balance($account, clone Session::get('end', Carbon::now()->endOfMonth()));
@@ -199,13 +201,14 @@ class AccountController extends Controller
'user' => Auth::user()->id, 'user' => Auth::user()->id,
'accountRole' => $request->input('accountRole'), 'accountRole' => $request->input('accountRole'),
'openingBalance' => floatval($request->input('openingBalance')), 'openingBalance' => floatval($request->input('openingBalance')),
'openingBalanceDate' => new Carbon((string) $request->input('openingBalanceDate')), 'openingBalanceDate' => new Carbon((string)$request->input('openingBalanceDate')),
'openingBalanceCurrency' => intval($request->input('balance_currency_id')), 'openingBalanceCurrency' => intval($request->input('balance_currency_id')),
]; ];
$account = $repository->store($accountData); $account = $repository->store($accountData);
Session::flash('success', 'New account "' . $account->name . '" stored!'); Session::flash('success', 'New account "' . $account->name . '" stored!');
Preferences::mark();
if (intval(Input::get('create_another')) === 1) { if (intval(Input::get('create_another')) === 1) {
// set value so create routine will not overwrite URL: // set value so create routine will not overwrite URL:
@@ -237,7 +240,7 @@ class AccountController extends Controller
'accountRole' => $request->input('accountRole'), 'accountRole' => $request->input('accountRole'),
'virtualBalance' => floatval($request->input('virtualBalance')), 'virtualBalance' => floatval($request->input('virtualBalance')),
'openingBalance' => floatval($request->input('openingBalance')), 'openingBalance' => floatval($request->input('openingBalance')),
'openingBalanceDate' => new Carbon((string) $request->input('openingBalanceDate')), 'openingBalanceDate' => new Carbon((string)$request->input('openingBalanceDate')),
'openingBalanceCurrency' => intval($request->input('balance_currency_id')), 'openingBalanceCurrency' => intval($request->input('balance_currency_id')),
'ccType' => $request->input('ccType'), 'ccType' => $request->input('ccType'),
'ccMonthlyPaymentDate' => $request->input('ccMonthlyPaymentDate'), 'ccMonthlyPaymentDate' => $request->input('ccMonthlyPaymentDate'),
@@ -246,6 +249,7 @@ class AccountController extends Controller
$repository->update($account, $accountData); $repository->update($account, $accountData);
Session::flash('success', 'Account "' . $account->name . '" updated.'); Session::flash('success', 'Account "' . $account->name . '" updated.');
Preferences::mark();
if (intval(Input::get('return_to_edit')) === 1) { if (intval(Input::get('return_to_edit')) === 1) {
// set value so edit routine will not overwrite URL: // set value so edit routine will not overwrite URL:

View File

@@ -109,7 +109,6 @@ class AuthController extends Controller
if (User::count() == 1) { if (User::count() == 1) {
$admin = Role::where('name', 'owner')->first(); $admin = Role::where('name', 'owner')->first();
$this->auth->user()->attachRole($admin); $this->auth->user()->attachRole($admin);
// $this->auth->user()->roles()->save($admin);
} }

View File

@@ -6,6 +6,7 @@ use FireflyIII\Models\Bill;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Bill\BillRepositoryInterface; use FireflyIII\Repositories\Bill\BillRepositoryInterface;
use Input; use Input;
use Preferences;
use Redirect; use Redirect;
use Session; use Session;
use URL; use URL;
@@ -75,6 +76,7 @@ class BillController extends Controller
$repository->destroy($bill); $repository->destroy($bill);
Session::flash('success', 'The bill was deleted.'); Session::flash('success', 'The bill was deleted.');
Preferences::mark();
return Redirect::to(Session::get('bills.delete.url')); return Redirect::to(Session::get('bills.delete.url'));
@@ -110,7 +112,7 @@ class BillController extends Controller
{ {
$bills = $repository->getBills(); $bills = $repository->getBills();
$bills->each( $bills->each(
function(Bill $bill) use ($repository) { function (Bill $bill) use ($repository) {
$bill->nextExpectedMatch = $repository->nextExpectedMatch($bill); $bill->nextExpectedMatch = $repository->nextExpectedMatch($bill);
$bill->lastFoundMatch = $repository->lastFoundMatch($bill); $bill->lastFoundMatch = $repository->lastFoundMatch($bill);
} }
@@ -141,6 +143,7 @@ class BillController extends Controller
Session::flash('success', 'Rescanned everything.'); Session::flash('success', 'Rescanned everything.');
Preferences::mark();
return Redirect::to(URL::previous()); return Redirect::to(URL::previous());
} }
@@ -172,6 +175,7 @@ class BillController extends Controller
$billData = $request->getBillData(); $billData = $request->getBillData();
$bill = $repository->store($billData); $bill = $repository->store($billData);
Session::flash('success', 'Bill "' . e($bill->name) . '" stored.'); Session::flash('success', 'Bill "' . e($bill->name) . '" stored.');
Preferences::mark();
if (intval(Input::get('create_another')) === 1) { if (intval(Input::get('create_another')) === 1) {
// set value so create routine will not overwrite URL: // set value so create routine will not overwrite URL:
@@ -198,6 +202,7 @@ class BillController extends Controller
$bill = $repository->update($bill, $billData); $bill = $repository->update($bill, $billData);
Session::flash('success', 'Bill "' . e($bill->name) . '" updated.'); Session::flash('success', 'Bill "' . e($bill->name) . '" updated.');
Preferences::mark();
if (intval(Input::get('return_to_edit')) === 1) { if (intval(Input::get('return_to_edit')) === 1) {
// set value so edit routine will not overwrite URL: // set value so edit routine will not overwrite URL:

View File

@@ -49,6 +49,7 @@ class BudgetController extends Controller
if ($amount == 0) { if ($amount == 0) {
$limitRepetition = null; $limitRepetition = null;
} }
Preferences::mark();
return Response::json(['name' => $budget->name, 'repetition' => $limitRepetition ? $limitRepetition->id : 0]); return Response::json(['name' => $budget->name, 'repetition' => $limitRepetition ? $limitRepetition->id : 0]);
@@ -102,6 +103,7 @@ class BudgetController extends Controller
Session::flash('success', 'The budget "' . e($name) . '" was deleted.'); Session::flash('success', 'The budget "' . e($name) . '" was deleted.');
Preferences::mark();
return Redirect::to(Session::get('budgets.delete.url')); return Redirect::to(Session::get('budgets.delete.url'));
@@ -196,6 +198,7 @@ class BudgetController extends Controller
$date = Session::get('start', Carbon::now()->startOfMonth())->format('FY'); $date = Session::get('start', Carbon::now()->startOfMonth())->format('FY');
Preferences::set('budgetIncomeTotal' . $date, intval(Input::get('amount'))); Preferences::set('budgetIncomeTotal' . $date, intval(Input::get('amount')));
Preferences::mark();
return Redirect::route('budgets.index'); return Redirect::route('budgets.index');
} }
@@ -216,12 +219,15 @@ class BudgetController extends Controller
} }
$journals = $repository->getJournals($budget, $repetition); $journals = $repository->getJournals($budget, $repetition);
$limits = !is_null($repetition->id) ? [$repetition->budgetLimit] : $repository->getBudgetLimits($budget);
$subTitle = !is_null($repetition->id) if (is_null($repetition->id)) {
? $limits = $repository->getBudgetLimits($budget);
trans('firefly.budget_in_month', ['name' => $budget->name, 'month' => $repetition->startdate->formatLocalized($this->monthFormat)]) $subTitle = e($budget->name);
: } else {
e($budget->name); $limits = [$repetition->budgetLimit];
$subTitle = trans('firefly.budget_in_month', ['name' => $budget->name, 'month' => $repetition->startdate->formatLocalized($this->monthFormat)]);
}
$journals->setPath('/budgets/show/' . $budget->id); $journals->setPath('/budgets/show/' . $budget->id);
return view('budgets.show', compact('limits', 'budget', 'repetition', 'journals', 'subTitle')); return view('budgets.show', compact('limits', 'budget', 'repetition', 'journals', 'subTitle'));
@@ -239,9 +245,10 @@ class BudgetController extends Controller
'name' => $request->input('name'), 'name' => $request->input('name'),
'user' => Auth::user()->id, 'user' => Auth::user()->id,
]; ];
$budget = $repository->store($budgetData); $budget = $repository->store($budgetData);
Session::flash('success', 'New budget "' . $budget->name . '" stored!'); Session::flash('success', 'New budget "' . $budget->name . '" stored!');
Preferences::mark();
if (intval(Input::get('create_another')) === 1) { if (intval(Input::get('create_another')) === 1) {
// set value so create routine will not overwrite URL: // set value so create routine will not overwrite URL:
@@ -272,6 +279,7 @@ class BudgetController extends Controller
$repository->update($budget, $budgetData); $repository->update($budget, $budgetData);
Session::flash('success', 'Budget "' . $budget->name . '" updated.'); Session::flash('success', 'Budget "' . $budget->name . '" updated.');
Preferences::mark();
if (intval(Input::get('return_to_edit')) === 1) { if (intval(Input::get('return_to_edit')) === 1) {
// set value so edit routine will not overwrite URL: // set value so edit routine will not overwrite URL:

View File

@@ -7,6 +7,7 @@ use FireflyIII\Models\Category;
use FireflyIII\Repositories\Category\CategoryRepositoryInterface; use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Pagination\LengthAwarePaginator;
use Input; use Input;
use Preferences;
use Redirect; use Redirect;
use Session; use Session;
use URL; use URL;
@@ -77,6 +78,7 @@ class CategoryController extends Controller
$repository->destroy($category); $repository->destroy($category);
Session::flash('success', 'The category "' . e($name) . '" was deleted.'); Session::flash('success', 'The category "' . e($name) . '" was deleted.');
Preferences::mark();
return Redirect::to(Session::get('categories.delete.url')); return Redirect::to(Session::get('categories.delete.url'));
} }
@@ -112,7 +114,7 @@ class CategoryController extends Controller
$categories = $repository->getCategories(); $categories = $repository->getCategories();
$categories->each( $categories->each(
function(Category $category) use ($repository) { function (Category $category) use ($repository) {
$category->lastActivity = $repository->getLatestActivity($category); $category->lastActivity = $repository->getLatestActivity($category);
} }
); );
@@ -165,9 +167,10 @@ class CategoryController extends Controller
'name' => $request->input('name'), 'name' => $request->input('name'),
'user' => Auth::user()->id, 'user' => Auth::user()->id,
]; ];
$category = $repository->store($categoryData); $category = $repository->store($categoryData);
Session::flash('success', 'New category "' . $category->name . '" stored!'); Session::flash('success', 'New category "' . $category->name . '" stored!');
Preferences::mark();
if (intval(Input::get('create_another')) === 1) { if (intval(Input::get('create_another')) === 1) {
Session::put('categories.create.fromStore', true); Session::put('categories.create.fromStore', true);
@@ -195,6 +198,7 @@ class CategoryController extends Controller
$repository->update($category, $categoryData); $repository->update($category, $categoryData);
Session::flash('success', 'Category "' . $category->name . '" updated.'); Session::flash('success', 'Category "' . $category->name . '" updated.');
Preferences::mark();
if (intval(Input::get('return_to_edit')) === 1) { if (intval(Input::get('return_to_edit')) === 1) {
Session::put('categories.edit.fromUpdate', true); Session::put('categories.edit.fromUpdate', true);

View File

@@ -6,6 +6,7 @@ use Carbon\Carbon;
use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Support\CacheProperties;
use Grumpydictator\Gchart\GChart; use Grumpydictator\Gchart\GChart;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Preferences; use Preferences;
@@ -37,6 +38,18 @@ class AccountController extends Controller
$start = new Carbon($year . '-' . $month . '-01'); $start = new Carbon($year . '-' . $month . '-01');
$end = clone $start; $end = clone $start;
$end->endOfMonth(); $end->endOfMonth();
// chart properties for cache:
$cache = new CacheProperties();
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty('all');
$cache->addProperty('accounts');
if ($cache->has()) {
return Response::json($cache->get()); // @codeCoverageIgnore
}
$chart->addColumn(trans('firefly.dayOfMonth'), 'date'); $chart->addColumn(trans('firefly.dayOfMonth'), 'date');
/** @var Collection $accounts */ /** @var Collection $accounts */
@@ -50,6 +63,7 @@ class AccountController extends Controller
} }
} }
//
$index = 1; $index = 1;
/** @var Account $account */ /** @var Account $account */
@@ -73,7 +87,10 @@ class AccountController extends Controller
} }
$chart->generate(); $chart->generate();
return Response::json($chart->getData()); $data = $chart->getData();
$cache->store($data);
return Response::json($data);
} }
/** /**
@@ -93,6 +110,17 @@ class AccountController extends Controller
$end = Session::get('end', Carbon::now()->endOfMonth()); $end = Session::get('end', Carbon::now()->endOfMonth());
$accounts = $repository->getFrontpageAccounts($frontPage); $accounts = $repository->getFrontpageAccounts($frontPage);
// chart properties for cache:
$cache = new CacheProperties();
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty('frontpage');
$cache->addProperty('accounts');
if ($cache->has()) {
return Response::json($cache->get()); // @codeCoverageIgnore
}
$index = 1; $index = 1;
/** @var Account $account */ /** @var Account $account */
foreach ($accounts as $account) { foreach ($accounts as $account) {
@@ -115,7 +143,10 @@ class AccountController extends Controller
} }
$chart->generate(); $chart->generate();
return Response::json($chart->getData()); $data = $chart->getData();
$cache->store($data);
return Response::json($data);
} }
@@ -138,6 +169,17 @@ class AccountController extends Controller
$current = clone $start; $current = clone $start;
$today = new Carbon; $today = new Carbon;
// chart properties for cache:
$cache = new CacheProperties();
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty('frontpage');
$cache->addProperty('single');
$cache->addProperty($account->id);
if ($cache->has()) {
return Response::json($cache->get()); // @codeCoverageIgnore
}
while ($end >= $current) { while ($end >= $current) {
$certain = $current < $today; $certain = $current < $today;
$chart->addRow(clone $current, Steam::balance($account, $current), $certain); $chart->addRow(clone $current, Steam::balance($account, $current), $certain);
@@ -147,6 +189,9 @@ class AccountController extends Controller
$chart->generate(); $chart->generate();
return Response::json($chart->getData()); $data = $chart->getData();
$cache->store($data);
return Response::json($data);
} }
} }

View File

@@ -8,6 +8,7 @@ use FireflyIII\Models\Bill;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Bill\BillRepositoryInterface; use FireflyIII\Repositories\Bill\BillRepositoryInterface;
use FireflyIII\Support\CacheProperties;
use Grumpydictator\Gchart\GChart; use Grumpydictator\Gchart\GChart;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Response; use Response;
@@ -38,6 +39,14 @@ class BillController extends Controller
$chart->addColumn(trans('firefly.minAmount'), 'number'); $chart->addColumn(trans('firefly.minAmount'), 'number');
$chart->addColumn(trans('firefly.billEntry'), 'number'); $chart->addColumn(trans('firefly.billEntry'), 'number');
$cache = new CacheProperties;
$cache->addProperty('single');
$cache->addProperty('bill');
$cache->addProperty($bill->id);
if ($cache->has()) {
return Response::json($cache->get()); // @codeCoverageIgnore
}
// get first transaction or today for start: // get first transaction or today for start:
$results = $repository->getJournals($bill); $results = $repository->getJournals($bill);
/** @var TransactionJournal $result */ /** @var TransactionJournal $result */
@@ -47,8 +56,10 @@ class BillController extends Controller
$chart->generate(); $chart->generate();
return Response::json($chart->getData()); $data = $chart->getData();
$cache->store($data);
return Response::json($data);
} }
/** /**
@@ -66,8 +77,20 @@ class BillController extends Controller
$chart->addColumn(trans('firefly.name'), 'string'); $chart->addColumn(trans('firefly.name'), 'string');
$chart->addColumn(trans('firefly.amount'), 'number'); $chart->addColumn(trans('firefly.amount'), 'number');
$start = Session::get('start', Carbon::now()->startOfMonth()); $start = Session::get('start', Carbon::now()->startOfMonth());
$end = Session::get('end', Carbon::now()->endOfMonth()); $end = Session::get('end', Carbon::now()->endOfMonth());
// chart properties for cache:
$cache = new CacheProperties();
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty('bills');
$cache->addProperty('frontpage');
if ($cache->has()) {
return Response::json($cache->get()); // @codeCoverageIgnore
}
$bills = $repository->getActiveBills(); $bills = $repository->getActiveBills();
$paid = new Collection; // journals. $paid = new Collection; // journals.
$unpaid = new Collection; // bills $unpaid = new Collection; // bills
@@ -133,8 +156,12 @@ class BillController extends Controller
$chart->addRow(trans('firefly.unpaid') . ': ' . join(', ', $unpaidDescriptions), $unpaidAmount); $chart->addRow(trans('firefly.unpaid') . ': ' . join(', ', $unpaidDescriptions), $unpaidAmount);
$chart->addRow(trans('firefly.paid') . ': ' . join(', ', $paidDescriptions), $paidAmount); $chart->addRow(trans('firefly.paid') . ': ' . join(', ', $paidDescriptions), $paidAmount);
$chart->generate(); $chart->generate();
return Response::json($chart->getData()); $data = $chart->getData();
$cache->store($data);
return Response::json($data);
} }
} }

View File

@@ -7,6 +7,7 @@ use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Budget; use FireflyIII\Models\Budget;
use FireflyIII\Models\LimitRepetition; use FireflyIII\Models\LimitRepetition;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface; use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Support\CacheProperties;
use Grumpydictator\Gchart\GChart; use Grumpydictator\Gchart\GChart;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Navigation; use Navigation;
@@ -41,19 +42,41 @@ class BudgetController extends Controller
$final->addYears(2); $final->addYears(2);
$last = Navigation::endOfX($last, $range, $final); $last = Navigation::endOfX($last, $range, $final);
// chart properties for cache:
$cache = new CacheProperties();
$cache->addProperty($first);
$cache->addProperty($last);
$cache->addProperty('budget');
$cache->addProperty('budget');
if ($cache->has()) {
return Response::json($cache->get()); // @codeCoverageIgnore
}
while ($first < $last) { while ($first < $last) {
$end = Navigation::addPeriod($first, $range, 0); $end = Navigation::addPeriod($first, $range, 0);
$end->subDay();
// start date for chart.
$chartDate = clone $end;
$chartDate->startOfMonth();
$spent = $repository->spentInPeriodCorrected($budget, $first, $end); $spent = $repository->spentInPeriodCorrected($budget, $first, $end);
$chart->addRow($end, $spent); $chart->addRow($chartDate, $spent);
$first = Navigation::addPeriod($first, $range, 0); $first = Navigation::addPeriod($first, $range, 0);
} }
$chart->generate(); $chart->generate();
return Response::json($chart->getData()); $data = $chart->getData();
$cache->store($data);
return Response::json($data);
} }
/** /**
@@ -71,6 +94,18 @@ class BudgetController extends Controller
$start = clone $repetition->startdate; $start = clone $repetition->startdate;
$end = $repetition->enddate; $end = $repetition->enddate;
// chart properties for cache:
$cache = new CacheProperties();
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty('budget');
$cache->addProperty('limit');
$cache->addProperty($budget->id);
$cache->addProperty($repetition->id);
if ($cache->has()) {
return Response::json($cache->get()); // @codeCoverageIgnore
}
$chart->addColumn(trans('firefly.day'), 'date'); $chart->addColumn(trans('firefly.day'), 'date');
$chart->addColumn(trans('firefly.left'), 'number'); $chart->addColumn(trans('firefly.left'), 'number');
@@ -88,7 +123,10 @@ class BudgetController extends Controller
} }
$chart->generate(); $chart->generate();
return Response::json($chart->getData()); $data = $chart->getData();
$cache->store($data);
return Response::json($data);
} }
@@ -112,6 +150,18 @@ class BudgetController extends Controller
$end = Session::get('end', Carbon::now()->endOfMonth()); $end = Session::get('end', Carbon::now()->endOfMonth());
$allEntries = new Collection; $allEntries = new Collection;
// chart properties for cache:
$cache = new CacheProperties();
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty('budget');
$cache->addProperty('all');
if ($cache->has()) {
return Response::json($cache->get()); // @codeCoverageIgnore
}
/** @var Budget $budget */
foreach ($budgets as $budget) { foreach ($budgets as $budget) {
$repetitions = $repository->getBudgetLimitRepetitions($budget, $start, $end); $repetitions = $repository->getBudgetLimitRepetitions($budget, $start, $end);
if ($repetitions->count() == 0) { if ($repetitions->count() == 0) {
@@ -127,9 +177,9 @@ class BudgetController extends Controller
$overspent = $expenses > floatval($repetition->amount) ? $expenses - floatval($repetition->amount) : 0; $overspent = $expenses > floatval($repetition->amount) ? $expenses - floatval($repetition->amount) : 0;
$allEntries->push( $allEntries->push(
[$budget->name . ' (' . $repetition->startdate->formatLocalized($this->monthAndDayFormat) . ')', [$budget->name . ' (' . $repetition->startdate->formatLocalized($this->monthAndDayFormat) . ')',
$left, $left,
$spent, $spent,
$overspent $overspent
] ]
); );
} }
@@ -146,7 +196,10 @@ class BudgetController extends Controller
$chart->generate(); $chart->generate();
return Response::json($chart->getData()); $data = $chart->getData();
$cache->store($data);
return Response::json($data);
} }
@@ -167,6 +220,16 @@ class BudgetController extends Controller
$shared = $shared == 'shared' ? true : false; $shared = $shared == 'shared' ? true : false;
$budgets = $repository->getBudgets(); $budgets = $repository->getBudgets();
// chart properties for cache:
$cache = new CacheProperties();
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty('budget');
$cache->addProperty('year');
if ($cache->has()) {
return Response::json($cache->get()); // @codeCoverageIgnore
}
// add columns: // add columns:
$chart->addColumn(trans('firefly.month'), 'date'); $chart->addColumn(trans('firefly.month'), 'date');
foreach ($budgets as $budget) { foreach ($budgets as $budget) {
@@ -187,11 +250,14 @@ class BudgetController extends Controller
} }
$chart->addRowArray($row); $chart->addRowArray($row);
$start->addMonth(); $start->endOfMonth()->addDay();
} }
$chart->generate(); $chart->generate();
return Response::json($chart->getData()); $data = $chart->getData();
$cache->store($data);
return Response::json($data);
} }
} }

View File

@@ -7,6 +7,7 @@ use Carbon\Carbon;
use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Category; use FireflyIII\Models\Category;
use FireflyIII\Repositories\Category\CategoryRepositoryInterface; use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
use FireflyIII\Support\CacheProperties;
use Grumpydictator\Gchart\GChart; use Grumpydictator\Gchart\GChart;
use Navigation; use Navigation;
use Preferences; use Preferences;
@@ -75,12 +76,23 @@ class CategoryController extends Controller
$start = Session::get('start', Carbon::now()->startOfMonth()); $start = Session::get('start', Carbon::now()->startOfMonth());
$end = Session::get('end', Carbon::now()->endOfMonth()); $end = Session::get('end', Carbon::now()->endOfMonth());
$set = $repository->getCategoriesAndExpensesCorrected($start, $end);
// chart properties for cache:
$cache = new CacheProperties;
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty('category');
$cache->addProperty('frontpage');
if ($cache->has()) {
return Response::json($cache->get()); // @codeCoverageIgnore
}
$set = $repository->getCategoriesAndExpensesCorrected($start, $end);
// sort by callback: // sort by callback:
uasort( uasort(
$set, $set,
function($left, $right) { function ($left, $right) {
if ($left['sum'] == $right['sum']) { if ($left['sum'] == $right['sum']) {
return 0; return 0;
} }
@@ -99,7 +111,10 @@ class CategoryController extends Controller
$chart->generate(); $chart->generate();
return Response::json($chart->getData()); $data = $chart->getData();
$cache->store($data);
return Response::json($data);
} }

View File

@@ -59,6 +59,7 @@ class CurrencyController extends Controller
{ {
Preferences::set('currencyPreference', $currency->code); Preferences::set('currencyPreference', $currency->code);
Preferences::mark();
Session::flash('success', $currency->name . ' is now the default currency.'); Session::flash('success', $currency->name . ' is now the default currency.');
Cache::forget('FFCURRENCYSYMBOL'); Cache::forget('FFCURRENCYSYMBOL');
@@ -170,6 +171,7 @@ class CurrencyController extends Controller
if (Auth::user()->hasRole('owner')) { if (Auth::user()->hasRole('owner')) {
$currency = $repository->store($data); $currency = $repository->store($data);
Session::flash('success', 'Currency "' . $currency->name . '" created'); Session::flash('success', 'Currency "' . $currency->name . '" created');
} }
if (intval(Input::get('create_another')) === 1) { if (intval(Input::get('create_another')) === 1) {
@@ -198,6 +200,7 @@ class CurrencyController extends Controller
$currency = $repository->update($currency, $data); $currency = $repository->update($currency, $data);
} }
Session::flash('success', 'Currency "' . e($currency->name) . '" updated.'); Session::flash('success', 'Currency "' . e($currency->name) . '" updated.');
Preferences::mark();
if (intval(Input::get('return_to_edit')) === 1) { if (intval(Input::get('return_to_edit')) === 1) {

View File

@@ -6,7 +6,6 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use Input; use Input;
use Preferences; use Preferences;
use Redirect; use Redirect;
use Route;
use Session; use Session;
use Steam; use Steam;
@@ -46,40 +45,52 @@ class HomeController extends Controller
/** /**
* @param AccountRepositoryInterface $repository * @param AccountRepositoryInterface $repository
* *
* @return \Illuminate\View\View * @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View
*/ */
public function index(AccountRepositoryInterface $repository) public function index(AccountRepositoryInterface $repository)
{ {
$types = Config::get('firefly.accountTypesByIdentifier.asset');
$count = $repository->countAccounts($types); $types = Config::get('firefly.accountTypesByIdentifier.asset');
$title = 'Firefly'; $count = $repository->countAccounts($types);
$subTitle = trans('firefly.welcomeBack');
$mainTitleIcon = 'fa-fire';
$transactions = []; if ($count == 0) {
$frontPage = Preferences::get('frontPageAccounts', []); return Redirect::route('new-user.index');
$start = Session::get('start', Carbon::now()->startOfMonth()); }
$end = Session::get('end', Carbon::now()->endOfMonth());
$accounts = $repository->getFrontpageAccounts($frontPage); $title = 'Firefly';
$savings = $repository->getSavingsAccounts(); $subTitle = trans('firefly.welcomeBack');
$mainTitleIcon = 'fa-fire';
$transactions = [];
$frontPage = Preferences::get('frontPageAccounts', []);
$start = Session::get('start', Carbon::now()->startOfMonth());
$end = Session::get('end', Carbon::now()->endOfMonth());
$accounts = $repository->getFrontpageAccounts($frontPage);
$savings = $repository->getSavingsAccounts();
$piggyBankAccounts = $repository->getPiggyBankAccounts(); $piggyBankAccounts = $repository->getPiggyBankAccounts();
$savingsTotal = 0; $savingsTotal = 0;
foreach ($savings as $savingAccount) { foreach ($savings as $savingAccount) {
$savingsTotal += Steam::balance($savingAccount, $end); $savingsTotal += Steam::balance($savingAccount, $end);
} }
$sum = $repository->sumOfEverything(); $sum = $repository->sumOfEverything();
if ($sum != 0) { if ($sum != 0) {
Session::flash( Session::flash(
'error', 'Your transactions are unbalanced. This means a' 'error', 'Your transactions are unbalanced. This means a'
. ' withdrawal, deposit or transfer was not stored properly. ' . ' withdrawal, deposit or transfer was not stored properly. '
. 'Please check your accounts and transactions for errors.' . 'Please check your accounts and transactions for errors.'
); );
} }
foreach ($accounts as $account) { foreach ($accounts as $account) {
$set = $repository->getFrontpageTransactions($account, $start, $end); $set = $repository->getFrontpageTransactions($account, $start, $end);
if (count($set) > 0) { if (count($set) > 0) {
$transactions[] = [$set, $account]; $transactions[] = [$set, $account];
} }
@@ -87,79 +98,4 @@ class HomeController extends Controller
return view('index', compact('count', 'title', 'savings', 'subTitle', 'mainTitleIcon', 'transactions', 'savingsTotal', 'piggyBankAccounts')); return view('index', compact('count', 'title', 'savings', 'subTitle', 'mainTitleIcon', 'transactions', 'savingsTotal', 'piggyBankAccounts'));
} }
/**
* @codeCoverageIgnore
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function routes()
{
$directory = '/vagrant_data/Sites/firefly-iii-help';
$languages = array_keys(Config::get('firefly.lang'));
$routes = [];
$ignored = [
'debugbar.openhandler', 'debugbar.assets.css', 'debugbar.assets.js', 'register', 'routes', 'daterange',
'flush', 'delete-account-post', 'change-password-post', 'logout', 'login', 'tags.hideTagHelp',
'budgets.postIncome', 'flush'
];
$ignoreMatch = ['.store', '.update', '.destroy', 'json.'];
$routeCollection = Route::getRoutes();
/** @var \Illuminate\Routing\Route $object */
foreach ($routeCollection as $object) {
// get name:
$name = $object->getName();
// has name and not in ignore list?
if (strlen($name) > 0 && !in_array($name, $ignored)) {
// not in ignoreMatch?
$continue = true;
foreach ($ignoreMatch as $ignore) {
$match = strpos($name, $ignore);
if (!($match === false)) {
$continue = false;
}
}
unset($ignore, $match);
if ($continue) {
$routes[] = $name;
// check all languages:
foreach ($languages as $lang) {
$file = $directory . '/' . $lang . '/' . $name . '.md';
if (!file_exists($file)) {
touch($file);
echo $name . '<br />';
}
}
}
}
}
// loop directories with language file.
// tag the ones not in the list of approved routes.
foreach ($languages as $lang) {
$dir = $directory . '/' . $lang;
$set = scandir($dir);
foreach ($set as $entry) {
if ($entry != '.' && $entry != '..') {
$name = str_replace('.md', '', $entry);
if (!in_array($name, $routes)) {
$file = $dir . '/' . $entry;
unlink($file);
}
}
}
}
echo 'Done!';
}
} }

View File

@@ -10,6 +10,7 @@ use FireflyIII\Repositories\Bill\BillRepositoryInterface;
use FireflyIII\Repositories\Category\CategoryRepositoryInterface; use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface; use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\Tag\TagRepositoryInterface; use FireflyIII\Repositories\Tag\TagRepositoryInterface;
use FireflyIII\Support\CacheProperties;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Response; use Response;
use Session; use Session;
@@ -33,10 +34,21 @@ class JsonController extends Controller
*/ */
public function boxBillsPaid(BillRepositoryInterface $repository, AccountRepositoryInterface $accountRepository) public function boxBillsPaid(BillRepositoryInterface $repository, AccountRepositoryInterface $accountRepository)
{ {
$start = Session::get('start', Carbon::now()->startOfMonth()); $start = Session::get('start', Carbon::now()->startOfMonth());
$end = Session::get('end', Carbon::now()->endOfMonth()); $end = Session::get('end', Carbon::now()->endOfMonth());
// works for json too!
$cache = new CacheProperties;
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty('box-bills-paid');
if ($cache->has()) {
return Response::json($cache->get()); // @codeCoverageIgnore
}
$amount = 0; $amount = 0;
// these two functions are the same as the chart // these two functions are the same as the chart
$bills = $repository->getActiveBills(); $bills = $repository->getActiveBills();
@@ -60,8 +72,11 @@ class JsonController extends Controller
$amount += $accountRepository->getTransfersInRange($creditCard, $start, $end)->sum('amount'); $amount += $accountRepository->getTransfersInRange($creditCard, $start, $end)->sum('amount');
} }
} }
$data = ['box' => 'bills-paid', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount];
$cache->store($data);
return Response::json(['box' => 'bills-paid', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount]);
return Response::json($data);
} }
/** /**
@@ -75,6 +90,16 @@ class JsonController extends Controller
$amount = 0; $amount = 0;
$start = Session::get('start', Carbon::now()->startOfMonth()); $start = Session::get('start', Carbon::now()->startOfMonth());
$end = Session::get('end', Carbon::now()->endOfMonth()); $end = Session::get('end', Carbon::now()->endOfMonth());
// works for json too!
$cache = new CacheProperties;
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty('box-bills-unpaid');
if ($cache->has()) {
return Response::json($cache->get()); // @codeCoverageIgnore
}
$bills = $repository->getActiveBills(); $bills = $repository->getActiveBills();
$unpaid = new Collection; // bills $unpaid = new Collection; // bills
@@ -109,7 +134,10 @@ class JsonController extends Controller
$amount += $current; $amount += $current;
} }
return Response::json(['box' => 'bills-unpaid', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount]); $data = ['box' => 'bills-unpaid', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount];
$cache->store($data);
return Response::json($data);
} }
/** /**
@@ -119,11 +147,24 @@ class JsonController extends Controller
*/ */
public function boxIn(ReportQueryInterface $reportQuery) public function boxIn(ReportQueryInterface $reportQuery)
{ {
$start = Session::get('start', Carbon::now()->startOfMonth()); $start = Session::get('start', Carbon::now()->startOfMonth());
$end = Session::get('end', Carbon::now()->endOfMonth()); $end = Session::get('end', Carbon::now()->endOfMonth());
// works for json too!
$cache = new CacheProperties;
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty('box-in');
if ($cache->has()) {
return Response::json($cache->get()); // @codeCoverageIgnore
}
$amount = $reportQuery->incomeInPeriodCorrected($start, $end, true)->sum('amount'); $amount = $reportQuery->incomeInPeriodCorrected($start, $end, true)->sum('amount');
return Response::json(['box' => 'in', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount]); $data = ['box' => 'in', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount];
$cache->store($data);
return Response::json($data);
} }
/** /**
@@ -133,11 +174,25 @@ class JsonController extends Controller
*/ */
public function boxOut(ReportQueryInterface $reportQuery) public function boxOut(ReportQueryInterface $reportQuery)
{ {
$start = Session::get('start', Carbon::now()->startOfMonth()); $start = Session::get('start', Carbon::now()->startOfMonth());
$end = Session::get('end', Carbon::now()->endOfMonth()); $end = Session::get('end', Carbon::now()->endOfMonth());
// works for json too!
$cache = new CacheProperties;
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty('box-out');
if ($cache->has()) {
return Response::json($cache->get()); // @codeCoverageIgnore
}
$amount = $reportQuery->expenseInPeriodCorrected($start, $end, true)->sum('amount'); $amount = $reportQuery->expenseInPeriodCorrected($start, $end, true)->sum('amount');
return Response::json(['box' => 'out', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount]); $data = ['box' => 'out', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount];
$cache->store($data);
return Response::json($data);
} }
/** /**

View File

@@ -0,0 +1,111 @@
<?php namespace FireflyIII\Http\Controllers;
use Auth;
use Carbon\Carbon;
use Config;
use FireflyIII\Http\Requests\NewUserFormRequest;
use FireflyIII\Models\AccountMeta;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use Preferences;
use Redirect;
use Session;
use View;
/**
* Class NewUserController
*
* @package FireflyIII\Http\Controllers
*/
class NewUserController extends Controller
{
/**
* @param AccountRepositoryInterface $repository
*
* @@return \Illuminate\Http\RedirectResponse|\Illuminate\View\View
*/
public function index(AccountRepositoryInterface $repository)
{
View::share('title', 'Welcome to Firefly!');
View::share('mainTitleIcon', 'fa-fire');
$types = Config::get('firefly.accountTypesByIdentifier.asset');
$count = $repository->countAccounts($types);
if ($count > 0) {
return Redirect::route('index');
}
return view('new-user.index');
}
/**
* @param NewUserFormRequest $request
* @param AccountRepositoryInterface $repository
*
* @return \Illuminate\Http\RedirectResponse
*/
public function submit(NewUserFormRequest $request, AccountRepositoryInterface $repository)
{
// create normal asset account:
$assetAccount = [
'name' => $request->get('bank_name'),
'accountType' => 'asset',
'virtualBalance' => 0,
'active' => true,
'user' => Auth::user()->id,
'accountRole' => 'defaultAsset',
'openingBalance' => floatval($request->input('bank_balance')),
'openingBalanceDate' => new Carbon,
'openingBalanceCurrency' => intval($request->input('balance_currency_id')),
];
$repository->store($assetAccount);
// create savings account
if (strlen($request->get('savings_balance') > 0)) {
$savingsAccount = [
'name' => $request->get('bank_name') . ' savings account',
'accountType' => 'asset',
'virtualBalance' => 0,
'active' => true,
'user' => Auth::user()->id,
'accountRole' => 'savingAsset',
'openingBalance' => floatval($request->input('savings_balance')),
'openingBalanceDate' => new Carbon,
'openingBalanceCurrency' => intval($request->input('balance_currency_id')),
];
$repository->store($savingsAccount);
}
// create credit card.
if (strlen($request->get('credit_card_limit') > 0)) {
$creditAccount = [
'name' => 'Credit card',
'accountType' => 'asset',
'virtualBalance' => floatval($request->get('credit_card_limit')),
'active' => true,
'user' => Auth::user()->id,
'accountRole' => 'ccAsset',
'openingBalance' => null,
'openingBalanceDate' => null,
'openingBalanceCurrency' => intval($request->input('balance_currency_id')),
];
$creditCard = $repository->store($creditAccount);
// store meta for CC:
AccountMeta::create(['name' => 'ccType', 'data' => 'monthlyFull', 'account_id' => $creditCard->id,]);
AccountMeta::create(['name' => 'ccMonthlyPaymentDate', 'data' => Carbon::now()->year . '-01-01', 'account_id' => $creditCard->id,]);
}
Session::flash('success', 'New account(s) created!');
Preferences::mark();
return Redirect::route('index');
}
}

View File

@@ -10,6 +10,7 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface; use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Input; use Input;
use Preferences;
use Redirect; use Redirect;
use Session; use Session;
use Steam; use Steam;
@@ -108,6 +109,7 @@ class PiggyBankController extends Controller
Session::flash('success', 'Piggy bank "' . e($piggyBank->name) . '" deleted.'); Session::flash('success', 'Piggy bank "' . e($piggyBank->name) . '" deleted.');
Preferences::mark();
$repository->destroy($piggyBank); $repository->destroy($piggyBank);
return Redirect::to(Session::get('piggy-banks.delete.url')); return Redirect::to(Session::get('piggy-banks.delete.url'));
@@ -137,11 +139,11 @@ class PiggyBankController extends Controller
$targetDate = $targetDate->format('Y-m-d'); $targetDate = $targetDate->format('Y-m-d');
} }
$preFilled = ['name' => $piggyBank->name, $preFilled = ['name' => $piggyBank->name,
'account_id' => $piggyBank->account_id, 'account_id' => $piggyBank->account_id,
'targetamount' => $piggyBank->targetamount, 'targetamount' => $piggyBank->targetamount,
'targetdate' => $targetDate, 'targetdate' => $targetDate,
'reminder' => $piggyBank->reminder, 'reminder' => $piggyBank->reminder,
'remind_me' => intval($piggyBank->remind_me) == 1 && !is_null($piggyBank->reminder) ? true : false 'remind_me' => intval($piggyBank->remind_me) == 1 && !is_null($piggyBank->reminder) ? true : false
]; ];
Session::flash('preFilled', $preFilled); Session::flash('preFilled', $preFilled);
Session::flash('gaEventCategory', 'piggy-banks'); Session::flash('gaEventCategory', 'piggy-banks');
@@ -208,6 +210,7 @@ class PiggyBankController extends Controller
// set all users piggy banks to zero: // set all users piggy banks to zero:
$repository->reset(); $repository->reset();
if (is_array($data)) { if (is_array($data)) {
foreach ($data as $order => $id) { foreach ($data as $order => $id) {
$repository->setOrder(intval($id), (intval($order) + 1)); $repository->setOrder(intval($id), (intval($order) + 1));
@@ -240,6 +243,7 @@ class PiggyBankController extends Controller
$repository->createEvent($piggyBank, $amount); $repository->createEvent($piggyBank, $amount);
Session::flash('success', 'Added ' . Amount::format($amount, false) . ' to "' . e($piggyBank->name) . '".'); Session::flash('success', 'Added ' . Amount::format($amount, false) . ' to "' . e($piggyBank->name) . '".');
Preferences::mark();
} else { } else {
Session::flash('error', 'Could not add ' . Amount::format($amount, false) . ' to "' . e($piggyBank->name) . '".'); Session::flash('error', 'Could not add ' . Amount::format($amount, false) . ' to "' . e($piggyBank->name) . '".');
} }
@@ -268,6 +272,7 @@ class PiggyBankController extends Controller
$repository->createEvent($piggyBank, $amount * -1); $repository->createEvent($piggyBank, $amount * -1);
Session::flash('success', 'Removed ' . Amount::format($amount, false) . ' from "' . e($piggyBank->name) . '".'); Session::flash('success', 'Removed ' . Amount::format($amount, false) . ' from "' . e($piggyBank->name) . '".');
Preferences::mark();
} else { } else {
Session::flash('error', 'Could not remove ' . Amount::format($amount, false) . ' from "' . e($piggyBank->name) . '".'); Session::flash('error', 'Could not remove ' . Amount::format($amount, false) . ' from "' . e($piggyBank->name) . '".');
} }
@@ -328,6 +333,7 @@ class PiggyBankController extends Controller
$piggyBank = $repository->store($piggyBankData); $piggyBank = $repository->store($piggyBankData);
Session::flash('success', 'Stored piggy bank "' . e($piggyBank->name) . '".'); Session::flash('success', 'Stored piggy bank "' . e($piggyBank->name) . '".');
Preferences::mark();
if (intval(Input::get('create_another')) === 1) { if (intval(Input::get('create_another')) === 1) {
Session::put('piggy-banks.create.fromStore', true); Session::put('piggy-banks.create.fromStore', true);
@@ -362,6 +368,7 @@ class PiggyBankController extends Controller
$piggyBank = $repository->update($piggyBank, $piggyBankData); $piggyBank = $repository->update($piggyBank, $piggyBankData);
Session::flash('success', 'Updated piggy bank "' . e($piggyBank->name) . '".'); Session::flash('success', 'Updated piggy bank "' . e($piggyBank->name) . '".');
Preferences::mark();
if (intval(Input::get('return_to_edit')) === 1) { if (intval(Input::get('return_to_edit')) === 1) {
Session::put('piggy-banks.edit.fromUpdate', true); Session::put('piggy-banks.edit.fromUpdate', true);

View File

@@ -77,6 +77,7 @@ class PreferencesController extends Controller
Session::flash('success', 'Preferences saved!'); Session::flash('success', 'Preferences saved!');
Preferences::mark();
return Redirect::route('preferences'); return Redirect::route('preferences');
} }

View File

@@ -141,18 +141,9 @@ class ReportController extends Controller
Session::flash('gaEventAction', 'year'); Session::flash('gaEventAction', 'year');
Session::flash('gaEventLabel', $start->format('Y')); Session::flash('gaEventLabel', $start->format('Y'));
return view( return view(
'reports.year', 'reports.year',
compact( compact('start', 'shared', 'accounts', 'incomes', 'expenses', 'subTitle', 'subTitleIcon', 'incomeTopLength', 'expenseTopLength')
'start', // the date for this report.
'shared', // is a shared report?
'accounts', // all accounts
'incomes', 'expenses', // expenses and incomes.
'subTitle', 'subTitleIcon', // subtitle and subtitle icon.
'incomeTopLength', // length of income top X
'expenseTopLength' // length of expense top X.
)
); );
} }

View File

@@ -106,6 +106,7 @@ class TagController extends Controller
$repository->destroy($tag); $repository->destroy($tag);
Session::flash('success', 'Tag "' . e($tagName) . '" was deleted.'); Session::flash('success', 'Tag "' . e($tagName) . '" was deleted.');
Preferences::mark();
return Redirect::to(route('tags.index')); return Redirect::to(route('tags.index'));
} }
@@ -226,6 +227,7 @@ class TagController extends Controller
$repository->store($data); $repository->store($data);
Session::flash('success', 'The tag has been created!'); Session::flash('success', 'The tag has been created!');
Preferences::mark();
if (intval(Input::get('create_another')) === 1) { if (intval(Input::get('create_another')) === 1) {
// set value so create routine will not overwrite URL: // set value so create routine will not overwrite URL:
@@ -268,9 +270,11 @@ class TagController extends Controller
'tagMode' => $request->get('tagMode'), 'tagMode' => $request->get('tagMode'),
]; ];
$repository->update($tag, $data); $repository->update($tag, $data);
Session::flash('success', 'Tag "' . e($data['tag']) . '" updated.'); Session::flash('success', 'Tag "' . e($data['tag']) . '" updated.');
Preferences::mark();
if (intval(Input::get('return_to_edit')) === 1) { if (intval(Input::get('return_to_edit')) === 1) {
// set value so edit routine will not overwrite URL: // set value so edit routine will not overwrite URL:

View File

@@ -11,6 +11,7 @@ use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface; use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use Input; use Input;
use Preferences;
use Redirect; use Redirect;
use Response; use Response;
use Session; use Session;
@@ -79,15 +80,15 @@ class TransactionController extends Controller
*/ */
public function delete(TransactionJournal $journal) public function delete(TransactionJournal $journal)
{ {
$type = strtolower($journal->transactionType->type); $what = strtolower($journal->transactionType->type);
$subTitle = trans('firefly.delete_' . $type, ['description' => $journal->description]); $subTitle = trans('firefly.delete_' . $what, ['description' => $journal->description]);
// put previous url in session // put previous url in session
Session::put('transactions.delete.url', URL::previous()); Session::put('transactions.delete.url', URL::previous());
Session::flash('gaEventCategory', 'transactions'); Session::flash('gaEventCategory', 'transactions');
Session::flash('gaEventAction', 'delete-' . $type); Session::flash('gaEventAction', 'delete-' . $what);
return view('transactions.delete', compact('journal', 'subTitle')); return view('transactions.delete', compact('journal', 'subTitle','what'));
} }
@@ -104,6 +105,8 @@ class TransactionController extends Controller
$repository->delete($transactionJournal); $repository->delete($transactionJournal);
Preferences::mark();
// redirect to previous URL: // redirect to previous URL:
return Redirect::to(Session::get('transactions.delete.url')); return Redirect::to(Session::get('transactions.delete.url'));
} }
@@ -154,7 +157,7 @@ class TransactionController extends Controller
} }
$preFilled['amount'] = $journal->actual_amount; $preFilled['amount'] = $journal->actual_amount;
$preFilled['account_id'] = $journal->asset_account->id; $preFilled['account_id'] = $journal->destination_account->id;
$preFilled['expense_account'] = $transactions[0]->account->name; $preFilled['expense_account'] = $transactions[0]->account->name;
$preFilled['revenue_account'] = $transactions[1]->account->name; $preFilled['revenue_account'] = $transactions[1]->account->name;
$preFilled['account_from_id'] = $transactions[1]->account->id; $preFilled['account_from_id'] = $transactions[1]->account->id;
@@ -235,6 +238,7 @@ class TransactionController extends Controller
} }
} }
} }
Preferences::mark();
return Response::json([true]); return Response::json([true]);
@@ -249,14 +253,15 @@ class TransactionController extends Controller
public function show(JournalRepositoryInterface $repository, TransactionJournal $journal) public function show(JournalRepositoryInterface $repository, TransactionJournal $journal)
{ {
$journal->transactions->each( $journal->transactions->each(
function(Transaction $t) use ($journal, $repository) { function (Transaction $t) use ($journal, $repository) {
$t->before = $repository->getAmountBefore($journal, $t); $t->before = $repository->getAmountBefore($journal, $t);
$t->after = $t->before + $t->amount; $t->after = $t->before + $t->amount;
} }
); );
$what = strtolower($journal->transactionType->type);
$subTitle = trans('firefly.' . $journal->transactionType->type) . ' "' . e($journal->description) . '"'; $subTitle = trans('firefly.' . $journal->transactionType->type) . ' "' . e($journal->description) . '"';
return view('transactions.show', compact('journal', 'subTitle')); return view('transactions.show', compact('journal', 'subTitle','what'));
} }
/** /**
@@ -281,6 +286,7 @@ class TransactionController extends Controller
$repository->deactivateReminder($request->get('reminder_id')); $repository->deactivateReminder($request->get('reminder_id'));
Session::flash('success', 'New transaction "' . $journal->description . '" stored!'); Session::flash('success', 'New transaction "' . $journal->description . '" stored!');
Preferences::mark();
if (intval(Input::get('create_another')) === 1) { if (intval(Input::get('create_another')) === 1) {
// set value so create routine will not overwrite URL: // set value so create routine will not overwrite URL:
@@ -312,6 +318,7 @@ class TransactionController extends Controller
// update, get events by date and sort DESC // update, get events by date and sort DESC
Session::flash('success', 'Transaction "' . e($journalData['description']) . '" updated.'); Session::flash('success', 'Transaction "' . e($journalData['description']) . '" updated.');
Preferences::mark();
if (intval(Input::get('return_to_edit')) === 1) { if (intval(Input::get('return_to_edit')) === 1) {
// set value so edit routine will not overwrite URL: // set value so edit routine will not overwrite URL:

View File

@@ -37,7 +37,6 @@ class Kernel extends HttpKernel
'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth', 'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth',
'guest' => 'FireflyIII\Http\Middleware\RedirectIfAuthenticated', 'guest' => 'FireflyIII\Http\Middleware\RedirectIfAuthenticated',
'range' => 'FireflyIII\Http\Middleware\Range', 'range' => 'FireflyIII\Http\Middleware\Range',
'cleanup' => 'FireflyIII\Http\Middleware\Cleanup',
'reminders' => 'FireflyIII\Http\Middleware\Reminders', 'reminders' => 'FireflyIII\Http\Middleware\Reminders',
]; ];

View File

@@ -1,12 +1,13 @@
<?php namespace FireflyIII\Http\Middleware; <?php namespace FireflyIII\Http\Middleware;
use App; use App;
use Carbon\Carbon;
use Closure; use Closure;
use Config; use Config;
use Illuminate\Contracts\Auth\Guard; use Illuminate\Contracts\Auth\Guard;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Preferences; use Preferences;
use Carbon\Carbon;
/** /**
* Class Authenticate * Class Authenticate
* *

View File

@@ -1,223 +0,0 @@
<?php namespace FireflyIII\Http\Middleware;
use Closure;
use FireflyIII\Models\Account;
use FireflyIII\Models\Bill;
use FireflyIII\Models\Budget;
use FireflyIII\Models\Category;
use FireflyIII\Models\PiggyBank;
use FireflyIII\Models\Preference;
use FireflyIII\Models\Reminder;
use FireflyIII\Models\TransactionJournal;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Http\Request;
use Session;
/**
* Class Cleanup
*
* @codeCoverageIgnore
* @package FireflyIII\Http\Middleware
*/
class Cleanup
{
/**
* The Guard implementation.
*
* @var Guard
*/
protected $auth;
/**
* Create a new filter instance.
*
* @param Guard $auth
*
*/
public function __construct(Guard $auth)
{
$this->auth = $auth;
}
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
*
* @return mixed
*/
public function handle(Request $request, Closure $next)
{
if ($this->auth->guest()) {
return response('Unauthorized.', 401);
}
$count = -1;
bcscale(0);
if (env('RUNCLEANUP') == 'true') {
$count = 0;
$count = bcadd($count, $this->encryptAccountAndBills());
$count = bcadd($count, $this->encryptBudgetsAndCategories());
$count = bcadd($count, $this->encryptPiggiesAndJournals());
$count = bcadd($count, $this->encryptRemindersAndPreferences());
}
if ($count == 0) {
Session::flash('warning', 'Please open the .env file and change RUNCLEANUP=true to RUNCLEANUP=false');
}
return $next($request);
}
/**
* @return int
*/
protected function encryptAccountAndBills()
{
$count = 0;
// encrypt account name
$set = Account::where('encrypted', 0)->take(5)->get();
/** @var Account $entry */
foreach ($set as $entry) {
$count++;
$name = $entry->name;
$entry->name = $name;
$entry->save();
}
unset($set, $entry, $name);
// encrypt bill name
$set = Bill::where('name_encrypted', 0)->take(5)->get();
/** @var Bill $entry */
foreach ($set as $entry) {
$count++;
$name = $entry->name;
$entry->name = $name;
$entry->save();
}
unset($set, $entry, $name);
// encrypt bill match
$set = Bill::where('match_encrypted', 0)->take(5)->get();
/** @var Bill $entry */
foreach ($set as $entry) {
$match = $entry->match;
$entry->match = $match;
$entry->save();
}
unset($set, $entry, $match);
return $count;
}
/**
* @return int
*/
protected function encryptBudgetsAndCategories()
{
$count = 0;
// encrypt budget name
$set = Budget::where('encrypted', 0)->take(5)->get();
/** @var Budget $entry */
foreach ($set as $entry) {
$count++;
$name = $entry->name;
$entry->name = $name;
$entry->save();
}
unset($set, $entry, $name);
// encrypt category name
$set = Category::where('encrypted', 0)->take(5)->get();
/** @var Category $entry */
foreach ($set as $entry) {
$count++;
$name = $entry->name;
$entry->name = $name;
$entry->save();
}
unset($set, $entry, $name);
return $count;
}
/**
* @return int
*/
protected function encryptPiggiesAndJournals()
{
$count = 0;
// encrypt piggy bank name
$set = PiggyBank::where('encrypted', 0)->take(5)->get();
/** @var PiggyBank $entry */
foreach ($set as $entry) {
$count++;
$name = $entry->name;
$entry->name = $name;
$entry->save();
}
unset($set, $entry, $name);
// encrypt transaction journal description
$set = TransactionJournal::where('encrypted', 0)->take(5)->get();
/** @var TransactionJournal $entry */
foreach ($set as $entry) {
$count++;
$description = $entry->description;
$entry->description = $description;
$entry->save();
}
unset($set, $entry, $description);
return $count;
}
/**
* @return int
*/
protected function encryptRemindersAndPreferences()
{
$count = 0;
// encrypt reminder metadata
$set = Reminder::where('encrypted', 0)->take(5)->get();
/** @var Reminder $entry */
foreach ($set as $entry) {
$count++;
$metadata = $entry->metadata;
$entry->metadata = $metadata;
$entry->save();
}
unset($set, $entry, $metadata);
//encrypt preference name
$set = Preference::whereNull('name_encrypted')->take(5)->get();
/** @var Preference $entry */
foreach ($set as $entry) {
$count++;
$name = $entry->name;
$entry->name = $name;
$entry->save();
}
unset($set, $entry, $name);
//encrypt preference data
$set = Preference::whereNull('data_encrypted')->take(5)->get();
/** @var Preference $entry */
foreach ($set as $entry) {
$count++;
$data = $entry->data;
$entry->data = $data;
$entry->save();
}
unset($set, $entry, $data);
return $count;
}
}

View File

@@ -7,6 +7,7 @@ use Carbon\Carbon;
use Closure; use Closure;
use FireflyIII\Models\PiggyBank; use FireflyIII\Models\PiggyBank;
use FireflyIII\Models\Reminder; use FireflyIII\Models\Reminder;
use FireflyIII\Support\CacheProperties;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Contracts\Auth\Guard; use Illuminate\Contracts\Auth\Guard;
use Illuminate\Http\Request; use Illuminate\Http\Request;
@@ -47,35 +48,46 @@ class Reminders
*/ */
public function handle(Request $request, Closure $next) public function handle(Request $request, Closure $next)
{ {
if ($this->auth->check() && !$request->isXmlHttpRequest()) {
$user = $this->auth->user();
if ($this->auth->check() && !$request->isXmlHttpRequest() && $user instanceof User) {
// do reminders stuff. // do reminders stuff.
$reminders = [];
if ($this->auth->user() instanceof User) {
$piggyBanks = $this->auth->user()->piggyBanks()->where('remind_me', 1)->get();
/** @var \FireflyIII\Helpers\Reminders\ReminderHelperInterface $helper */
$helper = App::make('FireflyIII\Helpers\Reminders\ReminderHelperInterface');
/** @var PiggyBank $piggyBank */ // abuse CacheProperties to find out if we need to do this:
foreach ($piggyBanks as $piggyBank) { $cache = new CacheProperties;
$helper->createReminders($piggyBank, new Carbon);
}
// delete invalid reminders
// this is a construction SQLITE cannot handle :(
if (env('DB_CONNECTION') != 'sqlite') {
Reminder::whereUserId($this->auth->user()->id)
->leftJoin('piggy_banks', 'piggy_banks.id', '=', 'remindersable_id')
->whereNull('piggy_banks.id')
->delete();
}
// get and list active reminders: $cache->addProperty('reminders');
$reminders = $this->auth->user()->reminders()->today()->get(); if ($cache->has()) {
$reminders->each( $reminders = $cache->get();
function (Reminder $reminder) use ($helper) { View::share('reminders', $reminders);
$reminder->description = $helper->getReminderText($reminder);
} return $next($request);
);
} }
$piggyBanks = $user->piggyBanks()->where('remind_me', 1)->get();
/** @var \FireflyIII\Helpers\Reminders\ReminderHelperInterface $helper */
$helper = App::make('FireflyIII\Helpers\Reminders\ReminderHelperInterface');
/** @var PiggyBank $piggyBank */
foreach ($piggyBanks as $piggyBank) {
$helper->createReminders($piggyBank, new Carbon);
}
// delete invalid reminders
// this is a construction SQLITE cannot handle :(
if (env('DB_CONNECTION') != 'sqlite') {
Reminder::whereUserId($user->id)->leftJoin('piggy_banks', 'piggy_banks.id', '=', 'remindersable_id')->whereNull('piggy_banks.id')->delete();
}
// get and list active reminders:
$reminders = $user->reminders()->today()->get();
$reminders->each(
function (Reminder $reminder) use ($helper) {
$reminder->description = $helper->getReminderText($reminder);
}
);
$cache->store($reminders);
View::share('reminders', $reminders); View::share('reminders', $reminders);
} }

View File

@@ -48,8 +48,8 @@ class BillFormRequest extends Request
*/ */
public function rules() public function rules()
{ {
$nameRule = 'required|between:1,255|uniqueObjectForUser:bills,name,name_encrypted'; $nameRule = 'required|between:1,255|uniqueObjectForUser:bills,name';
$matchRule = 'required|between:1,255|uniqueObjectForUser:bills,match,match_encrypted'; $matchRule = 'required|between:1,255|uniqueObjectForUser:bills,match';
if (intval(Input::get('id')) > 0) { if (intval(Input::get('id')) > 0) {
$nameRule .= ',' . intval(Input::get('id')); $nameRule .= ',' . intval(Input::get('id'));
$matchRule .= ',' . intval(Input::get('id')); $matchRule .= ',' . intval(Input::get('id'));

View File

@@ -29,9 +29,9 @@ class BudgetFormRequest extends Request
public function rules() public function rules()
{ {
$nameRule = 'required|between:1,100|uniqueObjectForUser:budgets,name,encrypted'; $nameRule = 'required|between:1,100|uniqueObjectForUser:budgets,name';
if (Budget::find(Input::get('id'))) { if (Budget::find(Input::get('id'))) {
$nameRule = 'required|between:1,100|uniqueObjectForUser:budgets,name,encrypted,' . intval(Input::get('id')); $nameRule = 'required|between:1,100|uniqueObjectForUser:budgets,' . intval(Input::get('id'));
} }
return [ return [

View File

@@ -29,9 +29,9 @@ class CategoryFormRequest extends Request
public function rules() public function rules()
{ {
$nameRule = 'required|between:1,100|uniqueObjectForUser:categories,name,encrypted'; $nameRule = 'required|between:1,100|uniqueObjectForUser:categories,name';
if (Category::find(Input::get('id'))) { if (Category::find(Input::get('id'))) {
$nameRule = 'required|between:1,100|uniqueObjectForUser:categories,name,encrypted,' . intval(Input::get('id')); $nameRule = 'required|between:1,100|uniqueObjectForUser:categories,name,' . intval(Input::get('id'));
} }
return [ return [

View File

@@ -0,0 +1,37 @@
<?php
namespace FireflyIII\Http\Requests;
use Auth;
/**
* Class NewUserFormRequest
*
* @codeCoverageIgnore
* @package FireflyIII\Http\Requests
*/
class NewUserFormRequest extends Request
{
/**
* @return bool
*/
public function authorize()
{
// Only allow logged in users
return Auth::check();
}
/**
* @return array
*/
public function rules()
{
return [
'bank_name' => 'required|between:1,200',
'bank_balance' => 'required|numeric',
'savings_balance' => 'numeric',
'credit_card_limit' => 'numeric',
'balance_currency_id' => 'exists:transaction_currencies,id',
];
}
}

View File

@@ -28,10 +28,10 @@ class TagFormRequest extends Request
public function rules() public function rules()
{ {
$idRule = ''; $idRule = '';
$tagRule = 'required|min:1|uniqueObjectForUser:tags,tag,TRUE'; $tagRule = 'required|min:1|uniqueObjectForUser:tags,tag';
if (Tag::find(Input::get('id'))) { if (Tag::find(Input::get('id'))) {
$idRule = 'belongsToUser:tags'; $idRule = 'belongsToUser:tags';
$tagRule = 'required|min:1|uniqueObjectForUser:tags,tag,TRUE,' . Input::get('id'); $tagRule = 'required|min:1|uniqueObjectForUser:tags,tag,' . Input::get('id');
} }
return [ return [

View File

@@ -17,7 +17,7 @@ use FireflyIII\Models\TransactionJournal;
*/ */
Breadcrumbs::register( Breadcrumbs::register(
'home', 'home',
function(Generator $breadcrumbs) { function (Generator $breadcrumbs) {
$breadcrumbs->push(trans('breadcrumbs.home'), route('index')); $breadcrumbs->push(trans('breadcrumbs.home'), route('index'));
} }
@@ -25,7 +25,7 @@ Breadcrumbs::register(
Breadcrumbs::register( Breadcrumbs::register(
'index', 'index',
function(Generator $breadcrumbs) { function (Generator $breadcrumbs) {
$breadcrumbs->push(trans('breadcrumbs.home'), route('index')); $breadcrumbs->push(trans('breadcrumbs.home'), route('index'));
} }
@@ -34,21 +34,21 @@ Breadcrumbs::register(
// accounts // accounts
Breadcrumbs::register( Breadcrumbs::register(
'accounts.index', function(Generator $breadcrumbs, $what) { 'accounts.index', function (Generator $breadcrumbs, $what) {
$breadcrumbs->parent('home'); $breadcrumbs->parent('home');
$breadcrumbs->push(trans('breadcrumbs.' . strtolower(e($what)) . '_accounts'), route('accounts.index', [$what])); $breadcrumbs->push(trans('breadcrumbs.' . strtolower(e($what)) . '_accounts'), route('accounts.index', [$what]));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'accounts.create', function(Generator $breadcrumbs, $what) { 'accounts.create', function (Generator $breadcrumbs, $what) {
$breadcrumbs->parent('accounts.index', $what); $breadcrumbs->parent('accounts.index', $what);
$breadcrumbs->push(trans('breadcrumbs.new_' . strtolower(e($what)) . '_account'), route('accounts.create', [$what])); $breadcrumbs->push(trans('breadcrumbs.new_' . strtolower(e($what)) . '_account'), route('accounts.create', [$what]));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'accounts.show', function(Generator $breadcrumbs, Account $account) { 'accounts.show', function (Generator $breadcrumbs, Account $account) {
$what = Config::get('firefly.shortNamesByFullName.' . $account->accountType->type); $what = Config::get('firefly.shortNamesByFullName.' . $account->accountType->type);
@@ -58,7 +58,7 @@ Breadcrumbs::register(
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'accounts.delete', function(Generator $breadcrumbs, Account $account) { 'accounts.delete', function (Generator $breadcrumbs, Account $account) {
$breadcrumbs->parent('accounts.show', $account); $breadcrumbs->parent('accounts.show', $account);
$breadcrumbs->push(trans('breadcrumbs.delete_account', ['name' => e($account->name)]), route('accounts.delete', [$account->id])); $breadcrumbs->push(trans('breadcrumbs.delete_account', ['name' => e($account->name)]), route('accounts.delete', [$account->id]));
} }
@@ -66,7 +66,7 @@ Breadcrumbs::register(
Breadcrumbs::register( Breadcrumbs::register(
'accounts.edit', function(Generator $breadcrumbs, Account $account) { 'accounts.edit', function (Generator $breadcrumbs, Account $account) {
$breadcrumbs->parent('accounts.show', $account); $breadcrumbs->parent('accounts.show', $account);
$what = Config::get('firefly.shortNamesByFullName.' . $account->accountType->type); $what = Config::get('firefly.shortNamesByFullName.' . $account->accountType->type);
@@ -76,40 +76,40 @@ Breadcrumbs::register(
// budgets. // budgets.
Breadcrumbs::register( Breadcrumbs::register(
'budgets.index', function(Generator $breadcrumbs) { 'budgets.index', function (Generator $breadcrumbs) {
$breadcrumbs->parent('home'); $breadcrumbs->parent('home');
$breadcrumbs->push(trans('breadcrumbs.budgets'), route('budgets.index')); $breadcrumbs->push(trans('breadcrumbs.budgets'), route('budgets.index'));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'budgets.create', function(Generator $breadcrumbs) { 'budgets.create', function (Generator $breadcrumbs) {
$breadcrumbs->parent('budgets.index'); $breadcrumbs->parent('budgets.index');
$breadcrumbs->push(trans('breadcrumbs.newBudget'), route('budgets.create')); $breadcrumbs->push(trans('breadcrumbs.newBudget'), route('budgets.create'));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'budgets.edit', function(Generator $breadcrumbs, Budget $budget) { 'budgets.edit', function (Generator $breadcrumbs, Budget $budget) {
$breadcrumbs->parent('budgets.show', $budget); $breadcrumbs->parent('budgets.show', $budget);
$breadcrumbs->push(trans('breadcrumbs.edit_budget', ['name' => e($budget->name)]), route('budgets.edit', [$budget->id])); $breadcrumbs->push(trans('breadcrumbs.edit_budget', ['name' => e($budget->name)]), route('budgets.edit', [$budget->id]));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'budgets.delete', function(Generator $breadcrumbs, Budget $budget) { 'budgets.delete', function (Generator $breadcrumbs, Budget $budget) {
$breadcrumbs->parent('budgets.show', $budget); $breadcrumbs->parent('budgets.show', $budget);
$breadcrumbs->push(trans('breadcrumbs.delete_budget', ['name' => e($budget->name)]), route('budgets.delete', [$budget->id])); $breadcrumbs->push(trans('breadcrumbs.delete_budget', ['name' => e($budget->name)]), route('budgets.delete', [$budget->id]));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'budgets.noBudget', function(Generator $breadcrumbs, $subTitle) { 'budgets.noBudget', function (Generator $breadcrumbs, $subTitle) {
$breadcrumbs->parent('budgets.index'); $breadcrumbs->parent('budgets.index');
$breadcrumbs->push($subTitle, route('budgets.noBudget')); $breadcrumbs->push($subTitle, route('budgets.noBudget'));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'budgets.show', function(Generator $breadcrumbs, Budget $budget, LimitRepetition $repetition = null) { 'budgets.show', function (Generator $breadcrumbs, Budget $budget, LimitRepetition $repetition = null) {
$breadcrumbs->parent('budgets.index'); $breadcrumbs->parent('budgets.index');
$breadcrumbs->push(e($budget->name), route('budgets.show', [$budget->id])); $breadcrumbs->push(e($budget->name), route('budgets.show', [$budget->id]));
if (!is_null($repetition) && !is_null($repetition->id)) { if (!is_null($repetition) && !is_null($repetition->id)) {
@@ -122,33 +122,33 @@ Breadcrumbs::register(
// categories // categories
Breadcrumbs::register( Breadcrumbs::register(
'categories.index', function(Generator $breadcrumbs) { 'categories.index', function (Generator $breadcrumbs) {
$breadcrumbs->parent('home'); $breadcrumbs->parent('home');
$breadcrumbs->push(trans('breadcrumbs.categories'), route('categories.index')); $breadcrumbs->push(trans('breadcrumbs.categories'), route('categories.index'));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'categories.create', function(Generator $breadcrumbs) { 'categories.create', function (Generator $breadcrumbs) {
$breadcrumbs->parent('categories.index'); $breadcrumbs->parent('categories.index');
$breadcrumbs->push(trans('breadcrumbs.newCategory'), route('categories.create')); $breadcrumbs->push(trans('breadcrumbs.newCategory'), route('categories.create'));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'categories.edit', function(Generator $breadcrumbs, Category $category) { 'categories.edit', function (Generator $breadcrumbs, Category $category) {
$breadcrumbs->parent('categories.show', $category); $breadcrumbs->parent('categories.show', $category);
$breadcrumbs->push(trans('breadcrumbs.edit_category', ['name' => e($category->name)]), route('categories.edit', [$category->id])); $breadcrumbs->push(trans('breadcrumbs.edit_category', ['name' => e($category->name)]), route('categories.edit', [$category->id]));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'categories.delete', function(Generator $breadcrumbs, Category $category) { 'categories.delete', function (Generator $breadcrumbs, Category $category) {
$breadcrumbs->parent('categories.show', $category); $breadcrumbs->parent('categories.show', $category);
$breadcrumbs->push(trans('breadcrumbs.delete_category', ['name' => e($category->name)]), route('categories.delete', [$category->id])); $breadcrumbs->push(trans('breadcrumbs.delete_category', ['name' => e($category->name)]), route('categories.delete', [$category->id]));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'categories.show', function(Generator $breadcrumbs, Category $category) { 'categories.show', function (Generator $breadcrumbs, Category $category) {
$breadcrumbs->parent('categories.index'); $breadcrumbs->parent('categories.index');
$breadcrumbs->push(e($category->name), route('categories.show', [$category->id])); $breadcrumbs->push(e($category->name), route('categories.show', [$category->id]));
@@ -156,7 +156,7 @@ Breadcrumbs::register(
); );
Breadcrumbs::register( Breadcrumbs::register(
'categories.noCategory', function(Generator $breadcrumbs, $subTitle) { 'categories.noCategory', function (Generator $breadcrumbs, $subTitle) {
$breadcrumbs->parent('categories.index'); $breadcrumbs->parent('categories.index');
$breadcrumbs->push($subTitle, route('categories.noCategory')); $breadcrumbs->push($subTitle, route('categories.noCategory'));
} }
@@ -164,20 +164,20 @@ Breadcrumbs::register(
// currencies. // currencies.
Breadcrumbs::register( Breadcrumbs::register(
'currency.index', function(Generator $breadcrumbs) { 'currency.index', function (Generator $breadcrumbs) {
$breadcrumbs->parent('home'); $breadcrumbs->parent('home');
$breadcrumbs->push(trans('breadcrumbs.currencies'), route('currency.index')); $breadcrumbs->push(trans('breadcrumbs.currencies'), route('currency.index'));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'currency.edit', function(Generator $breadcrumbs, TransactionCurrency $currency) { 'currency.edit', function (Generator $breadcrumbs, TransactionCurrency $currency) {
$breadcrumbs->parent('currency.index'); $breadcrumbs->parent('currency.index');
$breadcrumbs->push(trans('breadcrumbs.edit_currency', ['name' => e($currency->name)]), route('currency.edit', [$currency->id])); $breadcrumbs->push(trans('breadcrumbs.edit_currency', ['name' => e($currency->name)]), route('currency.edit', [$currency->id]));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'currency.delete', function(Generator $breadcrumbs, TransactionCurrency $currency) { 'currency.delete', function (Generator $breadcrumbs, TransactionCurrency $currency) {
$breadcrumbs->parent('currency.index'); $breadcrumbs->parent('currency.index');
$breadcrumbs->push(trans('breadcrumbs.delete_currency', ['name' => e($currency->name)]), route('currency.delete', [$currency->id])); $breadcrumbs->push(trans('breadcrumbs.delete_currency', ['name' => e($currency->name)]), route('currency.delete', [$currency->id]));
} }
@@ -186,33 +186,33 @@ Breadcrumbs::register(
// piggy banks // piggy banks
Breadcrumbs::register( Breadcrumbs::register(
'piggy-banks.index', function(Generator $breadcrumbs) { 'piggy-banks.index', function (Generator $breadcrumbs) {
$breadcrumbs->parent('home'); $breadcrumbs->parent('home');
$breadcrumbs->push(trans('breadcrumbs.piggyBanks'), route('piggy-banks.index')); $breadcrumbs->push(trans('breadcrumbs.piggyBanks'), route('piggy-banks.index'));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'piggy-banks.create', function(Generator $breadcrumbs) { 'piggy-banks.create', function (Generator $breadcrumbs) {
$breadcrumbs->parent('piggy-banks.index'); $breadcrumbs->parent('piggy-banks.index');
$breadcrumbs->push(trans('breadcrumbs.newPiggyBank'), route('piggy-banks.create')); $breadcrumbs->push(trans('breadcrumbs.newPiggyBank'), route('piggy-banks.create'));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'piggy-banks.edit', function(Generator $breadcrumbs, PiggyBank $piggyBank) { 'piggy-banks.edit', function (Generator $breadcrumbs, PiggyBank $piggyBank) {
$breadcrumbs->parent('piggy-banks.show', $piggyBank); $breadcrumbs->parent('piggy-banks.show', $piggyBank);
$breadcrumbs->push(trans('breadcrumbs.edit_piggyBank', ['name' => e($piggyBank->name)]), route('piggy-banks.edit', [$piggyBank->id])); $breadcrumbs->push(trans('breadcrumbs.edit_piggyBank', ['name' => e($piggyBank->name)]), route('piggy-banks.edit', [$piggyBank->id]));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'piggy-banks.delete', function(Generator $breadcrumbs, PiggyBank $piggyBank) { 'piggy-banks.delete', function (Generator $breadcrumbs, PiggyBank $piggyBank) {
$breadcrumbs->parent('piggy-banks.show', $piggyBank); $breadcrumbs->parent('piggy-banks.show', $piggyBank);
$breadcrumbs->push(trans('breadcrumbs.delete_piggyBank', ['name' => e($piggyBank->name)]), route('piggy-banks.delete', [$piggyBank->id])); $breadcrumbs->push(trans('breadcrumbs.delete_piggyBank', ['name' => e($piggyBank->name)]), route('piggy-banks.delete', [$piggyBank->id]));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'piggy-banks.show', function(Generator $breadcrumbs, PiggyBank $piggyBank) { 'piggy-banks.show', function (Generator $breadcrumbs, PiggyBank $piggyBank) {
$breadcrumbs->parent('piggy-banks.index'); $breadcrumbs->parent('piggy-banks.index');
$breadcrumbs->push(e($piggyBank->name), route('piggy-banks.show', [$piggyBank->id])); $breadcrumbs->push(e($piggyBank->name), route('piggy-banks.show', [$piggyBank->id]));
@@ -221,7 +221,7 @@ Breadcrumbs::register(
// preferences // preferences
Breadcrumbs::register( Breadcrumbs::register(
'preferences', function(Generator $breadcrumbs) { 'preferences', function (Generator $breadcrumbs) {
$breadcrumbs->parent('home'); $breadcrumbs->parent('home');
$breadcrumbs->push(trans('breadcrumbs.preferences'), route('preferences')); $breadcrumbs->push(trans('breadcrumbs.preferences'), route('preferences'));
@@ -230,14 +230,14 @@ Breadcrumbs::register(
// profile // profile
Breadcrumbs::register( Breadcrumbs::register(
'profile', function(Generator $breadcrumbs) { 'profile', function (Generator $breadcrumbs) {
$breadcrumbs->parent('home'); $breadcrumbs->parent('home');
$breadcrumbs->push(trans('breadcrumbs.profile'), route('profile')); $breadcrumbs->push(trans('breadcrumbs.profile'), route('profile'));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'change-password', function(Generator $breadcrumbs) { 'change-password', function (Generator $breadcrumbs) {
$breadcrumbs->parent('profile'); $breadcrumbs->parent('profile');
$breadcrumbs->push(trans('breadcrumbs.changePassword'), route('change-password')); $breadcrumbs->push(trans('breadcrumbs.changePassword'), route('change-password'));
@@ -246,33 +246,33 @@ Breadcrumbs::register(
// bills // bills
Breadcrumbs::register( Breadcrumbs::register(
'bills.index', function(Generator $breadcrumbs) { 'bills.index', function (Generator $breadcrumbs) {
$breadcrumbs->parent('home'); $breadcrumbs->parent('home');
$breadcrumbs->push(trans('breadcrumbs.bills'), route('bills.index')); $breadcrumbs->push(trans('breadcrumbs.bills'), route('bills.index'));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'bills.create', function(Generator $breadcrumbs) { 'bills.create', function (Generator $breadcrumbs) {
$breadcrumbs->parent('bills.index'); $breadcrumbs->parent('bills.index');
$breadcrumbs->push(trans('breadcrumbs.newBill'), route('bills.create')); $breadcrumbs->push(trans('breadcrumbs.newBill'), route('bills.create'));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'bills.edit', function(Generator $breadcrumbs, Bill $bill) { 'bills.edit', function (Generator $breadcrumbs, Bill $bill) {
$breadcrumbs->parent('bills.show', $bill); $breadcrumbs->parent('bills.show', $bill);
$breadcrumbs->push(trans('breadcrumbs.edit_bill', ['name' => e($bill->name)]), route('bills.edit', [$bill->id])); $breadcrumbs->push(trans('breadcrumbs.edit_bill', ['name' => e($bill->name)]), route('bills.edit', [$bill->id]));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'bills.delete', function(Generator $breadcrumbs, Bill $bill) { 'bills.delete', function (Generator $breadcrumbs, Bill $bill) {
$breadcrumbs->parent('bills.show', $bill); $breadcrumbs->parent('bills.show', $bill);
$breadcrumbs->push(trans('breadcrumbs.delete_bill', ['name' => e($bill->name)]), route('bills.delete', [$bill->id])); $breadcrumbs->push(trans('breadcrumbs.delete_bill', ['name' => e($bill->name)]), route('bills.delete', [$bill->id]));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'bills.show', function(Generator $breadcrumbs, Bill $bill) { 'bills.show', function (Generator $breadcrumbs, Bill $bill) {
$breadcrumbs->parent('bills.index'); $breadcrumbs->parent('bills.index');
$breadcrumbs->push(e($bill->name), route('bills.show', [$bill->id])); $breadcrumbs->push(e($bill->name), route('bills.show', [$bill->id]));
@@ -281,7 +281,7 @@ Breadcrumbs::register(
// reminders // reminders
Breadcrumbs::register( Breadcrumbs::register(
'reminders.index', function(Generator $breadcrumbs) { 'reminders.index', function (Generator $breadcrumbs) {
$breadcrumbs->parent('home'); $breadcrumbs->parent('home');
$breadcrumbs->push(trans('breadcrumbs.reminders'), route('reminders.index')); $breadcrumbs->push(trans('breadcrumbs.reminders'), route('reminders.index'));
@@ -290,7 +290,7 @@ Breadcrumbs::register(
// reminders // reminders
Breadcrumbs::register( Breadcrumbs::register(
'reminders.show', function(Generator $breadcrumbs, Reminder $reminder) { 'reminders.show', function (Generator $breadcrumbs, Reminder $reminder) {
$breadcrumbs->parent('reminders.index'); $breadcrumbs->parent('reminders.index');
$breadcrumbs->push(trans('breadcrumbs.reminder', ['id' => e($reminder->id)]), route('reminders.show', [$reminder->id])); $breadcrumbs->push(trans('breadcrumbs.reminder', ['id' => e($reminder->id)]), route('reminders.show', [$reminder->id]));
@@ -300,14 +300,14 @@ Breadcrumbs::register(
// reports // reports
Breadcrumbs::register( Breadcrumbs::register(
'reports.index', function(Generator $breadcrumbs) { 'reports.index', function (Generator $breadcrumbs) {
$breadcrumbs->parent('home'); $breadcrumbs->parent('home');
$breadcrumbs->push(trans('breadcrumbs.reports'), route('reports.index')); $breadcrumbs->push(trans('breadcrumbs.reports'), route('reports.index'));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'reports.year', function(Generator $breadcrumbs, Carbon $date, $shared) { 'reports.year', function (Generator $breadcrumbs, Carbon $date, $shared) {
$breadcrumbs->parent('reports.index'); $breadcrumbs->parent('reports.index');
if ($shared) { if ($shared) {
$title = trans('breadcrumbs.yearly_report_shared', ['date' => $date->year]); $title = trans('breadcrumbs.yearly_report_shared', ['date' => $date->year]);
@@ -319,7 +319,7 @@ Breadcrumbs::register(
); );
Breadcrumbs::register( Breadcrumbs::register(
'reports.month', function(Generator $breadcrumbs, Carbon $date, $shared) { 'reports.month', function (Generator $breadcrumbs, Carbon $date, $shared) {
$breadcrumbs->parent('reports.year', $date, $shared); $breadcrumbs->parent('reports.year', $date, $shared);
if ($shared) { if ($shared) {
@@ -334,7 +334,7 @@ Breadcrumbs::register(
// search // search
Breadcrumbs::register( Breadcrumbs::register(
'search', function(Generator $breadcrumbs, $query) { 'search', function (Generator $breadcrumbs, $query) {
$breadcrumbs->parent('home'); $breadcrumbs->parent('home');
$breadcrumbs->push(trans('breadcrumbs.searchResult', ['query' => e($query)]), route('search')); $breadcrumbs->push(trans('breadcrumbs.searchResult', ['query' => e($query)]), route('search'));
} }
@@ -342,33 +342,33 @@ Breadcrumbs::register(
// transactions // transactions
Breadcrumbs::register( Breadcrumbs::register(
'transactions.index', function(Generator $breadcrumbs, $what) { 'transactions.index', function (Generator $breadcrumbs, $what) {
$breadcrumbs->parent('home'); $breadcrumbs->parent('home');
$breadcrumbs->push(trans('breadcrumbs.' . $what . '_list'), route('transactions.index', [$what])); $breadcrumbs->push(trans('breadcrumbs.' . $what . '_list'), route('transactions.index', [$what]));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'transactions.create', function(Generator $breadcrumbs, $what) { 'transactions.create', function (Generator $breadcrumbs, $what) {
$breadcrumbs->parent('transactions.index', $what); $breadcrumbs->parent('transactions.index', $what);
$breadcrumbs->push(trans('breadcrumbs.create_' . e($what)), route('transactions.create', [$what])); $breadcrumbs->push(trans('breadcrumbs.create_' . e($what)), route('transactions.create', [$what]));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'transactions.edit', function(Generator $breadcrumbs, TransactionJournal $journal) { 'transactions.edit', function (Generator $breadcrumbs, TransactionJournal $journal) {
$breadcrumbs->parent('transactions.show', $journal); $breadcrumbs->parent('transactions.show', $journal);
$breadcrumbs->push(trans('breadcrumbs.edit_journal', ['description' => $journal->description]), route('transactions.edit', [$journal->id])); $breadcrumbs->push(trans('breadcrumbs.edit_journal', ['description' => $journal->description]), route('transactions.edit', [$journal->id]));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'transactions.delete', function(Generator $breadcrumbs, TransactionJournal $journal) { 'transactions.delete', function (Generator $breadcrumbs, TransactionJournal $journal) {
$breadcrumbs->parent('transactions.show', $journal); $breadcrumbs->parent('transactions.show', $journal);
$breadcrumbs->push(trans('breadcrumbs.delete_journal', ['description' => e($journal->description)]), route('transactions.delete', [$journal->id])); $breadcrumbs->push(trans('breadcrumbs.delete_journal', ['description' => e($journal->description)]), route('transactions.delete', [$journal->id]));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'transactions.show', function(Generator $breadcrumbs, TransactionJournal $journal) { 'transactions.show', function (Generator $breadcrumbs, TransactionJournal $journal) {
$breadcrumbs->parent('transactions.index', strtolower($journal->transactionType->type)); $breadcrumbs->parent('transactions.index', strtolower($journal->transactionType->type));
$breadcrumbs->push($journal->description, route('transactions.show', [$journal->id])); $breadcrumbs->push($journal->description, route('transactions.show', [$journal->id]));
@@ -378,28 +378,28 @@ Breadcrumbs::register(
// tags // tags
Breadcrumbs::register( Breadcrumbs::register(
'tags.index', function(Generator $breadcrumbs) { 'tags.index', function (Generator $breadcrumbs) {
$breadcrumbs->parent('home'); $breadcrumbs->parent('home');
$breadcrumbs->push(trans('breadcrumbs.tags'), route('tags.index')); $breadcrumbs->push(trans('breadcrumbs.tags'), route('tags.index'));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'tags.create', function(Generator $breadcrumbs) { 'tags.create', function (Generator $breadcrumbs) {
$breadcrumbs->parent('tags.index'); $breadcrumbs->parent('tags.index');
$breadcrumbs->push(trans('breadcrumbs.createTag'), route('tags.create')); $breadcrumbs->push(trans('breadcrumbs.createTag'), route('tags.create'));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'tags.edit', function(Generator $breadcrumbs, Tag $tag) { 'tags.edit', function (Generator $breadcrumbs, Tag $tag) {
$breadcrumbs->parent('tags.show', $tag); $breadcrumbs->parent('tags.show', $tag);
$breadcrumbs->push(trans('breadcrumbs.edit_tag', ['tag' => e($tag->tag)]), route('tags.edit', [$tag->id])); $breadcrumbs->push(trans('breadcrumbs.edit_tag', ['tag' => e($tag->tag)]), route('tags.edit', [$tag->id]));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'tags.delete', function(Generator $breadcrumbs, Tag $tag) { 'tags.delete', function (Generator $breadcrumbs, Tag $tag) {
$breadcrumbs->parent('tags.show', $tag); $breadcrumbs->parent('tags.show', $tag);
$breadcrumbs->push(trans('breadcrumbs.delete_tag', ['tag' => e($tag->tag)]), route('tags.delete', [$tag->id])); $breadcrumbs->push(trans('breadcrumbs.delete_tag', ['tag' => e($tag->tag)]), route('tags.delete', [$tag->id]));
} }
@@ -407,7 +407,7 @@ Breadcrumbs::register(
Breadcrumbs::register( Breadcrumbs::register(
'tags.show', function(Generator $breadcrumbs, Tag $tag) { 'tags.show', function (Generator $breadcrumbs, Tag $tag) {
$breadcrumbs->parent('tags.index'); $breadcrumbs->parent('tags.index');
$breadcrumbs->push(e($tag->tag), route('tags.show', [$tag->id])); $breadcrumbs->push(e($tag->tag), route('tags.show', [$tag->id]));
} }

View File

@@ -15,13 +15,13 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
// models // models
Route::bind( Route::bind(
'account', 'account',
function($value) { function ($value) {
if (Auth::check()) { if (Auth::check()) {
$object = Account::leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id') $object = Account::leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
->where('account_types.editable', 1) ->where('account_types.editable', 1)
->where('accounts.id', $value) ->where('accounts.id', $value)
->where('user_id', Auth::user()->id) ->where('user_id', Auth::user()->id)
->first(['accounts.*']); ->first(['accounts.*']);
if ($object) { if ($object) {
return $object; return $object;
} }
@@ -31,7 +31,7 @@ Route::bind(
); );
Route::bind( Route::bind(
'tj', function($value) { 'tj', function ($value) {
if (Auth::check()) { if (Auth::check()) {
$object = TransactionJournal::where('id', $value)->where('user_id', Auth::user()->id)->first(); $object = TransactionJournal::where('id', $value)->where('user_id', Auth::user()->id)->first();
if ($object) { if ($object) {
@@ -44,7 +44,7 @@ Route::bind(
); );
Route::bind( Route::bind(
'currency', function($value) { 'currency', function ($value) {
if (Auth::check()) { if (Auth::check()) {
$object = TransactionCurrency::find($value); $object = TransactionCurrency::find($value);
if ($object) { if ($object) {
@@ -56,7 +56,7 @@ Route::bind(
); );
Route::bind( Route::bind(
'bill', function($value) { 'bill', function ($value) {
if (Auth::check()) { if (Auth::check()) {
$object = Bill::where('id', $value)->where('user_id', Auth::user()->id)->first(); $object = Bill::where('id', $value)->where('user_id', Auth::user()->id)->first();
if ($object) { if ($object) {
@@ -69,7 +69,7 @@ Route::bind(
); );
Route::bind( Route::bind(
'budget', function($value) { 'budget', function ($value) {
if (Auth::check()) { if (Auth::check()) {
$object = Budget::where('id', $value)->where('user_id', Auth::user()->id)->first(); $object = Budget::where('id', $value)->where('user_id', Auth::user()->id)->first();
if ($object) { if ($object) {
@@ -82,7 +82,7 @@ Route::bind(
); );
Route::bind( Route::bind(
'reminder', function($value) { 'reminder', function ($value) {
if (Auth::check()) { if (Auth::check()) {
$object = Reminder::where('id', $value)->where('user_id', Auth::user()->id)->first(); $object = Reminder::where('id', $value)->where('user_id', Auth::user()->id)->first();
if ($object) { if ($object) {
@@ -95,13 +95,13 @@ Route::bind(
); );
Route::bind( Route::bind(
'limitrepetition', function($value) { 'limitrepetition', function ($value) {
if (Auth::check()) { if (Auth::check()) {
$object = LimitRepetition::where('limit_repetitions.id', $value) $object = LimitRepetition::where('limit_repetitions.id', $value)
->leftjoin('budget_limits', 'budget_limits.id', '=', 'limit_repetitions.budget_limit_id') ->leftjoin('budget_limits', 'budget_limits.id', '=', 'limit_repetitions.budget_limit_id')
->leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id') ->leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id')
->where('budgets.user_id', Auth::user()->id) ->where('budgets.user_id', Auth::user()->id)
->first(['limit_repetitions.*']); ->first(['limit_repetitions.*']);
if ($object) { if ($object) {
return $object; return $object;
} }
@@ -112,12 +112,12 @@ Route::bind(
); );
Route::bind( Route::bind(
'piggyBank', function($value) { 'piggyBank', function ($value) {
if (Auth::check()) { if (Auth::check()) {
$object = PiggyBank::where('piggy_banks.id', $value) $object = PiggyBank::where('piggy_banks.id', $value)
->leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id') ->leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')
->where('accounts.user_id', Auth::user()->id) ->where('accounts.user_id', Auth::user()->id)
->first(['piggy_banks.*']); ->first(['piggy_banks.*']);
if ($object) { if ($object) {
return $object; return $object;
} }
@@ -128,7 +128,7 @@ Route::bind(
); );
Route::bind( Route::bind(
'category', function($value) { 'category', function ($value) {
if (Auth::check()) { if (Auth::check()) {
$object = Category::where('id', $value)->where('user_id', Auth::user()->id)->first(); $object = Category::where('id', $value)->where('user_id', Auth::user()->id)->first();
if ($object) { if ($object) {
@@ -142,7 +142,7 @@ Route::bind(
/** @noinspection PhpUnusedParameterInspection */ /** @noinspection PhpUnusedParameterInspection */
Route::bind( Route::bind(
'reminder', function($value) { 'reminder', function ($value) {
if (Auth::check()) { if (Auth::check()) {
/** @var \FireflyIII\Models\Reminder $object */ /** @var \FireflyIII\Models\Reminder $object */
$object = Reminder::find($value); $object = Reminder::find($value);
@@ -158,7 +158,7 @@ Route::bind(
); );
Route::bind( Route::bind(
'tag', function($value) { 'tag', function ($value) {
if (Auth::check()) { if (Auth::check()) {
$object = Tag::where('id', $value)->where('user_id', Auth::user()->id)->first(); $object = Tag::where('id', $value)->where('user_id', Auth::user()->id)->first();
if ($object) { if ($object) {
@@ -183,14 +183,12 @@ Route::controllers(
] ]
); );
Route::get('/routes', ['uses' => 'HomeController@routes', 'as' => 'routes']);
/** /**
* Home Controller * Home Controller
*/ */
Route::group( Route::group(
['middleware' => ['auth', 'range', 'reminders']], function() { ['middleware' => ['auth', 'range', 'reminders']], function () {
Route::get('/', ['uses' => 'HomeController@index', 'as' => 'index', 'middleware' => 'cleanup']); Route::get('/', ['uses' => 'HomeController@index', 'as' => 'index']);
Route::get('/home', ['uses' => 'HomeController@index', 'as' => 'home']); Route::get('/home', ['uses' => 'HomeController@index', 'as' => 'home']);
Route::post('/daterange', ['uses' => 'HomeController@dateRange', 'as' => 'daterange']); Route::post('/daterange', ['uses' => 'HomeController@dateRange', 'as' => 'daterange']);
Route::get('/flush', ['uses' => 'HomeController@flush', 'as' => 'flush']); Route::get('/flush', ['uses' => 'HomeController@flush', 'as' => 'flush']);
@@ -317,6 +315,12 @@ Route::group(
Route::get('/json/box/bills-paid', ['uses' => 'JsonController@boxBillsPaid', 'as' => 'json.box.unpaid']); Route::get('/json/box/bills-paid', ['uses' => 'JsonController@boxBillsPaid', 'as' => 'json.box.unpaid']);
Route::get('/json/transaction-journals/{what}', 'JsonController@transactionJournals'); Route::get('/json/transaction-journals/{what}', 'JsonController@transactionJournals');
/**
* New user Controller
*/
Route::get('/new-user', ['uses' => 'NewUserController@index', 'as' => 'new-user.index']);
Route::post('/new-user/submit', ['uses' => 'NewUserController@submit', 'as' => 'new-user.submit']);
/** /**
* Piggy Bank Controller * Piggy Bank Controller
*/ */

View File

@@ -11,22 +11,22 @@ use Watson\Validating\ValidatingTrait;
* Class Account * Class Account
* *
* @package FireflyIII\Models * @package FireflyIII\Models
* @property integer $id * @property integer $id
* @property \Carbon\Carbon $created_at * @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at * @property \Carbon\Carbon $updated_at
* @property \Carbon\Carbon $deleted_at * @property \Carbon\Carbon $deleted_at
* @property integer $user_id * @property integer $user_id
* @property integer $account_type_id * @property integer $account_type_id
* @property string $name * @property string $name
* @property boolean $active * @property boolean $active
* @property boolean $encrypted * @property boolean $encrypted
* @property float $virtual_balance * @property float $virtual_balance
* @property string $virtual_balance_encrypted * @property string $virtual_balance_encrypted
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\AccountMeta[] $accountMeta * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\AccountMeta[] $accountMeta
* @property-read \FireflyIII\Models\AccountType $accountType * @property-read \FireflyIII\Models\AccountType $accountType
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\PiggyBank[] $piggyBanks * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\PiggyBank[] $piggyBanks
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Transaction[] $transactions * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Transaction[] $transactions
* @property-read \FireflyIII\User $user * @property-read \FireflyIII\User $user
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Account whereId($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Account whereId($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Account whereCreatedAt($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Account whereCreatedAt($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Account whereUpdatedAt($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Account whereUpdatedAt($value)
@@ -40,14 +40,13 @@ use Watson\Validating\ValidatingTrait;
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Account whereVirtualBalanceEncrypted($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Account whereVirtualBalanceEncrypted($value)
* @method static \FireflyIII\Models\Account accountTypeIn($types) * @method static \FireflyIII\Models\Account accountTypeIn($types)
* @method static \FireflyIII\Models\Account hasMetaValue($name, $value) * @method static \FireflyIII\Models\Account hasMetaValue($name, $value)
* @property boolean joinedAccountTypes * @property boolean joinedAccountTypes
* @property mixed startBalance * @property mixed startBalance
* @property mixed endBalance * @property mixed endBalance
* @property mixed lastActivityDate * @property mixed lastActivityDate
* @property mixed piggyBalance * @property mixed piggyBalance
* @property mixed difference * @property mixed difference
* @propery mixed percentage * @property mixed percentage
*
*/ */
class Account extends Model class Account extends Model
{ {
@@ -216,7 +215,7 @@ class Account extends Model
{ {
$joinName = str_replace('.', '_', $name); $joinName = str_replace('.', '_', $name);
$query->leftJoin( $query->leftJoin(
'account_meta as ' . $joinName, function(JoinClause $join) use ($joinName, $name) { 'account_meta as ' . $joinName, function (JoinClause $join) use ($joinName, $name) {
$join->on($joinName . '.account_id', '=', 'accounts.id')->where($joinName . '.name', '=', $name); $join->on($joinName . '.account_id', '=', 'accounts.id')->where($joinName . '.name', '=', $name);
} }
); );

View File

@@ -6,14 +6,14 @@ use Watson\Validating\ValidatingTrait;
/** /**
* Class AccountMeta * Class AccountMeta
* *
* @codeCoverageIgnore * @codeCoverageIgnore
* @package FireflyIII\Models * @package FireflyIII\Models
* @property integer $id * @property integer $id
* @property \Carbon\Carbon $created_at * @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at * @property \Carbon\Carbon $updated_at
* @property integer $account_id * @property integer $account_id
* @property string $name * @property string $name
* @property string $data * @property string $data
* @property-read \FireflyIII\Models\Account $account * @property-read \FireflyIII\Models\Account $account
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\AccountMeta whereId($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\AccountMeta whereId($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\AccountMeta whereCreatedAt($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\AccountMeta whereCreatedAt($value)
@@ -33,7 +33,7 @@ class AccountMeta extends Model
'name' => 'required|between:1,100', 'name' => 'required|between:1,100',
'data' => 'required' 'data' => 'required'
]; ];
protected $table = 'account_meta'; protected $table = 'account_meta';
/** /**
* *

View File

@@ -5,13 +5,13 @@ use Illuminate\Database\Eloquent\Model;
/** /**
* Class AccountType * Class AccountType
* *
* @codeCoverageIgnore * @codeCoverageIgnore
* @package FireflyIII\Models * @package FireflyIII\Models
* @property integer $id * @property integer $id
* @property \Carbon\Carbon $created_at * @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at * @property \Carbon\Carbon $updated_at
* @property string $type * @property string $type
* @property boolean $editable * @property boolean $editable
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Account[] $accounts * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Account[] $accounts
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\AccountType whereId($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\AccountType whereId($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\AccountType whereCreatedAt($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\AccountType whereCreatedAt($value)

View File

@@ -7,26 +7,26 @@ use Illuminate\Database\Eloquent\Model;
* FireflyIII\Models\Bill * FireflyIII\Models\Bill
* *
* @codeCoverageIgnore Class Bill * @codeCoverageIgnore Class Bill
* @package FireflyIII\Models * @package FireflyIII\Models
* @property integer $id * @property integer $id
* @property \Carbon\Carbon $created_at * @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at * @property \Carbon\Carbon $updated_at
* @property integer $user_id * @property integer $user_id
* @property string $name * @property string $name
* @property string $match * @property string $match
* @property float $amount_min * @property float $amount_min
* @property string $amount_min_encrypted * @property string $amount_min_encrypted
* @property float $amount_max * @property float $amount_max
* @property string $amount_max_encrypted * @property string $amount_max_encrypted
* @property \Carbon\Carbon $date * @property \Carbon\Carbon $date
* @property boolean $active * @property boolean $active
* @property boolean $automatch * @property boolean $automatch
* @property string $repeat_freq * @property string $repeat_freq
* @property integer $skip * @property integer $skip
* @property boolean $name_encrypted * @property boolean $name_encrypted
* @property boolean $match_encrypted * @property boolean $match_encrypted
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\TransactionJournal[] $transactionjournals * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\TransactionJournal[] $transactionjournals
* @property-read \FireflyIII\User $user * @property-read \FireflyIII\User $user
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Bill whereId($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Bill whereId($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Bill whereCreatedAt($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Bill whereCreatedAt($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Bill whereUpdatedAt($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Bill whereUpdatedAt($value)
@@ -44,17 +44,18 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Bill whereSkip($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Bill whereSkip($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Bill whereNameEncrypted($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Bill whereNameEncrypted($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Bill whereMatchEncrypted($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Bill whereMatchEncrypted($value)
* @property mixed nextExpectedMatch * @property mixed nextExpectedMatch
* @property mixed lastFoundMatch * @property mixed lastFoundMatch
*/ */
class Bill extends Model class Bill extends Model
{ {
protected $fillable protected $fillable
= ['name', 'match', 'amount_min', 'match_encrypted', 'name_encrypted', 'user_id', 'amount_max', 'date', 'repeat_freq', 'skip', 'automatch', 'active', ]; = ['name', 'match', 'amount_min', 'match_encrypted', 'name_encrypted', 'user_id', 'amount_max', 'date', 'repeat_freq', 'skip', 'automatch', 'active',];
protected $hidden = ['amount_min_encrypted', 'amount_max_encrypted', 'name_encrypted', 'match_encrypted']; protected $hidden = ['amount_min_encrypted', 'amount_max_encrypted', 'name_encrypted', 'match_encrypted'];
/** /**
* @return array * @return array
*/ */

View File

@@ -7,19 +7,19 @@ use Illuminate\Database\Eloquent\SoftDeletes;
/** /**
* Class Budget * Class Budget
* *
* @codeCoverageIgnore * @codeCoverageIgnore
* @package FireflyIII\Models * @package FireflyIII\Models
* @property integer $id * @property integer $id
* @property \Carbon\Carbon $created_at * @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at * @property \Carbon\Carbon $updated_at
* @property \Carbon\Carbon $deleted_at * @property \Carbon\Carbon $deleted_at
* @property string $name * @property string $name
* @property integer $user_id * @property integer $user_id
* @property boolean $active * @property boolean $active
* @property boolean $encrypted * @property boolean $encrypted
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\BudgetLimit[] $budgetlimits * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\BudgetLimit[] $budgetlimits
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\TransactionJournal[] $transactionjournals * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\TransactionJournal[] $transactionjournals
* @property-read \FireflyIII\User $user * @property-read \FireflyIII\User $user
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Budget whereId($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Budget whereId($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Budget whereCreatedAt($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Budget whereCreatedAt($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Budget whereUpdatedAt($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Budget whereUpdatedAt($value)

View File

@@ -5,18 +5,18 @@ use Illuminate\Database\Eloquent\Model;
/** /**
* Class BudgetLimit * Class BudgetLimit
* *
* @codeCoverageIgnore * @codeCoverageIgnore
* @package FireflyIII\Models * @package FireflyIII\Models
* @property integer $id * @property integer $id
* @property \Carbon\Carbon $created_at * @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at * @property \Carbon\Carbon $updated_at
* @property integer $budget_id * @property integer $budget_id
* @property \Carbon\Carbon $startdate * @property \Carbon\Carbon $startdate
* @property float $amount * @property float $amount
* @property string $amount_encrypted * @property string $amount_encrypted
* @property boolean $repeats * @property boolean $repeats
* @property string $repeat_freq * @property string $repeat_freq
* @property-read \FireflyIII\Models\Budget $budget * @property-read \FireflyIII\Models\Budget $budget
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\LimitRepetition[] $limitrepetitions * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\LimitRepetition[] $limitrepetitions
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\BudgetLimit whereId($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\BudgetLimit whereId($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\BudgetLimit whereCreatedAt($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\BudgetLimit whereCreatedAt($value)

View File

@@ -8,15 +8,15 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* Class Category * Class Category
* *
* @package FireflyIII\Models * @package FireflyIII\Models
* @property integer $id * @property integer $id
* @property \Carbon\Carbon $created_at * @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at * @property \Carbon\Carbon $updated_at
* @property \Carbon\Carbon $deleted_at * @property \Carbon\Carbon $deleted_at
* @property string $name * @property string $name
* @property integer $user_id * @property integer $user_id
* @property boolean $encrypted * @property boolean $encrypted
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\TransactionJournal[] $transactionjournals * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\TransactionJournal[] $transactionjournals
* @property-read \FireflyIII\User $user * @property-read \FireflyIII\User $user
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Category whereId($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Category whereId($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Category whereCreatedAt($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Category whereCreatedAt($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Category whereUpdatedAt($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Category whereUpdatedAt($value)
@@ -24,8 +24,8 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Category whereName($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Category whereName($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Category whereUserId($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Category whereUserId($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Category whereEncrypted($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Category whereEncrypted($value)
* @property mixed spent * @property mixed spent
* @property mixed lastActivity * @property mixed lastActivity
*/ */
class Category extends Model class Category extends Model
{ {

View File

@@ -6,15 +6,15 @@ use Illuminate\Database\Eloquent\SoftDeletes;
/** /**
* Class Component * Class Component
* *
* @codeCoverageIgnore * @codeCoverageIgnore
* @package FireflyIII\Models * @package FireflyIII\Models
* @property integer $id * @property integer $id
* @property \Carbon\Carbon $created_at * @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at * @property \Carbon\Carbon $updated_at
* @property \Carbon\Carbon $deleted_at * @property \Carbon\Carbon $deleted_at
* @property string $name * @property string $name
* @property integer $user_id * @property integer $user_id
* @property string $class * @property string $class
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Component whereId($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Component whereId($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Component whereCreatedAt($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Component whereCreatedAt($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Component whereUpdatedAt($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Component whereUpdatedAt($value)

View File

@@ -5,16 +5,16 @@ use Illuminate\Database\Eloquent\Model;
/** /**
* Class LimitRepetition * Class LimitRepetition
* *
* @codeCoverageIgnore * @codeCoverageIgnore
* @package FireflyIII\Models * @package FireflyIII\Models
* @property integer $id * @property integer $id
* @property \Carbon\Carbon $created_at * @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at * @property \Carbon\Carbon $updated_at
* @property integer $budget_limit_id * @property integer $budget_limit_id
* @property \Carbon\Carbon $startdate * @property \Carbon\Carbon $startdate
* @property \Carbon\Carbon $enddate * @property \Carbon\Carbon $enddate
* @property float $amount * @property float $amount
* @property string $amount_encrypted * @property string $amount_encrypted
* @property-read \FireflyIII\Models\BudgetLimit $budgetLimit * @property-read \FireflyIII\Models\BudgetLimit $budgetLimit
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\LimitRepetition whereId($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\LimitRepetition whereId($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\LimitRepetition whereCreatedAt($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\LimitRepetition whereCreatedAt($value)

View File

@@ -8,7 +8,20 @@ use Zizaco\Entrust\EntrustPermission;
* Class Permission * Class Permission
* *
* @package FireflyIII\Models * @package FireflyIII\Models
* @property integer $id
* @property string $name
* @property string $display_name
* @property string $description
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
* @property-read \Illuminate\Database\Eloquent\Collection|\Config::get('entrust.role')[] $roles
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Permission whereId($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Permission whereName($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Permission whereDisplayName($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Permission whereDescription($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Permission whereCreatedAt($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Permission whereUpdatedAt($value)
*/ */
class Permission extends EntrustPermission class Permission extends EntrustPermission
{ {
} }

View File

@@ -7,27 +7,27 @@ use Illuminate\Database\Eloquent\SoftDeletes;
/** /**
* Class PiggyBank * Class PiggyBank
* *
* @codeCoverageIgnore * @codeCoverageIgnore
* @package FireflyIII\Models * @package FireflyIII\Models
* @property integer $id * @property integer $id
* @property \Carbon\Carbon $created_at * @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at * @property \Carbon\Carbon $updated_at
* @property \Carbon\Carbon $deleted_at * @property \Carbon\Carbon $deleted_at
* @property integer $account_id * @property integer $account_id
* @property string $name * @property string $name
* @property float $targetamount * @property float $targetamount
* @property string $targetamount_encrypted * @property string $targetamount_encrypted
* @property \Carbon\Carbon $startdate * @property \Carbon\Carbon $startdate
* @property \Carbon\Carbon $targetdate * @property \Carbon\Carbon $targetdate
* @property string $reminder * @property string $reminder
* @property integer $reminder_skip * @property integer $reminder_skip
* @property boolean $remind_me * @property boolean $remind_me
* @property integer $order * @property integer $order
* @property boolean $encrypted * @property boolean $encrypted
* @property-read \FireflyIII\Models\Account $account * @property-read \FireflyIII\Models\Account $account
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\PiggyBankRepetition[] $piggyBankRepetitions * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\PiggyBankRepetition[] $piggyBankRepetitions
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\PiggyBankEvent[] $piggyBankEvents * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\PiggyBankEvent[] $piggyBankEvents
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Reminder[] $reminders * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Reminder[] $reminders
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBank whereId($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBank whereId($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBank whereCreatedAt($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBank whereCreatedAt($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBank whereUpdatedAt($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBank whereUpdatedAt($value)
@@ -43,14 +43,14 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBank whereRemindMe($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBank whereRemindMe($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBank whereOrder($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBank whereOrder($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBank whereEncrypted($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBank whereEncrypted($value)
* @property PiggyBankRepetition currentRep * @property PiggyBankRepetition currentRep
*/ */
class PiggyBank extends Model class PiggyBank extends Model
{ {
use SoftDeletes; use SoftDeletes;
protected $fillable protected $fillable
= ['name', 'account_id', 'order', 'reminder_skip', 'targetamount', 'startdate', 'targetdate', 'reminder', 'remind_me']; = ['name', 'account_id', 'order', 'reminder_skip', 'targetamount', 'startdate', 'targetdate', 'reminder', 'remind_me'];
protected $hidden = ['targetamount_encrypted', 'encrypted']; protected $hidden = ['targetamount_encrypted', 'encrypted'];
/** /**

View File

@@ -5,17 +5,17 @@ use Illuminate\Database\Eloquent\Model;
/** /**
* Class PiggyBankEvent * Class PiggyBankEvent
* *
* @codeCoverageIgnore * @codeCoverageIgnore
* @package FireflyIII\Models * @package FireflyIII\Models
* @property integer $id * @property integer $id
* @property \Carbon\Carbon $created_at * @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at * @property \Carbon\Carbon $updated_at
* @property integer $piggy_bank_id * @property integer $piggy_bank_id
* @property integer $transaction_journal_id * @property integer $transaction_journal_id
* @property \Carbon\Carbon $date * @property \Carbon\Carbon $date
* @property float $amount * @property float $amount
* @property string $amount_encrypted * @property string $amount_encrypted
* @property-read \FireflyIII\Models\PiggyBank $piggyBank * @property-read \FireflyIII\Models\PiggyBank $piggyBank
* @property-read \FireflyIII\Models\TransactionJournal $transactionJournal * @property-read \FireflyIII\Models\TransactionJournal $transactionJournal
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBankEvent whereId($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBankEvent whereId($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBankEvent whereCreatedAt($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBankEvent whereCreatedAt($value)

View File

@@ -7,16 +7,16 @@ use Illuminate\Database\Eloquent\Model;
/** /**
* Class PiggyBankRepetition * Class PiggyBankRepetition
* *
* @codeCoverageIgnore * @codeCoverageIgnore
* @package FireflyIII\Models * @package FireflyIII\Models
* @property integer $id * @property integer $id
* @property \Carbon\Carbon $created_at * @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at * @property \Carbon\Carbon $updated_at
* @property integer $piggy_bank_id * @property integer $piggy_bank_id
* @property \Carbon\Carbon $startdate * @property \Carbon\Carbon $startdate
* @property \Carbon\Carbon $targetdate * @property \Carbon\Carbon $targetdate
* @property float $currentamount * @property float $currentamount
* @property string $currentamount_encrypted * @property string $currentamount_encrypted
* @property-read \FireflyIII\Models\PiggyBank $piggyBank * @property-read \FireflyIII\Models\PiggyBank $piggyBank
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBankRepetition whereId($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBankRepetition whereId($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBankRepetition whereCreatedAt($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBankRepetition whereCreatedAt($value)
@@ -77,13 +77,13 @@ class PiggyBankRepetition extends Model
$q->orWhereNull('startdate'); $q->orWhereNull('startdate');
} }
) )
->where( ->where(
function (EloquentBuilder $q) use ($date) { function (EloquentBuilder $q) use ($date) {
$q->where('targetdate', '>=', $date->format('Y-m-d 00:00:00')); $q->where('targetdate', '>=', $date->format('Y-m-d 00:00:00'));
$q->orWhereNull('targetdate'); $q->orWhereNull('targetdate');
} }
); );
} }
/** /**

View File

@@ -6,16 +6,16 @@ use Illuminate\Database\Eloquent\Model;
/** /**
* Class Preference * Class Preference
* *
* @codeCoverageIgnore * @codeCoverageIgnore
* @package FireflyIII\Models * @package FireflyIII\Models
* @property integer $id * @property integer $id
* @property \Carbon\Carbon $created_at * @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at * @property \Carbon\Carbon $updated_at
* @property integer $user_id * @property integer $user_id
* @property string $name * @property string $name
* @property string $name_encrypted * @property string $name_encrypted
* @property string $data * @property string $data
* @property string $data_encrypted * @property string $data_encrypted
* @property-read \FireflyIII\User $user * @property-read \FireflyIII\User $user
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Preference whereId($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Preference whereId($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Preference whereCreatedAt($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Preference whereCreatedAt($value)
@@ -55,21 +55,6 @@ class Preference extends Model
return ['created_at', 'updated_at']; return ['created_at', 'updated_at'];
} }
/**
* @param $value
*
* @return float|int
*/
public function getNameAttribute($value)
{
if (is_null($this->name_encrypted)) {
return $value;
}
$value = Crypt::decrypt($this->name_encrypted);
return $value;
}
/** /**
* @param $value * @param $value
*/ */
@@ -79,15 +64,6 @@ class Preference extends Model
$this->attributes['data_encrypted'] = Crypt::encrypt(json_encode($value)); $this->attributes['data_encrypted'] = Crypt::encrypt(json_encode($value));
} }
/**
* @param $value
*/
public function setNameAttribute($value)
{
$this->attributes['name_encrypted'] = Crypt::encrypt($value);
$this->attributes['name'] = $value;
}
/** /**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/ */

View File

@@ -8,21 +8,21 @@ use Illuminate\Database\Eloquent\Model;
/** /**
* Class Reminder * Class Reminder
* *
* @codeCoverageIgnore * @codeCoverageIgnore
* @package FireflyIII\Models * @package FireflyIII\Models
* @property integer $id * @property integer $id
* @property \Carbon\Carbon $created_at * @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at * @property \Carbon\Carbon $updated_at
* @property integer $user_id * @property integer $user_id
* @property \Carbon\Carbon $startdate * @property \Carbon\Carbon $startdate
* @property \Carbon\Carbon $enddate * @property \Carbon\Carbon $enddate
* @property boolean $active * @property boolean $active
* @property boolean $notnow * @property boolean $notnow
* @property integer $remindersable_id * @property integer $remindersable_id
* @property string $remindersable_type * @property string $remindersable_type
* @property string $metadata * @property string $metadata
* @property boolean $encrypted * @property boolean $encrypted
* @property-read \ $remindersable * @property-read \ $remindersable
* @property-read \FireflyIII\User $user * @property-read \FireflyIII\User $user
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Reminder whereId($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Reminder whereId($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Reminder whereCreatedAt($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Reminder whereCreatedAt($value)
@@ -38,13 +38,13 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Reminder whereEncrypted($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Reminder whereEncrypted($value)
* @method static \FireflyIII\Models\Reminder onDates($start, $end) * @method static \FireflyIII\Models\Reminder onDates($start, $end)
* @method static \FireflyIII\Models\Reminder today() * @method static \FireflyIII\Models\Reminder today()
* @property string description * @property string description
*/ */
class Reminder extends Model class Reminder extends Model
{ {
protected $fillable = ['user_id', 'startdate', 'metadata', 'enddate', 'active', 'notnow', 'remindersable_id', 'remindersable_type', ]; protected $fillable = ['user_id', 'startdate', 'metadata', 'enddate', 'active', 'notnow', 'remindersable_id', 'remindersable_type',];
protected $hidden = ['encrypted']; protected $hidden = ['encrypted'];
/** /**
@@ -124,7 +124,7 @@ class Reminder extends Model
$today = new Carbon; $today = new Carbon;
return $query->where('startdate', '<=', $today->format('Y-m-d 00:00:00'))->where('enddate', '>=', $today->format('Y-m-d 00:00:00'))->where('active', 1) return $query->where('startdate', '<=', $today->format('Y-m-d 00:00:00'))->where('enddate', '>=', $today->format('Y-m-d 00:00:00'))->where('active', 1)
->where('notnow', 0); ->where('notnow', 0);
} }
/** /**

View File

@@ -8,7 +8,21 @@ use Zizaco\Entrust\EntrustRole;
* Class Role * Class Role
* *
* @package FireflyIII\Models * @package FireflyIII\Models
* @property integer $id
* @property string $name
* @property string $display_name
* @property string $description
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
* @property-read \Illuminate\Database\Eloquent\Collection|\Config::get('auth.model')[] $users
* @property-read \Illuminate\Database\Eloquent\Collection|\Config::get('entrust.permission')[] $perms
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Role whereId($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Role whereName($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Role whereDisplayName($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Role whereDescription($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Role whereCreatedAt($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Role whereUpdatedAt($value)
*/ */
class Role extends EntrustRole class Role extends EntrustRole
{ {
} }

View File

@@ -10,20 +10,20 @@ use Watson\Validating\ValidatingTrait;
* Class Tag * Class Tag
* *
* @package FireflyIII\Models * @package FireflyIII\Models
* @property integer $id * @property integer $id
* @property \Carbon\Carbon $created_at * @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at * @property \Carbon\Carbon $updated_at
* @property string $deleted_at * @property string $deleted_at
* @property integer $user_id * @property integer $user_id
* @property string $tag * @property string $tag
* @property string $tagMode * @property string $tagMode
* @property \Carbon\Carbon $date * @property \Carbon\Carbon $date
* @property string $description * @property string $description
* @property float $latitude * @property float $latitude
* @property float $longitude * @property float $longitude
* @property integer $zoomLevel * @property integer $zoomLevel
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\TransactionJournal[] $transactionjournals * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\TransactionJournal[] $transactionjournals
* @property-read \FireflyIII\User $user * @property-read \FireflyIII\User $user
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Tag whereId($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Tag whereId($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Tag whereCreatedAt($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Tag whereCreatedAt($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Tag whereUpdatedAt($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Tag whereUpdatedAt($value)
@@ -44,7 +44,7 @@ class Tag extends Model
protected $fillable = ['user_id', 'tag', 'date', 'description', 'longitude', 'latitude', 'zoomLevel', 'tagMode']; protected $fillable = ['user_id', 'tag', 'date', 'description', 'longitude', 'latitude', 'zoomLevel', 'tagMode'];
protected $rules protected $rules
= [ = [
'tag' => 'required|min:1|uniqueObjectForUser:tags,tag,TRUE', 'tag' => 'required|min:1',
'description' => 'min:1', 'description' => 'min:1',
'date' => 'date', 'date' => 'date',
'latitude' => 'numeric|min:-90|max:90', 'latitude' => 'numeric|min:-90|max:90',

View File

@@ -9,18 +9,18 @@ use Watson\Validating\ValidatingTrait;
/** /**
* Class Transaction * Class Transaction
* *
* @codeCoverageIgnore * @codeCoverageIgnore
* @package FireflyIII\Models * @package FireflyIII\Models
* @property integer $id * @property integer $id
* @property \Carbon\Carbon $created_at * @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at * @property \Carbon\Carbon $updated_at
* @property \Carbon\Carbon $deleted_at * @property \Carbon\Carbon $deleted_at
* @property integer $account_id * @property integer $account_id
* @property integer $transaction_journal_id * @property integer $transaction_journal_id
* @property string $description * @property string $description
* @property float $amount * @property float $amount
* @property string $amount_encrypted * @property string $amount_encrypted
* @property-read \FireflyIII\Models\Account $account * @property-read \FireflyIII\Models\Account $account
* @property-read \FireflyIII\Models\TransactionJournal $transactionJournal * @property-read \FireflyIII\Models\TransactionJournal $transactionJournal
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Transaction whereId($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Transaction whereId($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Transaction whereCreatedAt($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Transaction whereCreatedAt($value)
@@ -33,8 +33,8 @@ use Watson\Validating\ValidatingTrait;
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Transaction whereAmountEncrypted($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Transaction whereAmountEncrypted($value)
* @method static \FireflyIII\Models\Transaction after($date) * @method static \FireflyIII\Models\Transaction after($date)
* @method static \FireflyIII\Models\Transaction before($date) * @method static \FireflyIII\Models\Transaction before($date)
* @property mixed before * @property mixed before
* @property mixed after * @property mixed after
*/ */
class Transaction extends Model class Transaction extends Model
{ {

View File

@@ -6,15 +6,15 @@ use Illuminate\Database\Eloquent\SoftDeletes;
/** /**
* Class TransactionCurrency * Class TransactionCurrency
* *
* @codeCoverageIgnore * @codeCoverageIgnore
* @package FireflyIII\Models * @package FireflyIII\Models
* @property integer $id * @property integer $id
* @property \Carbon\Carbon $created_at * @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at * @property \Carbon\Carbon $updated_at
* @property \Carbon\Carbon $deleted_at * @property \Carbon\Carbon $deleted_at
* @property string $code * @property string $code
* @property string $name * @property string $name
* @property string $symbol * @property string $symbol
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\TransactionJournal[] $transactionJournals * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\TransactionJournal[] $transactionJournals
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionCurrency whereId($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionCurrency whereId($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionCurrency whereCreatedAt($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionCurrency whereCreatedAt($value)

View File

@@ -6,16 +6,16 @@ use Illuminate\Database\Eloquent\SoftDeletes;
/** /**
* Class TransactionGroup * Class TransactionGroup
* *
* @codeCoverageIgnore * @codeCoverageIgnore
* @package FireflyIII\Models * @package FireflyIII\Models
* @property integer $id * @property integer $id
* @property \Carbon\Carbon $created_at * @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at * @property \Carbon\Carbon $updated_at
* @property \Carbon\Carbon $deleted_at * @property \Carbon\Carbon $deleted_at
* @property integer $user_id * @property integer $user_id
* @property string $relation * @property string $relation
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\TransactionJournal[] $transactionjournals * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\TransactionJournal[] $transactionjournals
* @property-read \FireflyIII\User $user * @property-read \FireflyIII\User $user
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionGroup whereId($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionGroup whereId($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionGroup whereCreatedAt($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionGroup whereCreatedAt($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionGroup whereUpdatedAt($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionGroup whereUpdatedAt($value)

View File

@@ -2,6 +2,7 @@
use Carbon\Carbon; use Carbon\Carbon;
use Crypt; use Crypt;
use FireflyIII\Support\CacheProperties;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder; use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasMany;
@@ -60,13 +61,17 @@ use Watson\Validating\ValidatingTrait;
* @method static \FireflyIII\Models\TransactionJournal onDate($date) * @method static \FireflyIII\Models\TransactionJournal onDate($date)
* @method static \FireflyIII\Models\TransactionJournal transactionTypes($types) * @method static \FireflyIII\Models\TransactionJournal transactionTypes($types)
* @method static \FireflyIII\Models\TransactionJournal withRelevantData() * @method static \FireflyIII\Models\TransactionJournal withRelevantData()
* @property-read mixed $expense_account * @property-read mixed $expense_account
* @property string account_encrypted * @property string account_encrypted
* @property bool joinedTransactions * @property bool joinedTransactions
* @property bool joinedTransactionTypes * @property bool joinedTransactionTypes
* @property mixed account_id * @property mixed account_id
* @property mixed name * @property mixed name
* @property mixed symbol * @property mixed symbol
* @property-read mixed $correct_amount
* @method static \FireflyIII\Models\TransactionJournal orderBy
* @method static \FireflyIII\Models\TransactionJournal|null first
* @property-read mixed $source_account
*/ */
class TransactionJournal extends Model class TransactionJournal extends Model
{ {
@@ -134,6 +139,13 @@ class TransactionJournal extends Model
*/ */
public function getAmountAttribute() public function getAmountAttribute()
{ {
$cache = new CacheProperties();
$cache->addProperty($this->id);
$cache->addProperty('amount');
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
}
$amount = '0'; $amount = '0';
bcscale(2); bcscale(2);
/** @var Transaction $t */ /** @var Transaction $t */
@@ -142,51 +154,61 @@ class TransactionJournal extends Model
$amount = $t->amount; $amount = $t->amount;
} }
} }
$count = $this->tags->count();
/* if ($count === 1) {
* If the journal has tags, it gets complicated. // get amount for single tag:
*/ $amount = $this->amountByTag($this->tags()->first(), $amount);
if ($this->tags->count() == 0) {
return $amount;
} }
// if journal is part of advancePayment AND journal is a withdrawal, if ($count > 1) {
// then journal is being repaid by other journals, so the actual amount will lower: // get amount for either tag.
/** @var Tag $advancePayment */ $amount = $this->amountByTags($amount);
$advancePayment = $this->tags()->where('tagMode', 'advancePayment')->first();
if ($advancePayment && $this->transactionType->type == 'Withdrawal') {
// loop other deposits, remove from our amount.
$others = $advancePayment->transactionJournals()->transactionTypes(['Deposit'])->get();
foreach ($others as $other) {
$amount = bcsub($amount, $other->actual_amount);
}
return $amount;
} }
$cache->store($amount);
// if this journal is part of an advancePayment AND the journal is a deposit, return $amount;
// then the journal amount is correcting a withdrawal, and the amount is zero:
if ($advancePayment && $this->transactionType->type == 'Deposit') {
return '0';
}
}
// is balancing act? /**
$balancingAct = $this->tags()->where('tagMode', 'balancingAct')->first(); * Assuming the journal has only one tag. Parameter amount is used as fallback.
*
if ($balancingAct) { * @param Tag $tag
// this is the expense: * @param string $amount
*
* @return string
*/
protected function amountByTag(Tag $tag, $amount)
{
if ($tag->tagMode == 'advancePayment') {
if ($this->transactionType->type == 'Withdrawal') { if ($this->transactionType->type == 'Withdrawal') {
$transfer = $balancingAct->transactionJournals()->transactionTypes(['Transfer'])->first(); $others = $tag->transactionJournals()->transactionTypes(['Deposit'])->get();
foreach ($others as $other) {
$amount = bcsub($amount, $other->actual_amount);
}
return $amount;
}
if ($this->transactionType->type == 'Deposit') {
return '0';
}
}
if ($tag->tagMode == 'balancingAct') {
if ($this->transactionType->type == 'Withdrawal') {
$transfer = $tag->transactionJournals()->transactionTypes(['Transfer'])->first();
if ($transfer) { if ($transfer) {
$amount = bcsub($amount, $transfer->actual_amount); $amount = bcsub($amount, $transfer->actual_amount);
return $amount; return $amount;
} }
} // @codeCoverageIgnore }
} // @codeCoverageIgnore }
return $amount; return $amount;
} }
/** /**
@@ -199,24 +221,39 @@ class TransactionJournal extends Model
} }
/** /**
* @return Account * @param string $amount
*
* @return string
*/ */
public function getAssetAccountAttribute() public function amountByTags($amount)
{
$firstBalancingAct = $this->tags()->where('tagMode', 'balancingAct')->first();
if ($firstBalancingAct) {
return $this->amountByTag($firstBalancingAct, $amount);
}
$firstAdvancePayment = $this->tags()->where('tagMode', 'advancePayment')->first();
if ($firstAdvancePayment) {
return $this->amountByTag($firstAdvancePayment, $amount);
}
return $amount;
}
/**
* @return string
*/
public function getCorrectAmountAttribute()
{ {
// if it's a deposit, it's the one thats positive
// if it's a withdrawal, it's the one thats negative
// otherwise, it's either (return first one):
switch ($this->transactionType->type) { switch ($this->transactionType->type) {
case 'Deposit': case 'Deposit':
return $this->transactions()->where('amount', '>', 0)->first()->account; return $this->transactions()->where('amount', '>', 0)->first()->amount;
case 'Withdrawal': case 'Withdrawal':
return $this->transactions()->where('amount', '<', 0)->first()->account; return $this->transactions()->where('amount', '<', 0)->first()->amount;
} }
return $this->transactions()->first()->account; return $this->transactions()->where('amount', '>', 0)->first()->amount;
} }
/** /**
@@ -258,35 +295,35 @@ class TransactionJournal extends Model
*/ */
public function getDestinationAccountAttribute() public function getDestinationAccountAttribute()
{ {
/** @var Transaction $transaction */ $cache = new CacheProperties;
foreach ($this->transactions()->get() as $transaction) { $cache->addProperty($this->id);
if (floatval($transaction->amount) > 0) { $cache->addProperty('destinationAccount');
return $transaction->account;
}
}
return $this->transactions()->first()->account; if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
}
$account = $this->transactions()->where('amount', '>', 0)->first()->account;
$cache->store($account);
return $account;
} }
/** /**
* @return Account * @return Account
*/ */
public function getExpenseAccountAttribute() public function getSourceAccountAttribute()
{ {
// if it's a deposit, it's the one thats negative $cache = new CacheProperties;
// if it's a withdrawal, it's the one thats positive $cache->addProperty($this->id);
// otherwise, it's either (return first one): $cache->addProperty('destinationAccount');
if ($cache->has()) {
switch ($this->transactionType->type) { return $cache->get(); // @codeCoverageIgnore
case 'Deposit':
return $this->transactions()->where('amount', '<', 0)->first()->account;
case 'Withdrawal':
return $this->transactions()->where('amount', '>', 0)->first()->account;
} }
$account = $this->transactions()->where('amount', '<', 0)->first()->account;
return $this->transactions()->first()->account; $cache->store($account);
return $account;
} }
/** /**
@@ -379,7 +416,7 @@ class TransactionJournal extends Model
public function scopeWithRelevantData(EloquentBuilder $query) public function scopeWithRelevantData(EloquentBuilder $query)
{ {
$query->with( $query->with(
['transactions' => function(HasMany $q) { ['transactions' => function (HasMany $q) {
$q->orderBy('amount', 'ASC'); $q->orderBy('amount', 'ASC');
}, 'transactiontype', 'transactioncurrency', 'budgets', 'categories', 'transactions.account.accounttype', 'bill', 'budgets', 'categories'] }, 'transactiontype', 'transactioncurrency', 'budgets', 'categories', 'transactions.account.accounttype', 'bill', 'budgets', 'categories']
); );

View File

@@ -5,7 +5,7 @@ use Illuminate\Database\Eloquent\Model;
/** /**
* Class TransactionRelation * Class TransactionRelation
* *
* @codeCoverageIgnore * @codeCoverageIgnore
* @package FireflyIII\Models * @package FireflyIII\Models
*/ */
class TransactionRelation extends Model class TransactionRelation extends Model

View File

@@ -6,13 +6,13 @@ use Illuminate\Database\Eloquent\SoftDeletes;
/** /**
* Class TransactionType * Class TransactionType
* *
* @codeCoverageIgnore * @codeCoverageIgnore
* @package FireflyIII\Models * @package FireflyIII\Models
* @property integer $id * @property integer $id
* @property \Carbon\Carbon $created_at * @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at * @property \Carbon\Carbon $updated_at
* @property \Carbon\Carbon $deleted_at * @property \Carbon\Carbon $deleted_at
* @property string $type * @property string $type
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\TransactionJournal[] $transactionJournals * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\TransactionJournal[] $transactionJournals
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionType whereId($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionType whereId($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionType whereCreatedAt($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionType whereCreatedAt($value)

View File

@@ -23,7 +23,7 @@ class BusServiceProvider extends ServiceProvider
public function boot(Dispatcher $dispatcher) public function boot(Dispatcher $dispatcher)
{ {
$dispatcher->mapUsing( $dispatcher->mapUsing(
function($command) { function ($command) {
return Dispatcher::simpleMapping( return Dispatcher::simpleMapping(
$command, 'FireflyIII\Commands', 'FireflyIII\Handlers\Commands' $command, 'FireflyIII\Commands', 'FireflyIII\Handlers\Commands'
); );

View File

@@ -52,12 +52,15 @@ class EventServiceProvider extends ServiceProvider
$this->registerDeleteEvents(); $this->registerDeleteEvents();
$this->registerCreateEvents(); $this->registerCreateEvents();
BudgetLimit::saved( BudgetLimit::saved(
function(BudgetLimit $budgetLimit) { function (BudgetLimit $budgetLimit) {
Log::debug('Saved!');
$end = Navigation::addPeriod(clone $budgetLimit->startdate, $budgetLimit->repeat_freq, 0); $end = Navigation::addPeriod(clone $budgetLimit->startdate, $budgetLimit->repeat_freq, 0);
$end->subDay(); $end->subDay();
$set = $budgetLimit->limitrepetitions()->where('startdate', $budgetLimit->startdate->format('Y-m-d'))->where('enddate', $end->format('Y-m-d')) $set = $budgetLimit->limitrepetitions()
->get(); ->where('startdate', $budgetLimit->startdate->format('Y-m-d 00:00:00'))
->where('enddate', $end->format('Y-m-d 00:00:00'))
->get();
if ($set->count() == 0) { if ($set->count() == 0) {
$repetition = new LimitRepetition; $repetition = new LimitRepetition;
$repetition->startdate = $budgetLimit->startdate; $repetition->startdate = $budgetLimit->startdate;
@@ -68,8 +71,7 @@ class EventServiceProvider extends ServiceProvider
try { try {
$repetition->save(); $repetition->save();
} catch (QueryException $e) { } catch (QueryException $e) {
Log::error('Trying to save new LimitRepetition failed!'); Log::error('Trying to save new LimitRepetition failed: ' . $e->getMessage()); // @codeCoverageIgnore
Log::error($e->getMessage());
} }
} else { } else {
if ($set->count() == 1) { if ($set->count() == 1) {
@@ -91,7 +93,7 @@ class EventServiceProvider extends ServiceProvider
protected function registerDeleteEvents() protected function registerDeleteEvents()
{ {
TransactionJournal::deleted( TransactionJournal::deleted(
function(TransactionJournal $journal) { function (TransactionJournal $journal) {
/** @var Transaction $transaction */ /** @var Transaction $transaction */
foreach ($journal->transactions()->get() as $transaction) { foreach ($journal->transactions()->get() as $transaction) {
@@ -100,7 +102,7 @@ class EventServiceProvider extends ServiceProvider
} }
); );
PiggyBank::deleting( PiggyBank::deleting(
function(PiggyBank $piggyBank) { function (PiggyBank $piggyBank) {
$reminders = $piggyBank->reminders()->get(); $reminders = $piggyBank->reminders()->get();
/** @var Reminder $reminder */ /** @var Reminder $reminder */
foreach ($reminders as $reminder) { foreach ($reminders as $reminder) {
@@ -110,7 +112,7 @@ class EventServiceProvider extends ServiceProvider
); );
Account::deleted( Account::deleted(
function(Account $account) { function (Account $account) {
/** @var Transaction $transaction */ /** @var Transaction $transaction */
foreach ($account->transactions()->get() as $transaction) { foreach ($account->transactions()->get() as $transaction) {
@@ -131,7 +133,7 @@ class EventServiceProvider extends ServiceProvider
// move this routine to a filter // move this routine to a filter
// in case of repeated piggy banks and/or other problems. // in case of repeated piggy banks and/or other problems.
PiggyBank::created( PiggyBank::created(
function(PiggyBank $piggyBank) { function (PiggyBank $piggyBank) {
$repetition = new PiggyBankRepetition; $repetition = new PiggyBankRepetition;
$repetition->piggyBank()->associate($piggyBank); $repetition->piggyBank()->associate($piggyBank);
$repetition->startdate = is_null($piggyBank->startdate) ? null : $piggyBank->startdate; $repetition->startdate = is_null($piggyBank->startdate) ? null : $piggyBank->startdate;

View File

@@ -30,7 +30,7 @@ class FireflyServiceProvider extends ServiceProvider
public function boot() public function boot()
{ {
Validator::resolver( Validator::resolver(
function($translator, $data, $rules, $messages) { function ($translator, $data, $rules, $messages) {
return new FireflyValidator($translator, $data, $rules, $messages); return new FireflyValidator($translator, $data, $rules, $messages);
} }
); );
@@ -55,28 +55,28 @@ class FireflyServiceProvider extends ServiceProvider
$this->app->bind( $this->app->bind(
'preferences', function() { 'preferences', function () {
return new Preferences; return new Preferences;
} }
); );
$this->app->bind( $this->app->bind(
'navigation', function() { 'navigation', function () {
return new Navigation; return new Navigation;
} }
); );
$this->app->bind( $this->app->bind(
'amount', function() { 'amount', function () {
return new Amount; return new Amount;
} }
); );
$this->app->bind( $this->app->bind(
'steam', function() { 'steam', function () {
return new Steam; return new Steam;
} }
); );
$this->app->bind( $this->app->bind(
'expandedform', function() { 'expandedform', function () {
return new ExpandedForm; return new ExpandedForm;
} }
); );

View File

@@ -44,7 +44,7 @@ class RouteServiceProvider extends ServiceProvider
public function map(Router $router) public function map(Router $router)
{ {
$router->group( $router->group(
['namespace' => $this->namespace], function($router) { ['namespace' => $this->namespace], function ($router) {
/** @noinspection PhpIncludeInspection */ /** @noinspection PhpIncludeInspection */
require app_path('Http/routes.php'); require app_path('Http/routes.php');
} }

View File

@@ -15,6 +15,7 @@ use FireflyIII\Models\Preference;
use FireflyIII\Models\Transaction; use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType; use FireflyIII\Models\TransactionType;
use FireflyIII\Support\CacheProperties;
use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Query\Builder; use Illuminate\Database\Query\Builder;
use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Pagination\LengthAwarePaginator;
@@ -64,7 +65,7 @@ class AccountRepository implements AccountRepositoryInterface
public function getAccounts(array $types) public function getAccounts(array $types)
{ {
$result = Auth::user()->accounts()->with( $result = Auth::user()->accounts()->with(
['accountmeta' => function(HasMany $query) { ['accountmeta' => function (HasMany $query) {
$query->where('name', 'accountRole'); $query->where('name', 'accountRole');
}] }]
)->accountTypeIn($types)->orderBy('accounts.name', 'ASC')->get(['accounts.*'])->sortBy('name'); )->accountTypeIn($types)->orderBy('accounts.name', 'ASC')->get(['accounts.*'])->sortBy('name');
@@ -79,15 +80,15 @@ class AccountRepository implements AccountRepositoryInterface
public function getCreditCards() public function getCreditCards()
{ {
return Auth::user()->accounts() return Auth::user()->accounts()
->hasMetaValue('accountRole', 'ccAsset') ->hasMetaValue('accountRole', 'ccAsset')
->hasMetaValue('ccType', 'monthlyFull') ->hasMetaValue('ccType', 'monthlyFull')
->get( ->get(
[ [
'accounts.*', 'accounts.*',
'ccType.data as ccType', 'ccType.data as ccType',
'accountRole.data as accountRole' 'accountRole.data as accountRole'
] ]
); );
} }
/** /**
@@ -109,12 +110,22 @@ class AccountRepository implements AccountRepositoryInterface
*/ */
public function getFrontpageAccounts(Preference $preference) public function getFrontpageAccounts(Preference $preference)
{ {
$cache = new CacheProperties();
$cache->addProperty($preference->data);
$cache->addProperty('frontPageaccounts');
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
}
if ($preference->data == []) { if ($preference->data == []) {
$accounts = Auth::user()->accounts()->accountTypeIn(['Default account', 'Asset account'])->orderBy('accounts.name', 'ASC')->get(['accounts.*']); $accounts = Auth::user()->accounts()->accountTypeIn(['Default account', 'Asset account'])->orderBy('accounts.name', 'ASC')->get(['accounts.*']);
} else { } else {
$accounts = Auth::user()->accounts()->whereIn('id', $preference->data)->orderBy('accounts.name', 'ASC')->get(['accounts.*']); $accounts = Auth::user()->accounts()->whereIn('id', $preference->data)->orderBy('accounts.name', 'ASC')->get(['accounts.*']);
} }
$cache->store($accounts);
return $accounts; return $accounts;
} }
@@ -131,19 +142,30 @@ class AccountRepository implements AccountRepositoryInterface
*/ */
public function getFrontpageTransactions(Account $account, Carbon $start, Carbon $end) public function getFrontpageTransactions(Account $account, Carbon $start, Carbon $end)
{ {
return Auth::user() $cache = new CacheProperties();
->transactionjournals() $cache->addProperty($account->id);
->with(['transactions']) $cache->addProperty($start);
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id') $cache->addProperty($end);
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')->where('accounts.id', $account->id) if ($cache->has()) {
->leftJoin('transaction_currencies', 'transaction_currencies.id', '=', 'transaction_journals.transaction_currency_id') return $cache->get(); // @codeCoverageIgnore
->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id') }
->before($end)
->after($start) $set = Auth::user()
->orderBy('transaction_journals.date', 'DESC') ->transactionjournals()
->orderBy('transaction_journals.id', 'DESC') ->with(['transactions'])
->take(10) ->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->get(['transaction_journals.*', 'transaction_currencies.symbol', 'transaction_types.type']); ->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')->where('accounts.id', $account->id)
->leftJoin('transaction_currencies', 'transaction_currencies.id', '=', 'transaction_journals.transaction_currency_id')
->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
->before($end)
->after($start)
->orderBy('transaction_journals.date', 'DESC')
->orderBy('transaction_journals.id', 'DESC')
->take(10)
->get(['transaction_journals.*', 'transaction_currencies.symbol', 'transaction_types.type']);
$cache->store($set);
return $set;
} }
/** /**
@@ -156,13 +178,13 @@ class AccountRepository implements AccountRepositoryInterface
{ {
$offset = ($page - 1) * 50; $offset = ($page - 1) * 50;
$query = Auth::user() $query = Auth::user()
->transactionJournals() ->transactionJournals()
->withRelevantData() ->withRelevantData()
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id') ->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->where('transactions.account_id', $account->id) ->where('transactions.account_id', $account->id)
->orderBy('transaction_journals.date', 'DESC') ->orderBy('transaction_journals.date', 'DESC')
->orderBy('transaction_journals.order', 'ASC') ->orderBy('transaction_journals.order', 'ASC')
->orderBy('transaction_journals.id', 'DESC'); ->orderBy('transaction_journals.id', 'DESC');
$count = $query->count(); $count = $query->count();
$set = $query->take(50)->offset($offset)->get(['transaction_journals.*']); $set = $query->take(50)->offset($offset)->get(['transaction_journals.*']);
@@ -207,13 +229,20 @@ class AccountRepository implements AccountRepositoryInterface
$ids[] = intval($id->account_id); $ids[] = intval($id->account_id);
} }
$cache = new CacheProperties;
$cache->addProperty($ids);
$cache->addProperty('piggyAccounts');
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
}
$ids = array_unique($ids); $ids = array_unique($ids);
if (count($ids) > 0) { if (count($ids) > 0) {
$accounts = Auth::user()->accounts()->whereIn('id', $ids)->get(); $accounts = Auth::user()->accounts()->whereIn('id', $ids)->get();
} }
$accounts->each( $accounts->each(
function(Account $account) use ($start, $end) { function (Account $account) use ($start, $end) {
$account->startBalance = Steam::balance($account, $start, true); $account->startBalance = Steam::balance($account, $start, true);
$account->endBalance = Steam::balance($account, $end, true); $account->endBalance = Steam::balance($account, $end, true);
$account->piggyBalance = 0; $account->piggyBalance = 0;
@@ -231,6 +260,8 @@ class AccountRepository implements AccountRepositoryInterface
} }
); );
$cache->store($accounts);
return $accounts; return $accounts;
} }
@@ -251,7 +282,7 @@ class AccountRepository implements AccountRepositoryInterface
$end = clone Session::get('end', new Carbon); $end = clone Session::get('end', new Carbon);
$accounts->each( $accounts->each(
function(Account $account) use ($start, $end) { function (Account $account) use ($start, $end) {
$account->startBalance = Steam::balance($account, $start); $account->startBalance = Steam::balance($account, $start);
$account->endBalance = Steam::balance($account, $end); $account->endBalance = Steam::balance($account, $end);
@@ -289,25 +320,26 @@ class AccountRepository implements AccountRepositoryInterface
*/ */
public function getTransfersInRange(Account $account, Carbon $start, Carbon $end) public function getTransfersInRange(Account $account, Carbon $start, Carbon $end)
{ {
$set = TransactionJournal::whereIn( $set = TransactionJournal::whereIn(
'id', function(Builder $q) use ($account, $start, $end) { 'id', function (Builder $q) use ($account, $start, $end) {
$q->select('transaction_journals.id') $q->select('transaction_journals.id')
->from('transactions') ->from('transactions')
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id') ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id') ->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
->where('transactions.account_id', $account->id) ->where('transactions.account_id', $account->id)
->where('transaction_journals.user_id', Auth::user()->id) ->where('transaction_journals.user_id', Auth::user()->id)
->where('transaction_journals.date', '>=', $start->format('Y-m-d')) ->where('transaction_journals.date', '>=', $start->format('Y-m-d'))
->where('transaction_journals.date', '<=', $end->format('Y-m-d')) ->where('transaction_journals.date', '<=', $end->format('Y-m-d'))
->where('transaction_types.type', 'Transfer'); ->where('transaction_types.type', 'Transfer');
} }
)->get(); )->get();
$filtered = $set->filter( $filtered = $set->filter(
function(TransactionJournal $journal) use ($account) { function (TransactionJournal $journal) use ($account) {
if ($journal->destination_account->id == $account->id) { if ($journal->destination_account->id == $account->id) {
return $journal; return $journal;
} }
return null; return null;
} }
); );
@@ -341,10 +373,11 @@ class AccountRepository implements AccountRepositoryInterface
*/ */
public function openingBalanceTransaction(Account $account) public function openingBalanceTransaction(Account $account)
{ {
return TransactionJournal::accountIs($account) return TransactionJournal
->orderBy('transaction_journals.date', 'ASC') ::orderBy('transaction_journals.date', 'ASC')
->orderBy('created_at', 'ASC') ->accountIs($account)
->first(['transaction_journals.*']); ->orderBy('created_at', 'ASC')
->first(['transaction_journals.*']);
} }
/** /**
@@ -362,13 +395,13 @@ class AccountRepository implements AccountRepositoryInterface
if ($data['openingBalance'] != 0) { if ($data['openingBalance'] != 0) {
$type = $data['openingBalance'] < 0 ? 'expense' : 'revenue'; $type = $data['openingBalance'] < 0 ? 'expense' : 'revenue';
$opposingData = [ $opposingData = [
'user' => $data['user'], 'user' => $data['user'],
'accountType' => $type, 'accountType' => $type,
'virtual_balance' => $data['virtualBalance'], 'virtualBalance' => 0,
'name' => $data['name'] . ' initial balance', 'name' => $data['name'] . ' initial balance',
'active' => false, 'active' => false,
]; ];
$opposing = $this->storeAccount($opposingData); $opposing = $this->storeAccount($opposingData);
$this->storeInitialBalance($newAccount, $opposing, $data); $this->storeInitialBalance($newAccount, $opposing, $data);
} }
@@ -413,12 +446,13 @@ class AccountRepository implements AccountRepositoryInterface
// create new opening balance. // create new opening balance.
$type = $data['openingBalance'] < 0 ? 'expense' : 'revenue'; $type = $data['openingBalance'] < 0 ? 'expense' : 'revenue';
$opposingData = [ $opposingData = [
'user' => $data['user'], 'user' => $data['user'],
'accountType' => $type, 'accountType' => $type,
'name' => $data['name'] . ' initial balance', 'name' => $data['name'] . ' initial balance',
'active' => false, 'active' => false,
'virtualBalance' => 0,
]; ];
$opposing = $this->storeAccount($opposingData); $opposing = $this->storeAccount($opposingData);
$this->storeInitialBalance($account, $opposing, $data); $this->storeInitialBalance($account, $opposing, $data);
} }
@@ -445,15 +479,17 @@ class AccountRepository implements AccountRepositoryInterface
'user_id' => $data['user'], 'user_id' => $data['user'],
'account_type_id' => $accountType->id, 'account_type_id' => $accountType->id,
'name' => $data['name'], 'name' => $data['name'],
'virtual_balance' => $data['virtualBalance'],
'active' => $data['active'] === true ? true : false, 'active' => $data['active'] === true ? true : false,
] ]
); );
if (!$newAccount->isValid()) { if (!$newAccount->isValid()) {
// does the account already exist? // does the account already exist?
$searchData = [ $searchData = [
'user_id' => $data['user'], 'user_id' => $data['user'],
'account_type_id' => $accountType->id, 'account_type_id' => $accountType->id,
'virtual_balance' => $data['virtualBalance'],
'name' => $data['name'] 'name' => $data['name']
]; ];
$existingAccount = Account::firstOrNullEncrypted($searchData); $existingAccount = Account::firstOrNullEncrypted($searchData);

View File

@@ -262,27 +262,10 @@ class BillRepository implements BillRepositoryInterface
*/ */
public function scan(Bill $bill, TransactionJournal $journal) public function scan(Bill $bill, TransactionJournal $journal)
{ {
$amountMatch = false;
$wordMatch = false;
$matches = explode(',', $bill->match); $matches = explode(',', $bill->match);
$description = strtolower($journal->description) . ' ' . strtolower($journal->expense_account->name); $description = strtolower($journal->description) . ' ' . strtolower($journal->destination_account->name);
$count = 0; $wordMatch = $this->doWordMatch($matches, $description);
foreach ($matches as $word) { $amountMatch = $this->doAmountMatch($journal->amount, $bill->amount_min, $bill->amount_max);
if (!(strpos($description, strtolower($word)) === false)) {
$count++;
}
}
if ($count >= count($matches)) {
$wordMatch = true;
}
/*
* Match amount.
*/
if ($journal->amount >= $bill->amount_min && $journal->amount <= $bill->amount_max) {
$amountMatch = true;
}
/* /*
* If both, update! * If both, update!
@@ -290,13 +273,17 @@ class BillRepository implements BillRepositoryInterface
if ($wordMatch && $amountMatch) { if ($wordMatch && $amountMatch) {
$journal->bill()->associate($bill); $journal->bill()->associate($bill);
$journal->save(); $journal->save();
} else {
if ($bill->id == $journal->bill_id) { return true;
// if no match, but bill used to match, remove it:
$journal->bill_id = null;
$journal->save();
}
} }
if ($bill->id == $journal->bill_id) {
// if no match, but bill used to match, remove it:
$journal->bill_id = null;
$journal->save();
return true;
}
} }
/** /**
@@ -350,4 +337,42 @@ class BillRepository implements BillRepositoryInterface
return $bill; return $bill;
} }
/**
* @param array $matches
* @param $description
*
* @return bool
*/
protected function doWordMatch(array $matches, $description)
{
$wordMatch = false;
$count = 0;
foreach ($matches as $word) {
if (!(strpos($description, strtolower($word)) === false)) {
$count++;
}
}
if ($count >= count($matches)) {
$wordMatch = true;
}
return $wordMatch;
}
/**
* @param float $amount
* @param float $min
* @param float $max
*
* @return bool
*/
protected function doAmountMatch($amount, $min, $max)
{
if ($amount >= $min && $amount <= $max) {
return true;
}
return false;
}
} }

View File

@@ -7,8 +7,9 @@ use Carbon\Carbon;
use FireflyIII\Models\Budget; use FireflyIII\Models\Budget;
use FireflyIII\Models\BudgetLimit; use FireflyIII\Models\BudgetLimit;
use FireflyIII\Models\LimitRepetition; use FireflyIII\Models\LimitRepetition;
use FireflyIII\Repositories\Shared\ComponentRepository;
use FireflyIII\Support\CacheProperties;
use Illuminate\Database\Query\Builder as QueryBuilder; use Illuminate\Database\Query\Builder as QueryBuilder;
use Illuminate\Database\Query\JoinClause;
use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Input; use Input;
@@ -18,7 +19,7 @@ use Input;
* *
* @package FireflyIII\Repositories\Budget * @package FireflyIII\Repositories\Budget
*/ */
class BudgetRepository implements BudgetRepositoryInterface class BudgetRepository extends ComponentRepository implements BudgetRepositoryInterface
{ {
/** /**
@@ -79,10 +80,10 @@ class BudgetRepository implements BudgetRepositoryInterface
/** @var Collection $repetitions */ /** @var Collection $repetitions */
return LimitRepetition:: return LimitRepetition::
leftJoin('budget_limits', 'limit_repetitions.budget_limit_id', '=', 'budget_limits.id') leftJoin('budget_limits', 'limit_repetitions.budget_limit_id', '=', 'budget_limits.id')
->where('limit_repetitions.startdate', '<=', $end->format('Y-m-d 00:00:00')) ->where('limit_repetitions.startdate', '<=', $end->format('Y-m-d 00:00:00'))
->where('limit_repetitions.startdate', '>=', $start->format('Y-m-d 00:00:00')) ->where('limit_repetitions.startdate', '>=', $start->format('Y-m-d 00:00:00'))
->where('budget_limits.budget_id', $budget->id) ->where('budget_limits.budget_id', $budget->id)
->get(['limit_repetitions.*']); ->get(['limit_repetitions.*']);
} }
/** /**
@@ -113,7 +114,17 @@ class BudgetRepository implements BudgetRepositoryInterface
*/ */
public function getCurrentRepetition(Budget $budget, Carbon $date) public function getCurrentRepetition(Budget $budget, Carbon $date)
{ {
return $budget->limitrepetitions()->where('limit_repetitions.startdate', $date)->first(['limit_repetitions.*']); $cache = new CacheProperties;
$cache->addProperty($budget->id);
$cache->addProperty($date);
$cache->addProperty('getCurrentRepetition');
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
}
$data = $budget->limitrepetitions()->where('limit_repetitions.startdate', $date)->first(['limit_repetitions.*']);
$cache->store($data);
return $data;
} }
/** /**
@@ -150,13 +161,22 @@ class BudgetRepository implements BudgetRepositoryInterface
*/ */
public function getJournals(Budget $budget, LimitRepetition $repetition = null, $take = 50) public function getJournals(Budget $budget, LimitRepetition $repetition = null, $take = 50)
{ {
$offset = intval(Input::get('page')) > 0 ? intval(Input::get('page')) * $take : 0; $cache = new CacheProperties;
$cache->addProperty($budget->id);
if ($repetition) {
$cache->addProperty($repetition->id);
}
$cache->addProperty($take);
$cache->addProperty('getJournals');
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
}
$offset = intval(Input::get('page')) > 0 ? intval(Input::get('page')) * $take : 0;
$setQuery = $budget->transactionJournals()->withRelevantData()->take($take)->offset($offset) $setQuery = $budget->transactionJournals()->withRelevantData()->take($take)->offset($offset)
->orderBy('transaction_journals.date', 'DESC') ->orderBy('transaction_journals.date', 'DESC')
->orderBy('transaction_journals.order', 'ASC') ->orderBy('transaction_journals.order', 'ASC')
->orderBy('transaction_journals.id', 'DESC'); ->orderBy('transaction_journals.id', 'DESC');
$countQuery = $budget->transactionJournals(); $countQuery = $budget->transactionJournals();
@@ -169,7 +189,11 @@ class BudgetRepository implements BudgetRepositoryInterface
$set = $setQuery->get(['transaction_journals.*']); $set = $setQuery->get(['transaction_journals.*']);
$count = $countQuery->count(); $count = $countQuery->count();
return new LengthAwarePaginator($set, $count, $take, $offset);
$paginator = new LengthAwarePaginator($set, $count, $take, $offset);
$cache->store($paginator);
return $paginator;
} }
/** /**
@@ -196,9 +220,9 @@ class BudgetRepository implements BudgetRepositoryInterface
public function getLimitAmountOnDate(Budget $budget, Carbon $date) public function getLimitAmountOnDate(Budget $budget, Carbon $date)
{ {
$repetition = LimitRepetition::leftJoin('budget_limits', 'limit_repetitions.budget_limit_id', '=', 'budget_limits.id') $repetition = LimitRepetition::leftJoin('budget_limits', 'limit_repetitions.budget_limit_id', '=', 'budget_limits.id')
->where('limit_repetitions.startdate', $date->format('Y-m-d 00:00:00')) ->where('limit_repetitions.startdate', $date->format('Y-m-d 00:00:00'))
->where('budget_limits.budget_id', $budget->id) ->where('budget_limits.budget_id', $budget->id)
->first(['limit_repetitions.*']); ->first(['limit_repetitions.*']);
if ($repetition) { if ($repetition) {
return floatval($repetition->amount); return floatval($repetition->amount);
@@ -216,15 +240,15 @@ class BudgetRepository implements BudgetRepositoryInterface
public function getWithoutBudget(Carbon $start, Carbon $end) public function getWithoutBudget(Carbon $start, Carbon $end)
{ {
return Auth::user() return Auth::user()
->transactionjournals() ->transactionjournals()
->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id') ->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
->whereNull('budget_transaction_journal.id') ->whereNull('budget_transaction_journal.id')
->before($end) ->before($end)
->after($start) ->after($start)
->orderBy('transaction_journals.date', 'DESC') ->orderBy('transaction_journals.date', 'DESC')
->orderBy('transaction_journals.order', 'ASC') ->orderBy('transaction_journals.order', 'ASC')
->orderBy('transaction_journals.id', 'DESC') ->orderBy('transaction_journals.id', 'DESC')
->get(['transaction_journals.*']); ->get(['transaction_journals.*']);
} }
/** /**
@@ -236,22 +260,22 @@ class BudgetRepository implements BudgetRepositoryInterface
public function getWithoutBudgetSum(Carbon $start, Carbon $end) public function getWithoutBudgetSum(Carbon $start, Carbon $end)
{ {
$noBudgetSet = Auth::user() $noBudgetSet = Auth::user()
->transactionjournals() ->transactionjournals()
->whereNotIn( ->whereNotIn(
'transaction_journals.id', function (QueryBuilder $query) use ($start, $end) { 'transaction_journals.id', function (QueryBuilder $query) use ($start, $end) {
$query $query
->select('transaction_journals.id') ->select('transaction_journals.id')
->from('transaction_journals') ->from('transaction_journals')
->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id') ->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
->where('transaction_journals.date', '>=', $start->format('Y-m-d 00:00:00')) ->where('transaction_journals.date', '>=', $start->format('Y-m-d 00:00:00'))
->where('transaction_journals.date', '<=', $end->format('Y-m-d 00:00:00')) ->where('transaction_journals.date', '<=', $end->format('Y-m-d 00:00:00'))
->whereNotNull('budget_transaction_journal.budget_id'); ->whereNotNull('budget_transaction_journal.budget_id');
} }
) )
->after($start) ->after($start)
->before($end) ->before($end)
->transactionTypes(['Withdrawal']) ->transactionTypes(['Withdrawal'])
->get(['transaction_journals.*'])->sum('amount'); ->get(['transaction_journals.*'])->sum('amount');
return floatval($noBudgetSet) * -1; return floatval($noBudgetSet) * -1;
} }
@@ -262,32 +286,11 @@ class BudgetRepository implements BudgetRepositoryInterface
* @param Carbon $end * @param Carbon $end
* @param bool $shared * @param bool $shared
* *
* @return float * @return string
*/ */
public function spentInPeriodCorrected(Budget $budget, Carbon $start, Carbon $end, $shared = true) public function spentInPeriodCorrected(Budget $budget, Carbon $start, Carbon $end, $shared = true)
{ {
if ($shared === true) { return $this->spentInPeriod($budget, $start, $end, $shared);
// get everything:
$sum = floatval($budget->transactionjournals()->before($end)->after($start)->get(['transaction_journals.*'])->sum('amount'));
} else {
// get all journals in this month where the asset account is NOT shared.
$sum = $budget->transactionjournals()
->before($end)
->after($start)
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
->leftJoin(
'account_meta', function (JoinClause $join) {
$join->on('account_meta.account_id', '=', 'accounts.id')->where('account_meta.name', '=', 'accountRole');
}
)
->where('account_meta.data', '!=', '"sharedAsset"')
->get(['transaction_journals.*'])
->sum('amount');
$sum = floatval($sum);
}
return $sum;
} }
/** /**

View File

@@ -134,7 +134,7 @@ interface BudgetRepositoryInterface
* @param Carbon $end * @param Carbon $end
* @param boolean $shared * @param boolean $shared
* *
* @return float * @return string
*/ */
public function spentInPeriodCorrected(Budget $budget, Carbon $start, Carbon $end, $shared = true); public function spentInPeriodCorrected(Budget $budget, Carbon $start, Carbon $end, $shared = true);

View File

@@ -7,7 +7,7 @@ use Carbon\Carbon;
use Crypt; use Crypt;
use FireflyIII\Models\Category; use FireflyIII\Models\Category;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use Illuminate\Database\Query\JoinClause; use FireflyIII\Repositories\Shared\ComponentRepository;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
@@ -15,7 +15,7 @@ use Illuminate\Support\Collection;
* *
* @package FireflyIII\Repositories\Category * @package FireflyIII\Repositories\Category
*/ */
class CategoryRepository implements CategoryRepositoryInterface class CategoryRepository extends ComponentRepository implements CategoryRepositoryInterface
{ {
/** /**
@@ -49,7 +49,7 @@ class CategoryRepository implements CategoryRepositoryInterface
/** @var Collection $set */ /** @var Collection $set */
$set = Auth::user()->categories()->orderBy('name', 'ASC')->get(); $set = Auth::user()->categories()->orderBy('name', 'ASC')->get();
$set->sortBy( $set->sortBy(
function(Category $category) { function (Category $category) {
return $category->name; return $category->name;
} }
); );
@@ -67,22 +67,22 @@ class CategoryRepository implements CategoryRepositoryInterface
public function getCategoriesAndExpensesCorrected($start, $end) public function getCategoriesAndExpensesCorrected($start, $end)
{ {
$set = Auth::user()->transactionjournals() $set = Auth::user()->transactionjournals()
->leftJoin( ->leftJoin(
'category_transaction_journal', 'category_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id' 'category_transaction_journal', 'category_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id'
) )
->leftJoin('categories', 'categories.id', '=', 'category_transaction_journal.category_id') ->leftJoin('categories', 'categories.id', '=', 'category_transaction_journal.category_id')
->before($end) ->before($end)
->where('categories.user_id', Auth::user()->id) ->where('categories.user_id', Auth::user()->id)
->after($start) ->after($start)
->transactionTypes(['Withdrawal']) ->transactionTypes(['Withdrawal'])
->groupBy('categories.id') ->get(['categories.id as category_id', 'categories.encrypted as category_encrypted', 'categories.name', 'transaction_journals.*']);
->get(['categories.id as category_id', 'categories.encrypted as category_encrypted', 'categories.name', 'transaction_journals.*']);
$result = []; $result = [];
foreach ($set as $entry) { foreach ($set as $entry) {
$categoryId = intval($entry->category_id); $categoryId = intval($entry->category_id);
if (isset($result[$categoryId])) { if (isset($result[$categoryId])) {
$result[$categoryId]['sum'] += floatval($entry->amount); bcscale(2);
$result[$categoryId]['sum'] = bcadd($result[$categoryId]['sum'], $entry->amount);
} else { } else {
$isEncrypted = intval($entry->category_encrypted) == 1 ? true : false; $isEncrypted = intval($entry->category_encrypted) == 1 ? true : false;
$name = strlen($entry->name) == 0 ? trans('firefly.no_category') : $entry->name; $name = strlen($entry->name) == 0 ? trans('firefly.no_category') : $entry->name;
@@ -143,10 +143,10 @@ class CategoryRepository implements CategoryRepositoryInterface
public function getLatestActivity(Category $category) public function getLatestActivity(Category $category)
{ {
$latest = $category->transactionjournals() $latest = $category->transactionjournals()
->orderBy('transaction_journals.date', 'DESC') ->orderBy('transaction_journals.date', 'DESC')
->orderBy('transaction_journals.order', 'ASC') ->orderBy('transaction_journals.order', 'ASC')
->orderBy('transaction_journals.id', 'DESC') ->orderBy('transaction_journals.id', 'DESC')
->first(); ->first();
if ($latest) { if ($latest) {
return $latest->date; return $latest->date;
} }
@@ -163,15 +163,15 @@ class CategoryRepository implements CategoryRepositoryInterface
public function getWithoutCategory(Carbon $start, Carbon $end) public function getWithoutCategory(Carbon $start, Carbon $end)
{ {
return Auth::user() return Auth::user()
->transactionjournals() ->transactionjournals()
->leftJoin('category_transaction_journal', 'category_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id') ->leftJoin('category_transaction_journal', 'category_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
->whereNull('category_transaction_journal.id') ->whereNull('category_transaction_journal.id')
->before($end) ->before($end)
->after($start) ->after($start)
->orderBy('transaction_journals.date', 'DESC') ->orderBy('transaction_journals.date', 'DESC')
->orderBy('transaction_journals.order', 'ASC') ->orderBy('transaction_journals.order', 'ASC')
->orderBy('transaction_journals.id', 'DESC') ->orderBy('transaction_journals.id', 'DESC')
->get(['transaction_journals.*']); ->get(['transaction_journals.*']);
} }
/** /**
@@ -181,39 +181,11 @@ class CategoryRepository implements CategoryRepositoryInterface
* *
* @param bool $shared * @param bool $shared
* *
* @return float * @return string
*/ */
public function spentInPeriodCorrected(Category $category, Carbon $start, Carbon $end, $shared = false) public function spentInPeriodCorrected(Category $category, Carbon $start, Carbon $end, $shared = false)
{ {
if ($shared === true) { return $this->spentInPeriod($category, $start, $end, $shared);
// shared is true.
// always ignore transfers between accounts!
$sum = floatval(
$category->transactionjournals()
->transactionTypes(['Withdrawal'])
->before($end)->after($start)->get(['transaction_journals.*'])->sum('amount')
);
} else {
// do something else, SEE budgets.
// get all journals in this month where the asset account is NOT shared.
$sum = $category->transactionjournals()
->before($end)
->after($start)
->transactionTypes(['Withdrawal'])
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
->leftJoin(
'account_meta', function(JoinClause $join) {
$join->on('account_meta.account_id', '=', 'accounts.id')->where('account_meta.name', '=', 'accountRole');
}
)
->where('account_meta.data', '!=', '"sharedAsset"')
->get(['transaction_journals.*'])->sum('amount');
$sum = floatval($sum);
}
return $sum;
} }
/** /**

View File

@@ -81,7 +81,7 @@ interface CategoryRepositoryInterface
* *
* @param bool $shared * @param bool $shared
* *
* @return float * @return string
*/ */
public function spentInPeriodCorrected(Category $category, Carbon $start, Carbon $end, $shared = false); public function spentInPeriodCorrected(Category $category, Carbon $start, Carbon $end, $shared = false);

View File

@@ -48,11 +48,6 @@ class JournalRepository implements JournalRepositoryInterface
*/ */
public function delete(TransactionJournal $journal) public function delete(TransactionJournal $journal)
{ {
// delete transactions first:
/** @var Transaction $transaction */
foreach ($journal->transactions()->get() as $transaction) {
$transaction->delete();
}
$journal->delete(); $journal->delete();
return true; return true;
@@ -111,7 +106,7 @@ class JournalRepository implements JournalRepositoryInterface
*/ */
public function getJournalsOfTypes(array $types, $offset, $page) public function getJournalsOfTypes(array $types, $offset, $page)
{ {
$set = Auth::user()->transactionJournals()->transactionTypes($types)->withRelevantData()->take(50)->offset($offset) $set = Auth::user()->transactionJournals()->transactionTypes($types)->withRelevantData()->take(50)->offset($offset)
->orderBy('date', 'DESC') ->orderBy('date', 'DESC')
->orderBy('order', 'ASC') ->orderBy('order', 'ASC')
->orderBy('id', 'DESC') ->orderBy('id', 'DESC')

View File

@@ -102,7 +102,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
public function setOrder($id, $order) public function setOrder($id, $order)
{ {
$piggyBank = PiggyBank::leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')->where('accounts.user_id', Auth::user()->id) $piggyBank = PiggyBank::leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')->where('accounts.user_id', Auth::user()->id)
->where('piggy_banks.id', $id)->first(['piggy_banks.*']); ->where('piggy_banks.id', $id)->first(['piggy_banks.*']);
if ($piggyBank) { if ($piggyBank) {
$piggyBank->order = $order; $piggyBank->order = $order;
$piggyBank->save(); $piggyBank->save();

View File

@@ -36,14 +36,14 @@ class ReminderRepository implements ReminderRepositoryInterface
$today = new Carbon; $today = new Carbon;
// active reminders: // active reminders:
$active = Auth::user()->reminders() $active = Auth::user()->reminders()
->where('notnow', 0) ->where('notnow', 0)
->where('active', 1) ->where('active', 1)
->where('startdate', '<=', $today->format('Y-m-d 00:00:00')) ->where('startdate', '<=', $today->format('Y-m-d 00:00:00'))
->where('enddate', '>=', $today->format('Y-m-d 00:00:00')) ->where('enddate', '>=', $today->format('Y-m-d 00:00:00'))
->get(); ->get();
$active->each( $active->each(
function(Reminder $reminder) { function (Reminder $reminder) {
$reminder->description = $this->helper->getReminderText($reminder); $reminder->description = $this->helper->getReminderText($reminder);
} }
); );
@@ -58,11 +58,11 @@ class ReminderRepository implements ReminderRepositoryInterface
public function getDismissedReminders() public function getDismissedReminders()
{ {
$dismissed = Auth::user()->reminders() $dismissed = Auth::user()->reminders()
->where('notnow', 1) ->where('notnow', 1)
->get(); ->get();
$dismissed->each( $dismissed->each(
function(Reminder $reminder) { function (Reminder $reminder) {
$reminder->description = $this->helper->getReminderText($reminder); $reminder->description = $this->helper->getReminderText($reminder);
} }
); );
@@ -77,18 +77,18 @@ class ReminderRepository implements ReminderRepositoryInterface
{ {
$expired = Auth::user()->reminders() $expired = Auth::user()->reminders()
->where('notnow', 0) ->where('notnow', 0)
->where('active', 1) ->where('active', 1)
->where( ->where(
function (Builder $q) { function (Builder $q) {
$today = new Carbon; $today = new Carbon;
$q->where('startdate', '>', $today->format('Y-m-d 00:00:00')); $q->where('startdate', '>', $today->format('Y-m-d 00:00:00'));
$q->orWhere('enddate', '<', $today->format('Y-m-d 00:00:00')); $q->orWhere('enddate', '<', $today->format('Y-m-d 00:00:00'));
} }
)->get(); )->get();
$expired->each( $expired->each(
function(Reminder $reminder) { function (Reminder $reminder) {
$reminder->description = $this->helper->getReminderText($reminder); $reminder->description = $this->helper->getReminderText($reminder);
} }
); );
@@ -106,7 +106,7 @@ class ReminderRepository implements ReminderRepositoryInterface
->get(); ->get();
$inactive->each( $inactive->each(
function(Reminder $reminder) { function (Reminder $reminder) {
$reminder->description = $this->helper->getReminderText($reminder); $reminder->description = $this->helper->getReminderText($reminder);
} }
); );

View File

@@ -0,0 +1,74 @@
<?php
namespace FireflyIII\Repositories\Shared;
use Carbon\Carbon;
use FireflyIII\Support\CacheProperties;
use Illuminate\Database\Query\JoinClause;
/**
* Class ComponentRepository
*
* @package FireflyIII\Repositories\Shared
*/
class ComponentRepository
{
/**
* @param $object
* @param Carbon $start
* @param Carbon $end
*
* @param bool $shared
*
* @return string
*/
protected function spentInPeriod($object, Carbon $start, Carbon $end, $shared = false)
{
// we must cache this.
$cache = new CacheProperties;
$cache->addProperty($object->id);
$cache->addProperty(get_class($object));
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty($shared);
$cache->addProperty('spentInPeriod');
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
}
if ($shared === true) {
// shared is true.
// always ignore transfers between accounts!
$sum
= $object->transactionjournals()
->transactionTypes(['Withdrawal'])
->before($end)->after($start)->get(['transaction_journals.*'])->sum('amount');
} else {
// do something else, SEE budgets.
// get all journals in this month where the asset account is NOT shared.
$sum = $object->transactionjournals()
->before($end)
->after($start)
->transactionTypes(['Withdrawal'])
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
->leftJoin(
'account_meta', function (JoinClause $join) {
$join->on('account_meta.account_id', '=', 'accounts.id')->where('account_meta.name', '=', 'accountRole');
}
)
->where('account_meta.data', '!=', '"sharedAsset"')
->get(['transaction_journals.*'])->sum('amount');
}
$cache->store($sum);
return $sum;
}
}

View File

@@ -64,14 +64,15 @@ class TagRepository implements TagRepositoryInterface
* @param Carbon $start * @param Carbon $start
* @param Carbon $end * @param Carbon $end
* *
* @return integer * @return string
*/ */
public function coveredByBalancingActs(Account $account, Carbon $start, Carbon $end) public function coveredByBalancingActs(Account $account, Carbon $start, Carbon $end)
{ {
// the quickest way to do this is by scanning all balancingAct tags // the quickest way to do this is by scanning all balancingAct tags
// because there will be less of them any way. // because there will be less of them any way.
$tags = Auth::user()->tags()->where('tagMode', 'balancingAct')->get(); $tags = Auth::user()->tags()->where('tagMode', 'balancingAct')->get();
$amount = 0; $amount = '0';
bcscale(2);
/** @var Tag $tag */ /** @var Tag $tag */
foreach ($tags as $tag) { foreach ($tags as $tag) {
@@ -80,7 +81,7 @@ class TagRepository implements TagRepositoryInterface
/** @var TransactionJournal $journal */ /** @var TransactionJournal $journal */
foreach ($journals as $journal) { foreach ($journals as $journal) {
if ($journal->destination_account->id == $account->id) { if ($journal->destination_account->id == $account->id) {
$amount += $journal->amount; $amount = bcadd($amount, $journal->amount);
} }
} }
} }
@@ -109,7 +110,7 @@ class TagRepository implements TagRepositoryInterface
/** @var Collection $tags */ /** @var Collection $tags */
$tags = Auth::user()->tags()->get(); $tags = Auth::user()->tags()->get();
$tags->sortBy( $tags->sortBy(
function(Tag $tag) { function (Tag $tag) {
return $tag->tag; return $tag->tag;
} }
); );
@@ -198,16 +199,11 @@ class TagRepository implements TagRepositoryInterface
/* /*
* If any transaction is a deposit, cannot become a balancing act. * If any transaction is a deposit, cannot become a balancing act.
*/ */
$count = 0;
foreach ($tag->transactionjournals as $journal) { foreach ($tag->transactionjournals as $journal) {
if ($journal->transactionType->type == 'Deposit') { if ($journal->transactionType->type == 'Deposit') {
$count++; return false;
} }
} }
if ($count > 0) {
return false;
}
return true; return true;
} }
@@ -308,7 +304,8 @@ class TagRepository implements TagRepositoryInterface
return $this->matchAll($journal, $tag); return $this->matchAll($journal, $tag);
} }
return false; // this statement is unreachable.
return false; // @codeCoverageIgnore
} }
@@ -323,7 +320,7 @@ class TagRepository implements TagRepositoryInterface
$match = true; $match = true;
/** @var TransactionJournal $check */ /** @var TransactionJournal $check */
foreach ($tag->transactionjournals as $check) { foreach ($tag->transactionjournals as $check) {
if ($check->asset_account->id != $journal->asset_account->id) { if ($check->source_account->id != $journal->source_account->id) {
$match = false; $match = false;
} }
} }

View File

@@ -38,7 +38,7 @@ interface TagRepositoryInterface
* @param Carbon $start * @param Carbon $start
* @param Carbon $end * @param Carbon $end
* *
* @return float * @return string
*/ */
public function coveredByBalancingActs(Account $account, Carbon $start, Carbon $end); public function coveredByBalancingActs(Account $account, Carbon $start, Carbon $end);

View File

@@ -41,9 +41,9 @@ class Registrar implements RegistrarContract
{ {
return Validator::make( return Validator::make(
$data, [ $data, [
'email' => 'required|email|max:255|unique:users', 'email' => 'required|email|max:255|unique:users',
'password' => 'required|confirmed|min:6', 'password' => 'required|confirmed|min:6',
] ]
); );
} }

View File

@@ -35,15 +35,8 @@ class Amount
*/ */
public function getCurrencySymbol() public function getCurrencySymbol()
{ {
if (defined('FFCURRENCYSYMBOL')) {
return FFCURRENCYSYMBOL;
}
$currencyPreference = Prefs::get('currencyPreference', 'EUR'); $currencyPreference = Prefs::get('currencyPreference', 'EUR');
$currency = TransactionCurrency::whereCode($currencyPreference->data)->first(); $currency = TransactionCurrency::whereCode($currencyPreference->data)->first();
define('FFCURRENCYSYMBOL', $currency->symbol);
return $currency->symbol; return $currency->symbol;
} }
@@ -84,6 +77,15 @@ class Amount
*/ */
public function formatJournal(TransactionJournal $journal, $coloured = true) public function formatJournal(TransactionJournal $journal, $coloured = true)
{ {
$cache = new CacheProperties;
$cache->addProperty($journal->id);
$cache->addProperty('formatJournal');
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
}
if (is_null($journal->symbol)) { if (is_null($journal->symbol)) {
$symbol = $journal->transactionCurrency->symbol; $symbol = $journal->transactionCurrency->symbol;
} else { } else {
@@ -94,13 +96,22 @@ class Amount
$amount = $amount * -1; $amount = $amount * -1;
} }
if ($journal->transactionType->type == 'Transfer' && $coloured) { if ($journal->transactionType->type == 'Transfer' && $coloured) {
return '<span class="text-info">' . $this->formatWithSymbol($symbol, $amount, false) . '</span>'; $txt = '<span class="text-info">' . $this->formatWithSymbol($symbol, $amount, false) . '</span>';
$cache->store($txt);
return $txt;
} }
if ($journal->transactionType->type == 'Transfer' && !$coloured) { if ($journal->transactionType->type == 'Transfer' && !$coloured) {
return $this->formatWithSymbol($symbol, $amount, false); $txt = $this->formatWithSymbol($symbol, $amount, false);
$cache->store($txt);
return $txt;
} }
return $this->formatWithSymbol($symbol, $amount, $coloured); $txt = $this->formatWithSymbol($symbol, $amount, $coloured);
$cache->store($txt);
return $txt;
} }
/** /**
@@ -130,22 +141,16 @@ class Amount
*/ */
public function getCurrencyCode() public function getCurrencyCode()
{ {
if (defined('FFCURRENCYCODE')) {
return FFCURRENCYCODE;
}
$currencyPreference = Prefs::get('currencyPreference', 'EUR'); $currencyPreference = Prefs::get('currencyPreference', 'EUR');
$currency = TransactionCurrency::whereCode($currencyPreference->data)->first(); $currency = TransactionCurrency::whereCode($currencyPreference->data)->first();
if ($currency) { if ($currency) {
define('FFCURRENCYCODE', $currency->code);
return $currency->code; return $currency->code;
} }
return 'EUR'; return 'EUR'; // @codeCoverageIgnore
} }
/** /**

View File

@@ -0,0 +1,106 @@
<?php
namespace FireflyIII\Support;
use Auth;
use Cache;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection as EloquentCollection;
use Illuminate\Support\Collection;
use Preferences as Prefs;
/**
* Class CacheProperties
*
* @codeCoverageIgnore
* @package FireflyIII\Support
*/
class CacheProperties
{
/** @var string */
protected $md5 = '';
/** @var Collection */
protected $properties;
/**
*
*/
public function __construct()
{
$this->properties = new Collection;
$this->addProperty(Auth::user()->id);
$this->addProperty(Prefs::lastActivity());
}
/**
* @param $property
*/
public function addProperty($property)
{
$this->properties->push($property);
}
/**
* @return mixed
*/
public function get()
{
return Cache::get($this->md5);
}
/**
* @return string
*/
public function getMd5()
{
return $this->md5;
}
/**
* @return bool
*/
public function has()
{
if (getenv('APP_ENV') == 'testing') {
return false;
}
$this->md5();
return Cache::has($this->md5);
}
/**
* @return void
*/
private function md5()
{
foreach ($this->properties as $property) {
if ($property instanceof Collection || $property instanceof EloquentCollection) {
$this->md5 .= json_encode($property->toArray());
continue;
}
if ($property instanceof Carbon) {
$this->md5 .= $property->toRfc3339String();
continue;
}
if (is_object($property)) {
$this->md5 .= $property->__toString();
}
$this->md5 .= json_encode($property);
}
$this->md5 = md5($this->md5);
}
/**
* @param $data
*/
public function store($data)
{
Cache::forever($this->md5, $data);
}
}

View File

@@ -7,6 +7,7 @@ use Eloquent;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Illuminate\Support\MessageBag; use Illuminate\Support\MessageBag;
use Input; use Input;
use RuntimeException;
use Session; use Session;
use View; use View;
@@ -109,10 +110,17 @@ class ExpandedForm
$preFilled = Session::get('preFilled'); $preFilled = Session::get('preFilled');
$value = isset($preFilled[$name]) && is_null($value) ? $preFilled[$name] : $value; $value = isset($preFilled[$name]) && is_null($value) ? $preFilled[$name] : $value;
} }
if (!is_null(Input::old($name))) { // @codeCoverageIgnoreStart
$value = Input::old($name); try {
if (!is_null(Input::old($name))) {
$value = Input::old($name);
}
} catch (RuntimeException $e) {
// don't care about session errors.
} }
// @codeCoverageIgnoreEnd
return $value; return $value;
} }
@@ -249,24 +257,6 @@ class ExpandedForm
return $selectList; return $selectList;
} }
/**
* @param $name
* @param null $value
* @param array $options
*
* @return string
*/
public function month($name, $value = null, array $options = [])
{
$label = $this->label($name, $options);
$options = $this->expandOptionArray($name, $label, $options);
$classes = $this->getHolderClasses($name);
$value = $this->fillFieldValue($name, $value);
$html = View::make('form.month', compact('classes', 'name', 'label', 'value', 'options'))->render();
return $html;
}
/** /**
* @param $name * @param $name
* @param array $list * @param array $list
@@ -274,7 +264,6 @@ class ExpandedForm
* @param array $options * @param array $options
* *
* @return string * @return string
* @internal param null $value
*/ */
public function multiRadio($name, array $list = [], $selected = null, array $options = []) public function multiRadio($name, array $list = [], $selected = null, array $options = [])
{ {
@@ -297,7 +286,16 @@ class ExpandedForm
*/ */
public function optionsList($type, $name) public function optionsList($type, $name)
{ {
$previousValue = Input::old('post_submit_action'); $previousValue = null;
// @codeCoverageIgnoreStart
try {
$previousValue = Input::old('post_submit_action');
} catch (RuntimeException $e) {
// don't care
}
// @codeCoverageIgnoreEnd
$previousValue = is_null($previousValue) ? 'store' : $previousValue; $previousValue = is_null($previousValue) ? 'store' : $previousValue;
$html = View::make('form.options', compact('type', 'name', 'previousValue'))->render(); $html = View::make('form.options', compact('type', 'name', 'previousValue'))->render();

View File

@@ -41,6 +41,7 @@ class Navigation
'6M' => 6, '6M' => 6,
'half-year' => 6, 'half-year' => 6,
]; ];
if (!isset($functionMap[$repeatFreq])) { if (!isset($functionMap[$repeatFreq])) {
throw new FireflyException('Cannot do addPeriod for $repeat_freq "' . $repeatFreq . '"'); throw new FireflyException('Cannot do addPeriod for $repeat_freq "' . $repeatFreq . '"');
} }
@@ -118,7 +119,7 @@ class Navigation
'year' => 'endOfYear', 'year' => 'endOfYear',
'yearly' => 'endOfYear', 'yearly' => 'endOfYear',
]; ];
$specials = ['mont', 'monthly']; $specials = ['mont', 'monthly'];
$currentEnd = clone $theCurrentEnd; $currentEnd = clone $theCurrentEnd;
@@ -270,7 +271,7 @@ class Navigation
'3M' => 'lastOfQuarter', '3M' => 'lastOfQuarter',
'1Y' => 'endOfYear', '1Y' => 'endOfYear',
]; ];
$end = clone $start; $end = clone $start;
if (isset($functionMap[$range])) { if (isset($functionMap[$range])) {
$function = $functionMap[$range]; $function = $functionMap[$range];

View File

@@ -3,6 +3,7 @@
namespace FireflyIII\Support; namespace FireflyIII\Support;
use Auth; use Auth;
use Cache;
use FireflyIII\Models\Preference; use FireflyIII\Models\Preference;
/** /**
@@ -13,20 +14,34 @@ use FireflyIII\Models\Preference;
class Preferences class Preferences
{ {
/** /**
* @param $name * @return string
* @param null $default */
public function lastActivity()
{
$preference = $this->get('lastActivity', microtime())->data;
return md5($preference);
}
/**
* @param string $name
* @param string $default
* *
* @return null|\FireflyIII\Models\Preference * @return null|\FireflyIII\Models\Preference
*/ */
public function get($name, $default = null) public function get($name, $default = null)
{ {
$preferences = Preference::where('user_id', Auth::user()->id)->get(); $fullName = 'preference' . Auth::user()->id . $name;
if (Cache::has($fullName)) {
return Cache::get($fullName);
}
/** @var Preference $preference */ $preference = Preference::where('user_id', Auth::user()->id)->where('name', $name)->first(['id', 'name', 'data_encrypted']);
foreach ($preferences as $preference) {
if ($preference->name == $name) { if ($preference) {
return $preference; Cache::forever($fullName, $preference);
}
return $preference;
} }
// no preference found and default is null: // no preference found and default is null:
if (is_null($default)) { if (is_null($default)) {
@@ -39,33 +54,40 @@ class Preferences
} }
/** /**
* @param $name * @param $name
* @param $value * @param string $value
* *
* @return Preference * @return Preference
*/ */
public function set($name, $value) public function set($name, $value)
{ {
$preferences = Preference::where('user_id', Auth::user()->id)->get(); $fullName = 'preference' . Auth::user()->id . $name;
/** @var Preference $preference */ Cache::forget($fullName);
foreach ($preferences as $preference) { $pref = Preference::where('user_id', Auth::user()->id)->where('name', $name)->first(['id', 'name', 'data_encrypted']);
if ($preference->name == $name) { if ($pref) {
$preference->data = $value; $pref->data = $value;
$preference->save(); } else {
$pref = new Preference;
return $preference; $pref->name = $name;
} $pref->data = $value;
}
$pref = new Preference;
$pref->name = $name;
$pref->data = $value;
if (!is_null(Auth::user()->id)) {
$pref->user()->associate(Auth::user()); $pref->user()->associate(Auth::user());
$pref->save();
} }
$pref->save();
Cache::forever($fullName, $pref);
return $pref; return $pref;
} }
/**
* @return bool
*/
public function mark()
{
$this->set('lastActivity', microtime());
return true;
}
} }

View File

@@ -25,7 +25,7 @@ class Search implements SearchInterface
public function searchAccounts(array $words) public function searchAccounts(array $words)
{ {
return Auth::user()->accounts()->with('accounttype')->where( return Auth::user()->accounts()->with('accounttype')->where(
function(EloquentBuilder $q) use ($words) { function (EloquentBuilder $q) use ($words) {
foreach ($words as $word) { foreach ($words as $word) {
$q->orWhere('name', 'LIKE', '%' . e($word) . '%'); $q->orWhere('name', 'LIKE', '%' . e($word) . '%');
} }
@@ -43,7 +43,7 @@ class Search implements SearchInterface
/** @var Collection $set */ /** @var Collection $set */
$set = Auth::user()->budgets()->get(); $set = Auth::user()->budgets()->get();
$newSet = $set->filter( $newSet = $set->filter(
function(Budget $b) use ($words) { function (Budget $b) use ($words) {
$found = 0; $found = 0;
foreach ($words as $word) { foreach ($words as $word) {
if (!(strpos(strtolower($b->name), strtolower($word)) === false)) { if (!(strpos(strtolower($b->name), strtolower($word)) === false)) {
@@ -68,7 +68,7 @@ class Search implements SearchInterface
/** @var Collection $set */ /** @var Collection $set */
$set = Auth::user()->categories()->get(); $set = Auth::user()->categories()->get();
$newSet = $set->filter( $newSet = $set->filter(
function(Category $c) use ($words) { function (Category $c) use ($words) {
$found = 0; $found = 0;
foreach ($words as $word) { foreach ($words as $word) {
if (!(strpos(strtolower($c->name), strtolower($word)) === false)) { if (!(strpos(strtolower($c->name), strtolower($word)) === false)) {
@@ -103,7 +103,7 @@ class Search implements SearchInterface
{ {
// decrypted transaction journals: // decrypted transaction journals:
$decrypted = Auth::user()->transactionjournals()->withRelevantData()->where('encrypted', 0)->where( $decrypted = Auth::user()->transactionjournals()->withRelevantData()->where('encrypted', 0)->where(
function(EloquentBuilder $q) use ($words) { function (EloquentBuilder $q) use ($words) {
foreach ($words as $word) { foreach ($words as $word) {
$q->orWhere('description', 'LIKE', '%' . e($word) . '%'); $q->orWhere('description', 'LIKE', '%' . e($word) . '%');
} }
@@ -113,7 +113,7 @@ class Search implements SearchInterface
// encrypted // encrypted
$all = Auth::user()->transactionjournals()->withRelevantData()->where('encrypted', 1)->get(); $all = Auth::user()->transactionjournals()->withRelevantData()->where('encrypted', 1)->get();
$set = $all->filter( $set = $all->filter(
function(TransactionJournal $journal) use ($words) { function (TransactionJournal $journal) use ($words) {
foreach ($words as $word) { foreach ($words as $word) {
$haystack = strtolower($journal->description); $haystack = strtolower($journal->description);
$word = strtolower($word); $word = strtolower($word);
@@ -129,7 +129,7 @@ class Search implements SearchInterface
$filtered = $set->merge($decrypted); $filtered = $set->merge($decrypted);
$filtered->sortBy( $filtered->sortBy(
function(TransactionJournal $journal) { function (TransactionJournal $journal) {
return intval($journal->date->format('U')); return intval($journal->date->format('U'));
} }
); );

View File

@@ -4,8 +4,6 @@ namespace FireflyIII\Support;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Models\PiggyBank;
use FireflyIII\Models\PiggyBankRepetition;
/** /**
* Class Steam * Class Steam
@@ -24,6 +22,18 @@ class Steam
*/ */
public function balance(Account $account, Carbon $date, $ignoreVirtualBalance = false) public function balance(Account $account, Carbon $date, $ignoreVirtualBalance = false)
{ {
// abuse chart properties:
$cache = new CacheProperties;
$cache->addProperty($account->id);
$cache->addProperty('balance');
$cache->addProperty($date);
$cache->addProperty($ignoreVirtualBalance);
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
}
// find the first known transaction on this account: // find the first known transaction on this account:
$firstDateObject = $account $firstDateObject = $account
->transactions() ->transactions()
@@ -45,6 +55,7 @@ class Steam
if (!$ignoreVirtualBalance) { if (!$ignoreVirtualBalance) {
$balance = bcadd($balance, $account->virtual_balance); $balance = bcadd($balance, $account->virtual_balance);
} }
$cache->store(round($balance, 2));
return round($balance, 2); return round($balance, 2);
} }

View File

@@ -4,6 +4,7 @@ namespace FireflyIII\Support\Twig;
use Auth; use Auth;
use FireflyIII\Models\LimitRepetition; use FireflyIII\Models\LimitRepetition;
use FireflyIII\Support\CacheProperties;
use Twig_Extension; use Twig_Extension;
use Twig_SimpleFunction; use Twig_SimpleFunction;
@@ -19,20 +20,27 @@ class Budget extends Twig_Extension
*/ */
public function getFunctions() public function getFunctions()
{ {
$functions = []; $functions = [];
$functions[] = new Twig_SimpleFunction( $functions[] = new Twig_SimpleFunction(
'spentInRepetitionCorrected', function(LimitRepetition $repetition) { 'spentInRepetitionCorrected', function (LimitRepetition $repetition) {
$cache = new CacheProperties;
$cache->addProperty($repetition->id);
$cache->addProperty('spentInRepetitionCorrected');
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
}
$sum $sum
= Auth::user()->transactionjournals() = Auth::user()->transactionjournals()
->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id') ->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
->leftJoin('budget_limits', 'budget_limits.budget_id', '=', 'budget_transaction_journal.budget_id') ->leftJoin('budget_limits', 'budget_limits.budget_id', '=', 'budget_transaction_journal.budget_id')
->leftJoin('limit_repetitions', 'limit_repetitions.budget_limit_id', '=', 'budget_limits.id') ->leftJoin('limit_repetitions', 'limit_repetitions.budget_limit_id', '=', 'budget_limits.id')
->before($repetition->enddate) ->before($repetition->enddate)
->after($repetition->startdate) ->after($repetition->startdate)
->where('limit_repetitions.id', '=', $repetition->id) ->where('limit_repetitions.id', '=', $repetition->id)
->get(['transaction_journals.*'])->sum('amount'); ->get(['transaction_journals.*'])->sum('amount');
$cache->store($sum);
return floatval($sum); return $sum;
} }
); );

View File

@@ -28,51 +28,15 @@ class General extends Twig_Extension
*/ */
public function getFilters() public function getFilters()
{ {
$filters = []; return [
$this->formatAmount(),
$this->formatTransaction(),
$this->formatAmountPlain(),
$this->formatJournal(),
$this->balance(),
$this->getAccountRole()
];
$filters[] = new Twig_SimpleFilter(
'formatAmount', function($string) {
return App::make('amount')->format($string);
}, ['is_safe' => ['html']]
);
$filters[] = new Twig_SimpleFilter(
'formatTransaction', function(Transaction $transaction) {
return App::make('amount')->formatTransaction($transaction);
}, ['is_safe' => ['html']]
);
$filters[] = new Twig_SimpleFilter(
'formatAmountPlain', function($string) {
return App::make('amount')->format($string, false);
}, ['is_safe' => ['html']]
);
$filters[] = new Twig_SimpleFilter(
'formatJournal', function($journal) {
return App::make('amount')->formatJournal($journal);
}, ['is_safe' => ['html']]
);
$filters[] = new Twig_SimpleFilter(
'balance', function(Account $account = null) {
if (is_null($account)) {
return 'NULL';
}
$date = Session::get('end', Carbon::now()->endOfMonth());
return App::make('steam')->balance($account, $date);
}
);
// should be a function but OK
$filters[] = new Twig_SimpleFilter(
'getAccountRole', function($name) {
return Config::get('firefly.accountRoles.' . $name);
}
);
return $filters;
} }
/** /**
@@ -80,62 +44,16 @@ class General extends Twig_Extension
*/ */
public function getFunctions() public function getFunctions()
{ {
$functions = []; return [
$this->getCurrencyCode(),
$functions[] = new Twig_SimpleFunction( $this->getCurrencySymbol(),
'getCurrencyCode', function() { $this->phpdate(),
return App::make('amount')->getCurrencyCode(); $this->env(),
}
);
$functions[] = new Twig_SimpleFunction(
'getCurrencySymbol', function() {
return App::make('amount')->getCurrencySymbol();
}
);
$functions[] = new Twig_SimpleFunction(
'phpdate', function($str) {
return date($str);
}
);
$functions[] = new Twig_SimpleFunction(
'env', function($name, $default) {
return env($name, $default);
}
);
$functions[] = new Twig_SimpleFunction(
'activeRoute', function($context) {
$args = func_get_args();
$route = $args[1];
$what = isset($args[2]) ? $args[2] : false;
$strict = isset($args[3]) ? $args[3] : false;
$activeWhat = isset($context['what']) ? $context['what'] : false;
// activeRoute
if (!($what === false)) {
if ($what == $activeWhat && Route::getCurrentRoute()->getName() == $route) {
return 'active because-active-what';
}
} else {
if (!$strict && !(strpos(Route::getCurrentRoute()->getName(), $route) === false)) {
return 'active because-route-matches-non-strict';
} else {
if ($strict && Route::getCurrentRoute()->getName() == $route) {
return 'active because-route-matches-strict';
}
}
}
return 'not-xxx-at-all';
}, ['needs_context' => true]
);
return $functions;
$this->activeRouteStrict(),
$this->activeRoutePartial(),
$this->activeRoutePartialWhat(),
];
} }
@@ -147,4 +65,196 @@ class General extends Twig_Extension
return 'FireflyIII\Support\Twig\General'; return 'FireflyIII\Support\Twig\General';
} }
/**
* @return Twig_SimpleFilter
*/
protected function formatAmount()
{
return new Twig_SimpleFilter(
'formatAmount', function ($string) {
return App::make('amount')->format($string);
}, ['is_safe' => ['html']]
);
}
/**
* @return Twig_SimpleFilter
*/
protected function formatTransaction()
{
return new Twig_SimpleFilter(
'formatTransaction', function (Transaction $transaction) {
return App::make('amount')->formatTransaction($transaction);
}, ['is_safe' => ['html']]
);
}
/**
* @return Twig_SimpleFilter
*/
protected function formatAmountPlain()
{
return new Twig_SimpleFilter(
'formatAmountPlain', function ($string) {
return App::make('amount')->format($string, false);
}, ['is_safe' => ['html']]
);
}
/**
* @return Twig_SimpleFilter
*/
protected function formatJournal()
{
return new Twig_SimpleFilter(
'formatJournal', function ($journal) {
return App::make('amount')->formatJournal($journal);
}, ['is_safe' => ['html']]
);
}
/**
* @return Twig_SimpleFilter
*/
protected function balance()
{
return new Twig_SimpleFilter(
'balance', function (Account $account = null) {
if (is_null($account)) {
return 'NULL';
}
$date = Session::get('end', Carbon::now()->endOfMonth());
return App::make('steam')->balance($account, $date);
}
);
}
/**
* @return Twig_SimpleFilter
*/
protected function getAccountRole()
{
return new Twig_SimpleFilter(
'getAccountRole', function ($name) {
return Config::get('firefly.accountRoles.' . $name);
}
);
}
/**
* @return Twig_SimpleFunction
*/
protected function getCurrencyCode()
{
return new Twig_SimpleFunction(
'getCurrencyCode', function () {
return App::make('amount')->getCurrencyCode();
}
);
}
/**
* @return Twig_SimpleFunction
*/
protected function getCurrencySymbol()
{
return new Twig_SimpleFunction(
'getCurrencySymbol', function () {
return App::make('amount')->getCurrencySymbol();
}
);
}
/**
* @return Twig_SimpleFunction
*/
protected function phpdate()
{
return new Twig_SimpleFunction(
'phpdate', function ($str) {
return date($str);
}
);
}
/**
* @return Twig_SimpleFunction
*/
protected function env()
{
return new Twig_SimpleFunction(
'env', function ($name, $default) {
return env($name, $default);
}
);
}
/**
* Will return "active" when the current route matches the given argument
* exactly.
*
* @return Twig_SimpleFunction
*/
protected function activeRouteStrict()
{
return new Twig_SimpleFunction(
'activeRouteStrict', function () {
$args = func_get_args();
$route = $args[0]; // name of the route.
if (Route::getCurrentRoute()->getName() == $route) {
return 'active because-route-matches-strict';
}
return 'not-xxx-at-all';
}
);
}
/**
* Will return "active" when a part of the route matches the argument.
* ie. "accounts" will match "accounts.index".
*
* @return Twig_SimpleFunction
*/
protected function activeRoutePartial()
{
return new Twig_SimpleFunction(
'activeRoutePartial', function () {
$args = func_get_args();
$route = $args[0]; // name of the route.
if (!(strpos(Route::getCurrentRoute()->getName(), $route) === false)) {
return 'active because-route-matches-non-strict';
}
return 'not-xxx-at-all';
}
);
}
/**
* This function will return "active" when the current route matches the first argument (even partly)
* but, the variable $what has been set and matches the second argument.
*
* @return Twig_SimpleFunction
*/
protected function activeRoutePartialWhat()
{
return new Twig_SimpleFunction(
'activeRoutePartialWhat', function ($context) {
$args = func_get_args();
$route = $args[1]; // name of the route.
$what = $args[2]; // name of the route.
$activeWhat = isset($context['what']) ? $context['what'] : false;
if ($what == $activeWhat && !(strpos(Route::getCurrentRoute()->getName(), $route) === false)) {
return 'active because-route-matches-non-strict-what';
}
return 'not-xxx-at-all';
}, ['needs_context' => true]
);
}
} }

View File

@@ -4,7 +4,9 @@ namespace FireflyIII\Support\Twig;
use App; use App;
use FireflyIII\Models\Tag;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use FireflyIII\Support\CacheProperties;
use Twig_Extension; use Twig_Extension;
use Twig_SimpleFilter; use Twig_SimpleFilter;
use Twig_SimpleFunction; use Twig_SimpleFunction;
@@ -18,103 +20,24 @@ class Journal extends Twig_Extension
{ {
/** /**
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @return array * @return array
*/ */
public function getFilters() public function getFilters()
{ {
$filters = []; $filters = [$this->typeIcon()];
$filters[] = new Twig_SimpleFilter(
'typeIcon', function(TransactionJournal $journal) {
$type = $journal->transactionType->type;
switch ($type) {
case 'Withdrawal':
return '<span class="glyphicon glyphicon-arrow-left" title="' . trans('firefly.withdrawal') . '"></span>';
case 'Deposit':
return '<span class="glyphicon glyphicon-arrow-right" title="' . trans('firefly.deposit') . '"></span>';
case 'Transfer':
return '<i class="fa fa-fw fa-exchange" title="' . trans('firefly.transfer') . '"></i>';
case 'Opening balance':
return '<span class="glyphicon glyphicon-ban-circle" title="' . trans('firefly.openingBalance') . '"></span>';
default:
return '';
}
}, ['is_safe' => ['html']]
);
return $filters; return $filters;
} }
/** /**
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*
* @return array * @return array
*/ */
public function getFunctions() public function getFunctions()
{ {
$functions = []; $functions = [
$this->invalidJournal(),
$functions[] = new Twig_SimpleFunction( $this->relevantTags()
'invalidJournal', function(TransactionJournal $journal) { ];
if (!isset($journal->transactions[1]) || !isset($journal->transactions[0])) {
return true;
}
return false;
}
);
$functions[] = new Twig_SimpleFunction(
'relevantTags', function(TransactionJournal $journal) {
if ($journal->tags->count() == 0) {
return App::make('amount')->formatJournal($journal);
}
foreach ($journal->tags as $tag) {
if ($tag->tagMode == 'balancingAct') {
// return tag formatted for a "balancing act", even if other
// tags are present.
$amount = App::make('amount')->format($journal->actual_amount, false);
return '<a href="' . route('tags.show', [$tag->id]) . '" class="label label-success" title="' . $amount
. '"><i class="fa fa-fw fa-refresh"></i> ' . $tag->tag . '</a>';
}
/*
* AdvancePayment with a deposit will show the tag instead of the amount:
*/
if ($tag->tagMode == 'advancePayment' && $journal->transactionType->type == 'Deposit') {
$amount = App::make('amount')->formatJournal($journal, false);
return '<a href="' . route('tags.show', [$tag->id]) . '" class="label label-success" title="' . $amount
. '"><i class="fa fa-fw fa-sort-numeric-desc"></i> ' . $tag->tag . '</a>';
}
/*
* AdvancePayment with a withdrawal will show the amount with a link to
* the tag. The TransactionJournal should properly calculate the amount.
*/
if ($tag->tagMode == 'advancePayment' && $journal->transactionType->type == 'Withdrawal') {
$amount = App::make('amount')->formatJournal($journal);
return '<a href="' . route('tags.show', [$tag->id]) . '">' . $amount . '</a>';
}
if ($tag->tagMode == 'nothing') {
// return the amount:
return App::make('amount')->formatJournal($journal);
}
}
return 'TODO: ' . $journal->amount;
}
);
return $functions; return $functions;
} }
@@ -128,4 +51,192 @@ class Journal extends Twig_Extension
{ {
return 'FireflyIII\Support\Twig\Journals'; return 'FireflyIII\Support\Twig\Journals';
} }
/**
* @return Twig_SimpleFilter
*/
protected function typeIcon()
{
return new Twig_SimpleFilter(
'typeIcon', function (TransactionJournal $journal) {
$cache = new CacheProperties();
$cache->addProperty($journal->id);
$cache->addProperty('typeIcon');
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
}
$type = $journal->transactionType->type;
switch ($type) {
case 'Withdrawal':
$txt = '<span class="glyphicon glyphicon-arrow-left" title="' . trans('firefly.withdrawal') . '"></span>';
break;
case 'Deposit':
$txt = '<span class="glyphicon glyphicon-arrow-right" title="' . trans('firefly.deposit') . '"></span>';
break;
case 'Transfer':
$txt = '<i class="fa fa-fw fa-exchange" title="' . trans('firefly.transfer') . '"></i>';
break;
case 'Opening balance':
$txt = '<span class="glyphicon glyphicon-ban-circle" title="' . trans('firefly.openingBalance') . '"></span>';
break;
default:
$txt = '';
break;
}
$cache->store($txt);
return $txt;
}, ['is_safe' => ['html']]
);
}
/**
* @return Twig_SimpleFunction
*/
protected function invalidJournal()
{
return new Twig_SimpleFunction(
'invalidJournal', function (TransactionJournal $journal) {
if (!isset($journal->transactions[1]) || !isset($journal->transactions[0])) {
return true;
}
return false;
}
);
}
/**
* @return Twig_SimpleFunction
*/
protected function relevantTags()
{
return new Twig_SimpleFunction(
'relevantTags', function (TransactionJournal $journal) {
$cache = new CacheProperties;
$cache->addProperty('relevantTags');
$cache->addProperty($journal->id);
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
}
$count = $journal->tags->count();
$string = '';
if ($count === 0) {
$string = $this->relevantTagsNoTags($journal);
}
if ($count === 1) {
$string = $this->relevantTagsSingle($journal);
}
if ($count > 1) {
$string = $this->relevantTagsMulti($journal);
}
$cache->store($string);
return $string;
}
);
}
/**
* @param TransactionJournal $journal
*
* @return string
*/
protected function relevantTagsNoTags(TransactionJournal $journal)
{
return App::make('amount')->formatJournal($journal);
}
/**
* @param TransactionJournal $journal
*
* @return string
*/
protected function relevantTagsSingle(TransactionJournal $journal)
{
$tag = $journal->tags()->first();
return $this->formatJournalByTag($journal, $tag);
}
/**
* @param TransactionJournal $journal
* @param Tag $tag
*
* @return string
*/
protected function formatJournalByTag(TransactionJournal $journal, Tag $tag)
{
if ($tag->tagMode == 'balancingAct') {
// return tag formatted for a "balancing act", even if other
// tags are present.
$amount = App::make('amount')->format($journal->actual_amount, false);
$string = '<a href="' . route('tags.show', [$tag->id]) . '" class="label label-success" title="' . $amount
. '"><i class="fa fa-fw fa-refresh"></i> ' . $tag->tag . '</a>';
return $string;
}
if ($tag->tagMode == 'advancePayment') {
if ($journal->transactionType->type == 'Deposit') {
$amount = App::make('amount')->formatJournal($journal, false);
$string = '<a href="' . route('tags.show', [$tag->id]) . '" class="label label-success" title="' . $amount
. '"><i class="fa fa-fw fa-sort-numeric-desc"></i> ' . $tag->tag . '</a>';
return $string;
}
/*
* AdvancePayment with a withdrawal will show the amount with a link to
* the tag. The TransactionJournal should properly calculate the amount.
*/
if ($journal->transactionType->type == 'Withdrawal') {
$amount = App::make('amount')->formatJournal($journal);
$string = '<a href="' . route('tags.show', [$tag->id]) . '">' . $amount . '</a>';
return $string;
}
}
return $this->relevantTagsNoTags($journal);
}
/**
* If a transaction journal has multiple tags, we'll have to gamble. FF3
* does not yet block adding multiple 'special' tags so we must wing it.
*
* We grab the first special tag (for advancePayment and for balancingAct
* and try to format those. If they're not present (it's all normal tags),
* we can format like any other journal.
*
* @param TransactionJournal $journal
*
* @return string
*/
protected function relevantTagsMulti(TransactionJournal $journal)
{
$firstBalancingAct = $journal->tags()->where('tagMode', 'balancingAct')->first();
if ($firstBalancingAct) {
return $this->formatJournalByTag($journal, $firstBalancingAct);
}
$firstAdvancePayment = $journal->tags()->where('tagMode', 'advancePayment')->first();
if ($firstAdvancePayment) {
return $this->formatJournalByTag($journal, $firstAdvancePayment);
}
return $this->relevantTagsNoTags($journal);
}
} }

View File

@@ -22,7 +22,7 @@ class PiggyBank extends Twig_Extension
$functions = []; $functions = [];
$functions[] = new Twig_SimpleFunction( $functions[] = new Twig_SimpleFunction(
'currentRelevantRepAmount', function(PB $piggyBank) { 'currentRelevantRepAmount', function (PB $piggyBank) {
return $piggyBank->currentRelevantRep()->currentamount; return $piggyBank->currentRelevantRep()->currentamount;
} }
); );

View File

@@ -21,7 +21,7 @@ class Translation extends Twig_Extension
$filters = []; $filters = [];
$filters[] = new Twig_SimpleFilter( $filters[] = new Twig_SimpleFilter(
'_', function($name) { '_', function ($name) {
return trans('firefly.' . $name); return trans('firefly.' . $name);

View File

@@ -11,20 +11,20 @@ use Zizaco\Entrust\Traits\EntrustUserTrait;
* Class User * Class User
* *
* @package FireflyIII * @package FireflyIII
* @property integer $id * @property integer $id
* @property \Carbon\Carbon $created_at * @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at * @property \Carbon\Carbon $updated_at
* @property string $email * @property string $email
* @property string $password * @property string $password
* @property string $reset * @property string $reset
* @property string $remember_token * @property string $remember_token
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Account[] $accounts * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Account[] $accounts
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Tag[] $tags * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Tag[] $tags
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Bill[] $bills * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Bill[] $bills
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Budget[] $budgets * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Budget[] $budgets
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Category[] $categories * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Category[] $categories
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Preference[] $preferences * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Preference[] $preferences
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Reminder[] $reminders * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Reminder[] $reminders
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\TransactionJournal[] $transactionjournals * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\TransactionJournal[] $transactionjournals
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\User whereId($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\User whereId($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\User whereCreatedAt($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\User whereCreatedAt($value)
@@ -33,6 +33,7 @@ use Zizaco\Entrust\Traits\EntrustUserTrait;
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\User wherePassword($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\User wherePassword($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\User whereReset($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\User whereReset($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\User whereRememberToken($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\User whereRememberToken($value)
* @property-read \Illuminate\Database\Eloquent\Collection|\Config::get('entrust.role')[] $roles
*/ */
class User extends Model implements AuthenticatableContract, CanResetPasswordContract class User extends Model implements AuthenticatableContract, CanResetPasswordContract
{ {

View File

@@ -9,9 +9,9 @@ use Crypt;
use DB; use DB;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType; use FireflyIII\Models\AccountType;
use FireflyIII\User;
use Illuminate\Contracts\Encryption\DecryptException; use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Validation\Validator; use Illuminate\Validation\Validator;
use Log;
use Navigation; use Navigation;
use Symfony\Component\Translation\TranslatorInterface; use Symfony\Component\Translation\TranslatorInterface;
@@ -93,54 +93,99 @@ class FireflyValidator extends Validator
*/ */
public function validateUniqueAccountForUser($attribute, $value, $parameters) public function validateUniqueAccountForUser($attribute, $value, $parameters)
{ {
$type = null; // because a user does not have to be logged in (tests and what-not).
if (!Auth::check()) {
/** return $this->validateAccountAnonymously();
* Switch on different cases on which this method can respond:
*/
$hasWhat = isset($this->data['what']);
$hasAccountTypeId = isset($this->data['account_type_id']) && isset($this->data['name']);
$hasAccountId = isset($this->data['id']);
$ignoreId = 0;
if ($hasWhat) {
$search = Config::get('firefly.accountTypeByIdentifier.' . $this->data['what']);
$type = AccountType::whereType($search)->first();
// this field can be used to find the exact type, and continue.
} }
if ($hasAccountTypeId) { if (isset($this->data['what'])) {
$type = AccountType::find($this->data['account_type_id']); return $this->validateByAccountTypeString($value, $parameters);
} }
if ($hasAccountId) { if (isset($this->data['account_type_id'])) {
/** @var Account $account */ return $this->validateByAccountTypeId($value, $parameters);
$account = Account::find($this->data['id']);
$ignoreId = intval($this->data['id']);
$type = AccountType::find($account->account_type_id);
unset($account);
} }
/** return false;
* Try to decrypt data just in case: }
*/
try {
$value = Crypt::decrypt($value);
} catch (DecryptException $e) {
// if it fails, probably not encrypted.
}
if (is_null($type)) {
Log::error('Could not determine type of account to validate.');
/**
* @return bool
*/
protected function validateAccountAnonymously()
{
if (!isset($this->data['user_id'])) {
return false; return false;
} }
// get all accounts with this type, and find the name. $user = User::find($this->data['user_id']);
$userId = Auth::check() ? Auth::user()->id : 0; $type = AccountType::find($this->data['account_type_id'])->first();
$set = Account::where('account_type_id', $type->id)->where('id', '!=', $ignoreId)->where('user_id', $userId)->get(); $value = $this->tryDecrypt($this->data['name']);
$set = $user->accounts()->where('account_type_id', $type->id)->get();
/** @var Account $entry */
foreach ($set as $entry) {
if ($entry->name == $value) {
return false;
}
}
return true;
}
/**
* @param $value
*
* @return mixed
*/
protected function tryDecrypt($value)
{
try {
$value = Crypt::decrypt($value);
} catch (DecryptException $e) {
// do not care.
}
return $value;
}
/**
* @param $value
* @param $parameters
*
* @return bool
*/
protected function validateByAccountTypeString($value, $parameters)
{
$search = Config::get('firefly.accountTypeByIdentifier.' . $this->data['what']);
$type = AccountType::whereType($search)->first();
$ignore = isset($parameters[0]) ? intval($parameters[0]) : 0;
$set = Auth::user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)->get();
/** @var Account $entry */
foreach ($set as $entry) {
if ($entry->name == $value) {
return false;
}
}
return true;
}
/**
* @param $value
* @param $parameters
*
* @return bool
*/
protected function validateByAccountTypeId($value, $parameters)
{
$type = AccountType::find($this->data['account_type_id'])->first();
$ignore = isset($parameters[0]) ? intval($parameters[0]) : 0;
$value = $this->tryDecrypt($value);
$set = Auth::user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)->get();
/** @var Account $entry */ /** @var Account $entry */
foreach ($set as $entry) { foreach ($set as $entry) {
if ($entry->name == $value) { if ($entry->name == $value) {
@@ -180,8 +225,7 @@ class FireflyValidator extends Validator
* *
* parameter 0: the table * parameter 0: the table
* parameter 1: the field * parameter 1: the field
* parameter 2: the encrypted / not encrypted boolean. Defaults to "encrypted". * parameter 2: an id to ignore (when editing)
* parameter 3: an id to ignore (when editing)
* *
* @param $attribute * @param $attribute
* @param $value * @param $value
@@ -191,37 +235,19 @@ class FireflyValidator extends Validator
*/ */
public function validateUniqueObjectForUser($attribute, $value, $parameters) public function validateUniqueObjectForUser($attribute, $value, $parameters)
{ {
$table = $parameters[0]; $value = $this->tryDecrypt($value);
$field = $parameters[1]; // exclude?
$encrypted = isset($parameters[2]) ? $parameters[2] : 'encrypted'; $table = $parameters[0];
$exclude = isset($parameters[3]) ? $parameters[3] : null; $field = $parameters[1];
$alwaysEncrypted = false; $exclude = isset($parameters[2]) ? intval($parameters[2]) : 0;
if ($encrypted == 'TRUE') {
$alwaysEncrypted = true;
}
if (is_null(Auth::user())) { // get entries from table
// user is not logged in.. weird. $set = DB::table($table)->where('user_id', Auth::user()->id)->where('id', '!=', $exclude)->get([$field]);
return true;
} else {
$query = DB::table($table)->where('user_id', Auth::user()->id);
}
if (!is_null($exclude)) {
$query->where('id', '!=', $exclude);
}
$set = $query->get();
foreach ($set as $entry) { foreach ($set as $entry) {
if (!$alwaysEncrypted) { $fieldValue = $this->tryDecrypt($entry->$field);
$isEncrypted = intval($entry->$encrypted) == 1 ? true : false;
} else { if ($fieldValue === $value) {
$isEncrypted = true;
}
$checkValue = $isEncrypted ? Crypt::decrypt($entry->$field) : $entry->$field;
if ($checkValue == $value) {
return false; return false;
} }
} }
@@ -248,9 +274,8 @@ class FireflyValidator extends Validator
$set = $query->get(['piggy_banks.*']); $set = $query->get(['piggy_banks.*']);
foreach ($set as $entry) { foreach ($set as $entry) {
$isEncrypted = intval($entry->encrypted) == 1 ? true : false; $fieldValue = $this->tryDecrypt($entry->name);
$checkValue = $isEncrypted ? Crypt::decrypt($entry->name) : $entry->name; if ($fieldValue == $value) {
if ($checkValue == $value) {
return false; return false;
} }
} }

View File

@@ -28,7 +28,6 @@
"illuminate/html": "~5.0", "illuminate/html": "~5.0",
"league/commonmark": "0.7.*", "league/commonmark": "0.7.*",
"rcrowe/twigbridge": "0.7.x@dev", "rcrowe/twigbridge": "0.7.x@dev",
"twig/extensions": "~1.2",
"zizaco/entrust": "dev-laravel-5" "zizaco/entrust": "dev-laravel-5"
}, },
"require-dev": { "require-dev": {

281
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"hash": "a0c92aa0223617ca2730500921bdd82c", "hash": "077d2b2548df62c8ef92871c6e52c856",
"packages": [ "packages": [
{ {
"name": "classpreloader/classpreloader", "name": "classpreloader/classpreloader",
@@ -943,16 +943,16 @@
}, },
{ {
"name": "laravel/framework", "name": "laravel/framework",
"version": "v5.0.31", "version": "v5.0.32",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/laravel/framework.git", "url": "https://github.com/laravel/framework.git",
"reference": "db0a7400465df159ba8c6eaa954f97f50bc19687" "reference": "85f12207cf45cc288e9e6b9b5d184aad5f08e2ca"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/db0a7400465df159ba8c6eaa954f97f50bc19687", "url": "https://api.github.com/repos/laravel/framework/zipball/85f12207cf45cc288e9e6b9b5d184aad5f08e2ca",
"reference": "db0a7400465df159ba8c6eaa954f97f50bc19687", "reference": "85f12207cf45cc288e9e6b9b5d184aad5f08e2ca",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -1065,7 +1065,7 @@
"framework", "framework",
"laravel" "laravel"
], ],
"time": "2015-05-11 22:15:00" "time": "2015-05-29 18:56:49"
}, },
{ {
"name": "league/commonmark", "name": "league/commonmark",
@@ -1645,17 +1645,17 @@
}, },
{ {
"name": "symfony/console", "name": "symfony/console",
"version": "v2.6.8", "version": "v2.6.9",
"target-dir": "Symfony/Component/Console", "target-dir": "Symfony/Component/Console",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/Console.git", "url": "https://github.com/symfony/Console.git",
"reference": "2343f6d8026306bd330e0c987e4c102483c213e7" "reference": "b5ec0c11a204718f2b656357f5505a8e578f30dd"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/Console/zipball/2343f6d8026306bd330e0c987e4c102483c213e7", "url": "https://api.github.com/repos/symfony/Console/zipball/b5ec0c11a204718f2b656357f5505a8e578f30dd",
"reference": "2343f6d8026306bd330e0c987e4c102483c213e7", "reference": "b5ec0c11a204718f2b656357f5505a8e578f30dd",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -1699,11 +1699,11 @@
], ],
"description": "Symfony Console Component", "description": "Symfony Console Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2015-05-22 14:53:08" "time": "2015-05-29 14:42:58"
}, },
{ {
"name": "symfony/debug", "name": "symfony/debug",
"version": "v2.6.8", "version": "v2.6.9",
"target-dir": "Symfony/Component/Debug", "target-dir": "Symfony/Component/Debug",
"source": { "source": {
"type": "git", "type": "git",
@@ -1764,21 +1764,20 @@
}, },
{ {
"name": "symfony/event-dispatcher", "name": "symfony/event-dispatcher",
"version": "v2.6.8", "version": "v2.7.0",
"target-dir": "Symfony/Component/EventDispatcher",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/EventDispatcher.git", "url": "https://github.com/symfony/EventDispatcher.git",
"reference": "672593bc4b0043a0acf91903bb75a1c82d8f2e02" "reference": "687039686d0e923429ba6e958d0baa920cd5d458"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/672593bc4b0043a0acf91903bb75a1c82d8f2e02", "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/687039686d0e923429ba6e958d0baa920cd5d458",
"reference": "672593bc4b0043a0acf91903bb75a1c82d8f2e02", "reference": "687039686d0e923429ba6e958d0baa920cd5d458",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=5.3.3" "php": ">=5.3.9"
}, },
"require-dev": { "require-dev": {
"psr/log": "~1.0", "psr/log": "~1.0",
@@ -1795,11 +1794,11 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "2.6-dev" "dev-master": "2.7-dev"
} }
}, },
"autoload": { "autoload": {
"psr-0": { "psr-4": {
"Symfony\\Component\\EventDispatcher\\": "" "Symfony\\Component\\EventDispatcher\\": ""
} }
}, },
@@ -1819,25 +1818,24 @@
], ],
"description": "Symfony EventDispatcher Component", "description": "Symfony EventDispatcher Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2015-05-02 15:18:45" "time": "2015-05-02 15:21:08"
}, },
{ {
"name": "symfony/filesystem", "name": "symfony/filesystem",
"version": "v2.6.8", "version": "v2.7.0",
"target-dir": "Symfony/Component/Filesystem",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/Filesystem.git", "url": "https://github.com/symfony/Filesystem.git",
"reference": "1f8429f72a5bfa58b33fd96824bea146fc4b3f49" "reference": "ae4551fd6d4d4f51f2e7390fbc902fbd67f3b7ba"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/Filesystem/zipball/1f8429f72a5bfa58b33fd96824bea146fc4b3f49", "url": "https://api.github.com/repos/symfony/Filesystem/zipball/ae4551fd6d4d4f51f2e7390fbc902fbd67f3b7ba",
"reference": "1f8429f72a5bfa58b33fd96824bea146fc4b3f49", "reference": "ae4551fd6d4d4f51f2e7390fbc902fbd67f3b7ba",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=5.3.3" "php": ">=5.3.9"
}, },
"require-dev": { "require-dev": {
"symfony/phpunit-bridge": "~2.7" "symfony/phpunit-bridge": "~2.7"
@@ -1845,11 +1843,11 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "2.6-dev" "dev-master": "2.7-dev"
} }
}, },
"autoload": { "autoload": {
"psr-0": { "psr-4": {
"Symfony\\Component\\Filesystem\\": "" "Symfony\\Component\\Filesystem\\": ""
} }
}, },
@@ -1869,11 +1867,11 @@
], ],
"description": "Symfony Filesystem Component", "description": "Symfony Filesystem Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2015-05-15 13:32:45" "time": "2015-05-15 13:33:16"
}, },
{ {
"name": "symfony/finder", "name": "symfony/finder",
"version": "v2.6.8", "version": "v2.6.9",
"target-dir": "Symfony/Component/Finder", "target-dir": "Symfony/Component/Finder",
"source": { "source": {
"type": "git", "type": "git",
@@ -1923,7 +1921,7 @@
}, },
{ {
"name": "symfony/http-foundation", "name": "symfony/http-foundation",
"version": "v2.6.8", "version": "v2.6.9",
"target-dir": "Symfony/Component/HttpFoundation", "target-dir": "Symfony/Component/HttpFoundation",
"source": { "source": {
"type": "git", "type": "git",
@@ -1977,17 +1975,17 @@
}, },
{ {
"name": "symfony/http-kernel", "name": "symfony/http-kernel",
"version": "v2.6.8", "version": "v2.6.9",
"target-dir": "Symfony/Component/HttpKernel", "target-dir": "Symfony/Component/HttpKernel",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/HttpKernel.git", "url": "https://github.com/symfony/HttpKernel.git",
"reference": "a9a6f595941fce8dddd64f4e9bf47747cf1515fc" "reference": "7c883eb1a5d8b52b1fa6d4134b82304c6bb7007f"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/HttpKernel/zipball/a9a6f595941fce8dddd64f4e9bf47747cf1515fc", "url": "https://api.github.com/repos/symfony/HttpKernel/zipball/7c883eb1a5d8b52b1fa6d4134b82304c6bb7007f",
"reference": "a9a6f595941fce8dddd64f4e9bf47747cf1515fc", "reference": "7c883eb1a5d8b52b1fa6d4134b82304c6bb7007f",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -2051,11 +2049,11 @@
], ],
"description": "Symfony HttpKernel Component", "description": "Symfony HttpKernel Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2015-05-27 00:17:10" "time": "2015-05-29 22:55:07"
}, },
{ {
"name": "symfony/process", "name": "symfony/process",
"version": "v2.6.8", "version": "v2.6.9",
"target-dir": "Symfony/Component/Process", "target-dir": "Symfony/Component/Process",
"source": { "source": {
"type": "git", "type": "git",
@@ -2105,7 +2103,7 @@
}, },
{ {
"name": "symfony/routing", "name": "symfony/routing",
"version": "v2.6.8", "version": "v2.6.9",
"target-dir": "Symfony/Component/Routing", "target-dir": "Symfony/Component/Routing",
"source": { "source": {
"type": "git", "type": "git",
@@ -2174,7 +2172,7 @@
}, },
{ {
"name": "symfony/security-core", "name": "symfony/security-core",
"version": "v2.6.8", "version": "v2.6.9",
"target-dir": "Symfony/Component/Security/Core", "target-dir": "Symfony/Component/Security/Core",
"source": { "source": {
"type": "git", "type": "git",
@@ -2238,17 +2236,17 @@
}, },
{ {
"name": "symfony/translation", "name": "symfony/translation",
"version": "v2.6.8", "version": "v2.6.9",
"target-dir": "Symfony/Component/Translation", "target-dir": "Symfony/Component/Translation",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/Translation.git", "url": "https://github.com/symfony/Translation.git",
"reference": "d030b3d8d9699795dbf8c59e915ef879007a4483" "reference": "89cdf3c43bc24c85dd8173dfcf5a979a95e5bd9c"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/Translation/zipball/d030b3d8d9699795dbf8c59e915ef879007a4483", "url": "https://api.github.com/repos/symfony/Translation/zipball/89cdf3c43bc24c85dd8173dfcf5a979a95e5bd9c",
"reference": "d030b3d8d9699795dbf8c59e915ef879007a4483", "reference": "89cdf3c43bc24c85dd8173dfcf5a979a95e5bd9c",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -2293,11 +2291,11 @@
], ],
"description": "Symfony Translation Component", "description": "Symfony Translation Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2015-05-22 14:37:51" "time": "2015-05-29 14:42:58"
}, },
{ {
"name": "symfony/var-dumper", "name": "symfony/var-dumper",
"version": "v2.6.8", "version": "v2.6.9",
"target-dir": "Symfony/Component/VarDumper", "target-dir": "Symfony/Component/VarDumper",
"source": { "source": {
"type": "git", "type": "git",
@@ -2355,58 +2353,6 @@
], ],
"time": "2015-05-01 14:14:24" "time": "2015-05-01 14:14:24"
}, },
{
"name": "twig/extensions",
"version": "v1.2.0",
"source": {
"type": "git",
"url": "https://github.com/twigphp/Twig-extensions.git",
"reference": "8cf4b9fe04077bd54fc73f4fde83347040c3b8cd"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/twigphp/Twig-extensions/zipball/8cf4b9fe04077bd54fc73f4fde83347040c3b8cd",
"reference": "8cf4b9fe04077bd54fc73f4fde83347040c3b8cd",
"shasum": ""
},
"require": {
"twig/twig": "~1.12"
},
"require-dev": {
"symfony/translation": "~2.3"
},
"suggest": {
"symfony/translation": "Allow the time_diff output to be translated"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.2.x-dev"
}
},
"autoload": {
"psr-0": {
"Twig_Extensions_": "lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
}
],
"description": "Common additional features for Twig that do not directly belong in core",
"homepage": "http://twig.sensiolabs.org/doc/extensions/index.html",
"keywords": [
"i18n",
"text"
],
"time": "2014-10-30 14:30:03"
},
{ {
"name": "twig/twig", "name": "twig/twig",
"version": "v1.18.1", "version": "v1.18.1",
@@ -2466,16 +2412,16 @@
}, },
{ {
"name": "vlucas/phpdotenv", "name": "vlucas/phpdotenv",
"version": "v1.1.0", "version": "v1.1.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/vlucas/phpdotenv.git", "url": "https://github.com/vlucas/phpdotenv.git",
"reference": "732d2adb7d916c9593b9d58c3b0d9ebefead07aa" "reference": "0cac554ce06277e33ddf9f0b7ade4b8bbf2af3fa"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/732d2adb7d916c9593b9d58c3b0d9ebefead07aa", "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/0cac554ce06277e33ddf9f0b7ade4b8bbf2af3fa",
"reference": "732d2adb7d916c9593b9d58c3b0d9ebefead07aa", "reference": "0cac554ce06277e33ddf9f0b7ade4b8bbf2af3fa",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -2485,11 +2431,6 @@
"phpunit/phpunit": "~4.0" "phpunit/phpunit": "~4.0"
}, },
"type": "library", "type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": { "autoload": {
"psr-0": { "psr-0": {
"Dotenv": "src/" "Dotenv": "src/"
@@ -2513,20 +2454,20 @@
"env", "env",
"environment" "environment"
], ],
"time": "2014-12-05 15:19:21" "time": "2015-05-30 15:59:26"
}, },
{ {
"name": "watson/validating", "name": "watson/validating",
"version": "1.0.2", "version": "1.0.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/dwightwatson/validating.git", "url": "https://github.com/dwightwatson/validating.git",
"reference": "47320813a45cc35384e72364484d54fe44dcd3fb" "reference": "c32912f760b456c043657951683ed6c468ab83e7"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/dwightwatson/validating/zipball/47320813a45cc35384e72364484d54fe44dcd3fb", "url": "https://api.github.com/repos/dwightwatson/validating/zipball/c32912f760b456c043657951683ed6c468ab83e7",
"reference": "47320813a45cc35384e72364484d54fe44dcd3fb", "reference": "c32912f760b456c043657951683ed6c468ab83e7",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -2568,7 +2509,7 @@
"laravel", "laravel",
"validation" "validation"
], ],
"time": "2015-05-23 00:03:54" "time": "2015-06-03 02:25:38"
}, },
{ {
"name": "zizaco/entrust", "name": "zizaco/entrust",
@@ -3322,16 +3263,16 @@
}, },
{ {
"name": "phpspec/phpspec", "name": "phpspec/phpspec",
"version": "2.2.0", "version": "2.2.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpspec/phpspec.git", "url": "https://github.com/phpspec/phpspec.git",
"reference": "9727d75919a00455433e867565bc022f0b985a39" "reference": "e9a40577323e67f1de2e214abf32976a0352d8f8"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpspec/phpspec/zipball/9727d75919a00455433e867565bc022f0b985a39", "url": "https://api.github.com/repos/phpspec/phpspec/zipball/e9a40577323e67f1de2e214abf32976a0352d8f8",
"reference": "9727d75919a00455433e867565bc022f0b985a39", "reference": "e9a40577323e67f1de2e214abf32976a0352d8f8",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -3396,7 +3337,7 @@
"testing", "testing",
"tests" "tests"
], ],
"time": "2015-04-18 16:22:51" "time": "2015-05-30 15:21:40"
}, },
{ {
"name": "phpspec/prophecy", "name": "phpspec/prophecy",
@@ -3460,16 +3401,16 @@
}, },
{ {
"name": "phpunit/php-code-coverage", "name": "phpunit/php-code-coverage",
"version": "2.0.17", "version": "2.1.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "c4e8e7725e351184a76544634855b8a9c405a6e3" "reference": "28a6b34e91d789b2608072ab3c82eaae7cdb973c"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/c4e8e7725e351184a76544634855b8a9c405a6e3", "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/28a6b34e91d789b2608072ab3c82eaae7cdb973c",
"reference": "c4e8e7725e351184a76544634855b8a9c405a6e3", "reference": "28a6b34e91d789b2608072ab3c82eaae7cdb973c",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -3492,7 +3433,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "2.0.x-dev" "dev-master": "2.1.x-dev"
} }
}, },
"autoload": { "autoload": {
@@ -3518,7 +3459,7 @@
"testing", "testing",
"xunit" "xunit"
], ],
"time": "2015-05-25 05:11:59" "time": "2015-06-03 07:01:01"
}, },
{ {
"name": "phpunit/php-file-iterator", "name": "phpunit/php-file-iterator",
@@ -3706,16 +3647,16 @@
}, },
{ {
"name": "phpunit/phpunit", "name": "phpunit/phpunit",
"version": "4.6.7", "version": "4.7.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git", "url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "57bf06dd4eebe2a5ced79a8de71509e7d5c18b25" "reference": "c2241b8d3381be3e4c6125ae347687d59f286784"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/57bf06dd4eebe2a5ced79a8de71509e7d5c18b25", "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c2241b8d3381be3e4c6125ae347687d59f286784",
"reference": "57bf06dd4eebe2a5ced79a8de71509e7d5c18b25", "reference": "c2241b8d3381be3e4c6125ae347687d59f286784",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -3726,7 +3667,7 @@
"ext-spl": "*", "ext-spl": "*",
"php": ">=5.3.3", "php": ">=5.3.3",
"phpspec/prophecy": "~1.3,>=1.3.1", "phpspec/prophecy": "~1.3,>=1.3.1",
"phpunit/php-code-coverage": "~2.0,>=2.0.11", "phpunit/php-code-coverage": "~2.1",
"phpunit/php-file-iterator": "~1.4", "phpunit/php-file-iterator": "~1.4",
"phpunit/php-text-template": "~1.2", "phpunit/php-text-template": "~1.2",
"phpunit/php-timer": "~1.0", "phpunit/php-timer": "~1.0",
@@ -3748,7 +3689,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "4.6.x-dev" "dev-master": "4.7.x-dev"
} }
}, },
"autoload": { "autoload": {
@@ -3774,20 +3715,20 @@
"testing", "testing",
"xunit" "xunit"
], ],
"time": "2015-05-25 05:18:18" "time": "2015-06-05 04:14:02"
}, },
{ {
"name": "phpunit/phpunit-mock-objects", "name": "phpunit/phpunit-mock-objects",
"version": "2.3.1", "version": "2.3.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
"reference": "74ffb87f527f24616f72460e54b595f508dccb5c" "reference": "253c005852591fd547fc18cd5b7b43a1ec82d8f7"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/74ffb87f527f24616f72460e54b595f508dccb5c", "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/253c005852591fd547fc18cd5b7b43a1ec82d8f7",
"reference": "74ffb87f527f24616f72460e54b595f508dccb5c", "reference": "253c005852591fd547fc18cd5b7b43a1ec82d8f7",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -3829,7 +3770,7 @@
"mock", "mock",
"xunit" "xunit"
], ],
"time": "2015-04-02 05:36:41" "time": "2015-05-29 05:19:18"
}, },
{ {
"name": "satooshi/php-coveralls", "name": "satooshi/php-coveralls",
@@ -4272,21 +4213,20 @@
}, },
{ {
"name": "symfony/class-loader", "name": "symfony/class-loader",
"version": "v2.6.8", "version": "v2.7.0",
"target-dir": "Symfony/Component/ClassLoader",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/ClassLoader.git", "url": "https://github.com/symfony/ClassLoader.git",
"reference": "abf5632a31402ae6ac19cd00683faf603046440a" "reference": "fa19598cb708b92d983b34aae313f57c217f9386"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/ClassLoader/zipball/abf5632a31402ae6ac19cd00683faf603046440a", "url": "https://api.github.com/repos/symfony/ClassLoader/zipball/fa19598cb708b92d983b34aae313f57c217f9386",
"reference": "abf5632a31402ae6ac19cd00683faf603046440a", "reference": "fa19598cb708b92d983b34aae313f57c217f9386",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=5.3.3" "php": ">=5.3.9"
}, },
"require-dev": { "require-dev": {
"symfony/finder": "~2.0,>=2.0.5", "symfony/finder": "~2.0,>=2.0.5",
@@ -4295,11 +4235,11 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "2.6-dev" "dev-master": "2.7-dev"
} }
}, },
"autoload": { "autoload": {
"psr-0": { "psr-4": {
"Symfony\\Component\\ClassLoader\\": "" "Symfony\\Component\\ClassLoader\\": ""
} }
}, },
@@ -4319,25 +4259,24 @@
], ],
"description": "Symfony ClassLoader Component", "description": "Symfony ClassLoader Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2015-05-15 13:32:45" "time": "2015-05-15 13:33:16"
}, },
{ {
"name": "symfony/config", "name": "symfony/config",
"version": "v2.6.8", "version": "v2.7.0",
"target-dir": "Symfony/Component/Config",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/Config.git", "url": "https://github.com/symfony/Config.git",
"reference": "2696c5bc7c31485a482c10865d713de9fcc7aa31" "reference": "537e9912063e66aa70cbcddd7d6e6e8db61d98e4"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/Config/zipball/2696c5bc7c31485a482c10865d713de9fcc7aa31", "url": "https://api.github.com/repos/symfony/Config/zipball/537e9912063e66aa70cbcddd7d6e6e8db61d98e4",
"reference": "2696c5bc7c31485a482c10865d713de9fcc7aa31", "reference": "537e9912063e66aa70cbcddd7d6e6e8db61d98e4",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=5.3.3", "php": ">=5.3.9",
"symfony/filesystem": "~2.3" "symfony/filesystem": "~2.3"
}, },
"require-dev": { "require-dev": {
@@ -4346,11 +4285,11 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "2.6-dev" "dev-master": "2.7-dev"
} }
}, },
"autoload": { "autoload": {
"psr-0": { "psr-4": {
"Symfony\\Component\\Config\\": "" "Symfony\\Component\\Config\\": ""
} }
}, },
@@ -4370,25 +4309,24 @@
], ],
"description": "Symfony Config Component", "description": "Symfony Config Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2015-05-15 13:32:45" "time": "2015-05-15 13:33:16"
}, },
{ {
"name": "symfony/stopwatch", "name": "symfony/stopwatch",
"version": "v2.6.8", "version": "v2.7.0",
"target-dir": "Symfony/Component/Stopwatch",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/Stopwatch.git", "url": "https://github.com/symfony/Stopwatch.git",
"reference": "b470f87c69837cb71115f1fa720388bb19b63635" "reference": "7702945bceddc0e1f744519abb8a2baeb94bd5ce"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/Stopwatch/zipball/b470f87c69837cb71115f1fa720388bb19b63635", "url": "https://api.github.com/repos/symfony/Stopwatch/zipball/7702945bceddc0e1f744519abb8a2baeb94bd5ce",
"reference": "b470f87c69837cb71115f1fa720388bb19b63635", "reference": "7702945bceddc0e1f744519abb8a2baeb94bd5ce",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=5.3.3" "php": ">=5.3.9"
}, },
"require-dev": { "require-dev": {
"symfony/phpunit-bridge": "~2.7" "symfony/phpunit-bridge": "~2.7"
@@ -4396,11 +4334,11 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "2.6-dev" "dev-master": "2.7-dev"
} }
}, },
"autoload": { "autoload": {
"psr-0": { "psr-4": {
"Symfony\\Component\\Stopwatch\\": "" "Symfony\\Component\\Stopwatch\\": ""
} }
}, },
@@ -4420,25 +4358,24 @@
], ],
"description": "Symfony Stopwatch Component", "description": "Symfony Stopwatch Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2015-05-02 15:18:45" "time": "2015-05-02 15:21:08"
}, },
{ {
"name": "symfony/yaml", "name": "symfony/yaml",
"version": "v2.6.8", "version": "v2.7.0",
"target-dir": "Symfony/Component/Yaml",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/Yaml.git", "url": "https://github.com/symfony/Yaml.git",
"reference": "f157ab074e453ecd4c0fa775f721f6e67a99d9e2" "reference": "4a29a5248aed4fb45f626a7bbbd330291492f5c3"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/Yaml/zipball/f157ab074e453ecd4c0fa775f721f6e67a99d9e2", "url": "https://api.github.com/repos/symfony/Yaml/zipball/4a29a5248aed4fb45f626a7bbbd330291492f5c3",
"reference": "f157ab074e453ecd4c0fa775f721f6e67a99d9e2", "reference": "4a29a5248aed4fb45f626a7bbbd330291492f5c3",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=5.3.3" "php": ">=5.3.9"
}, },
"require-dev": { "require-dev": {
"symfony/phpunit-bridge": "~2.7" "symfony/phpunit-bridge": "~2.7"
@@ -4446,11 +4383,11 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "2.6-dev" "dev-master": "2.7-dev"
} }
}, },
"autoload": { "autoload": {
"psr-0": { "psr-4": {
"Symfony\\Component\\Yaml\\": "" "Symfony\\Component\\Yaml\\": ""
} }
}, },
@@ -4470,7 +4407,7 @@
], ],
"description": "Symfony Yaml Component", "description": "Symfony Yaml Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2015-05-02 15:18:45" "time": "2015-05-02 15:21:08"
} }
], ],
"aliases": [], "aliases": [],

View File

@@ -115,7 +115,7 @@ return [
*/ */
'Illuminate\Foundation\Providers\ArtisanServiceProvider', 'Illuminate\Foundation\Providers\ArtisanServiceProvider',
'Illuminate\Auth\AuthServiceProvider', 'Illuminate\Auth\AuthServiceProvider',
'Illuminate\Bus\BusServiceProvider', //'Illuminate\Bus\BusServiceProvider',
'Illuminate\Cache\CacheServiceProvider', 'Illuminate\Cache\CacheServiceProvider',
'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider', 'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider',
'Illuminate\Routing\ControllerServiceProvider', 'Illuminate\Routing\ControllerServiceProvider',
@@ -139,16 +139,16 @@ return [
'TwigBridge\ServiceProvider', 'TwigBridge\ServiceProvider',
'DaveJamesMiller\Breadcrumbs\ServiceProvider', 'DaveJamesMiller\Breadcrumbs\ServiceProvider',
// 'Barryvdh\Debugbar\ServiceProvider', //'Barryvdh\Debugbar\ServiceProvider',
// 'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider', //'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider',
'Zizaco\Entrust\EntrustServiceProvider', 'Zizaco\Entrust\EntrustServiceProvider',
/* /*
* Application Service Providers... * Application Service Providers...
*/ */
'FireflyIII\Providers\AppServiceProvider', 'FireflyIII\Providers\AppServiceProvider',
'FireflyIII\Providers\BusServiceProvider', //'FireflyIII\Providers\BusServiceProvider',
'FireflyIII\Providers\ConfigServiceProvider', //'FireflyIII\Providers\ConfigServiceProvider',
'FireflyIII\Providers\EventServiceProvider', 'FireflyIII\Providers\EventServiceProvider',
'FireflyIII\Providers\RouteServiceProvider', 'FireflyIII\Providers\RouteServiceProvider',
'FireflyIII\Providers\FireflyServiceProvider', 'FireflyIII\Providers\FireflyServiceProvider',

View File

@@ -10,4 +10,10 @@
height: 100%; height: 100%;
margin: 0px; margin: 0px;
padding: 0px padding: 0px
} }
.medium {
font-size: 16px;
}
a.panel-link {color:#fff;text-decoration: none;}
a.panel-link:hover {color:#fff;text-decoration: none;}

View File

@@ -2,43 +2,47 @@
function drawSpentBar() { function drawSpentBar() {
"use strict"; "use strict";
if ($('.spentBar').length > 0) {
var overspent = spent > budgeted;
var pct;
var overspent = spent > budgeted; if (overspent) {
var pct; // draw overspent bar
pct = (budgeted / spent) * 100;
if (overspent) { $('.spentBar .progress-bar-warning').css('width', pct + '%');
// draw overspent bar $('.spentBar .progress-bar-danger').css('width', (100 - pct) + '%');
pct = (budgeted / spent) * 100; } else {
$('.spentBar .progress-bar-warning').css('width', pct + '%'); // draw normal bar:
$('.spentBar .progress-bar-danger').css('width', (100 - pct) + '%'); pct = (spent / budgeted) * 100;
} else { $('.spentBar .progress-bar-info').css('width', pct + '%');
// draw normal bar: }
pct = (spent / budgeted) * 100;
$('.spentBar .progress-bar-info').css('width', pct + '%');
} }
} }
function drawBudgetedBar() { function drawBudgetedBar() {
"use strict"; "use strict";
var budgetedMuch = budgeted > budgetIncomeTotal;
// recalculate percentage: if ($('.budgetedBar').length > 0) {
var budgetedMuch = budgeted > budgetIncomeTotal;
var pct; // recalculate percentage:
if (budgetedMuch) {
// budgeted too much. var pct;
pct = (budgetIncomeTotal / budgeted) * 100; if (budgetedMuch) {
$('.budgetedBar .progress-bar-warning').css('width', pct + '%'); // budgeted too much.
$('.budgetedBar .progress-bar-danger').css('width', (100 - pct) + '%'); pct = (budgetIncomeTotal / budgeted) * 100;
$('.budgetedBar .progress-bar-info').css('width', 0); $('.budgetedBar .progress-bar-warning').css('width', pct + '%');
} else { $('.budgetedBar .progress-bar-danger').css('width', (100 - pct) + '%');
pct = (budgeted / budgetIncomeTotal) * 100; $('.budgetedBar .progress-bar-info').css('width', 0);
$('.budgetedBar .progress-bar-warning').css('width', 0); } else {
$('.budgetedBar .progress-bar-danger').css('width', 0); pct = (budgeted / budgetIncomeTotal) * 100;
$('.budgetedBar .progress-bar-info').css('width', pct + '%'); $('.budgetedBar .progress-bar-warning').css('width', 0);
$('.budgetedBar .progress-bar-danger').css('width', 0);
$('.budgetedBar .progress-bar-info').css('width', pct + '%');
}
$('#budgetedAmount').html(currencySymbol + ' ' + budgeted.toFixed(2));
} }
$('#budgetedAmount').html(currencySymbol + ' ' + budgeted.toFixed(2));
} }
function updateBudgetedAmounts(e) { function updateBudgetedAmounts(e) {

Some files were not shown because too many files have changed in this diff Show More