mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-08-23 13:45:14 +00:00
Compare commits
83 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
657d16bb60 | ||
|
e23d3f5661 | ||
|
e13611f7af | ||
|
596cd09489 | ||
|
0be5b27d34 | ||
|
a27471ae55 | ||
|
e27e3622a8 | ||
|
e95273b72b | ||
|
583d4f3249 | ||
|
d6967c4516 | ||
|
40b3097374 | ||
|
1a1f127993 | ||
|
a0f34a7ce1 | ||
|
db020db34b | ||
|
681167bc1b | ||
|
40e49ffc37 | ||
|
834b1afb38 | ||
|
62d5a1da87 | ||
|
8d8308e557 | ||
|
e1aa63487a | ||
|
b7fbe110d4 | ||
|
58859eb35a | ||
|
4b7e1ae1c6 | ||
|
3a06a6ac07 | ||
|
db0f269dc8 | ||
|
3cabe6ca5a | ||
|
d483005219 | ||
|
fea9bc4e7e | ||
|
d579992c98 | ||
|
ad1c61d959 | ||
|
bb1da31830 | ||
|
a50949e554 | ||
|
14dce8a10b | ||
|
1240c8f685 | ||
|
cc7c2e952c | ||
|
409ec2e086 | ||
|
a7f6848e53 | ||
|
4b0b79199d | ||
|
d1d6c48d9b | ||
|
21631780bb | ||
|
b935e32340 | ||
|
72dd064932 | ||
|
2e75446665 | ||
|
be17e4481e | ||
|
616c849b1f | ||
|
71947c097f | ||
|
546787802d | ||
|
294d0e388a | ||
|
193a1b0325 | ||
|
12743217a2 | ||
|
b252b9da66 | ||
|
cdef9c3c7e | ||
|
71dcebb744 | ||
|
25f248c60a | ||
|
d5cbc17831 | ||
|
7a10217511 | ||
|
7559efab77 | ||
|
8254efbd03 | ||
|
4ae24225a5 | ||
|
67d9154563 | ||
|
ad0319c188 | ||
|
eb650ea3ec | ||
|
7eba33e805 | ||
|
e1cb9d387e | ||
|
2ace7c3ca0 | ||
|
58014f0592 | ||
|
1d4938bb09 | ||
|
bbf4007c3e | ||
|
4d5124fb4c | ||
|
14a7cd05b1 | ||
|
946be80eef | ||
|
9ad8b1a980 | ||
|
f733216fcb | ||
|
ffc6139e21 | ||
|
571cac6644 | ||
|
2738ac5a5c | ||
|
7dfde51b84 | ||
|
2d2f18e538 | ||
|
3af0dd2e3b | ||
|
349e077802 | ||
|
812aae358f | ||
|
c3c59d0627 | ||
|
89518b412d |
@@ -17,4 +17,5 @@ EMAIL_USERNAME=
|
||||
EMAIL_PASSWORD=
|
||||
ANALYTICS_ID=
|
||||
EMAIL_PRETEND=false
|
||||
RUNCLEANUP=true
|
||||
RUNCLEANUP=true
|
||||
SITE_OWNER=mail@example.com
|
5
.scrutinizer.yml
Normal file
5
.scrutinizer.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
# .scrutinizer.yml
|
||||
tools:
|
||||
external_code_coverage:
|
||||
timeout: 1800 # Timeout in seconds.
|
||||
runs: 2
|
@@ -18,3 +18,5 @@ after_script:
|
||||
- php vendor/bin/coveralls
|
||||
- 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"
|
||||
- wget https://scrutinizer-ci.com/ocular.phar
|
||||
- php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml
|
||||
|
20
README.md
20
README.md
@@ -1,13 +1,9 @@
|
||||
# Firefly III
|
||||
#### 3.4.2
|
||||
# Firefly III (v3.4.4)
|
||||
|
||||
[](https://scrutinizer-ci.com/g/JC5/firefly-iii/?branch=master)
|
||||
[](https://scrutinizer-ci.com/g/JC5/firefly-iii/?branch=master)
|
||||
[](https://scrutinizer-ci.com/g/JC5/firefly-iii/build-status/master)
|
||||
|
||||
[](https://travis-ci.org/JC5/firefly-iii)
|
||||
[](http://stillmaintained.com/JC5/firefly-iii)
|
||||
[](https://insight.sensiolabs.com/projects/d44c7012-5f50-41ad-add8-8445330e4102)
|
||||
[](https://codeclimate.com/github/JC5/firefly-iii)
|
||||
[](https://coveralls.io/r/JC5/firefly-iii?branch=master)
|
||||
[](https://packagist.org/packages/grumpydictator/firefly-iii)
|
||||

|
||||
## About
|
||||
|
||||
"Firefly III" is a financial manager. It can help you keep track of expenses, income, budgets and everything in between. It even supports credit cards, shared
|
||||
@@ -95,3 +91,9 @@ is adding translations.
|
||||
Questions, ideas, bugs or other things to contribute? [Let me know](https://github.com/JC5/firefly-iii/issues/new)!
|
||||
|
||||
If you like this tool, feel free to [donate me some beer money](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=2ZMV952UUSCLU&lc=NL&item_name=Development%20of%20Firefly¤cy_code=EUR&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted).
|
||||
|
||||
[](https://insight.sensiolabs.com/projects/d44c7012-5f50-41ad-add8-8445330e4102)
|
||||
[](https://codeclimate.com/github/JC5/firefly-iii)
|
||||
[](http://stillmaintained.com/JC5/firefly-iii)
|
||||
[](https://packagist.org/packages/grumpydictator/firefly-iii)
|
||||

|
||||
|
@@ -2,6 +2,7 @@
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
|
||||
/**
|
||||
* Class Handler
|
||||
@@ -33,7 +34,7 @@ class Handler extends ExceptionHandler
|
||||
*/
|
||||
public function render($request, Exception $e)
|
||||
{
|
||||
if ($this->isHttpException($e)) {
|
||||
if ($e instanceof HttpException) {
|
||||
return $this->renderHttpException($e);
|
||||
} else {
|
||||
return parent::render($request, $e);
|
||||
|
@@ -4,7 +4,6 @@ use Auth;
|
||||
use FireflyIII\Events\JournalCreated;
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
use FireflyIII\Models\PiggyBankEvent;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
|
||||
/**
|
||||
@@ -53,17 +52,9 @@ class ConnectJournalToPiggyBank
|
||||
return false;
|
||||
}
|
||||
|
||||
$amount = $journal->amount;
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($journal->transactions()->get() as $transaction) {
|
||||
if ($transaction->account_id == $piggyBank->account_id) {
|
||||
if ($transaction->amount < 0) {
|
||||
$amount = $transaction->amount * -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$repetition->currentamount += $amount;
|
||||
$amount = $journal->correct_amount;
|
||||
bcscale(2);
|
||||
$repetition->currentamount = bcadd($repetition->currentamount, $amount);
|
||||
$repetition->save();
|
||||
|
||||
PiggyBankEvent::create(['piggy_bank_id' => $piggyBank->id, 'transaction_journal_id' => $journal->id, 'date' => $journal->date, 'amount' => $amount]);
|
||||
|
@@ -50,7 +50,7 @@ class UpdateJournalConnection
|
||||
return;
|
||||
}
|
||||
$amount = $journal->amount;
|
||||
$diff = $amount - $event->amount;// update current repetition
|
||||
$diff = $amount - $event->amount; // update current repetition
|
||||
|
||||
$repetition->currentamount += $diff;
|
||||
$repetition->save();
|
||||
|
@@ -64,6 +64,8 @@ class BalanceLine
|
||||
if ($this->getRole() == self::ROLE_DIFFROLE) {
|
||||
return trans('firefly.leftUnbalanced');
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -18,7 +18,7 @@ class Income
|
||||
|
||||
/** @var Collection */
|
||||
protected $incomes;
|
||||
/** @var float */
|
||||
/** @var string */
|
||||
protected $total;
|
||||
|
||||
/**
|
||||
@@ -77,7 +77,7 @@ class Income
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
* @return string
|
||||
*/
|
||||
public function getTotal()
|
||||
{
|
||||
|
@@ -53,7 +53,7 @@ class ReportHelper implements ReportHelperInterface
|
||||
* @param Carbon $end
|
||||
* @param $shared
|
||||
*
|
||||
* @return Account
|
||||
* @return AccountCollection
|
||||
*/
|
||||
public function getAccountReport(Carbon $date, Carbon $end, $shared)
|
||||
{
|
||||
@@ -70,7 +70,9 @@ class ReportHelper implements ReportHelperInterface
|
||||
if ($account->accountType->type != 'Cash account') {
|
||||
return $account;
|
||||
}
|
||||
} // @codeCoverageIgnore
|
||||
|
||||
return null;
|
||||
}
|
||||
);
|
||||
|
||||
// summarize:
|
||||
|
@@ -3,8 +3,9 @@
|
||||
namespace FireflyIII\Helpers\Report;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Helpers\Collection\Account;
|
||||
use FireflyIII\Helpers\Collection\Account as AccountCollection;
|
||||
use FireflyIII\Helpers\Collection\Balance;
|
||||
use FireflyIII\Helpers\Collection\Bill as BillCollection;
|
||||
use FireflyIII\Helpers\Collection\Budget as BudgetCollection;
|
||||
use FireflyIII\Helpers\Collection\Category as CategoryCollection;
|
||||
use FireflyIII\Helpers\Collection\Expense;
|
||||
@@ -26,7 +27,7 @@ interface ReportHelperInterface
|
||||
* @param Carbon $end
|
||||
* @param boolean $shared
|
||||
*
|
||||
* @return Account
|
||||
* @return AccountCollection
|
||||
*/
|
||||
public function getAccountReport(Carbon $date, Carbon $end, $shared);
|
||||
|
||||
@@ -38,7 +39,7 @@ interface ReportHelperInterface
|
||||
* @param Carbon $end
|
||||
* @param boolean $shared
|
||||
*
|
||||
* @return Account
|
||||
* @return BillCollection
|
||||
*/
|
||||
public function getBillReport(Carbon $start, Carbon $end, $shared);
|
||||
|
||||
|
@@ -72,7 +72,9 @@ class ReportQuery implements ReportQueryInterface
|
||||
if ($journal->amount != 0) {
|
||||
return $journal;
|
||||
}
|
||||
} // @codeCoverageIgnore
|
||||
|
||||
return null;
|
||||
}
|
||||
);
|
||||
|
||||
return $data;
|
||||
@@ -188,7 +190,9 @@ class ReportQuery implements ReportQueryInterface
|
||||
if ($journal->amount != 0) {
|
||||
return $journal;
|
||||
}
|
||||
} // @codeCoverageIgnore
|
||||
|
||||
return null;
|
||||
}
|
||||
);
|
||||
|
||||
return $data;
|
||||
|
@@ -3,11 +3,11 @@
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
use Config;
|
||||
use FireflyIII\Http\Requests;
|
||||
use FireflyIII\Http\Requests\AccountFormRequest;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use Input;
|
||||
use Preferences;
|
||||
use Redirect;
|
||||
use Session;
|
||||
use Steam;
|
||||
@@ -87,6 +87,7 @@ class AccountController extends Controller
|
||||
$repository->destroy($account);
|
||||
|
||||
Session::flash('success', trans('firefly.' . $typeName . '_deleted', ['name' => $name]));
|
||||
Preferences::mark();
|
||||
|
||||
return Redirect::to(Session::get('accounts.delete.url'));
|
||||
}
|
||||
@@ -95,7 +96,7 @@ class AccountController extends Controller
|
||||
* @param AccountRepositoryInterface $repository
|
||||
* @param Account $account
|
||||
*
|
||||
* @return View
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function edit(AccountRepositoryInterface $repository, Account $account)
|
||||
{
|
||||
@@ -140,7 +141,7 @@ class AccountController extends Controller
|
||||
* @param AccountRepositoryInterface $repository
|
||||
* @param $what
|
||||
*
|
||||
* @return View
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function index(AccountRepositoryInterface $repository, $what)
|
||||
{
|
||||
@@ -169,7 +170,7 @@ class AccountController extends Controller
|
||||
* @param AccountRepositoryInterface $repository
|
||||
* @param Account $account
|
||||
*
|
||||
* @return View
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function show(AccountRepositoryInterface $repository, Account $account)
|
||||
{
|
||||
@@ -200,13 +201,14 @@ class AccountController extends Controller
|
||||
'user' => Auth::user()->id,
|
||||
'accountRole' => $request->input('accountRole'),
|
||||
'openingBalance' => floatval($request->input('openingBalance')),
|
||||
'openingBalanceDate' => new Carbon($request->input('openingBalanceDate')),
|
||||
'openingBalanceDate' => new Carbon((string)$request->input('openingBalanceDate')),
|
||||
'openingBalanceCurrency' => intval($request->input('balance_currency_id')),
|
||||
|
||||
];
|
||||
$account = $repository->store($accountData);
|
||||
|
||||
Session::flash('success', 'New account "' . $account->name . '" stored!');
|
||||
Preferences::mark();
|
||||
|
||||
if (intval(Input::get('create_another')) === 1) {
|
||||
// set value so create routine will not overwrite URL:
|
||||
@@ -226,7 +228,7 @@ class AccountController extends Controller
|
||||
* @param AccountRepositoryInterface $repository
|
||||
* @param Account $account
|
||||
*
|
||||
* @return $this|\Illuminate\Http\RedirectResponse
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(AccountFormRequest $request, AccountRepositoryInterface $repository, Account $account)
|
||||
{
|
||||
@@ -238,7 +240,7 @@ class AccountController extends Controller
|
||||
'accountRole' => $request->input('accountRole'),
|
||||
'virtualBalance' => floatval($request->input('virtualBalance')),
|
||||
'openingBalance' => floatval($request->input('openingBalance')),
|
||||
'openingBalanceDate' => new Carbon($request->input('openingBalanceDate')),
|
||||
'openingBalanceDate' => new Carbon((string)$request->input('openingBalanceDate')),
|
||||
'openingBalanceCurrency' => intval($request->input('balance_currency_id')),
|
||||
'ccType' => $request->input('ccType'),
|
||||
'ccMonthlyPaymentDate' => $request->input('ccMonthlyPaymentDate'),
|
||||
@@ -247,12 +249,13 @@ class AccountController extends Controller
|
||||
$repository->update($account, $accountData);
|
||||
|
||||
Session::flash('success', 'Account "' . $account->name . '" updated.');
|
||||
Preferences::mark();
|
||||
|
||||
if (intval(Input::get('return_to_edit')) === 1) {
|
||||
// set value so edit routine will not overwrite URL:
|
||||
Session::put('accounts.edit.fromUpdate', true);
|
||||
|
||||
return Redirect::route('accounts.edit', $account->id)->withInput(['return_to_edit' => 1]);
|
||||
return Redirect::route('accounts.edit', [$account->id])->withInput(['return_to_edit' => 1]);
|
||||
}
|
||||
|
||||
// redirect to previous URL.
|
||||
|
@@ -1,6 +1,9 @@
|
||||
<?php namespace FireflyIII\Http\Controllers\Auth;
|
||||
|
||||
use App;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\Role;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Contracts\Auth\Registrar;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
|
||||
@@ -67,7 +70,7 @@ class AuthController extends Controller
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function postRegister(Request $request)
|
||||
{
|
||||
@@ -87,22 +90,33 @@ class AuthController extends Controller
|
||||
$this->auth->login($this->registrar->create($data));
|
||||
|
||||
// get the email address
|
||||
$email = $this->auth->user()->email;
|
||||
if ($this->auth->user() instanceof User) {
|
||||
$email = $this->auth->user()->email;
|
||||
|
||||
// send email.
|
||||
Mail::send(
|
||||
'emails.registered', [], function (Message $message) use ($email) {
|
||||
$message->to($email, $email)->subject('Welcome to Firefly III!');
|
||||
// send email.
|
||||
Mail::send(
|
||||
'emails.registered', [], function (Message $message) use ($email) {
|
||||
$message->to($email, $email)->subject('Welcome to Firefly III!');
|
||||
}
|
||||
);
|
||||
|
||||
// set flash message
|
||||
Session::flash('success', 'You have registered successfully!');
|
||||
Session::flash('gaEventCategory', 'user');
|
||||
Session::flash('gaEventAction', 'new-registration');
|
||||
|
||||
// first user ever?
|
||||
if (User::count() == 1) {
|
||||
$admin = Role::where('name', 'owner')->first();
|
||||
$this->auth->user()->attachRole($admin);
|
||||
}
|
||||
|
||||
|
||||
return redirect($this->redirectPath());
|
||||
}
|
||||
);
|
||||
App::abort(500, 'Not a user!');
|
||||
|
||||
// set flash message
|
||||
Session::flash('success', 'You have registered successfully!');
|
||||
Session::flash('gaEventCategory', 'user');
|
||||
Session::flash('gaEventAction', 'new-registration');
|
||||
|
||||
|
||||
return redirect($this->redirectPath());
|
||||
return redirect('/');
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,13 +1,12 @@
|
||||
<?php namespace FireflyIII\Http\Controllers;
|
||||
|
||||
use Config;
|
||||
use FireflyIII\Http\Requests;
|
||||
use FireflyIII\Http\Requests\BillFormRequest;
|
||||
use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
use Input;
|
||||
use Preferences;
|
||||
use Redirect;
|
||||
use Session;
|
||||
use URL;
|
||||
@@ -32,7 +31,7 @@ class BillController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
@@ -53,7 +52,7 @@ class BillController extends Controller
|
||||
/**
|
||||
* @param Bill $bill
|
||||
*
|
||||
* @return $this
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function delete(Bill $bill)
|
||||
{
|
||||
@@ -77,6 +76,7 @@ class BillController extends Controller
|
||||
$repository->destroy($bill);
|
||||
|
||||
Session::flash('success', 'The bill was deleted.');
|
||||
Preferences::mark();
|
||||
|
||||
return Redirect::to(Session::get('bills.delete.url'));
|
||||
|
||||
@@ -85,7 +85,7 @@ class BillController extends Controller
|
||||
/**
|
||||
* @param Bill $bill
|
||||
*
|
||||
* @return $this
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function edit(Bill $bill)
|
||||
{
|
||||
@@ -143,6 +143,7 @@ class BillController extends Controller
|
||||
|
||||
|
||||
Session::flash('success', 'Rescanned everything.');
|
||||
Preferences::mark();
|
||||
|
||||
return Redirect::to(URL::previous());
|
||||
}
|
||||
@@ -151,7 +152,7 @@ class BillController extends Controller
|
||||
* @param BillRepositoryInterface $repository
|
||||
* @param Bill $bill
|
||||
*
|
||||
* @return mixed
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function show(BillRepositoryInterface $repository, Bill $bill)
|
||||
{
|
||||
@@ -167,13 +168,14 @@ class BillController extends Controller
|
||||
* @param BillFormRequest $request
|
||||
* @param BillRepositoryInterface $repository
|
||||
*
|
||||
* @return $this|\Illuminate\Http\RedirectResponse
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function store(BillFormRequest $request, BillRepositoryInterface $repository)
|
||||
{
|
||||
$billData = $request->getBillData();
|
||||
$bill = $repository->store($billData);
|
||||
Session::flash('success', 'Bill "' . e($bill->name) . '" stored.');
|
||||
Preferences::mark();
|
||||
|
||||
if (intval(Input::get('create_another')) === 1) {
|
||||
// set value so create routine will not overwrite URL:
|
||||
@@ -192,7 +194,7 @@ class BillController extends Controller
|
||||
* @param BillRepositoryInterface $repository
|
||||
* @param Bill $bill
|
||||
*
|
||||
* @return $this|\Illuminate\Http\RedirectResponse
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(BillFormRequest $request, BillRepositoryInterface $repository, Bill $bill)
|
||||
{
|
||||
@@ -200,12 +202,13 @@ class BillController extends Controller
|
||||
$bill = $repository->update($bill, $billData);
|
||||
|
||||
Session::flash('success', 'Bill "' . e($bill->name) . '" updated.');
|
||||
Preferences::mark();
|
||||
|
||||
if (intval(Input::get('return_to_edit')) === 1) {
|
||||
// set value so edit routine will not overwrite URL:
|
||||
Session::put('bills.edit.fromUpdate', true);
|
||||
|
||||
return Redirect::route('bills.edit', $bill->id)->withInput(['return_to_edit' => 1]);
|
||||
return Redirect::route('bills.edit', [$bill->id])->withInput(['return_to_edit' => 1]);
|
||||
}
|
||||
|
||||
// redirect to previous URL.
|
||||
|
@@ -3,7 +3,6 @@
|
||||
use Amount;
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Http\Requests;
|
||||
use FireflyIII\Http\Requests\BudgetFormRequest;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Models\LimitRepetition;
|
||||
@@ -20,6 +19,7 @@ use View;
|
||||
* Class BudgetController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers
|
||||
* @SuppressWarnings(PHPMD.TooManyMethods)
|
||||
*/
|
||||
class BudgetController extends Controller
|
||||
{
|
||||
@@ -49,13 +49,14 @@ class BudgetController extends Controller
|
||||
if ($amount == 0) {
|
||||
$limitRepetition = null;
|
||||
}
|
||||
Preferences::mark();
|
||||
|
||||
return Response::json(['name' => $budget->name, 'repetition' => $limitRepetition ? $limitRepetition->id : 0]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
@@ -102,6 +103,7 @@ class BudgetController extends Controller
|
||||
|
||||
|
||||
Session::flash('success', 'The budget "' . e($name) . '" was deleted.');
|
||||
Preferences::mark();
|
||||
|
||||
|
||||
return Redirect::to(Session::get('budgets.delete.url'));
|
||||
@@ -110,7 +112,7 @@ class BudgetController extends Controller
|
||||
/**
|
||||
* @param Budget $budget
|
||||
*
|
||||
* @return $this
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function edit(Budget $budget)
|
||||
{
|
||||
@@ -131,7 +133,7 @@ class BudgetController extends Controller
|
||||
/**
|
||||
* @param BudgetRepositoryInterface $repository
|
||||
*
|
||||
* @return View
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function index(BudgetRepositoryInterface $repository)
|
||||
{
|
||||
@@ -173,7 +175,7 @@ class BudgetController extends Controller
|
||||
/**
|
||||
* @param BudgetRepositoryInterface $repository
|
||||
*
|
||||
* @return View
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function noBudget(BudgetRepositoryInterface $repository)
|
||||
{
|
||||
@@ -196,6 +198,7 @@ class BudgetController extends Controller
|
||||
|
||||
$date = Session::get('start', Carbon::now()->startOfMonth())->format('FY');
|
||||
Preferences::set('budgetIncomeTotal' . $date, intval(Input::get('amount')));
|
||||
Preferences::mark();
|
||||
|
||||
return Redirect::route('budgets.index');
|
||||
}
|
||||
@@ -205,7 +208,7 @@ class BudgetController extends Controller
|
||||
* @param Budget $budget
|
||||
* @param LimitRepetition $repetition
|
||||
*
|
||||
* @return View
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function show(BudgetRepositoryInterface $repository, Budget $budget, LimitRepetition $repetition = null)
|
||||
{
|
||||
@@ -216,12 +219,15 @@ class BudgetController extends Controller
|
||||
}
|
||||
|
||||
$journals = $repository->getJournals($budget, $repetition);
|
||||
$limits = !is_null($repetition->id) ? [$repetition->budgetLimit] : $repository->getBudgetLimits($budget);
|
||||
$subTitle = !is_null($repetition->id)
|
||||
?
|
||||
trans('firefly.budget_in_month', ['name' => $budget->name, 'month' => $repetition->startdate->formatLocalized($this->monthFormat)])
|
||||
:
|
||||
e($budget->name);
|
||||
|
||||
if (is_null($repetition->id)) {
|
||||
$limits = $repository->getBudgetLimits($budget);
|
||||
$subTitle = e($budget->name);
|
||||
} else {
|
||||
$limits = [$repetition->budgetLimit];
|
||||
$subTitle = trans('firefly.budget_in_month', ['name' => $budget->name, 'month' => $repetition->startdate->formatLocalized($this->monthFormat)]);
|
||||
}
|
||||
|
||||
$journals->setPath('/budgets/show/' . $budget->id);
|
||||
|
||||
return view('budgets.show', compact('limits', 'budget', 'repetition', 'journals', 'subTitle'));
|
||||
@@ -242,6 +248,7 @@ class BudgetController extends Controller
|
||||
$budget = $repository->store($budgetData);
|
||||
|
||||
Session::flash('success', 'New budget "' . $budget->name . '" stored!');
|
||||
Preferences::mark();
|
||||
|
||||
if (intval(Input::get('create_another')) === 1) {
|
||||
// set value so create routine will not overwrite URL:
|
||||
@@ -260,7 +267,7 @@ class BudgetController extends Controller
|
||||
* @param BudgetRepositoryInterface $repository
|
||||
* @param Budget $budget
|
||||
*
|
||||
* @return $this|\Illuminate\Http\RedirectResponse
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(BudgetFormRequest $request, BudgetRepositoryInterface $repository, Budget $budget)
|
||||
{
|
||||
@@ -272,12 +279,13 @@ class BudgetController extends Controller
|
||||
$repository->update($budget, $budgetData);
|
||||
|
||||
Session::flash('success', 'Budget "' . $budget->name . '" updated.');
|
||||
Preferences::mark();
|
||||
|
||||
if (intval(Input::get('return_to_edit')) === 1) {
|
||||
// set value so edit routine will not overwrite URL:
|
||||
Session::put('budgets.edit.fromUpdate', true);
|
||||
|
||||
return Redirect::route('budgets.edit', $budget->id)->withInput(['return_to_edit' => 1]);
|
||||
return Redirect::route('budgets.edit', [$budget->id])->withInput(['return_to_edit' => 1]);
|
||||
}
|
||||
|
||||
// redirect to previous URL.
|
||||
@@ -286,7 +294,7 @@ class BudgetController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @return View
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function updateIncome()
|
||||
{
|
||||
|
@@ -7,6 +7,7 @@ use FireflyIII\Models\Category;
|
||||
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Input;
|
||||
use Preferences;
|
||||
use Redirect;
|
||||
use Session;
|
||||
use URL;
|
||||
@@ -31,7 +32,7 @@ class CategoryController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
@@ -77,6 +78,7 @@ class CategoryController extends Controller
|
||||
$repository->destroy($category);
|
||||
|
||||
Session::flash('success', 'The category "' . e($name) . '" was deleted.');
|
||||
Preferences::mark();
|
||||
|
||||
return Redirect::to(Session::get('categories.delete.url'));
|
||||
}
|
||||
@@ -84,7 +86,7 @@ class CategoryController extends Controller
|
||||
/**
|
||||
* @param Category $category
|
||||
*
|
||||
* @return $this
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function edit(Category $category)
|
||||
{
|
||||
@@ -105,7 +107,7 @@ class CategoryController extends Controller
|
||||
/**
|
||||
* @param CategoryRepositoryInterface $repository
|
||||
*
|
||||
* @return $this
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function index(CategoryRepositoryInterface $repository)
|
||||
{
|
||||
@@ -139,7 +141,7 @@ class CategoryController extends Controller
|
||||
* @param CategoryRepositoryInterface $repository
|
||||
* @param Category $category
|
||||
*
|
||||
* @return View
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function show(CategoryRepositoryInterface $repository, Category $category)
|
||||
{
|
||||
@@ -157,7 +159,7 @@ class CategoryController extends Controller
|
||||
* @param CategoryFormRequest $request
|
||||
* @param CategoryRepositoryInterface $repository
|
||||
*
|
||||
* @return mixed
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function store(CategoryFormRequest $request, CategoryRepositoryInterface $repository)
|
||||
{
|
||||
@@ -168,6 +170,7 @@ class CategoryController extends Controller
|
||||
$category = $repository->store($categoryData);
|
||||
|
||||
Session::flash('success', 'New category "' . $category->name . '" stored!');
|
||||
Preferences::mark();
|
||||
|
||||
if (intval(Input::get('create_another')) === 1) {
|
||||
Session::put('categories.create.fromStore', true);
|
||||
@@ -195,11 +198,12 @@ class CategoryController extends Controller
|
||||
$repository->update($category, $categoryData);
|
||||
|
||||
Session::flash('success', 'Category "' . $category->name . '" updated.');
|
||||
Preferences::mark();
|
||||
|
||||
if (intval(Input::get('return_to_edit')) === 1) {
|
||||
Session::put('categories.edit.fromUpdate', true);
|
||||
|
||||
return Redirect::route('categories.edit', $category->id);
|
||||
return Redirect::route('categories.edit', [$category->id]);
|
||||
}
|
||||
|
||||
// redirect to previous URL.
|
||||
|
@@ -6,6 +6,7 @@ use Carbon\Carbon;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use Grumpydictator\Gchart\GChart;
|
||||
use Illuminate\Support\Collection;
|
||||
use Preferences;
|
||||
@@ -26,6 +27,10 @@ class AccountController extends Controller
|
||||
* @param GChart $chart
|
||||
* @param AccountRepositoryInterface $repository
|
||||
*
|
||||
* @param $year
|
||||
* @param $month
|
||||
* @param bool $shared
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function all(GChart $chart, AccountRepositoryInterface $repository, $year, $month, $shared = false)
|
||||
@@ -33,12 +38,23 @@ class AccountController extends Controller
|
||||
$start = new Carbon($year . '-' . $month . '-01');
|
||||
$end = clone $start;
|
||||
$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');
|
||||
|
||||
/** @var Collection $accounts */
|
||||
$accounts = $repository->getAccounts(['Default account', 'Asset account']);
|
||||
if ($shared === false) {
|
||||
// remove the shared accounts from the collection:
|
||||
/** @var Account $account */
|
||||
foreach ($accounts as $index => $account) {
|
||||
if ($account->getMeta('accountRole') == 'sharedAsset') {
|
||||
@@ -47,6 +63,7 @@ class AccountController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
$index = 1;
|
||||
/** @var Account $account */
|
||||
@@ -70,8 +87,10 @@ class AccountController extends Controller
|
||||
}
|
||||
$chart->generate();
|
||||
|
||||
return Response::json($chart->getData());
|
||||
$data = $chart->getData();
|
||||
$cache->store($data);
|
||||
|
||||
return Response::json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -91,6 +110,17 @@ class AccountController extends Controller
|
||||
$end = Session::get('end', Carbon::now()->endOfMonth());
|
||||
$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;
|
||||
/** @var Account $account */
|
||||
foreach ($accounts as $account) {
|
||||
@@ -113,7 +143,10 @@ class AccountController extends Controller
|
||||
}
|
||||
$chart->generate();
|
||||
|
||||
return Response::json($chart->getData());
|
||||
$data = $chart->getData();
|
||||
$cache->store($data);
|
||||
|
||||
return Response::json($data);
|
||||
|
||||
}
|
||||
|
||||
@@ -136,6 +169,17 @@ class AccountController extends Controller
|
||||
$current = clone $start;
|
||||
$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) {
|
||||
$certain = $current < $today;
|
||||
$chart->addRow(clone $current, Steam::balance($account, $current), $certain);
|
||||
@@ -145,6 +189,9 @@ class AccountController extends Controller
|
||||
|
||||
$chart->generate();
|
||||
|
||||
return Response::json($chart->getData());
|
||||
$data = $chart->getData();
|
||||
$cache->store($data);
|
||||
|
||||
return Response::json($data);
|
||||
}
|
||||
}
|
||||
|
@@ -8,6 +8,7 @@ use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use Grumpydictator\Gchart\GChart;
|
||||
use Illuminate\Support\Collection;
|
||||
use Response;
|
||||
@@ -38,6 +39,14 @@ class BillController extends Controller
|
||||
$chart->addColumn(trans('firefly.minAmount'), '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:
|
||||
$results = $repository->getJournals($bill);
|
||||
/** @var TransactionJournal $result */
|
||||
@@ -47,8 +56,10 @@ class BillController extends Controller
|
||||
|
||||
$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.amount'), 'number');
|
||||
|
||||
$start = Session::get('start', Carbon::now()->startOfMonth());
|
||||
$end = Session::get('end', Carbon::now()->endOfMonth());
|
||||
$start = Session::get('start', Carbon::now()->startOfMonth());
|
||||
$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();
|
||||
$paid = new Collection; // journals.
|
||||
$unpaid = new Collection; // bills
|
||||
@@ -133,8 +156,12 @@ class BillController extends Controller
|
||||
|
||||
$chart->addRow(trans('firefly.unpaid') . ': ' . join(', ', $unpaidDescriptions), $unpaidAmount);
|
||||
$chart->addRow(trans('firefly.paid') . ': ' . join(', ', $paidDescriptions), $paidAmount);
|
||||
|
||||
$chart->generate();
|
||||
|
||||
return Response::json($chart->getData());
|
||||
$data = $chart->getData();
|
||||
$cache->store($data);
|
||||
|
||||
return Response::json($data);
|
||||
}
|
||||
}
|
||||
|
@@ -7,6 +7,7 @@ use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Models\LimitRepetition;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use Grumpydictator\Gchart\GChart;
|
||||
use Illuminate\Support\Collection;
|
||||
use Navigation;
|
||||
@@ -25,6 +26,8 @@ class BudgetController extends Controller
|
||||
* @param GChart $chart
|
||||
* @param BudgetRepositoryInterface $repository
|
||||
* @param Budget $budget
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function budget(GChart $chart, BudgetRepositoryInterface $repository, Budget $budget)
|
||||
{
|
||||
@@ -39,19 +42,41 @@ class BudgetController extends Controller
|
||||
$final->addYears(2);
|
||||
$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) {
|
||||
$end = Navigation::addPeriod($first, $range, 0);
|
||||
$end->subDay();
|
||||
|
||||
// start date for chart.
|
||||
$chartDate = clone $end;
|
||||
$chartDate->startOfMonth();
|
||||
|
||||
$spent = $repository->spentInPeriodCorrected($budget, $first, $end);
|
||||
$chart->addRow($end, $spent);
|
||||
|
||||
$chart->addRow($chartDate, $spent);
|
||||
|
||||
$first = Navigation::addPeriod($first, $range, 0);
|
||||
|
||||
|
||||
}
|
||||
|
||||
$chart->generate();
|
||||
|
||||
return Response::json($chart->getData());
|
||||
$data = $chart->getData();
|
||||
|
||||
|
||||
$cache->store($data);
|
||||
|
||||
return Response::json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,6 +94,18 @@ class BudgetController extends Controller
|
||||
$start = clone $repetition->startdate;
|
||||
$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.left'), 'number');
|
||||
|
||||
@@ -86,7 +123,10 @@ class BudgetController extends Controller
|
||||
}
|
||||
$chart->generate();
|
||||
|
||||
return Response::json($chart->getData());
|
||||
$data = $chart->getData();
|
||||
$cache->store($data);
|
||||
|
||||
return Response::json($data);
|
||||
|
||||
}
|
||||
|
||||
@@ -110,6 +150,18 @@ class BudgetController extends Controller
|
||||
$end = Session::get('end', Carbon::now()->endOfMonth());
|
||||
$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) {
|
||||
$repetitions = $repository->getBudgetLimitRepetitions($budget, $start, $end);
|
||||
if ($repetitions->count() == 0) {
|
||||
@@ -133,7 +185,7 @@ class BudgetController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
$noBudgetExpenses = $repository->getWithoutBudgetSum($start, $end);
|
||||
$noBudgetExpenses = $repository->getWithoutBudgetSum($start, $end) * -1;
|
||||
$allEntries->push([trans('firefly.noBudget'), 0, 0, $noBudgetExpenses]);
|
||||
|
||||
foreach ($allEntries as $entry) {
|
||||
@@ -144,7 +196,10 @@ class BudgetController extends Controller
|
||||
|
||||
$chart->generate();
|
||||
|
||||
return Response::json($chart->getData());
|
||||
$data = $chart->getData();
|
||||
$cache->store($data);
|
||||
|
||||
return Response::json($data);
|
||||
|
||||
}
|
||||
|
||||
@@ -165,6 +220,16 @@ class BudgetController extends Controller
|
||||
$shared = $shared == 'shared' ? true : false;
|
||||
$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:
|
||||
$chart->addColumn(trans('firefly.month'), 'date');
|
||||
foreach ($budgets as $budget) {
|
||||
@@ -185,11 +250,14 @@ class BudgetController extends Controller
|
||||
}
|
||||
$chart->addRowArray($row);
|
||||
|
||||
$start->addMonth();
|
||||
$start->endOfMonth()->addDay();
|
||||
}
|
||||
|
||||
$chart->generate();
|
||||
|
||||
return Response::json($chart->getData());
|
||||
$data = $chart->getData();
|
||||
$cache->store($data);
|
||||
|
||||
return Response::json($data);
|
||||
}
|
||||
}
|
||||
|
@@ -7,6 +7,7 @@ use Carbon\Carbon;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use Grumpydictator\Gchart\GChart;
|
||||
use Navigation;
|
||||
use Preferences;
|
||||
@@ -75,7 +76,18 @@ class CategoryController extends Controller
|
||||
|
||||
$start = Session::get('start', Carbon::now()->startOfMonth());
|
||||
$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:
|
||||
uasort(
|
||||
@@ -99,7 +111,10 @@ class CategoryController extends Controller
|
||||
|
||||
$chart->generate();
|
||||
|
||||
return Response::json($chart->getData());
|
||||
$data = $chart->getData();
|
||||
$cache->store($data);
|
||||
|
||||
return Response::json($data);
|
||||
|
||||
}
|
||||
|
||||
|
@@ -1,9 +1,8 @@
|
||||
<?php namespace FireflyIII\Http\Controllers;
|
||||
|
||||
use Auth;
|
||||
use Cache;
|
||||
use FireflyIII\Http\Requests;
|
||||
use FireflyIII\Http\Requests\CurrencyFormRequest;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use Input;
|
||||
@@ -60,6 +59,7 @@ class CurrencyController extends Controller
|
||||
{
|
||||
|
||||
Preferences::set('currencyPreference', $currency->code);
|
||||
Preferences::mark();
|
||||
|
||||
Session::flash('success', $currency->name . ' is now the default currency.');
|
||||
Cache::forget('FFCURRENCYSYMBOL');
|
||||
@@ -109,8 +109,9 @@ class CurrencyController extends Controller
|
||||
}
|
||||
|
||||
Session::flash('success', 'Currency "' . e($currency->name) . '" deleted');
|
||||
|
||||
$currency->delete();
|
||||
if (Auth::user()->hasRole('owner')) {
|
||||
$currency->delete();
|
||||
}
|
||||
|
||||
return Redirect::to(Session::get('currency.delete.url'));
|
||||
}
|
||||
@@ -148,6 +149,12 @@ class CurrencyController extends Controller
|
||||
$currencies = $repository->get();
|
||||
$defaultCurrency = $repository->getCurrencyByPreference(Preferences::get('currencyPreference', 'EUR'));
|
||||
|
||||
|
||||
if (!Auth::user()->hasRole('owner')) {
|
||||
Session::flash('warning', 'Please ask ' . env('SITE_OWNER') . ' to add, remove or edit currencies.');
|
||||
}
|
||||
|
||||
|
||||
return view('currency.index', compact('currencies', 'defaultCurrency'));
|
||||
}
|
||||
|
||||
@@ -160,11 +167,12 @@ class CurrencyController extends Controller
|
||||
*/
|
||||
public function store(CurrencyFormRequest $request, CurrencyRepositoryInterface $repository)
|
||||
{
|
||||
$data = $request->getCurrencyData();
|
||||
$currency = $repository->store($data);
|
||||
$data = $request->getCurrencyData();
|
||||
if (Auth::user()->hasRole('owner')) {
|
||||
$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) {
|
||||
Session::put('currency.create.fromStore', true);
|
||||
@@ -187,16 +195,18 @@ class CurrencyController extends Controller
|
||||
*/
|
||||
public function update(CurrencyFormRequest $request, CurrencyRepositoryInterface $repository, TransactionCurrency $currency)
|
||||
{
|
||||
$data = $request->getCurrencyData();
|
||||
$currency = $repository->update($currency, $data);
|
||||
|
||||
$data = $request->getCurrencyData();
|
||||
if (Auth::user()->hasRole('owner')) {
|
||||
$currency = $repository->update($currency, $data);
|
||||
}
|
||||
Session::flash('success', 'Currency "' . e($currency->name) . '" updated.');
|
||||
Preferences::mark();
|
||||
|
||||
|
||||
if (intval(Input::get('return_to_edit')) === 1) {
|
||||
Session::put('currency.edit.fromUpdate', true);
|
||||
|
||||
return Redirect::route('currency.edit', $currency->id);
|
||||
return Redirect::route('currency.edit', [$currency->id]);
|
||||
}
|
||||
|
||||
// redirect to previous URL.
|
||||
|
@@ -6,7 +6,6 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use Input;
|
||||
use Preferences;
|
||||
use Redirect;
|
||||
use Route;
|
||||
use Session;
|
||||
use Steam;
|
||||
|
||||
@@ -46,30 +45,41 @@ class HomeController extends Controller
|
||||
/**
|
||||
* @param AccountRepositoryInterface $repository
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View
|
||||
*/
|
||||
public function index(AccountRepositoryInterface $repository)
|
||||
{
|
||||
|
||||
$types = Config::get('firefly.accountTypesByIdentifier.asset');
|
||||
$count = $repository->countAccounts($types);
|
||||
$title = 'Firefly';
|
||||
$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();
|
||||
|
||||
$types = Config::get('firefly.accountTypesByIdentifier.asset');
|
||||
$count = $repository->countAccounts($types);
|
||||
|
||||
|
||||
if ($count == 0) {
|
||||
return Redirect::route('new-user.index');
|
||||
}
|
||||
|
||||
$title = 'Firefly';
|
||||
$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();
|
||||
|
||||
|
||||
$savingsTotal = 0;
|
||||
foreach ($savings as $savingAccount) {
|
||||
$savingsTotal += Steam::balance($savingAccount, $end);
|
||||
}
|
||||
|
||||
$sum = $repository->sumOfEverything();
|
||||
|
||||
if ($sum != 0) {
|
||||
Session::flash(
|
||||
'error', 'Your transactions are unbalanced. This means a'
|
||||
@@ -80,6 +90,7 @@ class HomeController extends Controller
|
||||
|
||||
foreach ($accounts as $account) {
|
||||
$set = $repository->getFrontpageTransactions($account, $start, $end);
|
||||
|
||||
if (count($set) > 0) {
|
||||
$transactions[] = [$set, $account];
|
||||
}
|
||||
@@ -87,79 +98,4 @@ class HomeController extends Controller
|
||||
|
||||
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!';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -10,6 +10,7 @@ use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use Illuminate\Support\Collection;
|
||||
use Response;
|
||||
use Session;
|
||||
@@ -33,10 +34,21 @@ class JsonController extends Controller
|
||||
*/
|
||||
public function boxBillsPaid(BillRepositoryInterface $repository, AccountRepositoryInterface $accountRepository)
|
||||
{
|
||||
$start = Session::get('start', Carbon::now()->startOfMonth());
|
||||
$end = Session::get('end', Carbon::now()->endOfMonth());
|
||||
$start = Session::get('start', Carbon::now()->startOfMonth());
|
||||
$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;
|
||||
|
||||
|
||||
// these two functions are the same as the chart
|
||||
$bills = $repository->getActiveBills();
|
||||
|
||||
@@ -60,8 +72,11 @@ class JsonController extends Controller
|
||||
$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;
|
||||
$start = Session::get('start', Carbon::now()->startOfMonth());
|
||||
$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();
|
||||
$unpaid = new Collection; // bills
|
||||
|
||||
@@ -109,7 +134,10 @@ class JsonController extends Controller
|
||||
$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)
|
||||
{
|
||||
$start = Session::get('start', Carbon::now()->startOfMonth());
|
||||
$end = Session::get('end', Carbon::now()->endOfMonth());
|
||||
$start = Session::get('start', Carbon::now()->startOfMonth());
|
||||
$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');
|
||||
|
||||
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)
|
||||
{
|
||||
$start = Session::get('start', Carbon::now()->startOfMonth());
|
||||
$end = Session::get('end', Carbon::now()->endOfMonth());
|
||||
$start = Session::get('start', Carbon::now()->startOfMonth());
|
||||
$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');
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
111
app/Http/Controllers/NewUserController.php
Normal file
111
app/Http/Controllers/NewUserController.php
Normal 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');
|
||||
}
|
||||
}
|
@@ -4,13 +4,13 @@ use Amount;
|
||||
use Carbon\Carbon;
|
||||
use Config;
|
||||
use ExpandedForm;
|
||||
use FireflyIII\Http\Requests;
|
||||
use FireflyIII\Http\Requests\PiggyBankFormRequest;
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Input;
|
||||
use Preferences;
|
||||
use Redirect;
|
||||
use Session;
|
||||
use Steam;
|
||||
@@ -18,6 +18,9 @@ use URL;
|
||||
use View;
|
||||
|
||||
/**
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.TooManyMethods)
|
||||
*
|
||||
* Class PiggyBankController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers
|
||||
@@ -106,6 +109,7 @@ class PiggyBankController extends Controller
|
||||
|
||||
|
||||
Session::flash('success', 'Piggy bank "' . e($piggyBank->name) . '" deleted.');
|
||||
Preferences::mark();
|
||||
$repository->destroy($piggyBank);
|
||||
|
||||
return Redirect::to(Session::get('piggy-banks.delete.url'));
|
||||
@@ -206,6 +210,7 @@ class PiggyBankController extends Controller
|
||||
// set all users piggy banks to zero:
|
||||
$repository->reset();
|
||||
|
||||
|
||||
if (is_array($data)) {
|
||||
foreach ($data as $order => $id) {
|
||||
$repository->setOrder(intval($id), (intval($order) + 1));
|
||||
@@ -237,12 +242,8 @@ class PiggyBankController extends Controller
|
||||
// create event
|
||||
$repository->createEvent($piggyBank, $amount);
|
||||
|
||||
/*
|
||||
* Create event!
|
||||
*/
|
||||
//Event::fire('piggy_bank.addMoney', [$piggyBank, $amount]); // new and used.
|
||||
|
||||
Session::flash('success', 'Added ' . Amount::format($amount, false) . ' to "' . e($piggyBank->name) . '".');
|
||||
Preferences::mark();
|
||||
} else {
|
||||
Session::flash('error', 'Could not add ' . Amount::format($amount, false) . ' to "' . e($piggyBank->name) . '".');
|
||||
}
|
||||
@@ -271,6 +272,7 @@ class PiggyBankController extends Controller
|
||||
$repository->createEvent($piggyBank, $amount * -1);
|
||||
|
||||
Session::flash('success', 'Removed ' . Amount::format($amount, false) . ' from "' . e($piggyBank->name) . '".');
|
||||
Preferences::mark();
|
||||
} else {
|
||||
Session::flash('error', 'Could not remove ' . Amount::format($amount, false) . ' from "' . e($piggyBank->name) . '".');
|
||||
}
|
||||
@@ -331,6 +333,7 @@ class PiggyBankController extends Controller
|
||||
$piggyBank = $repository->store($piggyBankData);
|
||||
|
||||
Session::flash('success', 'Stored piggy bank "' . e($piggyBank->name) . '".');
|
||||
Preferences::mark();
|
||||
|
||||
if (intval(Input::get('create_another')) === 1) {
|
||||
Session::put('piggy-banks.create.fromStore', true);
|
||||
@@ -365,11 +368,12 @@ class PiggyBankController extends Controller
|
||||
$piggyBank = $repository->update($piggyBank, $piggyBankData);
|
||||
|
||||
Session::flash('success', 'Updated piggy bank "' . e($piggyBank->name) . '".');
|
||||
Preferences::mark();
|
||||
|
||||
if (intval(Input::get('return_to_edit')) === 1) {
|
||||
Session::put('piggy-banks.edit.fromUpdate', true);
|
||||
|
||||
return Redirect::route('piggy-banks.edit', $piggyBank->id);
|
||||
return Redirect::route('piggy-banks.edit', [$piggyBank->id]);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -77,6 +77,7 @@ class PreferencesController extends Controller
|
||||
|
||||
|
||||
Session::flash('success', 'Preferences saved!');
|
||||
Preferences::mark();
|
||||
|
||||
return Redirect::route('preferences');
|
||||
}
|
||||
|
@@ -31,7 +31,7 @@ class ReminderController extends Controller
|
||||
];
|
||||
Session::flash('_old_input', $data);
|
||||
|
||||
return Redirect::route('transactions.create', 'transfer');
|
||||
return Redirect::route('transactions.create', ['transfer']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -141,18 +141,9 @@ class ReportController extends Controller
|
||||
Session::flash('gaEventAction', 'year');
|
||||
Session::flash('gaEventLabel', $start->format('Y'));
|
||||
|
||||
|
||||
return view(
|
||||
'reports.year',
|
||||
compact(
|
||||
'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.
|
||||
)
|
||||
compact('start', 'shared', 'accounts', 'incomes', 'expenses', 'subTitle', 'subTitleIcon', 'incomeTopLength', 'expenseTopLength')
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -106,14 +106,17 @@ class TagController extends Controller
|
||||
$repository->destroy($tag);
|
||||
|
||||
Session::flash('success', 'Tag "' . e($tagName) . '" was deleted.');
|
||||
Preferences::mark();
|
||||
|
||||
return Redirect::to(route('tags.index'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Tag $tag
|
||||
* @param Tag $tag
|
||||
*
|
||||
* @return View
|
||||
* @param TagRepositoryInterface $repository
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function edit(Tag $tag, TagRepositoryInterface $repository)
|
||||
{
|
||||
@@ -162,7 +165,7 @@ class TagController extends Controller
|
||||
$state = $state == 'true' ? true : false;
|
||||
Preferences::set('hideTagHelp', $state);
|
||||
|
||||
return Response::json(true);
|
||||
return Response::json([true]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -198,7 +201,7 @@ class TagController extends Controller
|
||||
*
|
||||
* @param TagRepositoryInterface $repository
|
||||
*
|
||||
* @return $this|\Illuminate\Http\RedirectResponse
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function store(TagFormRequest $request, TagRepositoryInterface $repository)
|
||||
{
|
||||
@@ -224,6 +227,7 @@ class TagController extends Controller
|
||||
$repository->store($data);
|
||||
|
||||
Session::flash('success', 'The tag has been created!');
|
||||
Preferences::mark();
|
||||
|
||||
if (intval(Input::get('create_another')) === 1) {
|
||||
// set value so create routine will not overwrite URL:
|
||||
@@ -242,7 +246,7 @@ class TagController extends Controller
|
||||
* @param TagRepositoryInterface $repository
|
||||
* @param Tag $tag
|
||||
*
|
||||
* @return $this|\Illuminate\Http\RedirectResponse
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(TagFormRequest $request, TagRepositoryInterface $repository, Tag $tag)
|
||||
{
|
||||
@@ -266,15 +270,17 @@ class TagController extends Controller
|
||||
'tagMode' => $request->get('tagMode'),
|
||||
];
|
||||
|
||||
|
||||
$repository->update($tag, $data);
|
||||
|
||||
Session::flash('success', 'Tag "' . e($data['tag']) . '" updated.');
|
||||
Preferences::mark();
|
||||
|
||||
if (intval(Input::get('return_to_edit')) === 1) {
|
||||
// set value so edit routine will not overwrite URL:
|
||||
Session::put('tags.edit.fromUpdate', true);
|
||||
|
||||
return Redirect::route('tags.edit', $tag->id)->withInput(['return_to_edit' => 1]);
|
||||
return Redirect::route('tags.edit', [$tag->id])->withInput(['return_to_edit' => 1]);
|
||||
}
|
||||
|
||||
// redirect to previous URL.
|
||||
|
@@ -5,13 +5,13 @@ use Carbon\Carbon;
|
||||
use ExpandedForm;
|
||||
use FireflyIII\Events\JournalCreated;
|
||||
use FireflyIII\Events\JournalSaved;
|
||||
use FireflyIII\Http\Requests;
|
||||
use FireflyIII\Http\Requests\JournalFormRequest;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use Input;
|
||||
use Preferences;
|
||||
use Redirect;
|
||||
use Response;
|
||||
use Session;
|
||||
@@ -39,7 +39,7 @@ class TransactionController extends Controller
|
||||
* @param AccountRepositoryInterface $repository
|
||||
* @param string $what
|
||||
*
|
||||
* @return View
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function create(AccountRepositoryInterface $repository, $what = 'deposit')
|
||||
{
|
||||
@@ -76,19 +76,19 @@ class TransactionController extends Controller
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return $this
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function delete(TransactionJournal $journal)
|
||||
{
|
||||
$type = strtolower($journal->transactionType->type);
|
||||
$subTitle = trans('firefly.delete_' . $type, ['description' => $journal->description]);
|
||||
$what = strtolower($journal->transactionType->type);
|
||||
$subTitle = trans('firefly.delete_' . $what, ['description' => $journal->description]);
|
||||
|
||||
// put previous url in session
|
||||
Session::put('transactions.delete.url', URL::previous());
|
||||
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'));
|
||||
|
||||
|
||||
}
|
||||
@@ -105,6 +105,8 @@ class TransactionController extends Controller
|
||||
|
||||
$repository->delete($transactionJournal);
|
||||
|
||||
Preferences::mark();
|
||||
|
||||
// redirect to previous URL:
|
||||
return Redirect::to(Session::get('transactions.delete.url'));
|
||||
}
|
||||
@@ -119,7 +121,7 @@ class TransactionController extends Controller
|
||||
*/
|
||||
public function edit(AccountRepositoryInterface $repository, TransactionJournal $journal)
|
||||
{
|
||||
$what = strtolower($journal->transactiontype->type);
|
||||
$what = strtolower($journal->transactionType->type);
|
||||
$accounts = ExpandedForm::makeSelectList($repository->getAccounts(['Default account', 'Asset account']));
|
||||
$budgets = ExpandedForm::makeSelectList(Auth::user()->budgets()->get());
|
||||
$budgets[0] = trans('form.noBudget');
|
||||
@@ -154,8 +156,8 @@ class TransactionController extends Controller
|
||||
$preFilled['piggy_bank_id'] = $journal->piggyBankEvents()->orderBy('date', 'DESC')->first()->piggy_bank_id;
|
||||
}
|
||||
|
||||
$preFilled['amount'] = $journal->actualAmount;
|
||||
$preFilled['account_id'] = $journal->assetAccount->id;
|
||||
$preFilled['amount'] = $journal->actual_amount;
|
||||
$preFilled['account_id'] = $journal->destination_account->id;
|
||||
$preFilled['expense_account'] = $transactions[0]->account->name;
|
||||
$preFilled['revenue_account'] = $transactions[1]->account->name;
|
||||
$preFilled['account_from_id'] = $transactions[1]->account->id;
|
||||
@@ -179,7 +181,7 @@ class TransactionController extends Controller
|
||||
* @param JournalRepositoryInterface $repository
|
||||
* @param $what
|
||||
*
|
||||
* @return View
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function index(JournalRepositoryInterface $repository, $what)
|
||||
{
|
||||
@@ -236,8 +238,9 @@ class TransactionController extends Controller
|
||||
}
|
||||
}
|
||||
}
|
||||
Preferences::mark();
|
||||
|
||||
return Response::json(true);
|
||||
return Response::json([true]);
|
||||
|
||||
}
|
||||
|
||||
@@ -245,7 +248,7 @@ class TransactionController extends Controller
|
||||
* @param JournalRepositoryInterface $repository
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return $this
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function show(JournalRepositoryInterface $repository, TransactionJournal $journal)
|
||||
{
|
||||
@@ -255,16 +258,17 @@ class TransactionController extends Controller
|
||||
$t->after = $t->before + $t->amount;
|
||||
}
|
||||
);
|
||||
$subTitle = trans('firefly.' . $journal->transactiontype->type) . ' "' . e($journal->description) . '"';
|
||||
$what = strtolower($journal->transactionType->type);
|
||||
$subTitle = trans('firefly.' . $journal->transactionType->type) . ' "' . e($journal->description) . '"';
|
||||
|
||||
return view('transactions.show', compact('journal', 'subTitle'));
|
||||
return view('transactions.show', compact('journal', 'subTitle','what'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param JournalFormRequest $request
|
||||
* @param JournalRepositoryInterface $repository
|
||||
*
|
||||
* @return $this|\Illuminate\Http\RedirectResponse
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function store(JournalFormRequest $request, JournalRepositoryInterface $repository)
|
||||
{
|
||||
@@ -282,12 +286,13 @@ class TransactionController extends Controller
|
||||
$repository->deactivateReminder($request->get('reminder_id'));
|
||||
|
||||
Session::flash('success', 'New transaction "' . $journal->description . '" stored!');
|
||||
Preferences::mark();
|
||||
|
||||
if (intval(Input::get('create_another')) === 1) {
|
||||
// set value so create routine will not overwrite URL:
|
||||
Session::put('transactions.create.fromStore', true);
|
||||
|
||||
return Redirect::route('transactions.create', $request->input('what'))->withInput();
|
||||
return Redirect::route('transactions.create', [$request->input('what')])->withInput();
|
||||
}
|
||||
|
||||
// redirect to previous URL.
|
||||
@@ -301,7 +306,7 @@ class TransactionController extends Controller
|
||||
* @param JournalRepositoryInterface $repository
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return $this|\Illuminate\Http\RedirectResponse
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(JournalFormRequest $request, JournalRepositoryInterface $repository, TransactionJournal $journal)
|
||||
{
|
||||
@@ -313,12 +318,13 @@ class TransactionController extends Controller
|
||||
// update, get events by date and sort DESC
|
||||
|
||||
Session::flash('success', 'Transaction "' . e($journalData['description']) . '" updated.');
|
||||
Preferences::mark();
|
||||
|
||||
if (intval(Input::get('return_to_edit')) === 1) {
|
||||
// set value so edit routine will not overwrite URL:
|
||||
Session::put('transactions.edit.fromUpdate', true);
|
||||
|
||||
return Redirect::route('transactions.edit', $journal->id)->withInput(['return_to_edit' => 1]);
|
||||
return Redirect::route('transactions.edit', [$journal->id])->withInput(['return_to_edit' => 1]);
|
||||
}
|
||||
|
||||
// redirect to previous URL.
|
||||
|
@@ -37,7 +37,6 @@ class Kernel extends HttpKernel
|
||||
'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth',
|
||||
'guest' => 'FireflyIII\Http\Middleware\RedirectIfAuthenticated',
|
||||
'range' => 'FireflyIII\Http\Middleware\Range',
|
||||
'cleanup' => 'FireflyIII\Http\Middleware\Cleanup',
|
||||
'reminders' => 'FireflyIII\Http\Middleware\Reminders',
|
||||
|
||||
];
|
||||
|
@@ -1,12 +1,13 @@
|
||||
<?php namespace FireflyIII\Http\Middleware;
|
||||
|
||||
use App;
|
||||
use Carbon\Carbon;
|
||||
use Closure;
|
||||
use Config;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Http\Request;
|
||||
use Preferences;
|
||||
use Carbon\Carbon;
|
||||
|
||||
/**
|
||||
* Class Authenticate
|
||||
*
|
||||
|
@@ -1,224 +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\Transaction;
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
@@ -7,6 +7,8 @@ use Carbon\Carbon;
|
||||
use Closure;
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
use FireflyIII\Models\Reminder;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Http\Request;
|
||||
use View;
|
||||
@@ -46,9 +48,25 @@ class Reminders
|
||||
*/
|
||||
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.
|
||||
$piggyBanks = $this->auth->user()->piggyBanks()->where('remind_me', 1)->get();
|
||||
|
||||
// abuse CacheProperties to find out if we need to do this:
|
||||
$cache = new CacheProperties;
|
||||
|
||||
$cache->addProperty('reminders');
|
||||
if ($cache->has()) {
|
||||
$reminders = $cache->get();
|
||||
View::share('reminders', $reminders);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
$piggyBanks = $user->piggyBanks()->where('remind_me', 1)->get();
|
||||
|
||||
/** @var \FireflyIII\Helpers\Reminders\ReminderHelperInterface $helper */
|
||||
$helper = App::make('FireflyIII\Helpers\Reminders\ReminderHelperInterface');
|
||||
|
||||
@@ -59,19 +77,17 @@ class Reminders
|
||||
// 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();
|
||||
Reminder::whereUserId($user->id)->leftJoin('piggy_banks', 'piggy_banks.id', '=', 'remindersable_id')->whereNull('piggy_banks.id')->delete();
|
||||
}
|
||||
|
||||
// get and list active reminders:
|
||||
$reminders = $this->auth->user()->reminders()->today()->get();
|
||||
$reminders = $user->reminders()->today()->get();
|
||||
$reminders->each(
|
||||
function (Reminder $reminder) use ($helper) {
|
||||
$reminder->description = $helper->getReminderText($reminder);
|
||||
}
|
||||
);
|
||||
$cache->store($reminders);
|
||||
View::share('reminders', $reminders);
|
||||
}
|
||||
|
||||
|
@@ -48,8 +48,8 @@ class BillFormRequest extends Request
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
$nameRule = 'required|between:1,255|uniqueObjectForUser:bills,name,name_encrypted';
|
||||
$matchRule = 'required|between:1,255|uniqueObjectForUser:bills,match,match_encrypted';
|
||||
$nameRule = 'required|between:1,255|uniqueObjectForUser:bills,name';
|
||||
$matchRule = 'required|between:1,255|uniqueObjectForUser:bills,match';
|
||||
if (intval(Input::get('id')) > 0) {
|
||||
$nameRule .= ',' . intval(Input::get('id'));
|
||||
$matchRule .= ',' . intval(Input::get('id'));
|
||||
|
@@ -29,9 +29,9 @@ class BudgetFormRequest extends Request
|
||||
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'))) {
|
||||
$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 [
|
||||
|
@@ -29,9 +29,9 @@ class CategoryFormRequest extends Request
|
||||
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'))) {
|
||||
$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 [
|
||||
|
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace FireflyIII\Http\Requests;
|
||||
|
||||
use App;
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
@@ -85,7 +86,7 @@ class JournalFormRequest extends Request
|
||||
$rules['category'] = 'between:1,255';
|
||||
break;
|
||||
default:
|
||||
throw new Exception('Cannot handle ' . $what);
|
||||
App::abort(500, 'Cannot handle ' . $what);
|
||||
break;
|
||||
}
|
||||
|
||||
|
37
app/Http/Requests/NewUserFormRequest.php
Normal file
37
app/Http/Requests/NewUserFormRequest.php
Normal 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',
|
||||
];
|
||||
}
|
||||
}
|
@@ -28,10 +28,10 @@ class TagFormRequest extends Request
|
||||
public function rules()
|
||||
{
|
||||
$idRule = '';
|
||||
$tagRule = 'required|min:1|uniqueObjectForUser:tags,tag,TRUE';
|
||||
$tagRule = 'required|min:1|uniqueObjectForUser:tags,tag';
|
||||
if (Tag::find(Input::get('id'))) {
|
||||
$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 [
|
||||
|
@@ -36,14 +36,14 @@ Breadcrumbs::register(
|
||||
Breadcrumbs::register(
|
||||
'accounts.index', function (Generator $breadcrumbs, $what) {
|
||||
$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(
|
||||
'accounts.create', function (Generator $breadcrumbs, $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]));
|
||||
}
|
||||
);
|
||||
|
||||
@@ -54,13 +54,13 @@ Breadcrumbs::register(
|
||||
|
||||
|
||||
$breadcrumbs->parent('accounts.index', $what);
|
||||
$breadcrumbs->push(e($account->name), route('accounts.show', $account->id));
|
||||
$breadcrumbs->push(e($account->name), route('accounts.show', [$account->id]));
|
||||
}
|
||||
);
|
||||
Breadcrumbs::register(
|
||||
'accounts.delete', function (Generator $breadcrumbs, Account $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]));
|
||||
}
|
||||
);
|
||||
|
||||
@@ -70,7 +70,7 @@ Breadcrumbs::register(
|
||||
$breadcrumbs->parent('accounts.show', $account);
|
||||
$what = Config::get('firefly.shortNamesByFullName.' . $account->accountType->type);
|
||||
|
||||
$breadcrumbs->push(trans('breadcrumbs.edit_' . $what . '_account', ['name' => e($account->name)]), route('accounts.edit', $account->id));
|
||||
$breadcrumbs->push(trans('breadcrumbs.edit_' . $what . '_account', ['name' => e($account->name)]), route('accounts.edit', [$account->id]));
|
||||
}
|
||||
);
|
||||
|
||||
@@ -91,13 +91,13 @@ Breadcrumbs::register(
|
||||
Breadcrumbs::register(
|
||||
'budgets.edit', function (Generator $breadcrumbs, Budget $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(
|
||||
'budgets.delete', function (Generator $breadcrumbs, Budget $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]));
|
||||
}
|
||||
);
|
||||
|
||||
@@ -111,10 +111,10 @@ Breadcrumbs::register(
|
||||
Breadcrumbs::register(
|
||||
'budgets.show', function (Generator $breadcrumbs, Budget $budget, LimitRepetition $repetition = null) {
|
||||
$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)) {
|
||||
$breadcrumbs->push(
|
||||
Navigation::periodShow($repetition->startdate, $repetition->budgetlimit->repeat_freq), route('budgets.show', $budget->id, $repetition->id)
|
||||
Navigation::periodShow($repetition->startdate, $repetition->budgetLimit->repeat_freq), route('budgets.show', [$budget->id, $repetition->id])
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -137,20 +137,20 @@ Breadcrumbs::register(
|
||||
Breadcrumbs::register(
|
||||
'categories.edit', function (Generator $breadcrumbs, Category $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(
|
||||
'categories.delete', function (Generator $breadcrumbs, Category $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(
|
||||
'categories.show', function (Generator $breadcrumbs, Category $category) {
|
||||
$breadcrumbs->parent('categories.index');
|
||||
$breadcrumbs->push(e($category->name), route('categories.show', $category->id));
|
||||
$breadcrumbs->push(e($category->name), route('categories.show', [$category->id]));
|
||||
|
||||
}
|
||||
);
|
||||
@@ -173,13 +173,13 @@ Breadcrumbs::register(
|
||||
Breadcrumbs::register(
|
||||
'currency.edit', function (Generator $breadcrumbs, TransactionCurrency $currency) {
|
||||
$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(
|
||||
'currency.delete', function (Generator $breadcrumbs, TransactionCurrency $currency) {
|
||||
$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]));
|
||||
}
|
||||
);
|
||||
|
||||
@@ -201,20 +201,20 @@ Breadcrumbs::register(
|
||||
Breadcrumbs::register(
|
||||
'piggy-banks.edit', function (Generator $breadcrumbs, PiggyBank $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(
|
||||
'piggy-banks.delete', function (Generator $breadcrumbs, PiggyBank $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(
|
||||
'piggy-banks.show', function (Generator $breadcrumbs, PiggyBank $piggyBank) {
|
||||
$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]));
|
||||
|
||||
}
|
||||
);
|
||||
@@ -261,20 +261,20 @@ Breadcrumbs::register(
|
||||
Breadcrumbs::register(
|
||||
'bills.edit', function (Generator $breadcrumbs, Bill $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(
|
||||
'bills.delete', function (Generator $breadcrumbs, Bill $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(
|
||||
'bills.show', function (Generator $breadcrumbs, Bill $bill) {
|
||||
$breadcrumbs->parent('bills.index');
|
||||
$breadcrumbs->push(e($bill->name), route('bills.show', $bill->id));
|
||||
$breadcrumbs->push(e($bill->name), route('bills.show', [$bill->id]));
|
||||
|
||||
}
|
||||
);
|
||||
@@ -292,7 +292,7 @@ Breadcrumbs::register(
|
||||
Breadcrumbs::register(
|
||||
'reminders.show', function (Generator $breadcrumbs, Reminder $reminder) {
|
||||
$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]));
|
||||
|
||||
}
|
||||
);
|
||||
@@ -314,7 +314,7 @@ Breadcrumbs::register(
|
||||
} else {
|
||||
$title = trans('breadcrumbs.yearly_report', ['date' => $date->year]);
|
||||
}
|
||||
$breadcrumbs->push($title, route('reports.year', $date->year));
|
||||
$breadcrumbs->push($title, route('reports.year', [$date->year]));
|
||||
}
|
||||
);
|
||||
|
||||
@@ -344,26 +344,26 @@ Breadcrumbs::register(
|
||||
Breadcrumbs::register(
|
||||
'transactions.index', function (Generator $breadcrumbs, $what) {
|
||||
$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(
|
||||
'transactions.create', function (Generator $breadcrumbs, $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(
|
||||
'transactions.edit', function (Generator $breadcrumbs, TransactionJournal $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(
|
||||
'transactions.delete', function (Generator $breadcrumbs, TransactionJournal $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]));
|
||||
}
|
||||
);
|
||||
|
||||
@@ -371,7 +371,7 @@ Breadcrumbs::register(
|
||||
'transactions.show', function (Generator $breadcrumbs, TransactionJournal $journal) {
|
||||
|
||||
$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]));
|
||||
|
||||
}
|
||||
);
|
||||
@@ -394,14 +394,14 @@ Breadcrumbs::register(
|
||||
Breadcrumbs::register(
|
||||
'tags.edit', function (Generator $breadcrumbs, Tag $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(
|
||||
'tags.delete', function (Generator $breadcrumbs, Tag $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]));
|
||||
}
|
||||
);
|
||||
|
||||
@@ -409,6 +409,6 @@ Breadcrumbs::register(
|
||||
Breadcrumbs::register(
|
||||
'tags.show', function (Generator $breadcrumbs, Tag $tag) {
|
||||
$breadcrumbs->parent('tags.index');
|
||||
$breadcrumbs->push(e($tag->tag), route('tags.show', $tag->id));
|
||||
$breadcrumbs->push(e($tag->tag), route('tags.show', [$tag->id]));
|
||||
}
|
||||
);
|
||||
|
@@ -13,10 +13,9 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
|
||||
// models
|
||||
/** @noinspection PhpUnusedParameterInspection */
|
||||
Route::bind(
|
||||
'account',
|
||||
function ($value, $route) {
|
||||
function ($value) {
|
||||
if (Auth::check()) {
|
||||
$object = Account::leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
|
||||
->where('account_types.editable', 1)
|
||||
@@ -31,9 +30,8 @@ Route::bind(
|
||||
}
|
||||
);
|
||||
|
||||
/** @noinspection PhpUnusedParameterInspection */
|
||||
Route::bind(
|
||||
'tj', function ($value, $route) {
|
||||
'tj', function ($value) {
|
||||
if (Auth::check()) {
|
||||
$object = TransactionJournal::where('id', $value)->where('user_id', Auth::user()->id)->first();
|
||||
if ($object) {
|
||||
@@ -45,9 +43,8 @@ Route::bind(
|
||||
}
|
||||
);
|
||||
|
||||
/** @noinspection PhpUnusedParameterInspection */
|
||||
Route::bind(
|
||||
'currency', function ($value, $route) {
|
||||
'currency', function ($value) {
|
||||
if (Auth::check()) {
|
||||
$object = TransactionCurrency::find($value);
|
||||
if ($object) {
|
||||
@@ -58,9 +55,8 @@ Route::bind(
|
||||
}
|
||||
);
|
||||
|
||||
/** @noinspection PhpUnusedParameterInspection */
|
||||
Route::bind(
|
||||
'bill', function ($value, $route) {
|
||||
'bill', function ($value) {
|
||||
if (Auth::check()) {
|
||||
$object = Bill::where('id', $value)->where('user_id', Auth::user()->id)->first();
|
||||
if ($object) {
|
||||
@@ -72,9 +68,8 @@ Route::bind(
|
||||
}
|
||||
);
|
||||
|
||||
/** @noinspection PhpUnusedParameterInspection */
|
||||
Route::bind(
|
||||
'budget', function ($value, $route) {
|
||||
'budget', function ($value) {
|
||||
if (Auth::check()) {
|
||||
$object = Budget::where('id', $value)->where('user_id', Auth::user()->id)->first();
|
||||
if ($object) {
|
||||
@@ -86,9 +81,8 @@ Route::bind(
|
||||
}
|
||||
);
|
||||
|
||||
/** @noinspection PhpUnusedParameterInspection */
|
||||
Route::bind(
|
||||
'reminder', function ($value, $route) {
|
||||
'reminder', function ($value) {
|
||||
if (Auth::check()) {
|
||||
$object = Reminder::where('id', $value)->where('user_id', Auth::user()->id)->first();
|
||||
if ($object) {
|
||||
@@ -100,9 +94,8 @@ Route::bind(
|
||||
}
|
||||
);
|
||||
|
||||
/** @noinspection PhpUnusedParameterInspection */
|
||||
Route::bind(
|
||||
'limitrepetition', function ($value, $route) {
|
||||
'limitrepetition', function ($value) {
|
||||
if (Auth::check()) {
|
||||
$object = LimitRepetition::where('limit_repetitions.id', $value)
|
||||
->leftjoin('budget_limits', 'budget_limits.id', '=', 'limit_repetitions.budget_limit_id')
|
||||
@@ -118,9 +111,8 @@ Route::bind(
|
||||
}
|
||||
);
|
||||
|
||||
/** @noinspection PhpUnusedParameterInspection */
|
||||
Route::bind(
|
||||
'piggyBank', function ($value, $route) {
|
||||
'piggyBank', function ($value) {
|
||||
if (Auth::check()) {
|
||||
$object = PiggyBank::where('piggy_banks.id', $value)
|
||||
->leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')
|
||||
@@ -135,9 +127,8 @@ Route::bind(
|
||||
}
|
||||
);
|
||||
|
||||
/** @noinspection PhpUnusedParameterInspection */
|
||||
Route::bind(
|
||||
'category', function ($value, $route) {
|
||||
'category', function ($value) {
|
||||
if (Auth::check()) {
|
||||
$object = Category::where('id', $value)->where('user_id', Auth::user()->id)->first();
|
||||
if ($object) {
|
||||
@@ -151,7 +142,7 @@ Route::bind(
|
||||
|
||||
/** @noinspection PhpUnusedParameterInspection */
|
||||
Route::bind(
|
||||
'reminder', function ($value, $route) {
|
||||
'reminder', function ($value) {
|
||||
if (Auth::check()) {
|
||||
/** @var \FireflyIII\Models\Reminder $object */
|
||||
$object = Reminder::find($value);
|
||||
@@ -166,9 +157,8 @@ Route::bind(
|
||||
}
|
||||
);
|
||||
|
||||
/** @noinspection PhpUnusedParameterInspection */
|
||||
Route::bind(
|
||||
'tag', function ($value, $route) {
|
||||
'tag', function ($value) {
|
||||
if (Auth::check()) {
|
||||
$object = Tag::where('id', $value)->where('user_id', Auth::user()->id)->first();
|
||||
if ($object) {
|
||||
@@ -193,14 +183,12 @@ Route::controllers(
|
||||
]
|
||||
);
|
||||
|
||||
Route::get('/routes', ['uses' => 'HomeController@routes', 'as' => 'routes']);
|
||||
|
||||
/**
|
||||
* Home Controller
|
||||
*/
|
||||
Route::group(
|
||||
['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::post('/daterange', ['uses' => 'HomeController@dateRange', 'as' => 'daterange']);
|
||||
Route::get('/flush', ['uses' => 'HomeController@flush', 'as' => 'flush']);
|
||||
@@ -327,6 +315,12 @@ Route::group(
|
||||
Route::get('/json/box/bills-paid', ['uses' => 'JsonController@boxBillsPaid', 'as' => 'json.box.unpaid']);
|
||||
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
|
||||
*/
|
||||
|
@@ -11,6 +11,42 @@ use Watson\Validating\ValidatingTrait;
|
||||
* Class Account
|
||||
*
|
||||
* @package FireflyIII\Models
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property \Carbon\Carbon $deleted_at
|
||||
* @property integer $user_id
|
||||
* @property integer $account_type_id
|
||||
* @property string $name
|
||||
* @property boolean $active
|
||||
* @property boolean $encrypted
|
||||
* @property float $virtual_balance
|
||||
* @property string $virtual_balance_encrypted
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\AccountMeta[] $accountMeta
|
||||
* @property-read \FireflyIII\Models\AccountType $accountType
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\PiggyBank[] $piggyBanks
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Transaction[] $transactions
|
||||
* @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 whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Account whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Account whereDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Account whereUserId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Account whereAccountTypeId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Account whereName($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Account whereActive($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Account whereEncrypted($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Account whereVirtualBalance($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Account whereVirtualBalanceEncrypted($value)
|
||||
* @method static \FireflyIII\Models\Account accountTypeIn($types)
|
||||
* @method static \FireflyIII\Models\Account hasMetaValue($name, $value)
|
||||
* @property boolean joinedAccountTypes
|
||||
* @property mixed startBalance
|
||||
* @property mixed endBalance
|
||||
* @property mixed lastActivityDate
|
||||
* @property mixed piggyBalance
|
||||
* @property mixed difference
|
||||
* @property mixed percentage
|
||||
*/
|
||||
class Account extends Model
|
||||
{
|
||||
@@ -100,7 +136,7 @@ class Account extends Model
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
* @return array
|
||||
* @return string[]
|
||||
*/
|
||||
public function getDates()
|
||||
{
|
||||
@@ -109,7 +145,7 @@ class Account extends Model
|
||||
|
||||
/**
|
||||
*
|
||||
* @param $fieldName
|
||||
* @param string $fieldName
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
|
@@ -8,6 +8,19 @@ use Watson\Validating\ValidatingTrait;
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
* @package FireflyIII\Models
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $account_id
|
||||
* @property string $name
|
||||
* @property string $data
|
||||
* @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 whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\AccountMeta whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\AccountMeta whereAccountId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\AccountMeta whereName($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\AccountMeta whereData($value)
|
||||
*/
|
||||
class AccountMeta extends Model
|
||||
{
|
||||
|
@@ -7,6 +7,17 @@ use Illuminate\Database\Eloquent\Model;
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
* @package FireflyIII\Models
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property string $type
|
||||
* @property boolean $editable
|
||||
* @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 whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\AccountType whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\AccountType whereType($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\AccountType whereEditable($value)
|
||||
*/
|
||||
class AccountType extends Model
|
||||
{
|
||||
|
@@ -4,10 +4,48 @@ use Crypt;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
* Class Bill
|
||||
* FireflyIII\Models\Bill
|
||||
*
|
||||
* @package FireflyIII\Models
|
||||
* @codeCoverageIgnore Class Bill
|
||||
* @package FireflyIII\Models
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $user_id
|
||||
* @property string $name
|
||||
* @property string $match
|
||||
* @property float $amount_min
|
||||
* @property string $amount_min_encrypted
|
||||
* @property float $amount_max
|
||||
* @property string $amount_max_encrypted
|
||||
* @property \Carbon\Carbon $date
|
||||
* @property boolean $active
|
||||
* @property boolean $automatch
|
||||
* @property string $repeat_freq
|
||||
* @property integer $skip
|
||||
* @property boolean $name_encrypted
|
||||
* @property boolean $match_encrypted
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\TransactionJournal[] $transactionjournals
|
||||
* @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 whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Bill whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Bill whereUserId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Bill whereName($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Bill whereMatch($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Bill whereAmountMin($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Bill whereAmountMinEncrypted($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Bill whereAmountMax($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Bill whereAmountMaxEncrypted($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Bill whereDate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Bill whereActive($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Bill whereAutomatch($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Bill whereRepeatFreq($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 whereMatchEncrypted($value)
|
||||
* @property mixed nextExpectedMatch
|
||||
* @property mixed lastFoundMatch
|
||||
*/
|
||||
class Bill extends Model
|
||||
{
|
||||
@@ -17,6 +55,7 @@ class Bill extends Model
|
||||
|
||||
protected $hidden = ['amount_min_encrypted', 'amount_max_encrypted', 'name_encrypted', 'match_encrypted'];
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
|
@@ -9,6 +9,25 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
* @package FireflyIII\Models
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property \Carbon\Carbon $deleted_at
|
||||
* @property string $name
|
||||
* @property integer $user_id
|
||||
* @property boolean $active
|
||||
* @property boolean $encrypted
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\BudgetLimit[] $budgetlimits
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\TransactionJournal[] $transactionjournals
|
||||
* @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 whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Budget whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Budget whereDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Budget whereName($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Budget whereUserId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Budget whereActive($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Budget whereEncrypted($value)
|
||||
*/
|
||||
class Budget extends Model
|
||||
{
|
||||
|
@@ -7,6 +7,26 @@ use Illuminate\Database\Eloquent\Model;
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
* @package FireflyIII\Models
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $budget_id
|
||||
* @property \Carbon\Carbon $startdate
|
||||
* @property float $amount
|
||||
* @property string $amount_encrypted
|
||||
* @property boolean $repeats
|
||||
* @property string $repeat_freq
|
||||
* @property-read \FireflyIII\Models\Budget $budget
|
||||
* @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 whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\BudgetLimit whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\BudgetLimit whereBudgetId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\BudgetLimit whereStartdate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\BudgetLimit whereAmount($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\BudgetLimit whereAmountEncrypted($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\BudgetLimit whereRepeats($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\BudgetLimit whereRepeatFreq($value)
|
||||
*/
|
||||
class BudgetLimit extends Model
|
||||
{
|
||||
|
@@ -7,8 +7,25 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
/**
|
||||
* Class Category
|
||||
*
|
||||
*
|
||||
* @package FireflyIII\Models
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property \Carbon\Carbon $deleted_at
|
||||
* @property string $name
|
||||
* @property integer $user_id
|
||||
* @property boolean $encrypted
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\TransactionJournal[] $transactionjournals
|
||||
* @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 whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Category whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Category whereDeletedAt($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 whereEncrypted($value)
|
||||
* @property mixed spent
|
||||
* @property mixed lastActivity
|
||||
*/
|
||||
class Category extends Model
|
||||
{
|
||||
@@ -21,7 +38,7 @@ class Category extends Model
|
||||
* @param array $fields
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
*
|
||||
* @return Account|null
|
||||
* @return Category
|
||||
*/
|
||||
public static function firstOrCreateEncrypted(array $fields)
|
||||
{
|
||||
@@ -48,7 +65,7 @@ class Category extends Model
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
* @return array
|
||||
* @return string[]
|
||||
*/
|
||||
public function getDates()
|
||||
{
|
||||
|
@@ -8,6 +8,20 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
* @package FireflyIII\Models
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property \Carbon\Carbon $deleted_at
|
||||
* @property string $name
|
||||
* @property integer $user_id
|
||||
* @property string $class
|
||||
* @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 whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Component whereDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Component whereName($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Component whereUserId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Component whereClass($value)
|
||||
*/
|
||||
class Component extends Model
|
||||
{
|
||||
|
@@ -6,8 +6,24 @@ use Illuminate\Database\Eloquent\Model;
|
||||
* Class LimitRepetition
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @package FireflyIII\Models
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $budget_limit_id
|
||||
* @property \Carbon\Carbon $startdate
|
||||
* @property \Carbon\Carbon $enddate
|
||||
* @property float $amount
|
||||
* @property string $amount_encrypted
|
||||
* @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 whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\LimitRepetition whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\LimitRepetition whereBudgetLimitId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\LimitRepetition whereStartdate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\LimitRepetition whereEnddate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\LimitRepetition whereAmount($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\LimitRepetition whereAmountEncrypted($value)
|
||||
*/
|
||||
class LimitRepetition extends Model
|
||||
{
|
||||
|
27
app/Models/Permission.php
Normal file
27
app/Models/Permission.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace FireflyIII\Models;
|
||||
|
||||
use Zizaco\Entrust\EntrustPermission;
|
||||
|
||||
/**
|
||||
* Class Permission
|
||||
*
|
||||
* @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
|
||||
{
|
||||
}
|
@@ -8,8 +8,42 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
* Class PiggyBank
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @package FireflyIII\Models
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property \Carbon\Carbon $deleted_at
|
||||
* @property integer $account_id
|
||||
* @property string $name
|
||||
* @property float $targetamount
|
||||
* @property string $targetamount_encrypted
|
||||
* @property \Carbon\Carbon $startdate
|
||||
* @property \Carbon\Carbon $targetdate
|
||||
* @property string $reminder
|
||||
* @property integer $reminder_skip
|
||||
* @property boolean $remind_me
|
||||
* @property integer $order
|
||||
* @property boolean $encrypted
|
||||
* @property-read \FireflyIII\Models\Account $account
|
||||
* @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\Reminder[] $reminders
|
||||
* @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 whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBank whereDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBank whereAccountId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBank whereName($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBank whereTargetamount($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBank whereTargetamountEncrypted($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBank whereStartdate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBank whereTargetdate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBank whereReminder($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBank whereReminderSkip($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 whereEncrypted($value)
|
||||
* @property PiggyBankRepetition currentRep
|
||||
*/
|
||||
class PiggyBank extends Model
|
||||
{
|
||||
@@ -55,7 +89,7 @@ class PiggyBank extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @return string[]
|
||||
*/
|
||||
public function getDates()
|
||||
{
|
||||
@@ -82,7 +116,7 @@ class PiggyBank extends Model
|
||||
*
|
||||
* @param $value
|
||||
*
|
||||
* @return int
|
||||
* @return boolean
|
||||
*/
|
||||
public function getRemindMeAttribute($value)
|
||||
{
|
||||
|
@@ -6,8 +6,25 @@ use Illuminate\Database\Eloquent\Model;
|
||||
* Class PiggyBankEvent
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @package FireflyIII\Models
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $piggy_bank_id
|
||||
* @property integer $transaction_journal_id
|
||||
* @property \Carbon\Carbon $date
|
||||
* @property float $amount
|
||||
* @property string $amount_encrypted
|
||||
* @property-read \FireflyIII\Models\PiggyBank $piggyBank
|
||||
* @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 whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBankEvent whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBankEvent wherePiggyBankId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBankEvent whereTransactionJournalId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBankEvent whereDate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBankEvent whereAmount($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBankEvent whereAmountEncrypted($value)
|
||||
*/
|
||||
class PiggyBankEvent extends Model
|
||||
{
|
||||
|
@@ -9,6 +9,25 @@ use Illuminate\Database\Eloquent\Model;
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
* @package FireflyIII\Models
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $piggy_bank_id
|
||||
* @property \Carbon\Carbon $startdate
|
||||
* @property \Carbon\Carbon $targetdate
|
||||
* @property float $currentamount
|
||||
* @property string $currentamount_encrypted
|
||||
* @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 whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBankRepetition whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBankRepetition wherePiggyBankId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBankRepetition whereStartdate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBankRepetition whereTargetdate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBankRepetition whereCurrentamount($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBankRepetition whereCurrentamountEncrypted($value)
|
||||
* @method static \FireflyIII\Models\PiggyBankRepetition onDates($start, $target)
|
||||
* @method static \FireflyIII\Models\PiggyBankRepetition relevantOnDate($date)
|
||||
*/
|
||||
class PiggyBankRepetition extends Model
|
||||
{
|
||||
|
@@ -8,6 +8,23 @@ use Illuminate\Database\Eloquent\Model;
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
* @package FireflyIII\Models
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $user_id
|
||||
* @property string $name
|
||||
* @property string $name_encrypted
|
||||
* @property string $data
|
||||
* @property string $data_encrypted
|
||||
* @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 whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Preference whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Preference whereUserId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Preference whereName($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Preference whereNameEncrypted($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Preference whereData($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Preference whereDataEncrypted($value)
|
||||
*/
|
||||
class Preference extends Model
|
||||
{
|
||||
@@ -38,21 +55,6 @@ class Preference extends Model
|
||||
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
|
||||
*/
|
||||
@@ -62,15 +64,6 @@ class Preference extends Model
|
||||
$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
|
||||
*/
|
||||
|
@@ -9,8 +9,36 @@ use Illuminate\Database\Eloquent\Model;
|
||||
* Class Reminder
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @package FireflyIII\Models
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $user_id
|
||||
* @property \Carbon\Carbon $startdate
|
||||
* @property \Carbon\Carbon $enddate
|
||||
* @property boolean $active
|
||||
* @property boolean $notnow
|
||||
* @property integer $remindersable_id
|
||||
* @property string $remindersable_type
|
||||
* @property string $metadata
|
||||
* @property boolean $encrypted
|
||||
* @property-read \ $remindersable
|
||||
* @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 whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Reminder whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Reminder whereUserId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Reminder whereStartdate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Reminder whereEnddate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Reminder whereActive($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Reminder whereNotnow($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Reminder whereRemindersableId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Reminder whereRemindersableType($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Reminder whereMetadata($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 today()
|
||||
* @property string description
|
||||
*/
|
||||
class Reminder extends Model
|
||||
{
|
||||
|
28
app/Models/Role.php
Normal file
28
app/Models/Role.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
namespace FireflyIII\Models;
|
||||
|
||||
|
||||
use Zizaco\Entrust\EntrustRole;
|
||||
|
||||
/**
|
||||
* Class Role
|
||||
*
|
||||
* @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
|
||||
{
|
||||
}
|
@@ -10,6 +10,32 @@ use Watson\Validating\ValidatingTrait;
|
||||
* Class Tag
|
||||
*
|
||||
* @package FireflyIII\Models
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property string $deleted_at
|
||||
* @property integer $user_id
|
||||
* @property string $tag
|
||||
* @property string $tagMode
|
||||
* @property \Carbon\Carbon $date
|
||||
* @property string $description
|
||||
* @property float $latitude
|
||||
* @property float $longitude
|
||||
* @property integer $zoomLevel
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\TransactionJournal[] $transactionjournals
|
||||
* @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 whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Tag whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Tag whereDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Tag whereUserId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Tag whereTag($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Tag whereTagMode($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Tag whereDate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Tag whereDescription($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Tag whereLatitude($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Tag whereLongitude($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Tag whereZoomLevel($value)
|
||||
*/
|
||||
class Tag extends Model
|
||||
{
|
||||
@@ -18,7 +44,7 @@ class Tag extends Model
|
||||
protected $fillable = ['user_id', 'tag', 'date', 'description', 'longitude', 'latitude', 'zoomLevel', 'tagMode'];
|
||||
protected $rules
|
||||
= [
|
||||
'tag' => 'required|min:1|uniqueObjectForUser:tags,tag,TRUE',
|
||||
'tag' => 'required|min:1',
|
||||
'description' => 'min:1',
|
||||
'date' => 'date',
|
||||
'latitude' => 'numeric|min:-90|max:90',
|
||||
@@ -63,7 +89,7 @@ class Tag extends Model
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
* @return array
|
||||
* @return string[]
|
||||
*/
|
||||
public function getDates()
|
||||
{
|
||||
|
@@ -11,6 +11,30 @@ use Watson\Validating\ValidatingTrait;
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
* @package FireflyIII\Models
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property \Carbon\Carbon $deleted_at
|
||||
* @property integer $account_id
|
||||
* @property integer $transaction_journal_id
|
||||
* @property string $description
|
||||
* @property float $amount
|
||||
* @property string $amount_encrypted
|
||||
* @property-read \FireflyIII\Models\Account $account
|
||||
* @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 whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Transaction whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Transaction whereDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Transaction whereAccountId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Transaction whereTransactionJournalId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Transaction whereDescription($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Transaction whereAmount($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Transaction whereAmountEncrypted($value)
|
||||
* @method static \FireflyIII\Models\Transaction after($date)
|
||||
* @method static \FireflyIII\Models\Transaction before($date)
|
||||
* @property mixed before
|
||||
* @property mixed after
|
||||
*/
|
||||
class Transaction extends Model
|
||||
{
|
||||
|
@@ -4,11 +4,25 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class TransactionCurrency
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
* @package FireflyIII\Models
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property \Carbon\Carbon $deleted_at
|
||||
* @property string $code
|
||||
* @property string $name
|
||||
* @property string $symbol
|
||||
* @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 whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionCurrency whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionCurrency whereDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionCurrency whereCode($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionCurrency whereName($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionCurrency whereSymbol($value)
|
||||
*/
|
||||
class TransactionCurrency extends Model
|
||||
{
|
||||
|
@@ -8,6 +8,20 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
* @package FireflyIII\Models
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property \Carbon\Carbon $deleted_at
|
||||
* @property integer $user_id
|
||||
* @property string $relation
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\TransactionJournal[] $transactionjournals
|
||||
* @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 whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionGroup whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionGroup whereDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionGroup whereUserId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionGroup whereRelation($value)
|
||||
*/
|
||||
class TransactionGroup extends Model
|
||||
{
|
||||
|
@@ -2,6 +2,7 @@
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Crypt;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
@@ -12,6 +13,65 @@ use Watson\Validating\ValidatingTrait;
|
||||
* Class TransactionJournal
|
||||
*
|
||||
* @package FireflyIII\Models
|
||||
* @SuppressWarnings (PHPMD.TooManyMethods)
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property \Carbon\Carbon $deleted_at
|
||||
* @property integer $user_id
|
||||
* @property integer $transaction_type_id
|
||||
* @property integer $bill_id
|
||||
* @property integer $transaction_currency_id
|
||||
* @property string $description
|
||||
* @property boolean $completed
|
||||
* @property \Carbon\Carbon $date
|
||||
* @property boolean $encrypted
|
||||
* @property integer $order
|
||||
* @property-read \FireflyIII\Models\Bill $bill
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Budget[] $budgets
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Category[] $categories
|
||||
* @property-read mixed $actual_amount
|
||||
* @property-read mixed $amount
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Tag[] $tags
|
||||
* @property-read mixed $asset_account
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Transaction[] $transactions
|
||||
* @property-read mixed $corrected_actual_amount
|
||||
* @property-read mixed $destination_account
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\PiggyBankEvent[] $piggyBankEvents
|
||||
* @property-read \FireflyIII\Models\TransactionCurrency $transactionCurrency
|
||||
* @property-read \FireflyIII\Models\TransactionType $transactionType
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\TransactionGroup[] $transactiongroups
|
||||
* @property-read \FireflyIII\User $user
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionJournal whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionJournal whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionJournal whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionJournal whereDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionJournal whereUserId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionJournal whereTransactionTypeId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionJournal whereBillId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionJournal whereTransactionCurrencyId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionJournal whereDescription($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionJournal whereCompleted($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionJournal whereDate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionJournal whereEncrypted($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionJournal whereOrder($value)
|
||||
* @method static \FireflyIII\Models\TransactionJournal accountIs($account)
|
||||
* @method static \FireflyIII\Models\TransactionJournal after($date)
|
||||
* @method static \FireflyIII\Models\TransactionJournal before($date)
|
||||
* @method static \FireflyIII\Models\TransactionJournal onDate($date)
|
||||
* @method static \FireflyIII\Models\TransactionJournal transactionTypes($types)
|
||||
* @method static \FireflyIII\Models\TransactionJournal withRelevantData()
|
||||
* @property-read mixed $expense_account
|
||||
* @property string account_encrypted
|
||||
* @property bool joinedTransactions
|
||||
* @property bool joinedTransactionTypes
|
||||
* @property mixed account_id
|
||||
* @property mixed name
|
||||
* @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
|
||||
{
|
||||
@@ -79,6 +139,13 @@ class TransactionJournal extends Model
|
||||
*/
|
||||
public function getAmountAttribute()
|
||||
{
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($this->id);
|
||||
$cache->addProperty('amount');
|
||||
if ($cache->has()) {
|
||||
return $cache->get(); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
$amount = '0';
|
||||
bcscale(2);
|
||||
/** @var Transaction $t */
|
||||
@@ -87,51 +154,61 @@ class TransactionJournal extends Model
|
||||
$amount = $t->amount;
|
||||
}
|
||||
}
|
||||
$count = $this->tags->count();
|
||||
|
||||
/*
|
||||
* If the journal has tags, it gets complicated.
|
||||
*/
|
||||
if ($this->tags->count() == 0) {
|
||||
return $amount;
|
||||
if ($count === 1) {
|
||||
// get amount for single tag:
|
||||
$amount = $this->amountByTag($this->tags()->first(), $amount);
|
||||
}
|
||||
|
||||
// if journal is part of advancePayment AND journal is a withdrawal,
|
||||
// then journal is being repaid by other journals, so the actual amount will lower:
|
||||
/** @var Tag $advancePayment */
|
||||
$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->actualAmount);
|
||||
}
|
||||
if ($count > 1) {
|
||||
// get amount for either tag.
|
||||
$amount = $this->amountByTags($amount);
|
||||
|
||||
return $amount;
|
||||
}
|
||||
$cache->store($amount);
|
||||
|
||||
// if this journal is part of an advancePayment AND the journal is a deposit,
|
||||
// then the journal amount is correcting a withdrawal, and the amount is zero:
|
||||
if ($advancePayment && $this->transactionType->type == 'Deposit') {
|
||||
return '0';
|
||||
}
|
||||
return $amount;
|
||||
|
||||
}
|
||||
|
||||
// is balancing act?
|
||||
$balancingAct = $this->tags()->where('tagMode', 'balancingAct')->first();
|
||||
|
||||
if ($balancingAct) {
|
||||
// this is the expense:
|
||||
/**
|
||||
* Assuming the journal has only one tag. Parameter amount is used as fallback.
|
||||
*
|
||||
* @param Tag $tag
|
||||
* @param string $amount
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function amountByTag(Tag $tag, $amount)
|
||||
{
|
||||
if ($tag->tagMode == 'advancePayment') {
|
||||
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) {
|
||||
$amount = bcsub($amount, $transfer->actualAmount);
|
||||
$amount = bcsub($amount, $transfer->actual_amount);
|
||||
|
||||
return $amount;
|
||||
}
|
||||
} // @codeCoverageIgnore
|
||||
} // @codeCoverageIgnore
|
||||
}
|
||||
}
|
||||
|
||||
return $amount;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,26 +221,39 @@ class TransactionJournal extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Account
|
||||
* @param string $amount
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAssetAccountAttribute()
|
||||
public function amountByTags($amount)
|
||||
{
|
||||
$positive = true; // the asset account is in the transaction with the positive amount.
|
||||
if ($this->transactionType->type === 'Withdrawal') {
|
||||
$positive = false;
|
||||
}
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($this->transactions()->get() as $transaction) {
|
||||
if (floatval($transaction->amount) > 0 && $positive === true) {
|
||||
return $transaction->account;
|
||||
}
|
||||
if (floatval($transaction->amount) < 0 && $positive === false) {
|
||||
return $transaction->account;
|
||||
}
|
||||
|
||||
$firstBalancingAct = $this->tags()->where('tagMode', 'balancingAct')->first();
|
||||
if ($firstBalancingAct) {
|
||||
return $this->amountByTag($firstBalancingAct, $amount);
|
||||
}
|
||||
|
||||
return $this->transactions()->first()->account;
|
||||
$firstAdvancePayment = $this->tags()->where('tagMode', 'advancePayment')->first();
|
||||
if ($firstAdvancePayment) {
|
||||
return $this->amountByTag($firstAdvancePayment, $amount);
|
||||
}
|
||||
|
||||
return $amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCorrectAmountAttribute()
|
||||
{
|
||||
|
||||
switch ($this->transactionType->type) {
|
||||
case 'Deposit':
|
||||
return $this->transactions()->where('amount', '>', 0)->first()->amount;
|
||||
case 'Withdrawal':
|
||||
return $this->transactions()->where('amount', '<', 0)->first()->amount;
|
||||
}
|
||||
|
||||
return $this->transactions()->where('amount', '>', 0)->first()->amount;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -175,31 +265,9 @@ class TransactionJournal extends Model
|
||||
return $this->hasMany('FireflyIII\Models\Transaction');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getCorrectedActualAmountAttribute()
|
||||
{
|
||||
$amount = '0';
|
||||
$type = $this->transactionType->type;
|
||||
/** @var Transaction $t */
|
||||
foreach ($this->transactions as $t) {
|
||||
if ($t->amount > 0 && $type != 'Withdrawal') {
|
||||
$amount = $t->amount;
|
||||
break;
|
||||
}
|
||||
if ($t->amount < 0 && $type == 'Withdrawal') {
|
||||
$amount = $t->amount;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
* @return array
|
||||
* @return string[]
|
||||
*/
|
||||
public function getDates()
|
||||
{
|
||||
@@ -227,14 +295,35 @@ class TransactionJournal extends Model
|
||||
*/
|
||||
public function getDestinationAccountAttribute()
|
||||
{
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($this->transactions()->get() as $transaction) {
|
||||
if (floatval($transaction->amount) > 0) {
|
||||
return $transaction->account;
|
||||
}
|
||||
}
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty($this->id);
|
||||
$cache->addProperty('destinationAccount');
|
||||
|
||||
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
|
||||
*/
|
||||
public function getSourceAccountAttribute()
|
||||
{
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty($this->id);
|
||||
$cache->addProperty('destinationAccount');
|
||||
if ($cache->has()) {
|
||||
return $cache->get(); // @codeCoverageIgnore
|
||||
}
|
||||
$account = $this->transactions()->where('amount', '<', 0)->first()->account;
|
||||
|
||||
$cache->store($account);
|
||||
|
||||
return $account;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -267,7 +356,7 @@ class TransactionJournal extends Model
|
||||
* @param EloquentBuilder $query
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return mixed
|
||||
* @return EloquentBuilder
|
||||
*/
|
||||
public function scopeAfter(EloquentBuilder $query, Carbon $date)
|
||||
{
|
||||
@@ -280,7 +369,7 @@ class TransactionJournal extends Model
|
||||
* @param EloquentBuilder $query
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return mixed
|
||||
* @return EloquentBuilder
|
||||
*/
|
||||
public function scopeBefore(EloquentBuilder $query, Carbon $date)
|
||||
{
|
||||
@@ -293,7 +382,7 @@ class TransactionJournal extends Model
|
||||
* @param EloquentBuilder $query
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return mixed
|
||||
* @return EloquentBuilder
|
||||
*/
|
||||
public function scopeOnDate(EloquentBuilder $query, Carbon $date)
|
||||
{
|
||||
|
@@ -8,6 +8,17 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
* @package FireflyIII\Models
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property \Carbon\Carbon $deleted_at
|
||||
* @property string $type
|
||||
* @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 whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionType whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionType whereDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionType whereType($value)
|
||||
*/
|
||||
class TransactionType extends Model
|
||||
{
|
||||
|
@@ -53,10 +53,13 @@ class EventServiceProvider extends ServiceProvider
|
||||
$this->registerCreateEvents();
|
||||
BudgetLimit::saved(
|
||||
function (BudgetLimit $budgetLimit) {
|
||||
Log::debug('Saved!');
|
||||
|
||||
$end = Navigation::addPeriod(clone $budgetLimit->startdate, $budgetLimit->repeat_freq, 0);
|
||||
$end->subDay();
|
||||
$set = $budgetLimit->limitrepetitions()->where('startdate', $budgetLimit->startdate->format('Y-m-d'))->where('enddate', $end->format('Y-m-d'))
|
||||
$set = $budgetLimit->limitrepetitions()
|
||||
->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) {
|
||||
$repetition = new LimitRepetition;
|
||||
@@ -68,8 +71,7 @@ class EventServiceProvider extends ServiceProvider
|
||||
try {
|
||||
$repetition->save();
|
||||
} catch (QueryException $e) {
|
||||
Log::error('Trying to save new LimitRepetition failed!');
|
||||
Log::error($e->getMessage());
|
||||
Log::error('Trying to save new LimitRepetition failed: ' . $e->getMessage()); // @codeCoverageIgnore
|
||||
}
|
||||
} else {
|
||||
if ($set->count() == 1) {
|
||||
|
@@ -15,6 +15,7 @@ use FireflyIII\Models\Preference;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
@@ -25,6 +26,8 @@ use Steam;
|
||||
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.TooManyMethods)
|
||||
*
|
||||
* Class AccountRepository
|
||||
*
|
||||
* @package FireflyIII\Repositories\Account
|
||||
@@ -107,12 +110,22 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
*/
|
||||
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 == []) {
|
||||
$accounts = Auth::user()->accounts()->accountTypeIn(['Default account', 'Asset account'])->orderBy('accounts.name', 'ASC')->get(['accounts.*']);
|
||||
} else {
|
||||
$accounts = Auth::user()->accounts()->whereIn('id', $preference->data)->orderBy('accounts.name', 'ASC')->get(['accounts.*']);
|
||||
}
|
||||
|
||||
$cache->store($accounts);
|
||||
|
||||
return $accounts;
|
||||
}
|
||||
|
||||
@@ -129,7 +142,15 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
*/
|
||||
public function getFrontpageTransactions(Account $account, Carbon $start, Carbon $end)
|
||||
{
|
||||
return Auth::user()
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($account->id);
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
if ($cache->has()) {
|
||||
return $cache->get(); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
$set = Auth::user()
|
||||
->transactionjournals()
|
||||
->with(['transactions'])
|
||||
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
@@ -142,6 +163,9 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
->orderBy('transaction_journals.id', 'DESC')
|
||||
->take(10)
|
||||
->get(['transaction_journals.*', 'transaction_currencies.symbol', 'transaction_types.type']);
|
||||
$cache->store($set);
|
||||
|
||||
return $set;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -205,6 +229,13 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
$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);
|
||||
if (count($ids) > 0) {
|
||||
$accounts = Auth::user()->accounts()->whereIn('id', $ids)->get();
|
||||
@@ -229,6 +260,8 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
}
|
||||
);
|
||||
|
||||
$cache->store($accounts);
|
||||
|
||||
return $accounts;
|
||||
|
||||
}
|
||||
@@ -306,7 +339,9 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
if ($journal->destination_account->id == $account->id) {
|
||||
return $journal;
|
||||
}
|
||||
} // @codeCoverageIgnore
|
||||
|
||||
return null;
|
||||
}
|
||||
);
|
||||
|
||||
return $filtered;
|
||||
@@ -338,16 +373,17 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
*/
|
||||
public function openingBalanceTransaction(Account $account)
|
||||
{
|
||||
return TransactionJournal::accountIs($account)
|
||||
->orderBy('transaction_journals.date', 'ASC')
|
||||
->orderBy('created_at', 'ASC')
|
||||
->first(['transaction_journals.*']);
|
||||
return TransactionJournal
|
||||
::orderBy('transaction_journals.date', 'ASC')
|
||||
->accountIs($account)
|
||||
->orderBy('created_at', 'ASC')
|
||||
->first(['transaction_journals.*']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return Account;
|
||||
* @return Account
|
||||
*/
|
||||
public function store(array $data)
|
||||
{
|
||||
@@ -359,11 +395,11 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
if ($data['openingBalance'] != 0) {
|
||||
$type = $data['openingBalance'] < 0 ? 'expense' : 'revenue';
|
||||
$opposingData = [
|
||||
'user' => $data['user'],
|
||||
'accountType' => $type,
|
||||
'virtual_balance' => $data['virtualBalance'],
|
||||
'name' => $data['name'] . ' initial balance',
|
||||
'active' => false,
|
||||
'user' => $data['user'],
|
||||
'accountType' => $type,
|
||||
'virtualBalance' => 0,
|
||||
'name' => $data['name'] . ' initial balance',
|
||||
'active' => false,
|
||||
];
|
||||
$opposing = $this->storeAccount($opposingData);
|
||||
$this->storeInitialBalance($newAccount, $opposing, $data);
|
||||
@@ -398,7 +434,6 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
|
||||
// update meta data:
|
||||
$this->updateMetadata($account, $data);
|
||||
|
||||
$openingBalance = $this->openingBalanceTransaction($account);
|
||||
|
||||
// if has openingbalance?
|
||||
@@ -411,20 +446,19 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
// create new opening balance.
|
||||
$type = $data['openingBalance'] < 0 ? 'expense' : 'revenue';
|
||||
$opposingData = [
|
||||
'user' => $data['user'],
|
||||
'accountType' => $type,
|
||||
'name' => $data['name'] . ' initial balance',
|
||||
'active' => false,
|
||||
'user' => $data['user'],
|
||||
'accountType' => $type,
|
||||
'name' => $data['name'] . ' initial balance',
|
||||
'active' => false,
|
||||
'virtualBalance' => 0,
|
||||
];
|
||||
$opposing = $this->storeAccount($opposingData);
|
||||
$this->storeInitialBalance($account, $opposing, $data);
|
||||
}
|
||||
|
||||
} else {
|
||||
// opening balance is zero, should we delete it?
|
||||
if ($openingBalance) {
|
||||
// delete existing opening balance.
|
||||
$openingBalance->delete();
|
||||
if ($openingBalance) { // opening balance is zero, should we delete it?
|
||||
$openingBalance->delete(); // delete existing opening balance.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -445,6 +479,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
'user_id' => $data['user'],
|
||||
'account_type_id' => $accountType->id,
|
||||
'name' => $data['name'],
|
||||
'virtual_balance' => $data['virtualBalance'],
|
||||
'active' => $data['active'] === true ? true : false,
|
||||
]
|
||||
);
|
||||
@@ -454,6 +489,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
$searchData = [
|
||||
'user_id' => $data['user'],
|
||||
'account_type_id' => $accountType->id,
|
||||
'virtual_balance' => $data['virtualBalance'],
|
||||
'name' => $data['name']
|
||||
];
|
||||
$existingAccount = Account::firstOrNullEncrypted($searchData);
|
||||
|
@@ -5,13 +5,10 @@ namespace FireflyIII\Repositories\Bill;
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
use DB;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Navigation;
|
||||
|
||||
/**
|
||||
@@ -28,7 +25,7 @@ class BillRepository implements BillRepositoryInterface
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return float
|
||||
* @return integer
|
||||
*/
|
||||
public function billPaymentsInRange(Bill $bill, Carbon $start, Carbon $end)
|
||||
{
|
||||
@@ -70,7 +67,7 @@ class BillRepository implements BillRepositoryInterface
|
||||
/**
|
||||
* @param Bill $bill
|
||||
*
|
||||
* @return mixed
|
||||
* @return boolean|null
|
||||
*/
|
||||
public function destroy(Bill $bill)
|
||||
{
|
||||
@@ -212,7 +209,7 @@ class BillRepository implements BillRepositoryInterface
|
||||
/**
|
||||
* @param Bill $bill
|
||||
*
|
||||
* @return Carbon
|
||||
* @return \Carbon\Carbon
|
||||
*/
|
||||
public function nextExpectedMatch(Bill $bill)
|
||||
{
|
||||
@@ -244,7 +241,7 @@ class BillRepository implements BillRepositoryInterface
|
||||
$end = Navigation::endOfPeriod(clone $start, $bill->repeat_freq);
|
||||
$journalCount = $bill->transactionjournals()->before($end)->after($start)->count();
|
||||
if ($journalCount == 0) {
|
||||
$finalDate = clone $start;
|
||||
$finalDate = new Carbon($start->format('Y-m-d'));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -261,77 +258,32 @@ class BillRepository implements BillRepositoryInterface
|
||||
* @param Bill $bill
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return bool
|
||||
* @return boolean|null
|
||||
*/
|
||||
public function scan(Bill $bill, TransactionJournal $journal)
|
||||
{
|
||||
$amountMatch = false;
|
||||
$wordMatch = false;
|
||||
$matches = explode(',', $bill->match);
|
||||
$description = strtolower($journal->description);
|
||||
|
||||
/*
|
||||
* Attach expense account to description for more narrow matching.
|
||||
*/
|
||||
$transactions = $journal->transactions()->get();
|
||||
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($transactions as $transaction) {
|
||||
/** @var Account $account */
|
||||
$account = $transaction->account()->first();
|
||||
/** @var AccountType $type */
|
||||
$type = $account->accountType()->first();
|
||||
if ($type->type == 'Expense account' || $type->type == 'Beneficiary account') {
|
||||
$description .= ' ' . strtolower($account->name);
|
||||
}
|
||||
}
|
||||
Log::debug('Final description: ' . $description);
|
||||
Log::debug('Matches searched: ' . join(':', $matches));
|
||||
|
||||
$count = 0;
|
||||
foreach ($matches as $word) {
|
||||
if (!(strpos($description, strtolower($word)) === false)) {
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
if ($count >= count($matches)) {
|
||||
$wordMatch = true;
|
||||
Log::debug('word match is true');
|
||||
} else {
|
||||
Log::debug('Count: ' . $count . ', count(matches): ' . count($matches));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Match amount.
|
||||
*/
|
||||
|
||||
if (count($transactions) > 1) {
|
||||
|
||||
$amount = max(floatval($transactions[0]->amount), floatval($transactions[1]->amount));
|
||||
$min = floatval($bill->amount_min);
|
||||
$max = floatval($bill->amount_max);
|
||||
if ($amount >= $min && $amount <= $max) {
|
||||
$amountMatch = true;
|
||||
Log::debug('Amount match is true!');
|
||||
}
|
||||
}
|
||||
|
||||
$description = strtolower($journal->description) . ' ' . strtolower($journal->destination_account->name);
|
||||
$wordMatch = $this->doWordMatch($matches, $description);
|
||||
$amountMatch = $this->doAmountMatch($journal->amount, $bill->amount_min, $bill->amount_max);
|
||||
|
||||
/*
|
||||
* If both, update!
|
||||
*/
|
||||
if ($wordMatch && $amountMatch) {
|
||||
Log::debug('TOTAL match is true!');
|
||||
$journal->bill()->associate($bill);
|
||||
$journal->save();
|
||||
} else {
|
||||
if ((!$wordMatch || !$amountMatch) && $bill->id == $journal->bill_id) {
|
||||
// if no match, but bill used to match, remove it:
|
||||
$journal->bill_id = null;
|
||||
$journal->save();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
if ($bill->id == $journal->bill_id) {
|
||||
// if no match, but bill used to match, remove it:
|
||||
$journal->bill_id = null;
|
||||
$journal->save();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -366,7 +318,7 @@ class BillRepository implements BillRepositoryInterface
|
||||
* @param Bill $bill
|
||||
* @param array $data
|
||||
*
|
||||
* @return Bill|static
|
||||
* @return Bill
|
||||
*/
|
||||
public function update(Bill $bill, array $data)
|
||||
{
|
||||
@@ -385,4 +337,42 @@ class BillRepository implements BillRepositoryInterface
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@@ -103,7 +103,7 @@ interface BillRepositoryInterface
|
||||
/**
|
||||
* @param Bill $bill
|
||||
*
|
||||
* @return Carbon|null
|
||||
* @return \Carbon\Carbon
|
||||
*/
|
||||
public function nextExpectedMatch(Bill $bill);
|
||||
|
||||
|
@@ -7,8 +7,9 @@ use Carbon\Carbon;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Models\BudgetLimit;
|
||||
use FireflyIII\Models\LimitRepetition;
|
||||
use FireflyIII\Repositories\Shared\ComponentRepository;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use Illuminate\Database\Query\Builder as QueryBuilder;
|
||||
use Illuminate\Database\Query\JoinClause;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Collection;
|
||||
use Input;
|
||||
@@ -18,7 +19,7 @@ use Input;
|
||||
*
|
||||
* @package FireflyIII\Repositories\Budget
|
||||
*/
|
||||
class BudgetRepository implements BudgetRepositoryInterface
|
||||
class BudgetRepository extends ComponentRepository implements BudgetRepositoryInterface
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -113,7 +114,17 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -146,13 +157,22 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
* @param LimitRepetition $repetition
|
||||
* @param int $take
|
||||
*
|
||||
* @return \Illuminate\Pagination\Paginator
|
||||
* @return LengthAwarePaginator
|
||||
*/
|
||||
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)
|
||||
->orderBy('transaction_journals.date', 'DESC')
|
||||
->orderBy('transaction_journals.order', 'ASC')
|
||||
@@ -169,7 +189,11 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
$set = $setQuery->get(['transaction_journals.*']);
|
||||
$count = $countQuery->count();
|
||||
|
||||
return new LengthAwarePaginator($set, $count, $take, $offset);
|
||||
|
||||
$paginator = new LengthAwarePaginator($set, $count, $take, $offset);
|
||||
$cache->store($paginator);
|
||||
|
||||
return $paginator;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -231,7 +255,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return mixed
|
||||
* @return double
|
||||
*/
|
||||
public function getWithoutBudgetSum(Carbon $start, Carbon $end)
|
||||
{
|
||||
@@ -262,32 +286,11 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
* @param Carbon $end
|
||||
* @param bool $shared
|
||||
*
|
||||
* @return float
|
||||
* @return string
|
||||
*/
|
||||
public function spentInPeriodCorrected(Budget $budget, Carbon $start, Carbon $end, $shared = true)
|
||||
{
|
||||
if ($shared === true) {
|
||||
// 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;
|
||||
return $this->spentInPeriod($budget, $start, $end, $shared);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -330,7 +333,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
* @param Carbon $date
|
||||
* @param $amount
|
||||
*
|
||||
* @return LimitRepetition|null
|
||||
* @return BudgetLimit
|
||||
*/
|
||||
public function updateLimitAmount(Budget $budget, Carbon $date, $amount)
|
||||
{
|
||||
|
@@ -5,6 +5,7 @@ namespace FireflyIII\Repositories\Budget;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Models\LimitRepetition;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
@@ -89,7 +90,7 @@ interface BudgetRepositoryInterface
|
||||
* @param LimitRepetition $repetition
|
||||
* @param int $take
|
||||
*
|
||||
* @return \Illuminate\Pagination\Paginator
|
||||
* @return LengthAwarePaginator
|
||||
*/
|
||||
public function getJournals(Budget $budget, LimitRepetition $repetition = null, $take = 50);
|
||||
|
||||
@@ -133,7 +134,7 @@ interface BudgetRepositoryInterface
|
||||
* @param Carbon $end
|
||||
* @param boolean $shared
|
||||
*
|
||||
* @return float
|
||||
* @return string
|
||||
*/
|
||||
public function spentInPeriodCorrected(Budget $budget, Carbon $start, Carbon $end, $shared = true);
|
||||
|
||||
|
@@ -7,7 +7,7 @@ use Carbon\Carbon;
|
||||
use Crypt;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use Illuminate\Database\Query\JoinClause;
|
||||
use FireflyIII\Repositories\Shared\ComponentRepository;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
@@ -15,7 +15,7 @@ use Illuminate\Support\Collection;
|
||||
*
|
||||
* @package FireflyIII\Repositories\Category
|
||||
*/
|
||||
class CategoryRepository implements CategoryRepositoryInterface
|
||||
class CategoryRepository extends ComponentRepository implements CategoryRepositoryInterface
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -62,7 +62,7 @@ class CategoryRepository implements CategoryRepositoryInterface
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return Collection
|
||||
* @return array
|
||||
*/
|
||||
public function getCategoriesAndExpensesCorrected($start, $end)
|
||||
{
|
||||
@@ -75,14 +75,14 @@ class CategoryRepository implements CategoryRepositoryInterface
|
||||
->where('categories.user_id', Auth::user()->id)
|
||||
->after($start)
|
||||
->transactionTypes(['Withdrawal'])
|
||||
->groupBy('categories.id')
|
||||
->get(['categories.id as category_id', 'categories.encrypted as category_encrypted', 'categories.name', 'transaction_journals.*']);
|
||||
|
||||
$result = [];
|
||||
foreach ($set as $entry) {
|
||||
$categoryId = intval($entry->category_id);
|
||||
if (isset($result[$categoryId])) {
|
||||
$result[$categoryId]['sum'] += floatval($entry->amount);
|
||||
bcscale(2);
|
||||
$result[$categoryId]['sum'] = bcadd($result[$categoryId]['sum'], $entry->amount);
|
||||
} else {
|
||||
$isEncrypted = intval($entry->category_encrypted) == 1 ? true : false;
|
||||
$name = strlen($entry->name) == 0 ? trans('firefly.no_category') : $entry->name;
|
||||
@@ -181,39 +181,11 @@ class CategoryRepository implements CategoryRepositoryInterface
|
||||
*
|
||||
* @param bool $shared
|
||||
*
|
||||
* @return float
|
||||
* @return string
|
||||
*/
|
||||
public function spentInPeriodCorrected(Category $category, Carbon $start, Carbon $end, $shared = false)
|
||||
{
|
||||
if ($shared === true) {
|
||||
// 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;
|
||||
return $this->spentInPeriod($category, $start, $end, $shared);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -38,7 +38,7 @@ interface CategoryRepositoryInterface
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return Collection
|
||||
* @return array
|
||||
*/
|
||||
public function getCategoriesAndExpensesCorrected($start, $end);
|
||||
|
||||
@@ -81,7 +81,7 @@ interface CategoryRepositoryInterface
|
||||
*
|
||||
* @param bool $shared
|
||||
*
|
||||
* @return float
|
||||
* @return string
|
||||
*/
|
||||
public function spentInPeriodCorrected(Category $category, Carbon $start, Carbon $end, $shared = false);
|
||||
|
||||
|
@@ -29,7 +29,7 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
/**
|
||||
* @param int $reminderId
|
||||
*
|
||||
* @return bool
|
||||
* @return boolean|null
|
||||
*/
|
||||
public function deactivateReminder($reminderId)
|
||||
{
|
||||
@@ -48,11 +48,6 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
*/
|
||||
public function delete(TransactionJournal $journal)
|
||||
{
|
||||
// delete transactions first:
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($journal->transactions()->get() as $transaction) {
|
||||
$transaction->delete();
|
||||
}
|
||||
$journal->delete();
|
||||
|
||||
return true;
|
||||
@@ -72,7 +67,7 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
* @param TransactionJournal $journal
|
||||
* @param Transaction $transaction
|
||||
*
|
||||
* @return float
|
||||
* @return integer
|
||||
*/
|
||||
public function getAmountBefore(TransactionJournal $journal, Transaction $transaction)
|
||||
{
|
||||
@@ -240,7 +235,7 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
* @param TransactionJournal $journal
|
||||
* @param array $data
|
||||
*
|
||||
* @return mixed
|
||||
* @return TransactionJournal
|
||||
*/
|
||||
public function update(TransactionJournal $journal, array $data)
|
||||
{
|
||||
|
@@ -33,7 +33,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
/**
|
||||
* @param PiggyBank $piggyBank
|
||||
*
|
||||
* @return bool
|
||||
* @return boolean|null
|
||||
*/
|
||||
public function destroy(PiggyBank $piggyBank)
|
||||
{
|
||||
|
74
app/Repositories/Shared/ComponentRepository.php
Normal file
74
app/Repositories/Shared/ComponentRepository.php
Normal 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;
|
||||
}
|
||||
}
|
@@ -43,13 +43,10 @@ class TagRepository implements TagRepositoryInterface
|
||||
$journal->tags()->save($tag);
|
||||
|
||||
return true;
|
||||
break;
|
||||
case 'balancingAct':
|
||||
return $this->connectBalancingAct($journal, $tag);
|
||||
break;
|
||||
case 'advancePayment':
|
||||
return $this->connectAdvancePayment($journal, $tag);
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -67,14 +64,15 @@ class TagRepository implements TagRepositoryInterface
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return float
|
||||
* @return string
|
||||
*/
|
||||
public function coveredByBalancingActs(Account $account, Carbon $start, Carbon $end)
|
||||
{
|
||||
// the quickest way to do this is by scanning all balancingAct tags
|
||||
// because there will be less of them any way.
|
||||
$tags = Auth::user()->tags()->where('tagMode', 'balancingAct')->get();
|
||||
$amount = 0;
|
||||
$amount = '0';
|
||||
bcscale(2);
|
||||
|
||||
/** @var Tag $tag */
|
||||
foreach ($tags as $tag) {
|
||||
@@ -83,7 +81,7 @@ class TagRepository implements TagRepositoryInterface
|
||||
/** @var TransactionJournal $journal */
|
||||
foreach ($journals as $journal) {
|
||||
if ($journal->destination_account->id == $account->id) {
|
||||
$amount += $journal->amount;
|
||||
$amount = bcadd($amount, $journal->amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -201,16 +199,11 @@ class TagRepository implements TagRepositoryInterface
|
||||
/*
|
||||
* If any transaction is a deposit, cannot become a balancing act.
|
||||
*/
|
||||
$count = 0;
|
||||
foreach ($tag->transactionjournals as $journal) {
|
||||
if ($journal->transactionType->type == 'Deposit') {
|
||||
$count++;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if ($count > 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -311,7 +304,8 @@ class TagRepository implements TagRepositoryInterface
|
||||
return $this->matchAll($journal, $tag);
|
||||
}
|
||||
|
||||
return false;
|
||||
// this statement is unreachable.
|
||||
return false; // @codeCoverageIgnore
|
||||
|
||||
}
|
||||
|
||||
@@ -326,7 +320,7 @@ class TagRepository implements TagRepositoryInterface
|
||||
$match = true;
|
||||
/** @var TransactionJournal $check */
|
||||
foreach ($tag->transactionjournals as $check) {
|
||||
if ($check->assetAccount->id != $journal->assetAccount->id) {
|
||||
if ($check->source_account->id != $journal->source_account->id) {
|
||||
$match = false;
|
||||
}
|
||||
}
|
||||
|
@@ -38,7 +38,7 @@ interface TagRepositoryInterface
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return float
|
||||
* @return string
|
||||
*/
|
||||
public function coveredByBalancingActs(Account $account, Carbon $start, Carbon $end);
|
||||
|
||||
|
@@ -35,15 +35,8 @@ class Amount
|
||||
*/
|
||||
public function getCurrencySymbol()
|
||||
{
|
||||
if (defined('FFCURRENCYSYMBOL')) {
|
||||
return FFCURRENCYSYMBOL;
|
||||
}
|
||||
|
||||
$currencyPreference = Prefs::get('currencyPreference', 'EUR');
|
||||
$currency = TransactionCurrency::whereCode($currencyPreference->data)->first();
|
||||
|
||||
define('FFCURRENCYSYMBOL', $currency->symbol);
|
||||
|
||||
return $currency->symbol;
|
||||
}
|
||||
|
||||
@@ -84,6 +77,15 @@ class Amount
|
||||
*/
|
||||
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)) {
|
||||
$symbol = $journal->transactionCurrency->symbol;
|
||||
} else {
|
||||
@@ -94,13 +96,22 @@ class Amount
|
||||
$amount = $amount * -1;
|
||||
}
|
||||
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) {
|
||||
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()
|
||||
{
|
||||
if (defined('FFCURRENCYCODE')) {
|
||||
return FFCURRENCYCODE;
|
||||
}
|
||||
|
||||
|
||||
$currencyPreference = Prefs::get('currencyPreference', 'EUR');
|
||||
|
||||
$currency = TransactionCurrency::whereCode($currencyPreference->data)->first();
|
||||
if ($currency) {
|
||||
|
||||
define('FFCURRENCYCODE', $currency->code);
|
||||
|
||||
return $currency->code;
|
||||
}
|
||||
|
||||
return 'EUR';
|
||||
return 'EUR'; // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
/**
|
||||
|
106
app/Support/CacheProperties.php
Normal file
106
app/Support/CacheProperties.php
Normal 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);
|
||||
}
|
||||
}
|
@@ -3,9 +3,11 @@
|
||||
namespace FireflyIII\Support;
|
||||
|
||||
use Amount as Amt;
|
||||
use Eloquent;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\MessageBag;
|
||||
use Input;
|
||||
use RuntimeException;
|
||||
use Session;
|
||||
use View;
|
||||
|
||||
@@ -13,6 +15,8 @@ use View;
|
||||
* Class ExpandedForm
|
||||
*
|
||||
* @package FireflyIII\Support
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.TooManyMethods)
|
||||
*/
|
||||
class ExpandedForm
|
||||
{
|
||||
@@ -46,7 +50,7 @@ class ExpandedForm
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function label($name, $options)
|
||||
protected function label($name, $options)
|
||||
{
|
||||
if (isset($options['label'])) {
|
||||
return $options['label'];
|
||||
@@ -63,7 +67,7 @@ class ExpandedForm
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function expandOptionArray($name, $label, array $options)
|
||||
protected function expandOptionArray($name, $label, array $options)
|
||||
{
|
||||
$options['class'] = 'form-control';
|
||||
$options['id'] = 'ffInput_' . $name;
|
||||
@@ -78,7 +82,7 @@ class ExpandedForm
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHolderClasses($name)
|
||||
protected function getHolderClasses($name)
|
||||
{
|
||||
/*
|
||||
* Get errors from session:
|
||||
@@ -100,16 +104,23 @@ class ExpandedForm
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function fillFieldValue($name, $value)
|
||||
protected function fillFieldValue($name, $value)
|
||||
{
|
||||
if (Session::has('preFilled')) {
|
||||
$preFilled = Session::get('preFilled');
|
||||
$value = isset($preFilled[$name]) && is_null($value) ? $preFilled[$name] : $value;
|
||||
}
|
||||
if (!is_null(Input::old($name))) {
|
||||
$value = Input::old($name);
|
||||
// @codeCoverageIgnoreStart
|
||||
try {
|
||||
if (!is_null(Input::old($name))) {
|
||||
$value = Input::old($name);
|
||||
}
|
||||
} catch (RuntimeException $e) {
|
||||
// don't care about session errors.
|
||||
}
|
||||
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
@@ -246,24 +257,6 @@ class ExpandedForm
|
||||
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 array $list
|
||||
@@ -271,7 +264,6 @@ class ExpandedForm
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
* @internal param null $value
|
||||
*/
|
||||
public function multiRadio($name, array $list = [], $selected = null, array $options = [])
|
||||
{
|
||||
@@ -294,7 +286,16 @@ class ExpandedForm
|
||||
*/
|
||||
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;
|
||||
$html = View::make('form.options', compact('type', 'name', 'previousValue'))->render();
|
||||
|
||||
|
@@ -41,6 +41,7 @@ class Navigation
|
||||
'6M' => 6,
|
||||
'half-year' => 6,
|
||||
];
|
||||
|
||||
if (!isset($functionMap[$repeatFreq])) {
|
||||
throw new FireflyException('Cannot do addPeriod for $repeat_freq "' . $repeatFreq . '"');
|
||||
}
|
||||
@@ -140,117 +141,6 @@ class Navigation
|
||||
return $currentEnd;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $range
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return Carbon
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function jumpToNext($range, Carbon $date)
|
||||
{
|
||||
switch ($range) {
|
||||
case '1D':
|
||||
$date->endOfDay()->addDay();
|
||||
break;
|
||||
case '1W':
|
||||
$date->endOfWeek()->addDay()->startOfWeek();
|
||||
break;
|
||||
case '1M':
|
||||
$date->endOfMonth()->addDay()->startOfMonth();
|
||||
break;
|
||||
case '3M':
|
||||
$date->lastOfQuarter()->addDay();
|
||||
break;
|
||||
case '6M':
|
||||
if ($date->month >= 7) {
|
||||
$date->startOfYear()->addYear();
|
||||
} else {
|
||||
$date->startOfYear()->addMonths(6);
|
||||
}
|
||||
break;
|
||||
case '1Y':
|
||||
$date->startOfYear()->addYear();
|
||||
break;
|
||||
default:
|
||||
throw new FireflyException('Cannot do _next() on ' . $range);
|
||||
break;
|
||||
}
|
||||
|
||||
return $date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $range
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return Carbon
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function jumpToPrevious($range, Carbon $date)
|
||||
{
|
||||
$functionMap = [
|
||||
'1D' => 'Day',
|
||||
'1W' => 'Week',
|
||||
'1M' => 'Month',
|
||||
'1Y' => 'Year'
|
||||
];
|
||||
|
||||
if (isset($functionMap[$range])) {
|
||||
$startFunction = 'startOf' . $functionMap[$range];
|
||||
$subFunction = 'sub' . $functionMap[$range];
|
||||
$date->$startFunction()->$subFunction();
|
||||
|
||||
return $date;
|
||||
}
|
||||
if ($range == '3M') {
|
||||
$date->firstOfQuarter()->subMonths(3)->firstOfQuarter();
|
||||
|
||||
return $date;
|
||||
}
|
||||
if ($range == '6M') {
|
||||
$date->startOfYear();
|
||||
if ($date->month <= 6) {
|
||||
$date->subMonths(6);
|
||||
}
|
||||
|
||||
return $date;
|
||||
}
|
||||
throw new FireflyException('Cannot do _previous() on ' . $range);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $range
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return string
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function periodName($range, Carbon $date)
|
||||
{
|
||||
$formatMap = [
|
||||
'1D' => 'jS F Y',
|
||||
'1W' => '\w\e\ek W, Y',
|
||||
'1M' => 'F Y',
|
||||
'1Y' => 'Y',
|
||||
];
|
||||
if (isset($formatMap[$range])) {
|
||||
return $date->format($formatMap[$range]);
|
||||
}
|
||||
if ($range == '3M') {
|
||||
|
||||
|
||||
return 'Q' . ceil(($date->month / 12) * 4) . ' ' . $date->year;
|
||||
}
|
||||
if ($range == '6M') {
|
||||
$half = ceil(($date->month / 12) * 2);
|
||||
$halfName = $half == 1 ? 'first' : 'second';
|
||||
|
||||
return $halfName . ' half of ' . $date->year;
|
||||
}
|
||||
throw new FireflyException('No _periodName() for range "' . $range . '"');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $date
|
||||
* @param $repeatFrequency
|
||||
|
@@ -3,8 +3,8 @@
|
||||
namespace FireflyIII\Support;
|
||||
|
||||
use Auth;
|
||||
use Cache;
|
||||
use FireflyIII\Models\Preference;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class Preferences
|
||||
@@ -14,20 +14,34 @@ use Log;
|
||||
class Preferences
|
||||
{
|
||||
/**
|
||||
* @param $name
|
||||
* @param null $default
|
||||
* @return string
|
||||
*/
|
||||
public function lastActivity()
|
||||
{
|
||||
$preference = $this->get('lastActivity', microtime())->data;
|
||||
|
||||
return md5($preference);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param string $default
|
||||
*
|
||||
* @return null|\FireflyIII\Models\Preference
|
||||
*/
|
||||
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 */
|
||||
foreach ($preferences as $preference) {
|
||||
if ($preference->name == $name) {
|
||||
return $preference;
|
||||
}
|
||||
$preference = Preference::where('user_id', Auth::user()->id)->where('name', $name)->first(['id', 'name', 'data_encrypted']);
|
||||
|
||||
if ($preference) {
|
||||
Cache::forever($fullName, $preference);
|
||||
|
||||
return $preference;
|
||||
}
|
||||
// no preference found and default is null:
|
||||
if (is_null($default)) {
|
||||
@@ -40,33 +54,40 @@ class Preferences
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param $value
|
||||
* @param $name
|
||||
* @param string $value
|
||||
*
|
||||
* @return Preference
|
||||
*/
|
||||
public function set($name, $value)
|
||||
{
|
||||
$preferences = Preference::where('user_id', Auth::user()->id)->get();
|
||||
/** @var Preference $preference */
|
||||
foreach ($preferences as $preference) {
|
||||
if ($preference->name == $name) {
|
||||
$preference->data = $value;
|
||||
$preference->save();
|
||||
|
||||
return $preference;
|
||||
}
|
||||
}
|
||||
$pref = new Preference;
|
||||
$pref->name = $name;
|
||||
$pref->data = $value;
|
||||
|
||||
if (!is_null(Auth::user()->id)) {
|
||||
$fullName = 'preference' . Auth::user()->id . $name;
|
||||
Cache::forget($fullName);
|
||||
$pref = Preference::where('user_id', Auth::user()->id)->where('name', $name)->first(['id', 'name', 'data_encrypted']);
|
||||
if ($pref) {
|
||||
$pref->data = $value;
|
||||
} else {
|
||||
$pref = new Preference;
|
||||
$pref->name = $name;
|
||||
$pref->data = $value;
|
||||
$pref->user()->associate(Auth::user());
|
||||
$pref->save();
|
||||
|
||||
}
|
||||
$pref->save();
|
||||
|
||||
Cache::forever($fullName, $pref);
|
||||
|
||||
return $pref;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function mark()
|
||||
{
|
||||
$this->set('lastActivity', microtime());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -4,9 +4,6 @@ namespace FireflyIII\Support;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
use FireflyIII\Models\PiggyBankRepetition;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Class Steam
|
||||
@@ -25,6 +22,18 @@ class Steam
|
||||
*/
|
||||
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:
|
||||
$firstDateObject = $account
|
||||
->transactions()
|
||||
@@ -46,159 +55,9 @@ class Steam
|
||||
if (!$ignoreVirtualBalance) {
|
||||
$balance = bcadd($balance, $account->virtual_balance);
|
||||
}
|
||||
$cache->store(round($balance, 2));
|
||||
|
||||
return round($balance, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Only return the top X entries, group the rest by amount
|
||||
* and described as 'Others'. id = 0 as well
|
||||
*
|
||||
* @param array $array
|
||||
* @param int $limit
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function limitArray(array $array, $limit = 10)
|
||||
{
|
||||
$others = [
|
||||
'name' => 'Others',
|
||||
'queryAmount' => 0
|
||||
];
|
||||
$return = [];
|
||||
$count = 0;
|
||||
foreach ($array as $id => $entry) {
|
||||
if ($count < ($limit - 1)) {
|
||||
$return[$id] = $entry;
|
||||
} else {
|
||||
$others['queryAmount'] += $entry['queryAmount'];
|
||||
}
|
||||
|
||||
$count++;
|
||||
}
|
||||
$return[0] = $others;
|
||||
|
||||
return $return;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns a collection into an array. Needs the field 'id' for the key,
|
||||
* and saves only 'name' and 'amount' as a sub array.
|
||||
*
|
||||
* @param \Illuminate\Support\Collection $collection
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function makeArray(Collection $collection)
|
||||
{
|
||||
$array = [];
|
||||
foreach ($collection as $entry) {
|
||||
$entry->spent = isset($entry->spent) ? floatval($entry->spent) : 0.0;
|
||||
$id = intval($entry->id);
|
||||
if (isset($array[$id])) {
|
||||
$array[$id]['amount'] += floatval($entry->amount);
|
||||
$array[$id]['queryAmount'] += floatval($entry->queryAmount);
|
||||
$array[$id]['spent'] += floatval($entry->spent);
|
||||
$array[$id]['encrypted'] = intval($entry->encrypted);
|
||||
} else {
|
||||
$array[$id] = [
|
||||
'amount' => floatval($entry->amount),
|
||||
'queryAmount' => floatval($entry->queryAmount),
|
||||
'spent' => floatval($entry->spent),
|
||||
'encrypted' => intval($entry->encrypted),
|
||||
'name' => $entry->name
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges two of the arrays as defined above. Can't handle more (yet)
|
||||
*
|
||||
* @param array $one
|
||||
* @param array $two
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function mergeArrays(array $one, array $two)
|
||||
{
|
||||
foreach ($two as $id => $value) {
|
||||
// $otherId also exists in $one:
|
||||
if (isset($one[$id])) {
|
||||
$one[$id]['queryAmount'] += $value['queryAmount'];
|
||||
$one[$id]['spent'] += $value['spent'];
|
||||
} else {
|
||||
$one[$id] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $one;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PiggyBank $piggyBank
|
||||
* @param PiggyBankRepetition $repetition
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function percentage(PiggyBank $piggyBank, PiggyBankRepetition $repetition)
|
||||
{
|
||||
$pct = $repetition->currentamount / $piggyBank->targetamount * 100;
|
||||
if ($pct > 100) {
|
||||
// @codeCoverageIgnoreStart
|
||||
return 100;
|
||||
// @codeCoverageIgnoreEnd
|
||||
} else {
|
||||
return floor($pct);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort an array where all 'amount' keys are positive floats.
|
||||
*
|
||||
* @param array $array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function sortArray(array $array)
|
||||
{
|
||||
uasort(
|
||||
$array, function ($left, $right) {
|
||||
if ($left['queryAmount'] == $right['queryAmount']) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ($left['queryAmount'] < $right['queryAmount']) ? 1 : -1;
|
||||
}
|
||||
);
|
||||
|
||||
return $array;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort an array where all 'amount' keys are negative floats.
|
||||
*
|
||||
* @param array $array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function sortNegativeArray(array $array)
|
||||
{
|
||||
uasort(
|
||||
$array, function ($left, $right) {
|
||||
if ($left['queryAmount'] == $right['queryAmount']) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ($left['queryAmount'] < $right['queryAmount']) ? -1 : 1;
|
||||
}
|
||||
);
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -4,6 +4,7 @@ namespace FireflyIII\Support\Twig;
|
||||
|
||||
use Auth;
|
||||
use FireflyIII\Models\LimitRepetition;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use Twig_Extension;
|
||||
use Twig_SimpleFunction;
|
||||
|
||||
@@ -19,8 +20,15 @@ class Budget extends Twig_Extension
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
$functions = [];
|
||||
$functions[] = new Twig_SimpleFunction(
|
||||
'spentInRepetitionCorrected', function (LimitRepetition $repetition) {
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty($repetition->id);
|
||||
$cache->addProperty('spentInRepetitionCorrected');
|
||||
if ($cache->has()) {
|
||||
return $cache->get(); // @codeCoverageIgnore
|
||||
}
|
||||
$sum
|
||||
= Auth::user()->transactionjournals()
|
||||
->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
@@ -30,8 +38,9 @@ class Budget extends Twig_Extension
|
||||
->after($repetition->startdate)
|
||||
->where('limit_repetitions.id', '=', $repetition->id)
|
||||
->get(['transaction_journals.*'])->sum('amount');
|
||||
$cache->store($sum);
|
||||
|
||||
return floatval($sum);
|
||||
return $sum;
|
||||
}
|
||||
);
|
||||
|
||||
|
@@ -28,51 +28,15 @@ class General extends Twig_Extension
|
||||
*/
|
||||
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()
|
||||
{
|
||||
$functions = [];
|
||||
|
||||
$functions[] = new Twig_SimpleFunction(
|
||||
'getCurrencyCode', function () {
|
||||
return App::make('amount')->getCurrencyCode();
|
||||
}
|
||||
);
|
||||
|
||||
$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;
|
||||
return [
|
||||
$this->getCurrencyCode(),
|
||||
$this->getCurrencySymbol(),
|
||||
$this->phpdate(),
|
||||
$this->env(),
|
||||
|
||||
$this->activeRouteStrict(),
|
||||
$this->activeRoutePartial(),
|
||||
$this->activeRoutePartialWhat(),
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
@@ -147,4 +65,196 @@ class General extends Twig_Extension
|
||||
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]
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -4,7 +4,9 @@ namespace FireflyIII\Support\Twig;
|
||||
|
||||
|
||||
use App;
|
||||
use FireflyIII\Models\Tag;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use Twig_Extension;
|
||||
use Twig_SimpleFilter;
|
||||
use Twig_SimpleFunction;
|
||||
@@ -18,108 +20,24 @@ class Journal extends Twig_Extension
|
||||
{
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
* @return array
|
||||
*/
|
||||
public function getFilters()
|
||||
{
|
||||
$filters = [];
|
||||
|
||||
$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>';
|
||||
break;
|
||||
case 'Deposit':
|
||||
return '<span class="glyphicon glyphicon-arrow-right" title="' . trans('firefly.deposit') . '"></span>';
|
||||
break;
|
||||
case 'Transfer':
|
||||
return '<i class="fa fa-fw fa-exchange" title="' . trans('firefly.transfer') . '"></i>';
|
||||
break;
|
||||
case 'Opening balance':
|
||||
return '<span class="glyphicon glyphicon-ban-circle" title="' . trans('firefly.openingBalance') . '"></span>';
|
||||
break;
|
||||
default:
|
||||
return '';
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}, ['is_safe' => ['html']]
|
||||
);
|
||||
$filters = [$this->typeIcon()];
|
||||
|
||||
return $filters;
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
$functions = [];
|
||||
|
||||
$functions[] = new Twig_SimpleFunction(
|
||||
'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;
|
||||
}
|
||||
);
|
||||
$functions = [
|
||||
$this->invalidJournal(),
|
||||
$this->relevantTags()
|
||||
];
|
||||
|
||||
return $functions;
|
||||
}
|
||||
@@ -133,4 +51,192 @@ class Journal extends Twig_Extension
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
26
app/User.php
26
app/User.php
@@ -5,16 +5,40 @@ use Illuminate\Auth\Passwords\CanResetPassword;
|
||||
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
|
||||
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Zizaco\Entrust\Traits\EntrustUserTrait;
|
||||
|
||||
/**
|
||||
* Class User
|
||||
*
|
||||
* @package FireflyIII
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property string $email
|
||||
* @property string $password
|
||||
* @property string $reset
|
||||
* @property string $remember_token
|
||||
* @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\Bill[] $bills
|
||||
* @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\Preference[] $preferences
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Reminder[] $reminders
|
||||
* @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 whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\User whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\User whereEmail($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 whereRememberToken($value)
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Config::get('entrust.role')[] $roles
|
||||
*/
|
||||
class User extends Model implements AuthenticatableContract, CanResetPasswordContract
|
||||
{
|
||||
|
||||
use Authenticatable, CanResetPassword;
|
||||
use Authenticatable, CanResetPassword, EntrustUserTrait;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
|
@@ -9,9 +9,9 @@ use Crypt;
|
||||
use DB;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Contracts\Encryption\DecryptException;
|
||||
use Illuminate\Validation\Validator;
|
||||
use Log;
|
||||
use Navigation;
|
||||
use Symfony\Component\Translation\TranslatorInterface;
|
||||
|
||||
@@ -56,13 +56,9 @@ class FireflyValidator extends Validator
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $attribute
|
||||
* @param $value
|
||||
* @param $parameters
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function validatePiggyBankReminder($attribute, $value, $parameters)
|
||||
public function validatePiggyBankReminder()
|
||||
{
|
||||
$array = $this->data;
|
||||
// no reminder? dont care.
|
||||
@@ -97,54 +93,99 @@ class FireflyValidator extends Validator
|
||||
*/
|
||||
public function validateUniqueAccountForUser($attribute, $value, $parameters)
|
||||
{
|
||||
$type = null;
|
||||
|
||||
|
||||
/**
|
||||
* 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.
|
||||
// because a user does not have to be logged in (tests and what-not).
|
||||
if (!Auth::check()) {
|
||||
return $this->validateAccountAnonymously();
|
||||
}
|
||||
|
||||
if ($hasAccountTypeId) {
|
||||
$type = AccountType::find($this->data['account_type_id']);
|
||||
if (isset($this->data['what'])) {
|
||||
return $this->validateByAccountTypeString($value, $parameters);
|
||||
}
|
||||
|
||||
if ($hasAccountId) {
|
||||
/** @var Account $account */
|
||||
$account = Account::find($this->data['id']);
|
||||
$ignoreId = intval($this->data['id']);
|
||||
$type = AccountType::find($account->account_type_id);
|
||||
unset($account);
|
||||
if (isset($this->data['account_type_id'])) {
|
||||
return $this->validateByAccountTypeId($value, $parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to decrypt data just in case:
|
||||
*/
|
||||
try {
|
||||
$value = Crypt::decrypt($value);
|
||||
} catch (DecryptException $e) {
|
||||
}
|
||||
|
||||
|
||||
if (is_null($type)) {
|
||||
Log::error('Could not determine type of account to validate.');
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateAccountAnonymously()
|
||||
{
|
||||
if (!isset($this->data['user_id'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// get all accounts with this type, and find the name.
|
||||
$userId = Auth::check() ? Auth::user()->id : 0;
|
||||
$set = Account::where('account_type_id', $type->id)->where('id', '!=', $ignoreId)->where('user_id', $userId)->get();
|
||||
$user = User::find($this->data['user_id']);
|
||||
$type = AccountType::find($this->data['account_type_id'])->first();
|
||||
$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 */
|
||||
foreach ($set as $entry) {
|
||||
if ($entry->name == $value) {
|
||||
@@ -167,7 +208,7 @@ class FireflyValidator extends Validator
|
||||
{
|
||||
$query = DB::table($parameters[0])->where($parameters[1], $value);
|
||||
$query->where('user_id', Auth::user()->id);
|
||||
if (isset($paramers[2])) {
|
||||
if (isset($parameters[2])) {
|
||||
$query->where('id', '!=', $parameters[2]);
|
||||
}
|
||||
$count = $query->count();
|
||||
@@ -184,8 +225,7 @@ class FireflyValidator extends Validator
|
||||
*
|
||||
* parameter 0: the table
|
||||
* parameter 1: the field
|
||||
* parameter 2: the encrypted / not encrypted boolean. Defaults to "encrypted".
|
||||
* parameter 3: an id to ignore (when editing)
|
||||
* parameter 2: an id to ignore (when editing)
|
||||
*
|
||||
* @param $attribute
|
||||
* @param $value
|
||||
@@ -195,37 +235,19 @@ class FireflyValidator extends Validator
|
||||
*/
|
||||
public function validateUniqueObjectForUser($attribute, $value, $parameters)
|
||||
{
|
||||
$table = $parameters[0];
|
||||
$field = $parameters[1];
|
||||
$encrypted = isset($parameters[2]) ? $parameters[2] : 'encrypted';
|
||||
$exclude = isset($parameters[3]) ? $parameters[3] : null;
|
||||
$alwaysEncrypted = false;
|
||||
if ($encrypted == 'TRUE') {
|
||||
$alwaysEncrypted = true;
|
||||
}
|
||||
$value = $this->tryDecrypt($value);
|
||||
// exclude?
|
||||
$table = $parameters[0];
|
||||
$field = $parameters[1];
|
||||
$exclude = isset($parameters[2]) ? intval($parameters[2]) : 0;
|
||||
|
||||
if (is_null(Auth::user())) {
|
||||
// user is not logged in.. weird.
|
||||
return true;
|
||||
} else {
|
||||
$query = DB::table($table)->where('user_id', Auth::user()->id);
|
||||
}
|
||||
// get entries from table
|
||||
$set = DB::table($table)->where('user_id', Auth::user()->id)->where('id', '!=', $exclude)->get([$field]);
|
||||
|
||||
|
||||
if (!is_null($exclude)) {
|
||||
$query->where('id', '!=', $exclude);
|
||||
}
|
||||
|
||||
|
||||
$set = $query->get();
|
||||
foreach ($set as $entry) {
|
||||
if (!$alwaysEncrypted) {
|
||||
$isEncrypted = intval($entry->$encrypted) == 1 ? true : false;
|
||||
} else {
|
||||
$isEncrypted = true;
|
||||
}
|
||||
$checkValue = $isEncrypted ? Crypt::decrypt($entry->$field) : $entry->$field;
|
||||
if ($checkValue == $value) {
|
||||
$fieldValue = $this->tryDecrypt($entry->$field);
|
||||
|
||||
if ($fieldValue === $value) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -252,9 +274,8 @@ class FireflyValidator extends Validator
|
||||
$set = $query->get(['piggy_banks.*']);
|
||||
|
||||
foreach ($set as $entry) {
|
||||
$isEncrypted = intval($entry->encrypted) == 1 ? true : false;
|
||||
$checkValue = $isEncrypted ? Crypt::decrypt($entry->name) : $entry->name;
|
||||
if ($checkValue == $value) {
|
||||
$fieldValue = $this->tryDecrypt($entry->name);
|
||||
if ($fieldValue == $value) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@@ -28,7 +28,7 @@
|
||||
"illuminate/html": "~5.0",
|
||||
"league/commonmark": "0.7.*",
|
||||
"rcrowe/twigbridge": "0.7.x@dev",
|
||||
"twig/extensions": "~1.2"
|
||||
"zizaco/entrust": "dev-laravel-5"
|
||||
},
|
||||
"require-dev": {
|
||||
"barryvdh/laravel-debugbar": "@stable",
|
||||
@@ -38,8 +38,9 @@
|
||||
"satooshi/php-coveralls": "0.6.1",
|
||||
"mockery/mockery": "0.9.*",
|
||||
"league/factory-muffin": "~2.1",
|
||||
"codeclimate/php-test-reporter": "^0.1.2"
|
||||
|
||||
"codeclimate/php-test-reporter": "^0.1.2",
|
||||
"fzaninotto/faker": "^1.4"
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
429
composer.lock
generated
429
composer.lock
generated
@@ -4,24 +4,24 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"hash": "5c085b2cc90ffa610e386897066315a7",
|
||||
"hash": "077d2b2548df62c8ef92871c6e52c856",
|
||||
"packages": [
|
||||
{
|
||||
"name": "classpreloader/classpreloader",
|
||||
"version": "1.3.0",
|
||||
"version": "1.4.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/ClassPreloader/ClassPreloader.git",
|
||||
"reference": "0544616ba33fb2a6b792b3a7822650810c6d65d9"
|
||||
"reference": "b76f3f4f603ebbe7e64351a7ef973431ddaf7b27"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/ClassPreloader/ClassPreloader/zipball/0544616ba33fb2a6b792b3a7822650810c6d65d9",
|
||||
"reference": "0544616ba33fb2a6b792b3a7822650810c6d65d9",
|
||||
"url": "https://api.github.com/repos/ClassPreloader/ClassPreloader/zipball/b76f3f4f603ebbe7e64351a7ef973431ddaf7b27",
|
||||
"reference": "b76f3f4f603ebbe7e64351a7ef973431ddaf7b27",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"nikic/php-parser": "^1.2.2",
|
||||
"nikic/php-parser": "~1.3",
|
||||
"php": ">=5.3.3",
|
||||
"symfony/console": "~2.1",
|
||||
"symfony/filesystem": "~2.1",
|
||||
@@ -36,7 +36,7 @@
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.3-dev"
|
||||
"dev-master": "1.4-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
@@ -49,13 +49,13 @@
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Graham Campbell",
|
||||
"email": "graham@mineuk.com"
|
||||
},
|
||||
{
|
||||
"name": "Michael Dowling",
|
||||
"email": "mtdowling@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Graham Campbell",
|
||||
"email": "graham@cachethq.io"
|
||||
}
|
||||
],
|
||||
"description": "Helps class loading performance by generating a single PHP file containing all of the autoloaded files for a specific use case",
|
||||
@@ -64,7 +64,7 @@
|
||||
"class",
|
||||
"preload"
|
||||
],
|
||||
"time": "2015-04-15 21:59:30"
|
||||
"time": "2015-05-26 10:57:51"
|
||||
},
|
||||
{
|
||||
"name": "danielstjules/stringy",
|
||||
@@ -943,16 +943,16 @@
|
||||
},
|
||||
{
|
||||
"name": "laravel/framework",
|
||||
"version": "v5.0.31",
|
||||
"version": "v5.0.32",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/laravel/framework.git",
|
||||
"reference": "db0a7400465df159ba8c6eaa954f97f50bc19687"
|
||||
"reference": "85f12207cf45cc288e9e6b9b5d184aad5f08e2ca"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/laravel/framework/zipball/db0a7400465df159ba8c6eaa954f97f50bc19687",
|
||||
"reference": "db0a7400465df159ba8c6eaa954f97f50bc19687",
|
||||
"url": "https://api.github.com/repos/laravel/framework/zipball/85f12207cf45cc288e9e6b9b5d184aad5f08e2ca",
|
||||
"reference": "85f12207cf45cc288e9e6b9b5d184aad5f08e2ca",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -1065,7 +1065,7 @@
|
||||
"framework",
|
||||
"laravel"
|
||||
],
|
||||
"time": "2015-05-11 22:15:00"
|
||||
"time": "2015-05-29 18:56:49"
|
||||
},
|
||||
{
|
||||
"name": "league/commonmark",
|
||||
@@ -1645,17 +1645,17 @@
|
||||
},
|
||||
{
|
||||
"name": "symfony/console",
|
||||
"version": "v2.6.7",
|
||||
"version": "v2.6.9",
|
||||
"target-dir": "Symfony/Component/Console",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/Console.git",
|
||||
"reference": "ebc5679854aa24ed7d65062e9e3ab0b18a917272"
|
||||
"reference": "b5ec0c11a204718f2b656357f5505a8e578f30dd"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/Console/zipball/ebc5679854aa24ed7d65062e9e3ab0b18a917272",
|
||||
"reference": "ebc5679854aa24ed7d65062e9e3ab0b18a917272",
|
||||
"url": "https://api.github.com/repos/symfony/Console/zipball/b5ec0c11a204718f2b656357f5505a8e578f30dd",
|
||||
"reference": "b5ec0c11a204718f2b656357f5505a8e578f30dd",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -1699,21 +1699,21 @@
|
||||
],
|
||||
"description": "Symfony Console Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2015-05-02 15:18:45"
|
||||
"time": "2015-05-29 14:42:58"
|
||||
},
|
||||
{
|
||||
"name": "symfony/debug",
|
||||
"version": "v2.6.7",
|
||||
"version": "v2.6.9",
|
||||
"target-dir": "Symfony/Component/Debug",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/Debug.git",
|
||||
"reference": "ad4511a8fddce7ec163b513ba39a30ea4f32c9e7"
|
||||
"reference": "4851a041c48e76b91a221db84ab5850daa6a7b33"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/Debug/zipball/ad4511a8fddce7ec163b513ba39a30ea4f32c9e7",
|
||||
"reference": "ad4511a8fddce7ec163b513ba39a30ea4f32c9e7",
|
||||
"url": "https://api.github.com/repos/symfony/Debug/zipball/4851a041c48e76b91a221db84ab5850daa6a7b33",
|
||||
"reference": "4851a041c48e76b91a221db84ab5850daa6a7b33",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -1760,25 +1760,24 @@
|
||||
],
|
||||
"description": "Symfony Debug Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2015-05-08 13:17:44"
|
||||
"time": "2015-05-20 13:09:45"
|
||||
},
|
||||
{
|
||||
"name": "symfony/event-dispatcher",
|
||||
"version": "v2.6.7",
|
||||
"target-dir": "Symfony/Component/EventDispatcher",
|
||||
"version": "v2.7.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/EventDispatcher.git",
|
||||
"reference": "672593bc4b0043a0acf91903bb75a1c82d8f2e02"
|
||||
"reference": "687039686d0e923429ba6e958d0baa920cd5d458"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/672593bc4b0043a0acf91903bb75a1c82d8f2e02",
|
||||
"reference": "672593bc4b0043a0acf91903bb75a1c82d8f2e02",
|
||||
"url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/687039686d0e923429ba6e958d0baa920cd5d458",
|
||||
"reference": "687039686d0e923429ba6e958d0baa920cd5d458",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
"php": ">=5.3.9"
|
||||
},
|
||||
"require-dev": {
|
||||
"psr/log": "~1.0",
|
||||
@@ -1795,11 +1794,11 @@
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.6-dev"
|
||||
"dev-master": "2.7-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\EventDispatcher\\": ""
|
||||
}
|
||||
},
|
||||
@@ -1819,25 +1818,24 @@
|
||||
],
|
||||
"description": "Symfony EventDispatcher Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2015-05-02 15:18:45"
|
||||
"time": "2015-05-02 15:21:08"
|
||||
},
|
||||
{
|
||||
"name": "symfony/filesystem",
|
||||
"version": "v2.6.7",
|
||||
"target-dir": "Symfony/Component/Filesystem",
|
||||
"version": "v2.7.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/Filesystem.git",
|
||||
"reference": "f73904bd2dae525c42ea1f0340c7c98480ecacde"
|
||||
"reference": "ae4551fd6d4d4f51f2e7390fbc902fbd67f3b7ba"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/Filesystem/zipball/f73904bd2dae525c42ea1f0340c7c98480ecacde",
|
||||
"reference": "f73904bd2dae525c42ea1f0340c7c98480ecacde",
|
||||
"url": "https://api.github.com/repos/symfony/Filesystem/zipball/ae4551fd6d4d4f51f2e7390fbc902fbd67f3b7ba",
|
||||
"reference": "ae4551fd6d4d4f51f2e7390fbc902fbd67f3b7ba",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
"php": ">=5.3.9"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/phpunit-bridge": "~2.7"
|
||||
@@ -1845,11 +1843,11 @@
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.6-dev"
|
||||
"dev-master": "2.7-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\Filesystem\\": ""
|
||||
}
|
||||
},
|
||||
@@ -1869,21 +1867,21 @@
|
||||
],
|
||||
"description": "Symfony Filesystem Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2015-05-08 00:09:07"
|
||||
"time": "2015-05-15 13:33:16"
|
||||
},
|
||||
{
|
||||
"name": "symfony/finder",
|
||||
"version": "v2.6.7",
|
||||
"version": "v2.6.9",
|
||||
"target-dir": "Symfony/Component/Finder",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/Finder.git",
|
||||
"reference": "704c64c8b12c8882640d5c0330a8414b1e06dc99"
|
||||
"reference": "ffedd3e0ff8155188155e9322fe21b9ee012ac14"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/Finder/zipball/704c64c8b12c8882640d5c0330a8414b1e06dc99",
|
||||
"reference": "704c64c8b12c8882640d5c0330a8414b1e06dc99",
|
||||
"url": "https://api.github.com/repos/symfony/Finder/zipball/ffedd3e0ff8155188155e9322fe21b9ee012ac14",
|
||||
"reference": "ffedd3e0ff8155188155e9322fe21b9ee012ac14",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -1919,21 +1917,21 @@
|
||||
],
|
||||
"description": "Symfony Finder Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2015-05-02 15:18:45"
|
||||
"time": "2015-05-15 13:32:45"
|
||||
},
|
||||
{
|
||||
"name": "symfony/http-foundation",
|
||||
"version": "v2.6.7",
|
||||
"version": "v2.6.9",
|
||||
"target-dir": "Symfony/Component/HttpFoundation",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/HttpFoundation.git",
|
||||
"reference": "8a0d00980ef9f6b47ddbf24bdfbf70fead760816"
|
||||
"reference": "f9b28dcc6d3e50f5568b42dda7292656a9fe8432"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/8a0d00980ef9f6b47ddbf24bdfbf70fead760816",
|
||||
"reference": "8a0d00980ef9f6b47ddbf24bdfbf70fead760816",
|
||||
"url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/f9b28dcc6d3e50f5568b42dda7292656a9fe8432",
|
||||
"reference": "f9b28dcc6d3e50f5568b42dda7292656a9fe8432",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -1973,21 +1971,21 @@
|
||||
],
|
||||
"description": "Symfony HttpFoundation Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2015-05-02 15:18:45"
|
||||
"time": "2015-05-22 14:53:08"
|
||||
},
|
||||
{
|
||||
"name": "symfony/http-kernel",
|
||||
"version": "v2.6.7",
|
||||
"version": "v2.6.9",
|
||||
"target-dir": "Symfony/Component/HttpKernel",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/HttpKernel.git",
|
||||
"reference": "2010194de0a57731af9404c7f97fd300db98b7a3"
|
||||
"reference": "7c883eb1a5d8b52b1fa6d4134b82304c6bb7007f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/HttpKernel/zipball/2010194de0a57731af9404c7f97fd300db98b7a3",
|
||||
"reference": "2010194de0a57731af9404c7f97fd300db98b7a3",
|
||||
"url": "https://api.github.com/repos/symfony/HttpKernel/zipball/7c883eb1a5d8b52b1fa6d4134b82304c6bb7007f",
|
||||
"reference": "7c883eb1a5d8b52b1fa6d4134b82304c6bb7007f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -2051,21 +2049,21 @@
|
||||
],
|
||||
"description": "Symfony HttpKernel Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2015-05-11 01:58:49"
|
||||
"time": "2015-05-29 22:55:07"
|
||||
},
|
||||
{
|
||||
"name": "symfony/process",
|
||||
"version": "v2.6.7",
|
||||
"version": "v2.6.9",
|
||||
"target-dir": "Symfony/Component/Process",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/Process.git",
|
||||
"reference": "9f3c4baaf840ed849e1b1f7bfd5ae246e8509562"
|
||||
"reference": "7856d78ab6cce6e59d02d9e1a873441f6bd21306"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/Process/zipball/9f3c4baaf840ed849e1b1f7bfd5ae246e8509562",
|
||||
"reference": "9f3c4baaf840ed849e1b1f7bfd5ae246e8509562",
|
||||
"url": "https://api.github.com/repos/symfony/Process/zipball/7856d78ab6cce6e59d02d9e1a873441f6bd21306",
|
||||
"reference": "7856d78ab6cce6e59d02d9e1a873441f6bd21306",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -2101,21 +2099,21 @@
|
||||
],
|
||||
"description": "Symfony Process Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2015-05-02 15:18:45"
|
||||
"time": "2015-05-15 13:32:45"
|
||||
},
|
||||
{
|
||||
"name": "symfony/routing",
|
||||
"version": "v2.6.7",
|
||||
"version": "v2.6.9",
|
||||
"target-dir": "Symfony/Component/Routing",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/Routing.git",
|
||||
"reference": "1455ec537940f7428ea6aa9411f3c4bca69413a0"
|
||||
"reference": "dc9df18a1cfe87de65e270e8f01407ca6d7c39cb"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/Routing/zipball/1455ec537940f7428ea6aa9411f3c4bca69413a0",
|
||||
"reference": "1455ec537940f7428ea6aa9411f3c4bca69413a0",
|
||||
"url": "https://api.github.com/repos/symfony/Routing/zipball/dc9df18a1cfe87de65e270e8f01407ca6d7c39cb",
|
||||
"reference": "dc9df18a1cfe87de65e270e8f01407ca6d7c39cb",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -2170,21 +2168,21 @@
|
||||
"uri",
|
||||
"url"
|
||||
],
|
||||
"time": "2015-05-02 15:18:45"
|
||||
"time": "2015-05-15 13:32:45"
|
||||
},
|
||||
{
|
||||
"name": "symfony/security-core",
|
||||
"version": "v2.6.7",
|
||||
"version": "v2.6.9",
|
||||
"target-dir": "Symfony/Component/Security/Core",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/security-core.git",
|
||||
"reference": "d25c17db741f58c0f615e52006a47f6fb23cd9b3"
|
||||
"reference": "1ad0ee4b2a1ab32924cd0be397f0196b5d47e5d0"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/security-core/zipball/d25c17db741f58c0f615e52006a47f6fb23cd9b3",
|
||||
"reference": "d25c17db741f58c0f615e52006a47f6fb23cd9b3",
|
||||
"url": "https://api.github.com/repos/symfony/security-core/zipball/1ad0ee4b2a1ab32924cd0be397f0196b5d47e5d0",
|
||||
"reference": "1ad0ee4b2a1ab32924cd0be397f0196b5d47e5d0",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -2223,32 +2221,32 @@
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "http://symfony.com/contributors"
|
||||
},
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony Security Component - Core Library",
|
||||
"homepage": "http://symfony.com",
|
||||
"time": "2015-03-30 15:54:10"
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2015-05-15 13:53:19"
|
||||
},
|
||||
{
|
||||
"name": "symfony/translation",
|
||||
"version": "v2.6.7",
|
||||
"version": "v2.6.9",
|
||||
"target-dir": "Symfony/Component/Translation",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/Translation.git",
|
||||
"reference": "398e0eedcb89243ad34a10d079a4b6ea4c0b61ff"
|
||||
"reference": "89cdf3c43bc24c85dd8173dfcf5a979a95e5bd9c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/Translation/zipball/398e0eedcb89243ad34a10d079a4b6ea4c0b61ff",
|
||||
"reference": "398e0eedcb89243ad34a10d079a4b6ea4c0b61ff",
|
||||
"url": "https://api.github.com/repos/symfony/Translation/zipball/89cdf3c43bc24c85dd8173dfcf5a979a95e5bd9c",
|
||||
"reference": "89cdf3c43bc24c85dd8173dfcf5a979a95e5bd9c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -2293,11 +2291,11 @@
|
||||
],
|
||||
"description": "Symfony Translation Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2015-05-05 16:51:00"
|
||||
"time": "2015-05-29 14:42:58"
|
||||
},
|
||||
{
|
||||
"name": "symfony/var-dumper",
|
||||
"version": "v2.6.7",
|
||||
"version": "v2.6.9",
|
||||
"target-dir": "Symfony/Component/VarDumper",
|
||||
"source": {
|
||||
"type": "git",
|
||||
@@ -2355,58 +2353,6 @@
|
||||
],
|
||||
"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",
|
||||
"version": "v1.18.1",
|
||||
@@ -2466,16 +2412,16 @@
|
||||
},
|
||||
{
|
||||
"name": "vlucas/phpdotenv",
|
||||
"version": "v1.1.0",
|
||||
"version": "v1.1.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/vlucas/phpdotenv.git",
|
||||
"reference": "732d2adb7d916c9593b9d58c3b0d9ebefead07aa"
|
||||
"reference": "0cac554ce06277e33ddf9f0b7ade4b8bbf2af3fa"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/732d2adb7d916c9593b9d58c3b0d9ebefead07aa",
|
||||
"reference": "732d2adb7d916c9593b9d58c3b0d9ebefead07aa",
|
||||
"url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/0cac554ce06277e33ddf9f0b7ade4b8bbf2af3fa",
|
||||
"reference": "0cac554ce06277e33ddf9f0b7ade4b8bbf2af3fa",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -2485,11 +2431,6 @@
|
||||
"phpunit/phpunit": "~4.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Dotenv": "src/"
|
||||
@@ -2513,20 +2454,20 @@
|
||||
"env",
|
||||
"environment"
|
||||
],
|
||||
"time": "2014-12-05 15:19:21"
|
||||
"time": "2015-05-30 15:59:26"
|
||||
},
|
||||
{
|
||||
"name": "watson/validating",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/dwightwatson/validating.git",
|
||||
"reference": "47320813a45cc35384e72364484d54fe44dcd3fb"
|
||||
"reference": "c32912f760b456c043657951683ed6c468ab83e7"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/dwightwatson/validating/zipball/47320813a45cc35384e72364484d54fe44dcd3fb",
|
||||
"reference": "47320813a45cc35384e72364484d54fe44dcd3fb",
|
||||
"url": "https://api.github.com/repos/dwightwatson/validating/zipball/c32912f760b456c043657951683ed6c468ab83e7",
|
||||
"reference": "c32912f760b456c043657951683ed6c468ab83e7",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -2568,7 +2509,74 @@
|
||||
"laravel",
|
||||
"validation"
|
||||
],
|
||||
"time": "2015-05-23 00:03:54"
|
||||
"time": "2015-06-03 02:25:38"
|
||||
},
|
||||
{
|
||||
"name": "zizaco/entrust",
|
||||
"version": "dev-laravel-5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Zizaco/entrust.git",
|
||||
"reference": "804000c1c535221792b4e173ecdcc02b5681f5ec"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Zizaco/entrust/zipball/804000c1c535221792b4e173ecdcc02b5681f5ec",
|
||||
"reference": "804000c1c535221792b4e173ecdcc02b5681f5ec",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/console": "~5.0",
|
||||
"illuminate/support": "~5.0",
|
||||
"php": ">=5.4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"illuminate/database": "~5.0",
|
||||
"mockery/mockery": "dev-master",
|
||||
"phpunit/phpunit": "~4.1",
|
||||
"sami/sami": "dev-master"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/commands"
|
||||
],
|
||||
"psr-4": {
|
||||
"Zizaco\\Entrust\\": "src/Entrust/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Andrew Elkins",
|
||||
"homepage": "http://andrewelkins.com"
|
||||
},
|
||||
{
|
||||
"name": "Zizaco Zizuini",
|
||||
"email": "zizaco@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Ben Batschelet",
|
||||
"homepage": "http://github.com/bbatsche"
|
||||
},
|
||||
{
|
||||
"name": "Michele Angioni",
|
||||
"email": "michele.angioni@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "This package provides a flexible way to add Role-based Permissions to Laravel",
|
||||
"keywords": [
|
||||
"acl",
|
||||
"auth",
|
||||
"illuminate",
|
||||
"laravel",
|
||||
"permission",
|
||||
"roles"
|
||||
],
|
||||
"time": "2015-05-25 00:17:51"
|
||||
}
|
||||
],
|
||||
"packages-dev": [
|
||||
@@ -3255,16 +3263,16 @@
|
||||
},
|
||||
{
|
||||
"name": "phpspec/phpspec",
|
||||
"version": "2.2.0",
|
||||
"version": "2.2.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpspec/phpspec.git",
|
||||
"reference": "9727d75919a00455433e867565bc022f0b985a39"
|
||||
"reference": "e9a40577323e67f1de2e214abf32976a0352d8f8"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpspec/phpspec/zipball/9727d75919a00455433e867565bc022f0b985a39",
|
||||
"reference": "9727d75919a00455433e867565bc022f0b985a39",
|
||||
"url": "https://api.github.com/repos/phpspec/phpspec/zipball/e9a40577323e67f1de2e214abf32976a0352d8f8",
|
||||
"reference": "e9a40577323e67f1de2e214abf32976a0352d8f8",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -3329,7 +3337,7 @@
|
||||
"testing",
|
||||
"tests"
|
||||
],
|
||||
"time": "2015-04-18 16:22:51"
|
||||
"time": "2015-05-30 15:21:40"
|
||||
},
|
||||
{
|
||||
"name": "phpspec/prophecy",
|
||||
@@ -3393,16 +3401,16 @@
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-code-coverage",
|
||||
"version": "2.0.16",
|
||||
"version": "2.1.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
|
||||
"reference": "934fd03eb6840508231a7f73eb8940cf32c3b66c"
|
||||
"reference": "28a6b34e91d789b2608072ab3c82eaae7cdb973c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/934fd03eb6840508231a7f73eb8940cf32c3b66c",
|
||||
"reference": "934fd03eb6840508231a7f73eb8940cf32c3b66c",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/28a6b34e91d789b2608072ab3c82eaae7cdb973c",
|
||||
"reference": "28a6b34e91d789b2608072ab3c82eaae7cdb973c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -3425,7 +3433,7 @@
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.0.x-dev"
|
||||
"dev-master": "2.1.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
@@ -3451,7 +3459,7 @@
|
||||
"testing",
|
||||
"xunit"
|
||||
],
|
||||
"time": "2015-04-11 04:35:00"
|
||||
"time": "2015-06-03 07:01:01"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-file-iterator",
|
||||
@@ -3639,16 +3647,16 @@
|
||||
},
|
||||
{
|
||||
"name": "phpunit/phpunit",
|
||||
"version": "4.6.6",
|
||||
"version": "4.7.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
||||
"reference": "3afe303d873a4d64c62ef84de491b97b006fbdac"
|
||||
"reference": "c2241b8d3381be3e4c6125ae347687d59f286784"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3afe303d873a4d64c62ef84de491b97b006fbdac",
|
||||
"reference": "3afe303d873a4d64c62ef84de491b97b006fbdac",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c2241b8d3381be3e4c6125ae347687d59f286784",
|
||||
"reference": "c2241b8d3381be3e4c6125ae347687d59f286784",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -3659,7 +3667,7 @@
|
||||
"ext-spl": "*",
|
||||
"php": ">=5.3.3",
|
||||
"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-text-template": "~1.2",
|
||||
"phpunit/php-timer": "~1.0",
|
||||
@@ -3681,7 +3689,7 @@
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "4.6.x-dev"
|
||||
"dev-master": "4.7.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
@@ -3707,20 +3715,20 @@
|
||||
"testing",
|
||||
"xunit"
|
||||
],
|
||||
"time": "2015-04-29 15:18:52"
|
||||
"time": "2015-06-05 04:14:02"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/phpunit-mock-objects",
|
||||
"version": "2.3.1",
|
||||
"version": "2.3.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
|
||||
"reference": "74ffb87f527f24616f72460e54b595f508dccb5c"
|
||||
"reference": "253c005852591fd547fc18cd5b7b43a1ec82d8f7"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/74ffb87f527f24616f72460e54b595f508dccb5c",
|
||||
"reference": "74ffb87f527f24616f72460e54b595f508dccb5c",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/253c005852591fd547fc18cd5b7b43a1ec82d8f7",
|
||||
"reference": "253c005852591fd547fc18cd5b7b43a1ec82d8f7",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -3762,7 +3770,7 @@
|
||||
"mock",
|
||||
"xunit"
|
||||
],
|
||||
"time": "2015-04-02 05:36:41"
|
||||
"time": "2015-05-29 05:19:18"
|
||||
},
|
||||
{
|
||||
"name": "satooshi/php-coveralls",
|
||||
@@ -4205,21 +4213,20 @@
|
||||
},
|
||||
{
|
||||
"name": "symfony/class-loader",
|
||||
"version": "v2.6.7",
|
||||
"target-dir": "Symfony/Component/ClassLoader",
|
||||
"version": "v2.7.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/ClassLoader.git",
|
||||
"reference": "695134c9b39559297fa5d1dcff6a9054bb56facb"
|
||||
"reference": "fa19598cb708b92d983b34aae313f57c217f9386"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/ClassLoader/zipball/695134c9b39559297fa5d1dcff6a9054bb56facb",
|
||||
"reference": "695134c9b39559297fa5d1dcff6a9054bb56facb",
|
||||
"url": "https://api.github.com/repos/symfony/ClassLoader/zipball/fa19598cb708b92d983b34aae313f57c217f9386",
|
||||
"reference": "fa19598cb708b92d983b34aae313f57c217f9386",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
"php": ">=5.3.9"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/finder": "~2.0,>=2.0.5",
|
||||
@@ -4228,11 +4235,11 @@
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.6-dev"
|
||||
"dev-master": "2.7-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\ClassLoader\\": ""
|
||||
}
|
||||
},
|
||||
@@ -4252,25 +4259,24 @@
|
||||
],
|
||||
"description": "Symfony ClassLoader Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2015-05-02 15:18:45"
|
||||
"time": "2015-05-15 13:33:16"
|
||||
},
|
||||
{
|
||||
"name": "symfony/config",
|
||||
"version": "v2.6.7",
|
||||
"target-dir": "Symfony/Component/Config",
|
||||
"version": "v2.7.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/Config.git",
|
||||
"reference": "b6fddb4aa2daaa2b06f0040071ac131b4a1ecf25"
|
||||
"reference": "537e9912063e66aa70cbcddd7d6e6e8db61d98e4"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/Config/zipball/b6fddb4aa2daaa2b06f0040071ac131b4a1ecf25",
|
||||
"reference": "b6fddb4aa2daaa2b06f0040071ac131b4a1ecf25",
|
||||
"url": "https://api.github.com/repos/symfony/Config/zipball/537e9912063e66aa70cbcddd7d6e6e8db61d98e4",
|
||||
"reference": "537e9912063e66aa70cbcddd7d6e6e8db61d98e4",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3",
|
||||
"php": ">=5.3.9",
|
||||
"symfony/filesystem": "~2.3"
|
||||
},
|
||||
"require-dev": {
|
||||
@@ -4279,11 +4285,11 @@
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.6-dev"
|
||||
"dev-master": "2.7-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\Config\\": ""
|
||||
}
|
||||
},
|
||||
@@ -4303,25 +4309,24 @@
|
||||
],
|
||||
"description": "Symfony Config Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2015-05-02 15:18:45"
|
||||
"time": "2015-05-15 13:33:16"
|
||||
},
|
||||
{
|
||||
"name": "symfony/stopwatch",
|
||||
"version": "v2.6.7",
|
||||
"target-dir": "Symfony/Component/Stopwatch",
|
||||
"version": "v2.7.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/Stopwatch.git",
|
||||
"reference": "b470f87c69837cb71115f1fa720388bb19b63635"
|
||||
"reference": "7702945bceddc0e1f744519abb8a2baeb94bd5ce"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/Stopwatch/zipball/b470f87c69837cb71115f1fa720388bb19b63635",
|
||||
"reference": "b470f87c69837cb71115f1fa720388bb19b63635",
|
||||
"url": "https://api.github.com/repos/symfony/Stopwatch/zipball/7702945bceddc0e1f744519abb8a2baeb94bd5ce",
|
||||
"reference": "7702945bceddc0e1f744519abb8a2baeb94bd5ce",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
"php": ">=5.3.9"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/phpunit-bridge": "~2.7"
|
||||
@@ -4329,11 +4334,11 @@
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.6-dev"
|
||||
"dev-master": "2.7-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\Stopwatch\\": ""
|
||||
}
|
||||
},
|
||||
@@ -4353,25 +4358,24 @@
|
||||
],
|
||||
"description": "Symfony Stopwatch Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2015-05-02 15:18:45"
|
||||
"time": "2015-05-02 15:21:08"
|
||||
},
|
||||
{
|
||||
"name": "symfony/yaml",
|
||||
"version": "v2.6.7",
|
||||
"target-dir": "Symfony/Component/Yaml",
|
||||
"version": "v2.7.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/Yaml.git",
|
||||
"reference": "f157ab074e453ecd4c0fa775f721f6e67a99d9e2"
|
||||
"reference": "4a29a5248aed4fb45f626a7bbbd330291492f5c3"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/Yaml/zipball/f157ab074e453ecd4c0fa775f721f6e67a99d9e2",
|
||||
"reference": "f157ab074e453ecd4c0fa775f721f6e67a99d9e2",
|
||||
"url": "https://api.github.com/repos/symfony/Yaml/zipball/4a29a5248aed4fb45f626a7bbbd330291492f5c3",
|
||||
"reference": "4a29a5248aed4fb45f626a7bbbd330291492f5c3",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
"php": ">=5.3.9"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/phpunit-bridge": "~2.7"
|
||||
@@ -4379,11 +4383,11 @@
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.6-dev"
|
||||
"dev-master": "2.7-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\Yaml\\": ""
|
||||
}
|
||||
},
|
||||
@@ -4403,13 +4407,14 @@
|
||||
],
|
||||
"description": "Symfony Yaml Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2015-05-02 15:18:45"
|
||||
"time": "2015-05-02 15:21:08"
|
||||
}
|
||||
],
|
||||
"aliases": [],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": {
|
||||
"rcrowe/twigbridge": 20,
|
||||
"zizaco/entrust": 20,
|
||||
"barryvdh/laravel-debugbar": 0
|
||||
},
|
||||
"prefer-stable": false,
|
||||
|
@@ -115,7 +115,7 @@ return [
|
||||
*/
|
||||
'Illuminate\Foundation\Providers\ArtisanServiceProvider',
|
||||
'Illuminate\Auth\AuthServiceProvider',
|
||||
'Illuminate\Bus\BusServiceProvider',
|
||||
//'Illuminate\Bus\BusServiceProvider',
|
||||
'Illuminate\Cache\CacheServiceProvider',
|
||||
'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider',
|
||||
'Illuminate\Routing\ControllerServiceProvider',
|
||||
@@ -139,15 +139,16 @@ return [
|
||||
'TwigBridge\ServiceProvider',
|
||||
|
||||
'DaveJamesMiller\Breadcrumbs\ServiceProvider',
|
||||
'Barryvdh\Debugbar\ServiceProvider',
|
||||
'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider',
|
||||
//'Barryvdh\Debugbar\ServiceProvider',
|
||||
//'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider',
|
||||
'Zizaco\Entrust\EntrustServiceProvider',
|
||||
|
||||
/*
|
||||
* Application Service Providers...
|
||||
*/
|
||||
'FireflyIII\Providers\AppServiceProvider',
|
||||
'FireflyIII\Providers\BusServiceProvider',
|
||||
'FireflyIII\Providers\ConfigServiceProvider',
|
||||
//'FireflyIII\Providers\BusServiceProvider',
|
||||
//'FireflyIII\Providers\ConfigServiceProvider',
|
||||
'FireflyIII\Providers\EventServiceProvider',
|
||||
'FireflyIII\Providers\RouteServiceProvider',
|
||||
'FireflyIII\Providers\FireflyServiceProvider',
|
||||
@@ -210,6 +211,7 @@ return [
|
||||
'Steam' => 'FireflyIII\Support\Facades\Steam',
|
||||
'ExpandedForm' => 'FireflyIII\Support\Facades\ExpandedForm',
|
||||
'Twig' => 'TwigBridge\Facade\Twig',
|
||||
'Entrust' => 'Zizaco\Entrust\EntrustFacade'
|
||||
|
||||
|
||||
],
|
||||
|
7
config/breadcrumbs.php
Normal file
7
config/breadcrumbs.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
'view' => 'breadcrumbs::bootstrap3',
|
||||
|
||||
];
|
78
config/entrust.php
Normal file
78
config/entrust.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of Entrust,
|
||||
* a role & permission management solution for Laravel.
|
||||
*
|
||||
* @license MIT
|
||||
* @package Zizaco\Entrust
|
||||
*/
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Entrust Role Model
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This is the Role model used by Entrust to create correct relations. Update
|
||||
| the role if it is in a different namespace.
|
||||
|
|
||||
*/
|
||||
'role' => 'FireflyIII\Models\Role',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Entrust Roles Table
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This is the roles table used by Entrust to save roles to the database.
|
||||
|
|
||||
*/
|
||||
'roles_table' => 'roles',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Entrust Permission Model
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This is the Permission model used by Entrust to create correct relations.
|
||||
| Update the permission if it is in a different namespace.
|
||||
|
|
||||
*/
|
||||
'permission' => 'FireflyIII\Models\Permission',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Entrust Permissions Table
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This is the permissions table used by Entrust to save permissions to the
|
||||
| database.
|
||||
|
|
||||
*/
|
||||
'permissions_table' => 'permissions',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Entrust permission_role Table
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This is the permission_role table used by Entrust to save relationship
|
||||
| between permissions and roles to the database.
|
||||
|
|
||||
*/
|
||||
'permission_role_table' => 'permission_role',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Entrust role_user Table
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This is the role_user table used by Entrust to save assigned roles to the
|
||||
| database.
|
||||
|
|
||||
*/
|
||||
'role_user_table' => 'role_user',
|
||||
|
||||
];
|
@@ -18,60 +18,12 @@ class ChangesForV3409 extends Migration
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
// remove decryption, but this will destroy amounts.
|
||||
|
||||
Schema::table(
|
||||
'accounts', function (Blueprint $table) {
|
||||
$table->dropColumn('virtual_balance_encrypted');
|
||||
}
|
||||
);
|
||||
|
||||
Schema::table(
|
||||
'bills', function (Blueprint $table) {
|
||||
$table->dropColumn('amount_min_encrypted');
|
||||
$table->dropColumn('amount_max_encrypted');
|
||||
}
|
||||
);
|
||||
|
||||
Schema::table(
|
||||
'budget_limits', function (Blueprint $table) {
|
||||
|
||||
$table->dropColumn('amount_encrypted');
|
||||
}
|
||||
);
|
||||
Schema::table(
|
||||
'limit_repetitions', function (Blueprint $table) {
|
||||
$table->dropColumn('amount_encrypted');
|
||||
}
|
||||
);
|
||||
Schema::table(
|
||||
'piggy_bank_events', function (Blueprint $table) {
|
||||
$table->dropColumn('amount_encrypted');
|
||||
}
|
||||
);
|
||||
Schema::table(
|
||||
'piggy_bank_repetitions', function (Blueprint $table) {
|
||||
$table->dropColumn('currentamount_encrypted');
|
||||
}
|
||||
);
|
||||
|
||||
Schema::table(
|
||||
'piggy_banks', function (Blueprint $table) {
|
||||
$table->dropColumn('targetamount_encrypted');
|
||||
}
|
||||
);
|
||||
Schema::table(
|
||||
'preferences', function (Blueprint $table) {
|
||||
$table->dropColumn('name_encrypted');
|
||||
$table->dropColumn('data_encrypted');
|
||||
}
|
||||
);
|
||||
|
||||
Schema::table(
|
||||
'transactions', function (Blueprint $table) {
|
||||
$table->dropColumn('amount_encrypted');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,52 +33,7 @@ class ChangesForV3409 extends Migration
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
// encrypt account virtual balance:
|
||||
Schema::table(
|
||||
'accounts', function (Blueprint $table) {
|
||||
$table->string('virtual_balance_encrypted')->nullable()->after('virtual_balance');
|
||||
}
|
||||
);
|
||||
|
||||
// encrypt bill amount_min and amount_max:
|
||||
Schema::table(
|
||||
'bills', function (Blueprint $table) {
|
||||
$table->string('amount_min_encrypted')->nullable()->after('amount_min');
|
||||
$table->string('amount_max_encrypted')->nullable()->after('amount_max');
|
||||
}
|
||||
);
|
||||
|
||||
// encrypt budget limit amount
|
||||
Schema::table(
|
||||
'budget_limits', function (Blueprint $table) {
|
||||
$table->string('amount_encrypted')->nullable()->after('amount');
|
||||
}
|
||||
);
|
||||
// encrypt limit repetition amount
|
||||
Schema::table(
|
||||
'limit_repetitions', function (Blueprint $table) {
|
||||
$table->string('amount_encrypted')->nullable()->after('amount');
|
||||
}
|
||||
);
|
||||
// encrypt piggy bank event amount
|
||||
Schema::table(
|
||||
'piggy_bank_events', function (Blueprint $table) {
|
||||
$table->string('amount_encrypted')->nullable()->after('amount');
|
||||
}
|
||||
);
|
||||
// encrypt piggy bank repetition currentamount
|
||||
Schema::table(
|
||||
'piggy_bank_repetitions', function (Blueprint $table) {
|
||||
$table->string('currentamount_encrypted')->nullable()->after('currentamount');
|
||||
}
|
||||
);
|
||||
|
||||
// encrypt piggy bank targetamount
|
||||
Schema::table(
|
||||
'piggy_banks', function (Blueprint $table) {
|
||||
$table->string('targetamount_encrypted')->nullable()->after('targetamount');
|
||||
}
|
||||
);
|
||||
// encrypt preference name (add field)
|
||||
// encrypt preference data (add field)
|
||||
Schema::table(
|
||||
@@ -136,13 +43,6 @@ class ChangesForV3409 extends Migration
|
||||
}
|
||||
);
|
||||
|
||||
// encrypt transaction amount
|
||||
Schema::table(
|
||||
'transactions', function (Blueprint $table) {
|
||||
$table->string('amount_encrypted')->nullable()->after('amount');
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Class EntrustSetupTables
|
||||
*/
|
||||
class EntrustSetupTables extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
// Create table for storing roles
|
||||
Schema::create('roles', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('name')->unique();
|
||||
$table->string('display_name')->nullable();
|
||||
$table->string('description')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
// Create table for associating roles to users (Many-to-Many)
|
||||
Schema::create('role_user', function (Blueprint $table) {
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->integer('role_id')->unsigned();
|
||||
|
||||
$table->foreign('user_id')->references('id')->on('users')
|
||||
->onUpdate('cascade')->onDelete('cascade');
|
||||
$table->foreign('role_id')->references('id')->on('roles')
|
||||
->onUpdate('cascade')->onDelete('cascade');
|
||||
|
||||
$table->primary(['user_id', 'role_id']);
|
||||
});
|
||||
|
||||
// Create table for storing permissions
|
||||
Schema::create('permissions', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('name')->unique();
|
||||
$table->string('display_name')->nullable();
|
||||
$table->string('description')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
// Create table for associating permissions to roles (Many-to-Many)
|
||||
Schema::create('permission_role', function (Blueprint $table) {
|
||||
$table->integer('permission_id')->unsigned();
|
||||
$table->integer('role_id')->unsigned();
|
||||
|
||||
$table->foreign('permission_id')->references('id')->on('permissions')
|
||||
->onUpdate('cascade')->onDelete('cascade');
|
||||
$table->foreign('role_id')->references('id')->on('roles')
|
||||
->onUpdate('cascade')->onDelete('cascade');
|
||||
|
||||
$table->primary(['permission_id', 'role_id']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('permission_role');
|
||||
Schema::drop('permissions');
|
||||
Schema::drop('role_user');
|
||||
Schema::drop('roles');
|
||||
}
|
||||
}
|
@@ -20,6 +20,7 @@ class DatabaseSeeder extends Seeder
|
||||
$this->call('AccountTypeSeeder');
|
||||
$this->call('TransactionCurrencySeeder');
|
||||
$this->call('TransactionTypeSeeder');
|
||||
$this->call('PermissionSeeder');
|
||||
|
||||
if (App::environment() == 'testing' || App::environment() == 'homestead' || gethostname() == 'vagrant-firefly-iii') {
|
||||
$this->call('TestDataSeeder');
|
||||
|
21
database/seeds/PermissionSeeder.php
Normal file
21
database/seeds/PermissionSeeder.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
use FireflyIII\Models\Role;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
/**
|
||||
* Class PermissionSeeder
|
||||
*/
|
||||
class PermissionSeeder extends Seeder
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
$owner = new Role;
|
||||
$owner->name = 'owner';
|
||||
$owner->display_name = 'Site Owner';
|
||||
$owner->description = 'User runs this instance of FF3'; // optional
|
||||
$owner->save();
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -10,4 +10,10 @@
|
||||
height: 100%;
|
||||
margin: 0px;
|
||||
padding: 0px
|
||||
}
|
||||
}
|
||||
.medium {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
a.panel-link {color:#fff;text-decoration: none;}
|
||||
a.panel-link:hover {color:#fff;text-decoration: none;}
|
@@ -1,4 +1,4 @@
|
||||
/* global $ */
|
||||
/* global $, googleLineChart, accountID, token */
|
||||
|
||||
|
||||
// Return a helper with preserved width of cells
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user