mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-16 17:57:29 +00:00
Merge branch 'release/3.4.0.1'
This commit is contained in:
18
.env.backup
18
.env.backup
@@ -1,18 +0,0 @@
|
||||
APP_ENV=local
|
||||
APP_DEBUG=true
|
||||
APP_KEY=SomeRandomString
|
||||
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=localhost
|
||||
DB_DATABASE=homestead
|
||||
DB_USERNAME=homestead
|
||||
DB_PASSWORD=secret
|
||||
|
||||
CACHE_DRIVER=file
|
||||
SESSION_DRIVER=file
|
||||
|
||||
EMAIL_SMTP=
|
||||
EMAIL_DRIVER=smtp
|
||||
EMAIL_USERNAME=
|
||||
EMAIL_PASSWORD=
|
||||
ANALYTICS_ID=
|
18
.env.local
18
.env.local
@@ -1,18 +0,0 @@
|
||||
APP_ENV=local
|
||||
APP_DEBUG=true
|
||||
APP_KEY=SomeRandomString
|
||||
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=localhost
|
||||
DB_DATABASE=homestead
|
||||
DB_USERNAME=homestead
|
||||
DB_PASSWORD=secret
|
||||
|
||||
CACHE_DRIVER=file
|
||||
SESSION_DRIVER=file
|
||||
|
||||
EMAIL_SMTP=
|
||||
EMAIL_DRIVER=smtp
|
||||
EMAIL_USERNAME=
|
||||
EMAIL_PASSWORD=
|
||||
ANALYTICS_ID=
|
2
.gitignore
vendored
2
.gitignore
vendored
@@ -29,3 +29,5 @@ clover.xml
|
||||
node_modules/
|
||||
addNewLines.php
|
||||
.phpstorm.meta.php
|
||||
.env.backup
|
||||
.env.local
|
||||
|
@@ -1,4 +1,4 @@
|
||||
Firefly III (v3.4)
|
||||
Firefly III (v3.4.0.1)
|
||||
===========
|
||||
|
||||
[](https://travis-ci.org/JC5/firefly-iii)
|
||||
@@ -6,7 +6,7 @@ Firefly III (v3.4)
|
||||
[](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://coveralls.io/r/JC5/firefly-iii?branch=develop)
|
||||
[](https://coveralls.io/r/JC5/firefly-iii?branch=develop)
|
||||
|
||||
[](https://packagist.org/packages/grumpydictator/firefly-iii)
|
||||
[](https://packagist.org/packages/grumpydictator/firefly-iii)
|
||||
|
@@ -19,7 +19,8 @@ class JournalCreated extends Event
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @return void
|
||||
* @param TransactionJournal $journal
|
||||
* @param $piggyBankId
|
||||
*/
|
||||
public function __construct(TransactionJournal $journal, $piggyBankId)
|
||||
{
|
||||
|
@@ -2,6 +2,11 @@
|
||||
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class JournalDeleted
|
||||
*
|
||||
* @package FireflyIII\Events
|
||||
*/
|
||||
class JournalDeleted extends Event
|
||||
{
|
||||
|
||||
@@ -10,7 +15,6 @@ class JournalDeleted extends Event
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
@@ -3,6 +3,11 @@
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class JournalSaved
|
||||
*
|
||||
* @package FireflyIII\Events
|
||||
*/
|
||||
class JournalSaved extends Event
|
||||
{
|
||||
|
||||
@@ -13,7 +18,7 @@ class JournalSaved extends Event
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @return void
|
||||
* @param TransactionJournal $journal
|
||||
*/
|
||||
public function __construct(TransactionJournal $journal)
|
||||
{
|
||||
|
@@ -49,8 +49,7 @@ class Handler extends ExceptionHandler
|
||||
*/
|
||||
public function report(Exception $e)
|
||||
{
|
||||
/** @noinspection PhpInconsistentReturnPointsInspection */
|
||||
return parent::report($e);
|
||||
parent::report($e);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -19,7 +19,6 @@ class ConnectJournalToPiggyBank
|
||||
/**
|
||||
* Create the event handler.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
@@ -15,7 +15,6 @@ class RescanJournal
|
||||
/**
|
||||
* Create the event handler.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
@@ -41,7 +40,7 @@ class RescanJournal
|
||||
|
||||
Log::debug('Found ' . $list->count() . ' bills to check.');
|
||||
|
||||
/** @var Bill $bill */
|
||||
/** @var \FireflyIII\Models\Bill $bill */
|
||||
foreach ($list as $bill) {
|
||||
Log::debug('Now calling bill #' . $bill->id . ' (' . $bill->name . ')');
|
||||
$repository->scan($bill, $journal);
|
||||
|
@@ -15,7 +15,6 @@ class UpdateJournalConnection
|
||||
/**
|
||||
* Create the event handler.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
@@ -54,7 +54,9 @@ class Help implements HelpInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
* @param $route
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasRoute($route)
|
||||
{
|
||||
@@ -62,10 +64,10 @@ class Help implements HelpInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $title
|
||||
* @param $route
|
||||
* @param array $content
|
||||
*
|
||||
* @return void
|
||||
* @internal param $title
|
||||
*/
|
||||
public function putInCache($route, array $content)
|
||||
{
|
||||
|
@@ -18,16 +18,25 @@ interface HelpInterface
|
||||
public function getFromCache($key);
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
* @param $route
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getFromGithub($route);
|
||||
|
||||
/**
|
||||
* @param $route
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasRoute($route);
|
||||
|
||||
/**
|
||||
* @param $route
|
||||
*
|
||||
* @return array
|
||||
* @return bool
|
||||
*/
|
||||
public function getFromGithub($route);
|
||||
public function inCache($route);
|
||||
|
||||
/**
|
||||
* @param $route
|
||||
@@ -36,11 +45,4 @@ interface HelpInterface
|
||||
* @return void
|
||||
*/
|
||||
public function putInCache($route, array $content);
|
||||
|
||||
/**
|
||||
* @param $route
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function inCache($route);
|
||||
}
|
@@ -91,11 +91,11 @@ class ReportHelper implements ReportHelperInterface
|
||||
$end = Carbon::now();
|
||||
$months = [];
|
||||
while ($start <= $end) {
|
||||
$year = $start->format('Y');
|
||||
$year = $start->year;
|
||||
$months[$year][] = [
|
||||
'formatted' => $start->format('F Y'),
|
||||
'month' => intval($start->format('m')),
|
||||
'year' => intval($start->format('Y')),
|
||||
'month' => $start->month,
|
||||
'year' => $year,
|
||||
];
|
||||
$start->addMonth();
|
||||
}
|
||||
@@ -114,10 +114,10 @@ class ReportHelper implements ReportHelperInterface
|
||||
$end = Carbon::now();
|
||||
$years = [];
|
||||
while ($start <= $end) {
|
||||
$years[] = $start->format('Y');
|
||||
$years[] = $start->year;
|
||||
$start->addYear();
|
||||
}
|
||||
$years[] = Carbon::now()->format('Y');
|
||||
$years[] = Carbon::now()->year;
|
||||
// force the current year.
|
||||
$years = array_unique($years);
|
||||
|
||||
|
@@ -150,8 +150,16 @@ class ReportQuery implements ReportQueryInterface
|
||||
$set = $query->get(['accounts.*']);
|
||||
$set->each(
|
||||
function (Account $account) use ($start, $end) {
|
||||
/**
|
||||
* The balance for today always incorporates transactions
|
||||
* made on today. So to get todays "start" balance, we sub one
|
||||
* day.
|
||||
*/
|
||||
$yesterday = clone $start;
|
||||
$yesterday->subDay();
|
||||
|
||||
/** @noinspection PhpParamsInspection */
|
||||
$account->startBalance = Steam::balance($account, $start);
|
||||
$account->startBalance = Steam::balance($account, $yesterday);
|
||||
$account->endBalance = Steam::balance($account, $end);
|
||||
}
|
||||
);
|
||||
|
@@ -67,11 +67,12 @@ class AccountController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
* @param AccountRepositoryInterface $repository
|
||||
* @param Account $account
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function destroy(Account $account, AccountRepositoryInterface $repository)
|
||||
public function destroy(AccountRepositoryInterface $repository, Account $account)
|
||||
{
|
||||
|
||||
$type = $account->accountType->type;
|
||||
@@ -86,12 +87,12 @@ class AccountController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
* @param AccountRepositoryInterface $repository
|
||||
* @param Account $account
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function edit(Account $account, AccountRepositoryInterface $repository)
|
||||
public function edit(AccountRepositoryInterface $repository, Account $account)
|
||||
{
|
||||
|
||||
$what = Config::get('firefly.shortNamesByFullName')[$account->accountType->type];
|
||||
@@ -129,12 +130,12 @@ class AccountController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $what
|
||||
* @param AccountRepositoryInterface $repository
|
||||
* @param $what
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function index($what, AccountRepositoryInterface $repository)
|
||||
public function index(AccountRepositoryInterface $repository, $what)
|
||||
{
|
||||
$subTitle = Config::get('firefly.subTitlesByIdentifier.' . $what);
|
||||
$subTitleIcon = Config::get('firefly.subIconsByIdentifier.' . $what);
|
||||
@@ -158,12 +159,12 @@ class AccountController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
* @param AccountRepositoryInterface $repository
|
||||
* @param Account $account
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function show(Account $account, AccountRepositoryInterface $repository)
|
||||
public function show(AccountRepositoryInterface $repository, Account $account)
|
||||
{
|
||||
$page = intval(Input::get('page')) == 0 ? 1 : intval(Input::get('page'));
|
||||
$subTitleIcon = Config::get('firefly.subTitlesByIdentifier.' . $account->accountType->type);
|
||||
@@ -214,13 +215,13 @@ class AccountController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
* @param AccountFormRequest $request
|
||||
* @param AccountRepositoryInterface $repository
|
||||
* @param Account $account
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
* @return $this|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(Account $account, AccountFormRequest $request, AccountRepositoryInterface $repository)
|
||||
public function update(AccountFormRequest $request, AccountRepositoryInterface $repository, Account $account)
|
||||
{
|
||||
|
||||
$accountData = [
|
||||
|
@@ -35,11 +35,12 @@ class BillController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Bill $bill
|
||||
* @param AccountRepositoryInterface $repository
|
||||
* @param Bill $bill
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function add(Bill $bill, AccountRepositoryInterface $repository)
|
||||
public function add(AccountRepositoryInterface $repository, Bill $bill)
|
||||
{
|
||||
$matches = explode(',', $bill->match);
|
||||
$description = [];
|
||||
@@ -89,8 +90,9 @@ class BillController extends Controller
|
||||
Session::put('bills.create.url', URL::previous());
|
||||
}
|
||||
Session::forget('bills.create.fromStore');
|
||||
$subTitle = 'Create new bill';
|
||||
|
||||
return view('bills.create')->with('periods', $periods)->with('subTitle', 'Create new');
|
||||
return view('bills.create', compact('periods', 'subTitle'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,16 +104,18 @@ class BillController extends Controller
|
||||
{
|
||||
// put previous url in session
|
||||
Session::put('bills.delete.url', URL::previous());
|
||||
$subTitle = 'Delete "' . e($bill->name) . '"';
|
||||
|
||||
return view('bills.delete')->with('bill', $bill)->with('subTitle', 'Delete "' . e($bill->name) . '"');
|
||||
return view('bills.delete', compact('bill', 'subTitle'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Bill $bill
|
||||
* @param BillRepositoryInterface $repository
|
||||
* @param Bill $bill
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function destroy(Bill $bill, BillRepositoryInterface $repository)
|
||||
public function destroy(BillRepositoryInterface $repository, Bill $bill)
|
||||
{
|
||||
$repository->destroy($bill);
|
||||
|
||||
@@ -128,7 +132,8 @@ class BillController extends Controller
|
||||
*/
|
||||
public function edit(Bill $bill)
|
||||
{
|
||||
$periods = Config::get('firefly.periods_to_text');
|
||||
$periods = Config::get('firefly.periods_to_text');
|
||||
$subTitle = 'Edit "' . e($bill->name) . '"';
|
||||
|
||||
// put previous url in session if not redirect from store (not "return_to_edit").
|
||||
if (Session::get('bills.edit.fromUpdate') !== true) {
|
||||
@@ -136,7 +141,7 @@ class BillController extends Controller
|
||||
}
|
||||
Session::forget('bills.edit.fromUpdate');
|
||||
|
||||
return view('bills.edit')->with('periods', $periods)->with('bill', $bill)->with('subTitle', 'Edit "' . e($bill->name) . '"');
|
||||
return view('bills.edit', compact('subTitle', 'periods', 'bill'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -158,11 +163,12 @@ class BillController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Bill $bill
|
||||
* @param BillRepositoryInterface $repository
|
||||
* @param Bill $bill
|
||||
*
|
||||
* @return mixed
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function rescan(Bill $bill, BillRepositoryInterface $repository)
|
||||
public function rescan(BillRepositoryInterface $repository, Bill $bill)
|
||||
{
|
||||
if (intval($bill->active) == 0) {
|
||||
Session::flash('warning', 'Inactive bills cannot be scanned.');
|
||||
@@ -183,21 +189,26 @@ class BillController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Bill $bill
|
||||
* @param BillRepositoryInterface $repository
|
||||
* @param Bill $bill
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function show(Bill $bill, BillRepositoryInterface $repository)
|
||||
public function show(BillRepositoryInterface $repository, Bill $bill)
|
||||
{
|
||||
$journals = $repository->getJournals($bill);
|
||||
$bill->nextExpectedMatch = $repository->nextExpectedMatch($bill);
|
||||
$hideBill = true;
|
||||
$subTitle = e($bill->name);
|
||||
|
||||
return view('bills.show', compact('journals', 'hideBill', 'bill'))->with('subTitle', e($bill->name));
|
||||
return view('bills.show', compact('journals', 'hideBill', 'bill', 'subTitle'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
* @param BillFormRequest $request
|
||||
* @param BillRepositoryInterface $repository
|
||||
*
|
||||
* @return $this|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function store(BillFormRequest $request, BillRepositoryInterface $repository)
|
||||
{
|
||||
@@ -218,11 +229,13 @@ class BillController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Bill $bill
|
||||
* @param BillFormRequest $request
|
||||
* @param BillRepositoryInterface $repository
|
||||
* @param Bill $bill
|
||||
*
|
||||
* @return $this
|
||||
* @return $this|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(Bill $bill, BillFormRequest $request, BillRepositoryInterface $repository)
|
||||
public function update(BillFormRequest $request, BillRepositoryInterface $repository, Bill $bill)
|
||||
{
|
||||
$billData = $request->getBillData();
|
||||
$bill = $repository->update($bill, $billData);
|
||||
|
@@ -36,11 +36,12 @@ class BudgetController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Budget $budget
|
||||
* @param BudgetRepositoryInterface $repository
|
||||
* @param Budget $budget
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function amount(Budget $budget, BudgetRepositoryInterface $repository)
|
||||
public function amount(BudgetRepositoryInterface $repository, Budget $budget)
|
||||
{
|
||||
$amount = intval(Input::get('amount'));
|
||||
$date = Session::get('start', Carbon::now()->startOfMonth());
|
||||
@@ -60,8 +61,9 @@ class BudgetController extends Controller
|
||||
Session::put('budgets.create.url', URL::previous());
|
||||
}
|
||||
Session::forget('budgets.create.fromStore');
|
||||
$subTitle = 'Create a new budget';
|
||||
|
||||
return view('budgets.create')->with('subTitle', 'Create a new budget');
|
||||
return view('budgets.create', compact('subTitle'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,7 +82,8 @@ class BudgetController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Budget $budget
|
||||
* @param Budget $budget
|
||||
* @param BudgetRepositoryInterface $repository
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
@@ -116,7 +119,9 @@ class BudgetController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
* @param BudgetRepositoryInterface $repository
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function index(BudgetRepositoryInterface $repository)
|
||||
{
|
||||
@@ -150,7 +155,9 @@ class BudgetController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\View\View
|
||||
* @param BudgetRepositoryInterface $repository
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function noBudget(BudgetRepositoryInterface $repository)
|
||||
{
|
||||
@@ -163,7 +170,7 @@ class BudgetController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function postUpdateIncome()
|
||||
{
|
||||
@@ -175,16 +182,18 @@ class BudgetController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BudgetRepositoryInterface $repository
|
||||
* @param Budget $budget
|
||||
* @param LimitRepetition $repetition
|
||||
*
|
||||
* @param Budget $budget
|
||||
* @param LimitRepetition $repetition
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
* @return View
|
||||
*/
|
||||
public function show(Budget $budget, LimitRepetition $repetition = null, BudgetRepositoryInterface $repository)
|
||||
public function show(BudgetRepositoryInterface $repository, Budget $budget, LimitRepetition $repetition = null)
|
||||
{
|
||||
if (!is_null($repetition->id) && $repetition->budgetLimit->budget->id != $budget->id) {
|
||||
return view('error')->with('message', 'Invalid selection.');
|
||||
$message = 'Invalid selection.';
|
||||
|
||||
return view('error', compact('message'));
|
||||
}
|
||||
|
||||
$journals = $repository->getJournals($budget, $repetition);
|
||||
@@ -224,13 +233,13 @@ class BudgetController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Budget $budget
|
||||
* @param BudgetFormRequest $request
|
||||
* @param BudgetRepositoryInterface $repository
|
||||
* @param Budget $budget
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
* @return $this|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(Budget $budget, BudgetFormRequest $request, BudgetRepositoryInterface $repository)
|
||||
public function update(BudgetFormRequest $request, BudgetRepositoryInterface $repository, Budget $budget)
|
||||
{
|
||||
$budgetData = [
|
||||
'name' => $request->input('name'),
|
||||
@@ -254,14 +263,14 @@ class BudgetController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
* @return View
|
||||
*/
|
||||
public function updateIncome()
|
||||
{
|
||||
$date = Session::get('start', Carbon::now()->startOfMonth())->format('FY');
|
||||
$budgetAmount = Preferences::get('budgetIncomeTotal' . $date, 1000);
|
||||
$date = Session::get('start', Carbon::now()->startOfMonth())->format('FY');
|
||||
$amount = Preferences::get('budgetIncomeTotal' . $date, 1000);
|
||||
|
||||
return view('budgets.income')->with('amount', $budgetAmount);
|
||||
return view('budgets.income', compact('amount'));
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,7 +2,6 @@
|
||||
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Http\Requests;
|
||||
use FireflyIII\Http\Requests\CategoryFormRequest;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||
@@ -41,8 +40,9 @@ class CategoryController extends Controller
|
||||
Session::put('categories.create.url', URL::previous());
|
||||
}
|
||||
Session::forget('categories.create.fromStore');
|
||||
$subTitle = 'Create a new category';
|
||||
|
||||
return view('categories.create')->with('subTitle', 'Create a new category');
|
||||
return view('categories.create', compact('subTitle'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,11 +61,12 @@ class CategoryController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Category $category
|
||||
* @param CategoryRepositoryInterface $repository
|
||||
* @param Category $category
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function destroy(Category $category, CategoryRepositoryInterface $repository)
|
||||
public function destroy(CategoryRepositoryInterface $repository, Category $category)
|
||||
{
|
||||
|
||||
$name = $category->name;
|
||||
@@ -96,8 +97,9 @@ class CategoryController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
* @param CategoryRepositoryInterface $repository
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function index(CategoryRepositoryInterface $repository)
|
||||
{
|
||||
@@ -113,6 +115,8 @@ class CategoryController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CategoryRepositoryInterface $repository
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function noCategory(CategoryRepositoryInterface $repository)
|
||||
@@ -126,11 +130,12 @@ class CategoryController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Category $category
|
||||
* @param CategoryRepositoryInterface $repository
|
||||
* @param Category $category
|
||||
*
|
||||
* @return $this
|
||||
* @return View
|
||||
*/
|
||||
public function show(Category $category, CategoryRepositoryInterface $repository)
|
||||
public function show(CategoryRepositoryInterface $repository, Category $category)
|
||||
{
|
||||
$hideCategory = true; // used in list.
|
||||
$page = intval(Input::get('page'));
|
||||
@@ -169,13 +174,13 @@ class CategoryController extends Controller
|
||||
|
||||
|
||||
/**
|
||||
* @param Category $category
|
||||
* @param CategoryFormRequest $request
|
||||
* @param CategoryRepositoryInterface $repository
|
||||
* @param Category $category
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(Category $category, CategoryFormRequest $request, CategoryRepositoryInterface $repository)
|
||||
public function update(CategoryFormRequest $request, CategoryRepositoryInterface $repository, Category $category)
|
||||
{
|
||||
$categoryData = [
|
||||
'name' => $request->input('name'),
|
||||
|
@@ -68,11 +68,12 @@ class CurrencyController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionCurrency $currency
|
||||
* @param CurrencyRepositoryInterface $repository
|
||||
* @param TransactionCurrency $currency
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View
|
||||
* @return \Illuminate\Http\RedirectResponse|View
|
||||
*/
|
||||
public function delete(TransactionCurrency $currency, CurrencyRepositoryInterface $repository)
|
||||
public function delete(CurrencyRepositoryInterface $repository, TransactionCurrency $currency)
|
||||
{
|
||||
|
||||
if ($repository->countJournals($currency) > 0) {
|
||||
@@ -89,11 +90,13 @@ class CurrencyController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionCurrency $currency
|
||||
* @param CurrencyRepositoryInterface $repository
|
||||
* @param TransactionCurrency $currency
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function destroy(TransactionCurrency $currency, CurrencyRepositoryInterface $repository)
|
||||
public function destroy(CurrencyRepositoryInterface $repository, TransactionCurrency $currency)
|
||||
{
|
||||
if ($repository->countJournals($currency) > 0) {
|
||||
Session::flash('error', 'Cannot destroy ' . e($currency->name) . ' because there are still transactions attached to it.');
|
||||
@@ -130,6 +133,8 @@ class CurrencyController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CurrencyRepositoryInterface $repository
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function index(CurrencyRepositoryInterface $repository)
|
||||
@@ -141,7 +146,9 @@ class CurrencyController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind.
|
||||
*
|
||||
* @param CurrencyFormRequest $request
|
||||
* @param CurrencyRepositoryInterface $repository
|
||||
*
|
||||
* @return $this|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
@@ -166,11 +173,13 @@ class CurrencyController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionCurrency $currency
|
||||
* @param CurrencyFormRequest $request
|
||||
* @param CurrencyRepositoryInterface $repository
|
||||
* @param TransactionCurrency $currency
|
||||
*
|
||||
* @return $this|\Illuminate\Http\RedirectResponse
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(TransactionCurrency $currency, CurrencyFormRequest $request, CurrencyRepositoryInterface $repository)
|
||||
public function update(CurrencyFormRequest $request, CurrencyRepositoryInterface $repository, TransactionCurrency $currency)
|
||||
{
|
||||
$data = $request->getCurrencyData();
|
||||
$currency = $repository->update($currency, $data);
|
||||
|
@@ -35,12 +35,12 @@ class GoogleChartController extends Controller
|
||||
|
||||
|
||||
/**
|
||||
* @param GChart $chart
|
||||
* @param Account $account
|
||||
* @param string $view
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function accountBalanceChart(Account $account, GChart $chart)
|
||||
public function accountBalanceChart(GChart $chart, Account $account)
|
||||
{
|
||||
$chart->addColumn('Day of month', 'date');
|
||||
$chart->addColumn('Balance for ' . $account->name, 'number');
|
||||
@@ -64,7 +64,8 @@ class GoogleChartController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param GChart $chart
|
||||
* @param GChart $chart
|
||||
* @param AccountRepositoryInterface $repository
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
@@ -104,11 +105,13 @@ class GoogleChartController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $year
|
||||
* @param GChart $chart
|
||||
* @param BudgetRepositoryInterface $repository
|
||||
* @param $year
|
||||
*
|
||||
* @return $this|\Illuminate\Http\JsonResponse
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function allBudgetsAndSpending($year, GChart $chart, BudgetRepositoryInterface $repository)
|
||||
public function allBudgetsAndSpending(GChart $chart, BudgetRepositoryInterface $repository, $year)
|
||||
{
|
||||
$budgets = $repository->getBudgets();
|
||||
$chart->addColumn('Month', 'date');
|
||||
@@ -137,7 +140,8 @@ class GoogleChartController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param GChart $chart
|
||||
* @param GChart $chart
|
||||
* @param BudgetRepositoryInterface $repository
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
@@ -145,7 +149,7 @@ class GoogleChartController extends Controller
|
||||
{
|
||||
$chart->addColumn('Budget', 'string');
|
||||
$chart->addColumn('Left', 'number');
|
||||
//$chart->addColumn('Spent', 'number');
|
||||
$chart->addColumn('Overspent', 'number');
|
||||
|
||||
$budgets = $repository->getBudgets();
|
||||
$start = Session::get('start', Carbon::now()->startOfMonth());
|
||||
@@ -172,7 +176,14 @@ class GoogleChartController extends Controller
|
||||
foreach ($allEntries as $entry) {
|
||||
if ($entry[2] > 0) {
|
||||
$left = $entry[1] - $entry[2];
|
||||
$chart->addRow($entry[0], $left);
|
||||
if ($left > 0) {
|
||||
$chart->addRow($entry[0], $left, null);
|
||||
} else {
|
||||
if ($left < 0) {
|
||||
$chart->addRow($entry[0], null, $left);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,7 +194,8 @@ class GoogleChartController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param GChart $chart
|
||||
* @param GChart $chart
|
||||
* @param CategoryRepositoryInterface $repository
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
@@ -210,12 +222,13 @@ class GoogleChartController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Bill $bill
|
||||
* @param GChart $chart
|
||||
* @param GChart $chart
|
||||
* @param BillRepositoryInterface $repository
|
||||
* @param Bill $bill
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function billOverview(Bill $bill, GChart $chart, BillRepositoryInterface $repository)
|
||||
public function billOverview(GChart $chart, BillRepositoryInterface $repository, Bill $bill)
|
||||
{
|
||||
|
||||
$chart->addColumn('Date', 'date');
|
||||
@@ -237,7 +250,10 @@ class GoogleChartController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param GChart $chart
|
||||
* @param GChart $chart
|
||||
*
|
||||
* @param BillRepositoryInterface $repository
|
||||
* @param AccountRepositoryInterface $accounts
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
@@ -319,13 +335,14 @@ class GoogleChartController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param GChart $chart
|
||||
* @param BudgetRepositoryInterface $repository
|
||||
* @param Budget $budget
|
||||
* @param LimitRepetition $repetition
|
||||
*
|
||||
* @param Budget $budget
|
||||
* @param LimitRepetition $repetition
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function budgetLimitSpending(Budget $budget, LimitRepetition $repetition, GChart $chart, BudgetRepositoryInterface $repository)
|
||||
public function budgetLimitSpending(GChart $chart, BudgetRepositoryInterface $repository, Budget $budget, LimitRepetition $repetition)
|
||||
{
|
||||
$start = clone $repetition->startdate;
|
||||
$end = $repetition->enddate;
|
||||
@@ -352,10 +369,10 @@ class GoogleChartController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Budget $budget
|
||||
* @param int $year
|
||||
* @param GChart $chart
|
||||
* @param BudgetRepositoryInterface $repository
|
||||
* @param Budget $budget
|
||||
* @param int $year
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
@@ -389,12 +406,13 @@ class GoogleChartController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param GChart $chart
|
||||
* @param CategoryRepositoryInterface $repository
|
||||
* @param Category $category
|
||||
*
|
||||
* @param Category $category
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function categoryOverviewChart(Category $category, GChart $chart, CategoryRepositoryInterface $repository)
|
||||
public function categoryOverviewChart(GChart $chart, CategoryRepositoryInterface $repository, Category $category)
|
||||
{
|
||||
// oldest transaction in category:
|
||||
$start = $repository->getFirstActivityDate($category);
|
||||
@@ -425,12 +443,13 @@ class GoogleChartController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param GChart $chart
|
||||
* @param CategoryRepositoryInterface $repository
|
||||
* @param Category $category
|
||||
*
|
||||
* @param Category $category
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function categoryPeriodChart(Category $category, GChart $chart, CategoryRepositoryInterface $repository)
|
||||
public function categoryPeriodChart(GChart $chart, CategoryRepositoryInterface $repository, Category $category)
|
||||
{
|
||||
$start = clone Session::get('start', Carbon::now()->startOfMonth());
|
||||
$chart->addColumn('Period', 'date');
|
||||
@@ -452,11 +471,13 @@ class GoogleChartController extends Controller
|
||||
|
||||
|
||||
/**
|
||||
* @param PiggyBank $piggyBank
|
||||
* @param GChart $chart
|
||||
* @param PiggyBankRepositoryInterface $repository
|
||||
* @param PiggyBank $piggyBank
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function piggyBankHistory(PiggyBank $piggyBank, GChart $chart, PiggyBankRepositoryInterface $repository)
|
||||
public function piggyBankHistory(GChart $chart, PiggyBankRepositoryInterface $repository, PiggyBank $piggyBank)
|
||||
{
|
||||
$chart->addColumn('Date', 'date');
|
||||
$chart->addColumn('Balance', 'number');
|
||||
@@ -477,12 +498,13 @@ class GoogleChartController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param GChart $chart
|
||||
* @param ReportQueryInterface $query
|
||||
* @param $year
|
||||
*
|
||||
* @param $year
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function yearInExp($year, GChart $chart, ReportQueryInterface $query)
|
||||
public function yearInExp(GChart $chart, ReportQueryInterface $query, $year)
|
||||
{
|
||||
$start = new Carbon('01-01-' . $year);
|
||||
$chart->addColumn('Month', 'date');
|
||||
@@ -515,12 +537,13 @@ class GoogleChartController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param GChart $chart
|
||||
* @param ReportQueryInterface $query
|
||||
* @param $year
|
||||
*
|
||||
* @param $year
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function yearInExpSum($year, GChart $chart, ReportQueryInterface $query)
|
||||
public function yearInExpSum(GChart $chart, ReportQueryInterface $query, $year)
|
||||
{
|
||||
$start = new Carbon('01-01-' . $year);
|
||||
$chart->addColumn('Summary', 'string');
|
||||
|
@@ -13,11 +13,12 @@ class HelpController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* @param $route
|
||||
* @param HelpInterface $help
|
||||
* @param $route
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function show($route, HelpInterface $help)
|
||||
public function show(HelpInterface $help, $route)
|
||||
{
|
||||
$content = [
|
||||
'text' => '<p>There is no help for this route!</p>',
|
||||
|
@@ -5,6 +5,7 @@ use Carbon\Carbon;
|
||||
use FireflyIII\Helpers\Report\ReportQueryInterface;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Models\Preference;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
@@ -28,7 +29,9 @@ class JsonController extends Controller
|
||||
|
||||
|
||||
/**
|
||||
* @param BillRepositoryInterface $repository
|
||||
* @param BillRepositoryInterface $repository
|
||||
*
|
||||
* @param AccountRepositoryInterface $accountRepository
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
@@ -149,6 +152,8 @@ class JsonController extends Controller
|
||||
/**
|
||||
* Returns a list of categories.
|
||||
*
|
||||
* @param CategoryRepositoryInterface $repository
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function categories(CategoryRepositoryInterface $repository)
|
||||
@@ -166,6 +171,8 @@ class JsonController extends Controller
|
||||
/**
|
||||
* Returns a JSON list of all beneficiaries.
|
||||
*
|
||||
* @param AccountRepositoryInterface $accountRepository
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function expenseAccounts(AccountRepositoryInterface $accountRepository)
|
||||
@@ -183,6 +190,8 @@ class JsonController extends Controller
|
||||
/**
|
||||
* Returns a JSON list of all beneficiaries.
|
||||
*
|
||||
* @param TagRepositoryInterface $tagRepository
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function tags(TagRepositoryInterface $tagRepository)
|
||||
@@ -198,6 +207,8 @@ class JsonController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AccountRepositoryInterface $accountRepository
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function revenueAccounts(AccountRepositoryInterface $accountRepository)
|
||||
@@ -217,6 +228,7 @@ class JsonController extends Controller
|
||||
*/
|
||||
public function setSharedReports()
|
||||
{
|
||||
/** @var Preference $pref */
|
||||
$pref = Preferences::get('showSharedReports', false);
|
||||
$new = !$pref->data;
|
||||
Preferences::set('showSharedReports', $new);
|
||||
@@ -236,11 +248,12 @@ class JsonController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $what
|
||||
* @param JournalRepositoryInterface $repository
|
||||
* @param $what
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function transactionJournals($what, JournalRepositoryInterface $repository)
|
||||
public function transactionJournals(JournalRepositoryInterface $repository, $what)
|
||||
{
|
||||
$descriptions = [];
|
||||
$dbType = $repository->getTransactionType($what);
|
||||
|
@@ -40,11 +40,12 @@ class PiggyBankController extends Controller
|
||||
/**
|
||||
* Add money to piggy bank
|
||||
*
|
||||
* @param PiggyBank $piggyBank
|
||||
* @param AccountRepositoryInterface $repository
|
||||
* @param PiggyBank $piggyBank
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function add(PiggyBank $piggyBank, AccountRepositoryInterface $repository)
|
||||
public function add(AccountRepositoryInterface $repository, PiggyBank $piggyBank)
|
||||
{
|
||||
$leftOnAccount = $repository->leftOnAccount($piggyBank->account);
|
||||
$savedSoFar = $piggyBank->currentRelevantRep()->currentamount;
|
||||
@@ -55,15 +56,15 @@ class PiggyBankController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AccountRepositoryInterface $repository
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function create(AccountRepositoryInterface $repository)
|
||||
{
|
||||
|
||||
$periods = Config::get('firefly.piggy_bank_periods');
|
||||
$accounts = ExpandedForm::makeSelectList($repository->getAccounts(['Default account', 'Asset account']));
|
||||
//Auth::user()->accounts()->orderBy('accounts.name', 'ASC')->accountTypeIn(['Default account', 'Asset account'])->get(['accounts.*'])
|
||||
// );
|
||||
$periods = Config::get('firefly.piggy_bank_periods');
|
||||
$accounts = ExpandedForm::makeSelectList($repository->getAccounts(['Default account', 'Asset account']));
|
||||
$subTitle = 'Create new piggy bank';
|
||||
$subTitleIcon = 'fa-plus';
|
||||
|
||||
@@ -92,11 +93,12 @@ class PiggyBankController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PiggyBank $piggyBank
|
||||
* @param PiggyBankRepositoryInterface $repository
|
||||
* @param PiggyBank $piggyBank
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function destroy(PiggyBank $piggyBank, PiggyBankRepositoryInterface $repository)
|
||||
public function destroy(PiggyBankRepositoryInterface $repository, PiggyBank $piggyBank)
|
||||
{
|
||||
|
||||
|
||||
@@ -107,13 +109,12 @@ class PiggyBankController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind.
|
||||
* @param AccountRepositoryInterface $repository
|
||||
* @param PiggyBank $piggyBank
|
||||
*
|
||||
* @param PiggyBank $piggyBank
|
||||
*
|
||||
* @return $this
|
||||
* @return View
|
||||
*/
|
||||
public function edit(PiggyBank $piggyBank, AccountRepositoryInterface $repository)
|
||||
public function edit(AccountRepositoryInterface $repository, PiggyBank $piggyBank)
|
||||
{
|
||||
|
||||
$periods = Config::get('firefly.piggy_bank_periods');
|
||||
@@ -149,7 +150,10 @@ class PiggyBankController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
* @param AccountRepositoryInterface $repository
|
||||
* @param PiggyBankRepositoryInterface $piggyRepository
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function index(AccountRepositoryInterface $repository, PiggyBankRepositoryInterface $piggyRepository)
|
||||
{
|
||||
@@ -187,7 +191,7 @@ class PiggyBankController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow user to order piggy banks.
|
||||
* @param PiggyBankRepositoryInterface $repository
|
||||
*/
|
||||
public function order(PiggyBankRepositoryInterface $repository)
|
||||
{
|
||||
@@ -204,13 +208,13 @@ class PiggyBankController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* POST add money to piggy bank
|
||||
*
|
||||
* @param PiggyBank $piggyBank
|
||||
* @param PiggyBankRepositoryInterface $repository
|
||||
* @param AccountRepositoryInterface $accounts
|
||||
* @param PiggyBank $piggyBank
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function postAdd(PiggyBank $piggyBank, PiggyBankRepositoryInterface $repository, AccountRepositoryInterface $accounts)
|
||||
public function postAdd(PiggyBankRepositoryInterface $repository, AccountRepositoryInterface $accounts, PiggyBank $piggyBank)
|
||||
{
|
||||
$amount = round(floatval(Input::get('amount')), 2);
|
||||
$leftOnAccount = $accounts->leftOnAccount($piggyBank->account);
|
||||
@@ -240,11 +244,12 @@ class PiggyBankController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PiggyBank $piggyBank
|
||||
* @param PiggyBankRepositoryInterface $repository
|
||||
* @param PiggyBank $piggyBank
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function postRemove(PiggyBank $piggyBank, PiggyBankRepositoryInterface $repository)
|
||||
public function postRemove(PiggyBankRepositoryInterface $repository, PiggyBank $piggyBank)
|
||||
{
|
||||
$amount = floatval(Input::get('amount'));
|
||||
|
||||
@@ -269,7 +274,6 @@ class PiggyBankController extends Controller
|
||||
/**
|
||||
* @param PiggyBank $piggyBank
|
||||
*
|
||||
* @SuppressWarnings("Unused")
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
@@ -279,11 +283,12 @@ class PiggyBankController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PiggyBank $piggyBank
|
||||
* @param PiggyBankRepositoryInterface $repository
|
||||
* @param PiggyBank $piggyBank
|
||||
*
|
||||
* @return $this
|
||||
* @return View
|
||||
*/
|
||||
public function show(PiggyBank $piggyBank, PiggyBankRepositoryInterface $repository)
|
||||
public function show(PiggyBankRepositoryInterface $repository, PiggyBank $piggyBank)
|
||||
{
|
||||
$events = $repository->getEvents($piggyBank);
|
||||
|
||||
@@ -332,13 +337,13 @@ class PiggyBankController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PiggyBank $piggyBank
|
||||
*
|
||||
* @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind.
|
||||
* @param PiggyBankRepositoryInterface $repository
|
||||
* @param PiggyBankFormRequest $request
|
||||
* @param PiggyBank $piggyBank
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function update(PiggyBank $piggyBank, PiggyBankRepositoryInterface $repository, PiggyBankFormRequest $request)
|
||||
public function update(PiggyBankRepositoryInterface $repository, PiggyBankFormRequest $request, PiggyBank $piggyBank)
|
||||
{
|
||||
$piggyBankData = [
|
||||
'name' => $request->get('name'),
|
||||
|
@@ -26,20 +26,20 @@ class PreferencesController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AccountRepositoryInterface $repository
|
||||
*
|
||||
* @return $this|\Illuminate\View\View
|
||||
*/
|
||||
public function index(AccountRepositoryInterface $repository)
|
||||
{
|
||||
$accounts = $repository->getAccounts(['Default account', 'Asset account']);
|
||||
$viewRange = Preferences::get('viewRange', '1M');
|
||||
$viewRangeValue = $viewRange->data;
|
||||
$frontPage = Preferences::get('frontPageAccounts', []);
|
||||
$budgetMax = Preferences::get('budgetMaximum', 1000);
|
||||
$budgetMaximum = $budgetMax->data;
|
||||
$accounts = $repository->getAccounts(['Default account', 'Asset account']);
|
||||
$viewRangePref = Preferences::get('viewRange', '1M');
|
||||
$viewRange = $viewRangePref->data;
|
||||
$frontPageAccounts = Preferences::get('frontPageAccounts', []);
|
||||
$budgetMax = Preferences::get('budgetMaximum', 1000);
|
||||
$budgetMaximum = $budgetMax->data;
|
||||
|
||||
return view('preferences.index', compact('budgetMaximum'))->with('accounts', $accounts)->with('frontPageAccounts', $frontPage)->with(
|
||||
'viewRange', $viewRangeValue
|
||||
);
|
||||
return view('preferences.index', compact('budgetMaximum', 'accounts', 'frontPageAccounts', 'viewRange'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -26,16 +26,6 @@ class ProfileController extends Controller
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\View\View
|
||||
*
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('profile.index')->with('title', 'Profile')->with('subTitle', Auth::user()->email)->with('mainTitleIcon', 'fa-user');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
@@ -47,8 +37,66 @@ class ProfileController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\View\View
|
||||
*
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('profile.index')->with('title', 'Profile')->with('subTitle', Auth::user()->email)->with('mainTitleIcon', 'fa-user');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ProfileFormRequest $request
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View
|
||||
*/
|
||||
public function postChangePassword(ProfileFormRequest $request)
|
||||
{
|
||||
// old, new1, new2
|
||||
if (!Hash::check($request->get('current_password'), Auth::user()->password)) {
|
||||
Session::flash('error', 'Invalid current password!');
|
||||
|
||||
return Redirect::route('change-password');
|
||||
}
|
||||
$result = $this->validatePassword($request->get('current_password'), $request->get('new_password'));
|
||||
if (!($result === true)) {
|
||||
Session::flash('error', $result);
|
||||
|
||||
return Redirect::route('change-password');
|
||||
}
|
||||
|
||||
// update the user with the new password.
|
||||
Auth::user()->password = $request->get('new_password');
|
||||
Auth::user()->save();
|
||||
|
||||
Session::flash('success', 'Password changed!');
|
||||
|
||||
return Redirect::route('profile');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $old
|
||||
* @param string $new1
|
||||
*
|
||||
* @return string|bool
|
||||
*/
|
||||
protected function validatePassword($old, $new1)
|
||||
{
|
||||
if ($new1 == $old) {
|
||||
return 'The idea is to change your password.';
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DeleteAccountFormRequest $request
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function postDeleteAccount(DeleteAccountFormRequest $request)
|
||||
{
|
||||
// old, new1, new2
|
||||
@@ -66,57 +114,4 @@ class ProfileController extends Controller
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View
|
||||
*/
|
||||
public function postChangePassword(ProfileFormRequest $request)
|
||||
{
|
||||
// old, new1, new2
|
||||
if (!Hash::check($request->get('current_password'), Auth::user()->password)) {
|
||||
Session::flash('error', 'Invalid current password!');
|
||||
|
||||
return Redirect::route('change-password');
|
||||
}
|
||||
$result = $this->validatePassword($request->get('current_password'), $request->get('new_password'), $request->get('new_password_confirmation'));
|
||||
if (!($result === true)) {
|
||||
Session::flash('error', $result);
|
||||
|
||||
return Redirect::route('change-password');
|
||||
}
|
||||
|
||||
// update the user with the new password.
|
||||
Auth::user()->password = $request->get('new_password');
|
||||
Auth::user()->save();
|
||||
|
||||
Session::flash('success', 'Password changed!');
|
||||
|
||||
return Redirect::route('profile');
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind.
|
||||
*
|
||||
* @param string $old
|
||||
* @param string $new1
|
||||
* @param string $new2
|
||||
*
|
||||
* @return string|bool
|
||||
*/
|
||||
protected function validatePassword($old, $new1, $new2)
|
||||
{
|
||||
if (strlen($new1) == 0 || strlen($new2) == 0) {
|
||||
return 'Do fill in a password!';
|
||||
|
||||
}
|
||||
if ($new1 == $old) {
|
||||
return 'The idea is to change your password.';
|
||||
}
|
||||
|
||||
if ($new1 !== $new2) {
|
||||
return 'New passwords do not match!';
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -1,9 +1,7 @@
|
||||
<?php namespace FireflyIII\Http\Controllers;
|
||||
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Helpers\Reminders\ReminderHelperInterface;
|
||||
use FireflyIII\Models\Reminder;
|
||||
use FireflyIII\Repositories\Reminder\ReminderRepositoryInterface;
|
||||
use Redirect;
|
||||
use Session;
|
||||
use URL;
|
||||
@@ -19,6 +17,8 @@ class ReminderController extends Controller
|
||||
|
||||
/**
|
||||
* @param Reminder $reminder
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function act(Reminder $reminder)
|
||||
{
|
||||
@@ -36,6 +36,8 @@ class ReminderController extends Controller
|
||||
|
||||
/**
|
||||
* @param Reminder $reminder
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function dismiss(Reminder $reminder)
|
||||
{
|
||||
@@ -48,55 +50,18 @@ class ReminderController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ReminderRepositoryInterface $repository
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function index(ReminderHelperInterface $helper)
|
||||
public function index(ReminderRepositoryInterface $repository)
|
||||
{
|
||||
|
||||
$reminders = Auth::user()->reminders()->get();
|
||||
|
||||
$reminders->each(
|
||||
function (Reminder $reminder) use ($helper) {
|
||||
$reminder->description = $helper->getReminderText($reminder);
|
||||
}
|
||||
);
|
||||
|
||||
$today = new Carbon;
|
||||
// active reminders:
|
||||
$active = $reminders->filter(
|
||||
function (Reminder $reminder) use ($today) {
|
||||
if ($reminder->notnow === false && $reminder->active === true && $reminder->startdate <= $today && $reminder->enddate >= $today) {
|
||||
return $reminder;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// expired reminders:
|
||||
$expired = $reminders->filter(
|
||||
function (Reminder $reminder) use ($today) {
|
||||
if ($reminder->notnow === false && $reminder->active === true && $reminder->startdate > $today || $reminder->enddate < $today) {
|
||||
return $reminder;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// inactive reminders
|
||||
$inactive = $reminders->filter(
|
||||
function (Reminder $reminder) {
|
||||
if ($reminder->active === false) {
|
||||
return $reminder;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// dismissed reminders
|
||||
$dismissed = $reminders->filter(
|
||||
function (Reminder $reminder) {
|
||||
if ($reminder->notnow === true) {
|
||||
return $reminder;
|
||||
}
|
||||
}
|
||||
);
|
||||
$active = $repository->getActiveReminders();
|
||||
$expired = $repository->getExpiredReminders();
|
||||
$inactive = $repository->getInactiveReminders();
|
||||
$dismissed = $repository->getDismissedReminders();
|
||||
|
||||
$title = 'Reminders';
|
||||
$mainTitleIcon = 'fa-clock-o';
|
||||
@@ -106,6 +71,8 @@ class ReminderController extends Controller
|
||||
|
||||
/**
|
||||
* @param Reminder $reminder
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function show(Reminder $reminder)
|
||||
{
|
||||
|
@@ -1,7 +1,6 @@
|
||||
<?php namespace FireflyIII\Http\Controllers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use FireflyIII\Helpers\Report\ReportHelperInterface;
|
||||
use FireflyIII\Helpers\Report\ReportQueryInterface;
|
||||
use FireflyIII\Models\Account;
|
||||
@@ -76,6 +75,7 @@ class ReportController extends Controller
|
||||
// should always hide account
|
||||
$hide = true;
|
||||
// loop all budgets
|
||||
/** @var \FireflyIII\Models\Budget $budget */
|
||||
foreach ($budgets as $budget) {
|
||||
$id = intval($budget->id);
|
||||
$data = $budget->toArray();
|
||||
@@ -107,9 +107,9 @@ class ReportController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ReportHelperInterface $helper
|
||||
*
|
||||
* @return View
|
||||
* @internal param ReportHelperInterface $helper
|
||||
*
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@@ -132,11 +132,6 @@ class ReportController extends Controller
|
||||
public function modalBalancedTransfers(Account $account, $year = '2014', $month = '1')
|
||||
{
|
||||
|
||||
try {
|
||||
new Carbon($year . '-' . $month . '-01');
|
||||
} catch (Exception $e) {
|
||||
return view('error')->with('message', 'Invalid date');
|
||||
}
|
||||
$start = new Carbon($year . '-' . $month . '-01');
|
||||
$end = clone $start;
|
||||
$end->endOfMonth();
|
||||
@@ -149,20 +144,16 @@ class ReportController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
* @param string $year
|
||||
* @param string $month
|
||||
* @param ReportQueryInterface $query
|
||||
* @param Account $account
|
||||
* @param string $year
|
||||
* @param string $month
|
||||
*
|
||||
* @return View
|
||||
* @internal param ReportQueryInterface $query
|
||||
*
|
||||
*/
|
||||
public function modalLeftUnbalanced(Account $account, $year = '2014', $month = '1')
|
||||
{
|
||||
try {
|
||||
new Carbon($year . '-' . $month . '-01');
|
||||
} catch (Exception $e) {
|
||||
return view('error')->with('message', 'Invalid date');
|
||||
}
|
||||
$start = new Carbon($year . '-' . $month . '-01');
|
||||
$end = clone $start;
|
||||
$end->endOfMonth();
|
||||
@@ -174,6 +165,8 @@ class ReportController extends Controller
|
||||
if ($count == 0) {
|
||||
return $journal;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
);
|
||||
|
||||
@@ -189,11 +182,6 @@ class ReportController extends Controller
|
||||
*/
|
||||
public function modalNoBudget(Account $account, $year = '2014', $month = '1')
|
||||
{
|
||||
try {
|
||||
new Carbon($year . '-' . $month . '-01');
|
||||
} catch (Exception $e) {
|
||||
return view('error')->with('message', 'Invalid date');
|
||||
}
|
||||
$start = new Carbon($year . '-' . $month . '-01');
|
||||
$end = clone $start;
|
||||
$end->endOfMonth();
|
||||
@@ -211,11 +199,6 @@ class ReportController extends Controller
|
||||
*/
|
||||
public function month($year = '2014', $month = '1')
|
||||
{
|
||||
try {
|
||||
new Carbon($year . '-' . $month . '-01');
|
||||
} catch (Exception $e) {
|
||||
return view('error')->with('message', 'Invalid date.');
|
||||
}
|
||||
$date = new Carbon($year . '-' . $month . '-01');
|
||||
$subTitle = 'Report for ' . $date->format('F Y');
|
||||
$subTitleIcon = 'fa-calendar';
|
||||
@@ -327,11 +310,6 @@ class ReportController extends Controller
|
||||
*/
|
||||
public function year($year)
|
||||
{
|
||||
try {
|
||||
new Carbon('01-01-' . $year);
|
||||
} catch (Exception $e) {
|
||||
return view('error')->with('message', 'Invalid date.');
|
||||
}
|
||||
/** @var Preference $pref */
|
||||
$pref = Preferences::get('showSharedReports', false);
|
||||
$showSharedReports = $pref->data;
|
||||
|
@@ -12,6 +12,10 @@ class SearchController extends Controller
|
||||
{
|
||||
/**
|
||||
* Results always come in the form of an array [results, count, fullCount]
|
||||
*
|
||||
* @param SearchInterface $searcher
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function index(SearchInterface $searcher)
|
||||
{
|
||||
|
@@ -87,11 +87,12 @@ class TagController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Tag $tag
|
||||
* @param TagRepositoryInterface $repository
|
||||
* @param Tag $tag
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function destroy(Tag $tag, TagRepositoryInterface $repository)
|
||||
public function destroy(TagRepositoryInterface $repository, Tag $tag)
|
||||
{
|
||||
|
||||
$tagName = $tag->tag;
|
||||
@@ -149,7 +150,7 @@ class TagController extends Controller
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
if($count > 1) {
|
||||
if ($count > 1) {
|
||||
$allowToAdvancePayment = false;
|
||||
}
|
||||
|
||||
@@ -169,12 +170,12 @@ class TagController extends Controller
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
if($count > 0) {
|
||||
if ($count > 0) {
|
||||
$allowToBalancingAct = false;
|
||||
}
|
||||
|
||||
|
||||
// edit tagoptions:
|
||||
// edit tag options:
|
||||
if ($allowToAdvancePayment === false) {
|
||||
unset($tagOptions['advancePayment']);
|
||||
}
|
||||
@@ -194,6 +195,8 @@ class TagController extends Controller
|
||||
|
||||
/**
|
||||
* @param $state
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function hideTagHelp($state)
|
||||
{
|
||||
@@ -233,7 +236,11 @@ class TagController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TagFormRequest $request
|
||||
* @param TagFormRequest $request
|
||||
*
|
||||
* @param TagRepositoryInterface $repository
|
||||
*
|
||||
* @return $this|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function store(TagFormRequest $request, TagRepositoryInterface $repository)
|
||||
{
|
||||
@@ -273,9 +280,13 @@ class TagController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Tag $tag
|
||||
* @param TagFormRequest $request
|
||||
* @param TagRepositoryInterface $repository
|
||||
* @param Tag $tag
|
||||
*
|
||||
* @return $this|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(Tag $tag, TagFormRequest $request, TagRepositoryInterface $repository)
|
||||
public function update(TagFormRequest $request, TagRepositoryInterface $repository, Tag $tag)
|
||||
{
|
||||
if (Input::get('setTag') == 'true') {
|
||||
$latitude = strlen($request->get('latitude')) > 0 ? $request->get('latitude') : null;
|
||||
|
@@ -1,6 +1,7 @@
|
||||
<?php namespace FireflyIII\Http\Controllers;
|
||||
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
use ExpandedForm;
|
||||
use FireflyIII\Events\JournalCreated;
|
||||
use FireflyIII\Events\JournalSaved;
|
||||
@@ -8,8 +9,8 @@ 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 Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Input;
|
||||
use Redirect;
|
||||
use Response;
|
||||
@@ -34,19 +35,14 @@ class TransactionController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the view helping the user to create a new transaction journal.
|
||||
* @param AccountRepositoryInterface $repository
|
||||
* @param string $what
|
||||
*
|
||||
* @param string $what
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
* @return View
|
||||
*/
|
||||
public function create($what = 'deposit')
|
||||
public function create(AccountRepositoryInterface $repository, $what = 'deposit')
|
||||
{
|
||||
$accounts = ExpandedForm::makeSelectList(
|
||||
Auth::user()->accounts()->accountTypeIn(['Default account', 'Asset account'])->orderBy('accounts.name', 'ASC')->orderBy('name', 'ASC')->where(
|
||||
'active', 1
|
||||
)->orderBy('name', 'DESC')->get(['accounts.*'])
|
||||
);
|
||||
$accounts = ExpandedForm::makeSelectList($repository->getAccounts(['Default account', 'Asset account']));
|
||||
$budgets = ExpandedForm::makeSelectList(Auth::user()->budgets()->get());
|
||||
$budgets[0] = '(no budget)';
|
||||
$piggies = ExpandedForm::makeSelectList(Auth::user()->piggyBanks()->get());
|
||||
@@ -95,15 +91,16 @@ class TransactionController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $transactionJournal
|
||||
* @param JournalRepositoryInterface $repository
|
||||
* @param TransactionJournal $transactionJournal
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function destroy(TransactionJournal $transactionJournal)
|
||||
public function destroy(JournalRepositoryInterface $repository, TransactionJournal $transactionJournal)
|
||||
{
|
||||
Session::flash('success', 'Transaction "' . e($transactionJournal->description) . '" destroyed.');
|
||||
|
||||
$transactionJournal->delete();
|
||||
$repository->delete($transactionJournal);
|
||||
|
||||
// redirect to previous URL:
|
||||
return Redirect::to(Session::get('transactions.delete.url'));
|
||||
@@ -112,18 +109,15 @@ class TransactionController extends Controller
|
||||
/**
|
||||
* Shows the view to edit a transaction.
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
* @param AccountRepositoryInterface $repository
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function edit(TransactionJournal $journal, JournalRepositoryInterface $repository)
|
||||
public function edit(AccountRepositoryInterface $repository, TransactionJournal $journal)
|
||||
{
|
||||
$what = strtolower($journal->transactiontype->type);
|
||||
$accounts = ExpandedForm::makeSelectList(
|
||||
Auth::user()->accounts()->accountTypeIn(['Default account', 'Asset account'])->orderBy('accounts.name', 'ASC')->where('active', 1)->orderBy(
|
||||
'name', 'DESC'
|
||||
)->get(['accounts.*'])
|
||||
);
|
||||
$accounts = ExpandedForm::makeSelectList($repository->getAccounts(['Default account', 'Asset account']));
|
||||
$budgets = ExpandedForm::makeSelectList(Auth::user()->budgets()->get());
|
||||
$budgets[0] = '(no budget)';
|
||||
$transactions = $journal->transactions()->orderBy('amount', 'DESC')->get();
|
||||
@@ -176,12 +170,14 @@ class TransactionController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $what
|
||||
* @param JournalRepositoryInterface $repository
|
||||
* @param $what
|
||||
*
|
||||
* @return $this
|
||||
* @return View
|
||||
*/
|
||||
public function index($what)
|
||||
public function index(JournalRepositoryInterface $repository, $what)
|
||||
{
|
||||
$types = [];
|
||||
switch ($what) {
|
||||
case 'expenses':
|
||||
case 'withdrawal':
|
||||
@@ -203,18 +199,10 @@ class TransactionController extends Controller
|
||||
break;
|
||||
}
|
||||
|
||||
$page = intval(\Input::get('page'));
|
||||
$offset = $page > 0 ? ($page - 1) * 50 : 0;
|
||||
$page = intval(Input::get('page'));
|
||||
$offset = $page > 0 ? ($page - 1) * 50 : 0;
|
||||
$journals = $repository->getJournalsOfTypes($types, $offset, $page);
|
||||
|
||||
$set = Auth::user()->transactionJournals()->transactionTypes($types)->withRelevantData()->take(50)->offset($offset)
|
||||
->orderBy('date', 'DESC')
|
||||
->orderBy('order', 'ASC')
|
||||
->orderBy('id', 'DESC')
|
||||
->get(
|
||||
['transaction_journals.*']
|
||||
);
|
||||
$count = Auth::user()->transactionJournals()->transactionTypes($types)->count();
|
||||
$journals = new LengthAwarePaginator($set, $count, 50, $page);
|
||||
$journals->setPath('transactions/' . $what);
|
||||
|
||||
return view('transactions.index', compact('subTitle', 'what', 'subTitleIcon', 'journals'));
|
||||
@@ -222,15 +210,19 @@ class TransactionController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Reorder transactions (which all must have the same date)
|
||||
* @param JournalRepositoryInterface $repository
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function reorder()
|
||||
public function reorder(JournalRepositoryInterface $repository)
|
||||
{
|
||||
$ids = Input::get('items');
|
||||
$ids = Input::get('items');
|
||||
$date = new Carbon(Input::get('date'));
|
||||
if (count($ids) > 0) {
|
||||
$order = 0;
|
||||
foreach ($ids as $id) {
|
||||
$journal = Auth::user()->transactionjournals()->where('id', $id)->where('date', Input::get('date'))->first();
|
||||
|
||||
$journal = $repository->getWithDate($id, $date);
|
||||
if ($journal) {
|
||||
$journal->order = $order;
|
||||
$order++;
|
||||
@@ -244,31 +236,22 @@ class TransactionController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
* @param JournalRepositoryInterface $repository
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function show(TransactionJournal $journal)
|
||||
public function show(JournalRepositoryInterface $repository, TransactionJournal $journal)
|
||||
{
|
||||
$journal->transactions->each(
|
||||
function (Transaction $t) use ($journal) {
|
||||
$t->before = floatval(
|
||||
$t->account->transactions()->leftJoin(
|
||||
'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id'
|
||||
)
|
||||
->where('transaction_journals.date', '<=', $journal->date->format('Y-m-d'))
|
||||
->where('transaction_journals.order', '>=', $journal->order)
|
||||
->where('transaction_journals.id', '!=', $journal->id)
|
||||
->sum('transactions.amount')
|
||||
);
|
||||
function (Transaction $t) use ($journal, $repository) {
|
||||
$t->before = $repository->getAmountBefore($journal, $t);
|
||||
$t->after = $t->before + $t->amount;
|
||||
}
|
||||
);
|
||||
$subTitle = e($journal->transactiontype->type) . ' "' . e($journal->description) . '"';
|
||||
|
||||
|
||||
return view('transactions.show', compact('journal'))->with(
|
||||
'subTitle', e($journal->transactiontype->type) . ' "' . e($journal->description) . '"'
|
||||
);
|
||||
return view('transactions.show', compact('journal', 'subTitle'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -280,7 +263,6 @@ class TransactionController extends Controller
|
||||
public function store(JournalFormRequest $request, JournalRepositoryInterface $repository)
|
||||
{
|
||||
|
||||
|
||||
$journalData = $request->getJournalData();
|
||||
$journal = $repository->store($journalData);
|
||||
|
||||
@@ -289,11 +271,7 @@ class TransactionController extends Controller
|
||||
// ConnectJournalToPiggyBank
|
||||
event(new JournalCreated($journal, intval($request->get('piggy_bank_id'))));
|
||||
|
||||
if (intval($request->get('reminder_id')) > 0) {
|
||||
$reminder = Auth::user()->reminders()->find($request->get('reminder_id'));
|
||||
$reminder->active = 0;
|
||||
$reminder->save();
|
||||
}
|
||||
$repository->deactivateReminder($request->get('reminder_id'));
|
||||
|
||||
Session::flash('success', 'New transaction "' . $journal->description . '" stored!');
|
||||
|
||||
@@ -309,14 +287,15 @@ class TransactionController extends Controller
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
* @param JournalFormRequest $request
|
||||
* @param JournalRepositoryInterface $repository
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind.
|
||||
*
|
||||
* @return $this
|
||||
* @return $this|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(TransactionJournal $journal, JournalFormRequest $request, JournalRepositoryInterface $repository)
|
||||
public function update(JournalFormRequest $request, JournalRepositoryInterface $repository, TransactionJournal $journal)
|
||||
{
|
||||
|
||||
$journalData = $request->getJournalData();
|
||||
|
@@ -26,7 +26,7 @@ class DeleteAccountFormRequest extends Request
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'password' => 'required',
|
||||
'password' => 'required',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -57,7 +57,7 @@ class JournalFormRequest extends Request
|
||||
|
||||
$rules = [
|
||||
'description' => 'required|min:1,max:255',
|
||||
'what' => 'required|in:withdrawal,deposit,transfer|exists:transaction_types,type',
|
||||
'what' => 'required|in:withdrawal,deposit,transfer',
|
||||
'amount' => 'numeric|required|min:0.01',
|
||||
'date' => 'required|date',
|
||||
'reminder_id' => 'numeric|exists:reminders,id',
|
||||
|
@@ -33,7 +33,7 @@ class TagFormRequest extends Request
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
$idRule = '';
|
||||
$idRule = '';
|
||||
$tagRule = 'required|min:1|uniqueObjectForUser:tags,tag,TRUE';
|
||||
if (Tag::find(Input::get('id'))) {
|
||||
$idRule = 'belongsToUser:tags';
|
||||
|
@@ -9,9 +9,10 @@ use FireflyIII\Models\Category;
|
||||
use FireflyIII\Models\LimitRepetition;
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
use FireflyIII\Models\Reminder;
|
||||
use FireflyIII\Models\Tag;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Models\Tag;
|
||||
|
||||
/*
|
||||
* Back home.
|
||||
*/
|
||||
@@ -176,13 +177,13 @@ Breadcrumbs::register(
|
||||
Breadcrumbs::register(
|
||||
'currency.edit', function (Generator $breadcrumbs, TransactionCurrency $currency) {
|
||||
$breadcrumbs->parent('currency.index');
|
||||
$breadcrumbs->push('Edit '.$currency->name, route('currency.edit', $currency->id));
|
||||
$breadcrumbs->push('Edit ' . $currency->name, route('currency.edit', $currency->id));
|
||||
}
|
||||
);
|
||||
Breadcrumbs::register(
|
||||
'currency.delete', function (Generator $breadcrumbs, TransactionCurrency $currency) {
|
||||
$breadcrumbs->parent('currency.index');
|
||||
$breadcrumbs->push('Delete '.$currency->name, route('currency.delete', $currency->id));
|
||||
$breadcrumbs->push('Delete ' . $currency->name, route('currency.delete', $currency->id));
|
||||
}
|
||||
);
|
||||
|
||||
@@ -312,21 +313,21 @@ Breadcrumbs::register(
|
||||
Breadcrumbs::register(
|
||||
'reports.year', function (Generator $breadcrumbs, Carbon $date) {
|
||||
$breadcrumbs->parent('reports.index');
|
||||
$breadcrumbs->push($date->format('Y'), route('reports.year', $date->format('Y')));
|
||||
$breadcrumbs->push($date->year, route('reports.year', $date->year));
|
||||
}
|
||||
);
|
||||
|
||||
Breadcrumbs::register(
|
||||
'reports.month', function (Generator $breadcrumbs, Carbon $date) {
|
||||
$breadcrumbs->parent('reports.index');
|
||||
$breadcrumbs->push('Monthly report for ' . $date->format('F Y'), route('reports.month', $date));
|
||||
$breadcrumbs->push('Monthly report for ' . $date->format('F Y'), route('reports.month', [$date->year, $date->month]));
|
||||
}
|
||||
);
|
||||
|
||||
Breadcrumbs::register(
|
||||
'reports.budget', function (Generator $breadcrumbs, Carbon $date) {
|
||||
$breadcrumbs->parent('reports.index');
|
||||
$breadcrumbs->push('Budget report for ' . $date->format('F Y'), route('reports.budget', $date));
|
||||
$breadcrumbs->push('Budget report for ' . $date->format('F Y'), route('reports.budget', [$date->year, $date->month]));
|
||||
}
|
||||
);
|
||||
|
||||
@@ -412,6 +413,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));
|
||||
$breadcrumbs->push(e($tag->tag), route('tags.show', $tag->id));
|
||||
}
|
||||
);
|
@@ -13,6 +13,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
|
||||
// models
|
||||
/** @noinspection PhpUnusedParameterInspection */
|
||||
Route::bind(
|
||||
'account',
|
||||
function ($value, $route) {
|
||||
@@ -30,6 +31,7 @@ Route::bind(
|
||||
}
|
||||
);
|
||||
|
||||
/** @noinspection PhpUnusedParameterInspection */
|
||||
Route::bind(
|
||||
'tj', function ($value, $route) {
|
||||
if (Auth::check()) {
|
||||
@@ -43,6 +45,7 @@ Route::bind(
|
||||
}
|
||||
);
|
||||
|
||||
/** @noinspection PhpUnusedParameterInspection */
|
||||
Route::bind(
|
||||
'currency', function ($value, $route) {
|
||||
if (Auth::check()) {
|
||||
@@ -55,6 +58,7 @@ Route::bind(
|
||||
}
|
||||
);
|
||||
|
||||
/** @noinspection PhpUnusedParameterInspection */
|
||||
Route::bind(
|
||||
'bill', function ($value, $route) {
|
||||
if (Auth::check()) {
|
||||
@@ -68,6 +72,7 @@ Route::bind(
|
||||
}
|
||||
);
|
||||
|
||||
/** @noinspection PhpUnusedParameterInspection */
|
||||
Route::bind(
|
||||
'budget', function ($value, $route) {
|
||||
if (Auth::check()) {
|
||||
@@ -81,6 +86,7 @@ Route::bind(
|
||||
}
|
||||
);
|
||||
|
||||
/** @noinspection PhpUnusedParameterInspection */
|
||||
Route::bind(
|
||||
'reminder', function ($value, $route) {
|
||||
if (Auth::check()) {
|
||||
@@ -94,6 +100,7 @@ Route::bind(
|
||||
}
|
||||
);
|
||||
|
||||
/** @noinspection PhpUnusedParameterInspection */
|
||||
Route::bind(
|
||||
'limitrepetition', function ($value, $route) {
|
||||
if (Auth::check()) {
|
||||
@@ -111,6 +118,7 @@ Route::bind(
|
||||
}
|
||||
);
|
||||
|
||||
/** @noinspection PhpUnusedParameterInspection */
|
||||
Route::bind(
|
||||
'piggyBank', function ($value, $route) {
|
||||
if (Auth::check()) {
|
||||
@@ -127,12 +135,13 @@ Route::bind(
|
||||
}
|
||||
);
|
||||
|
||||
/** @noinspection PhpUnusedParameterInspection */
|
||||
Route::bind(
|
||||
'category', function ($value, $route) {
|
||||
if (Auth::check()) {
|
||||
return Category::where('id', $value)->where('user_id', Auth::user()->id)->first();
|
||||
$object = Category::where('id', $value)->where('user_id', Auth::user()->id)->first();
|
||||
if ($object) {
|
||||
$object = $object;
|
||||
return $object;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,12 +149,30 @@ Route::bind(
|
||||
}
|
||||
);
|
||||
|
||||
/** @noinspection PhpUnusedParameterInspection */
|
||||
Route::bind(
|
||||
'reminder', function ($value, $route) {
|
||||
if (Auth::check()) {
|
||||
/** @var \FireflyIII\Models\Reminder $object */
|
||||
$object = Reminder::find($value);
|
||||
if ($object) {
|
||||
if ($object->remindersable->account->user_id == Auth::user()->id) {
|
||||
return $object;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException;
|
||||
}
|
||||
);
|
||||
|
||||
/** @noinspection PhpUnusedParameterInspection */
|
||||
Route::bind(
|
||||
'tag', function ($value, $route) {
|
||||
if (Auth::check()) {
|
||||
return Tag::where('id', $value)->where('user_id', Auth::user()->id)->first();
|
||||
$object = Tag::where('id', $value)->where('user_id', Auth::user()->id)->first();
|
||||
if ($object) {
|
||||
$object = $object;
|
||||
return $object;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -51,7 +51,7 @@ class Account extends Model
|
||||
$account = Account::create($fields);
|
||||
if (is_null($account->id)) {
|
||||
// could not create account:
|
||||
App::abort(500, 'Could not create new account with data: ' . json_encode($fields).' because ' . json_encode($account->getErrors()));
|
||||
App::abort(500, 'Could not create new account with data: ' . json_encode($fields) . ' because ' . json_encode($account->getErrors()));
|
||||
|
||||
|
||||
}
|
||||
|
@@ -1,9 +1,10 @@
|
||||
<?php namespace FireflyIII\Models;
|
||||
|
||||
use App;
|
||||
use Crypt;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use App;
|
||||
|
||||
/**
|
||||
* Class Category
|
||||
*
|
||||
|
@@ -14,7 +14,7 @@ class PiggyBank extends Model
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable
|
||||
= ['name', 'account_id','order', 'reminder_skip', 'targetamount', 'startdate', 'targetdate', 'reminder', 'remind_me'];
|
||||
= ['name', 'account_id', 'order', 'reminder_skip', 'targetamount', 'startdate', 'targetdate', 'reminder', 'remind_me'];
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
|
@@ -78,6 +78,11 @@ class Reminder extends Model
|
||||
return $query->where('reminders.startdate', '=', $start->format('Y-m-d 00:00:00'))->where('reminders.enddate', '=', $end->format('Y-m-d 00:00:00'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param EloquentBuilder $query
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function scopeToday(EloquentBuilder $query)
|
||||
{
|
||||
$today = new Carbon;
|
||||
|
@@ -52,9 +52,9 @@ class Tag extends Model
|
||||
}
|
||||
}
|
||||
// create it!
|
||||
$fields['tagMode'] = 'nothing';
|
||||
$fields['tagMode'] = 'nothing';
|
||||
$fields['description'] = isset($fields['description']) && !is_null($fields['description']) ? $fields['description'] : '';
|
||||
$tag = Tag::create($fields);
|
||||
$tag = Tag::create($fields);
|
||||
if (is_null($tag->id)) {
|
||||
// could not create account:
|
||||
App::abort(500, 'Could not create new tag with data: ' . json_encode($fields) . ' because ' . json_encode($tag->getErrors()));
|
||||
|
@@ -66,8 +66,13 @@ class TransactionJournal extends Model
|
||||
return floatval($t->amount);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Account|mixed
|
||||
*/
|
||||
public function getAssetAccountAttribute()
|
||||
{
|
||||
$positive = true; // the asset account is in the transaction with the positive amount.
|
||||
|
@@ -173,7 +173,7 @@ class ConfigServiceProvider extends ServiceProvider
|
||||
],
|
||||
'Form' => [
|
||||
'is_safe' => [
|
||||
'input', 'select', 'checkbox', 'model', 'open','radio','textarea'
|
||||
'input', 'select', 'checkbox', 'model', 'open', 'radio', 'textarea'
|
||||
]
|
||||
],
|
||||
],
|
||||
|
@@ -6,6 +6,7 @@ use FireflyIII\Models\BudgetLimit;
|
||||
use FireflyIII\Models\LimitRepetition;
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
use FireflyIII\Models\PiggyBankRepetition;
|
||||
use FireflyIII\Models\Reminder;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Support\Facades\Navigation;
|
||||
@@ -13,7 +14,6 @@ use Illuminate\Contracts\Events\Dispatcher as DispatcherContract;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
use Log;
|
||||
use FireflyIII\Models\Reminder;
|
||||
|
||||
/**
|
||||
* Class EventServiceProvider
|
||||
|
@@ -84,6 +84,7 @@ class FireflyServiceProvider extends ServiceProvider
|
||||
$this->app->bind('FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface', 'FireflyIII\Repositories\PiggyBank\PiggyBankRepository');
|
||||
$this->app->bind('FireflyIII\Repositories\Currency\CurrencyRepositoryInterface', 'FireflyIII\Repositories\Currency\CurrencyRepository');
|
||||
$this->app->bind('FireflyIII\Repositories\Tag\TagRepositoryInterface', 'FireflyIII\Repositories\Tag\TagRepository');
|
||||
$this->app->bind('FireflyIII\Repositories\Reminder\ReminderRepositoryInterface', 'FireflyIII\Repositories\Reminder\ReminderRepository');
|
||||
$this->app->bind('FireflyIII\Support\Search\SearchInterface', 'FireflyIII\Support\Search\Search');
|
||||
|
||||
|
||||
|
@@ -374,6 +374,8 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
/**
|
||||
* @param Account $account
|
||||
* @param array $data
|
||||
*
|
||||
* @return Account
|
||||
*/
|
||||
public function update(Account $account, array $data)
|
||||
{
|
||||
|
@@ -88,7 +88,7 @@ interface AccountRepositoryInterface
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
* @param string $range
|
||||
* @param $page
|
||||
*
|
||||
* @return LengthAwarePaginator
|
||||
*/
|
||||
|
@@ -211,10 +211,12 @@ class BillRepository implements BillRepositoryInterface
|
||||
* $today is the start of the next period, to make sure FF3 won't miss anything
|
||||
* when the current period has a transaction journal.
|
||||
*/
|
||||
$today = Navigation::addPeriod(new Carbon, $bill->repeat_freq, 0);
|
||||
/** @var \Carbon\Carbon $obj */
|
||||
$obj = new Carbon;
|
||||
$today = Navigation::addPeriod($obj, $bill->repeat_freq, 0);
|
||||
|
||||
$skip = $bill->skip + 1;
|
||||
$start = Navigation::startOfPeriod(new Carbon, $bill->repeat_freq);
|
||||
$start = Navigation::startOfPeriod($obj, $bill->repeat_freq);
|
||||
/*
|
||||
* go back exactly one month/week/etc because FF3 does not care about 'next'
|
||||
* bills if they're too far into the past.
|
||||
|
@@ -72,8 +72,8 @@ interface CategoryRepositoryInterface
|
||||
|
||||
/**
|
||||
* @param Category $category
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param \Carbon\Carbon $start
|
||||
* @param \Carbon\Carbon $end
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
|
@@ -4,6 +4,7 @@ namespace FireflyIII\Repositories\Journal;
|
||||
|
||||
use App;
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
use DB;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
@@ -13,6 +14,7 @@ use FireflyIII\Models\Tag;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
|
||||
@@ -24,6 +26,38 @@ use Log;
|
||||
class JournalRepository implements JournalRepositoryInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @param int $reminderId
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function deactivateReminder($reminderId)
|
||||
{
|
||||
$reminder = Auth::user()->reminders()->find($reminderId);
|
||||
if ($reminder) {
|
||||
$reminder->active = 0;
|
||||
$reminder->save();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function delete(TransactionJournal $journal)
|
||||
{
|
||||
// delete transactions first:
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($journal->transactions()->get() as $transaction) {
|
||||
$transaction->delete();
|
||||
}
|
||||
$journal->delete();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get users first transaction journal
|
||||
*
|
||||
@@ -34,6 +68,25 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
return Auth::user()->transactionjournals()->orderBy('date', 'ASC')->first(['transaction_journals.*']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
* @param Transaction $transaction
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getAmountBefore(TransactionJournal $journal, Transaction $transaction)
|
||||
{
|
||||
return floatval(
|
||||
$transaction->account->transactions()->leftJoin(
|
||||
'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id'
|
||||
)
|
||||
->where('transaction_journals.date', '<=', $journal->date->format('Y-m-d'))
|
||||
->where('transaction_journals.order', '>=', $journal->order)
|
||||
->where('transaction_journals.id', '!=', $journal->id)
|
||||
->sum('transactions.amount')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionType $dbType
|
||||
*
|
||||
@@ -44,6 +97,28 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
return Auth::user()->transactionjournals()->where('transaction_type_id', $dbType->id)->orderBy('id', 'DESC')->take(50)->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $types
|
||||
* @param int $offset
|
||||
* @param int $page
|
||||
*
|
||||
* @return LengthAwarePaginator
|
||||
*/
|
||||
public function getJournalsOfTypes(array $types, $offset, $page)
|
||||
{
|
||||
$set = Auth::user()->transactionJournals()->transactionTypes($types)->withRelevantData()->take(50)->offset($offset)
|
||||
->orderBy('date', 'DESC')
|
||||
->orderBy('order', 'ASC')
|
||||
->orderBy('id', 'DESC')
|
||||
->get(
|
||||
['transaction_journals.*']
|
||||
);
|
||||
$count = Auth::user()->transactionJournals()->transactionTypes($types)->count();
|
||||
$journals = new LengthAwarePaginator($set, $count, 50, $page);
|
||||
|
||||
return $journals;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $type
|
||||
*
|
||||
@@ -54,6 +129,17 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
return TransactionType::whereType($type)->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return TransactionJournal
|
||||
*/
|
||||
public function getWithDate($id, Carbon $date)
|
||||
{
|
||||
return Auth::user()->transactionjournals()->where('id', $id)->where('date', $date->format('Y-m-d'))->first();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* * Remember: a balancingAct takes at most one expense and one transfer.
|
||||
@@ -109,6 +195,7 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
|
||||
// store or get budget
|
||||
if (intval($data['budget_id']) > 0) {
|
||||
/** @var \FireflyIII\Models\Budget $budget */
|
||||
$budget = Budget::find($data['budget_id']);
|
||||
$journal->budgets()->save($budget);
|
||||
}
|
||||
@@ -168,6 +255,7 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
// unlink all budgets and recreate them:
|
||||
$journal->budgets()->detach();
|
||||
if (intval($data['budget_id']) > 0) {
|
||||
/** @var \FireflyIII\Models\Budget $budget */
|
||||
$budget = Budget::find($data['budget_id']);
|
||||
$journal->budgets()->save($budget);
|
||||
}
|
||||
@@ -231,7 +319,7 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
DB::table('tag_transaction_journal')->where('transaction_journal_id', $journal->id)->whereNotIn('tag_id', $ids)->delete();
|
||||
}
|
||||
// if count is zero, delete them all:
|
||||
if(count($ids) == 0) {
|
||||
if (count($ids) == 0) {
|
||||
DB::table('tag_transaction_journal')->where('transaction_journal_id', $journal->id)->delete();
|
||||
}
|
||||
|
||||
|
@@ -2,9 +2,11 @@
|
||||
|
||||
namespace FireflyIII\Repositories\Journal;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
@@ -14,6 +16,20 @@ use Illuminate\Support\Collection;
|
||||
*/
|
||||
interface JournalRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* @param int $reminderId
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function deactivateReminder($reminderId);
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function delete(TransactionJournal $journal);
|
||||
|
||||
/**
|
||||
* Get users first transaction journal
|
||||
*
|
||||
@@ -21,6 +37,14 @@ interface JournalRepositoryInterface
|
||||
*/
|
||||
public function first();
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
* @param Transaction $transaction
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getAmountBefore(TransactionJournal $journal, Transaction $transaction);
|
||||
|
||||
/**
|
||||
* @param TransactionType $dbType
|
||||
*
|
||||
@@ -28,6 +52,15 @@ interface JournalRepositoryInterface
|
||||
*/
|
||||
public function getJournalsOfType(TransactionType $dbType);
|
||||
|
||||
/**
|
||||
* @param array $types
|
||||
* @param int $offset
|
||||
* @param int $page
|
||||
*
|
||||
* @return LengthAwarePaginator
|
||||
*/
|
||||
public function getJournalsOfTypes(array $types, $offset, $page);
|
||||
|
||||
/**
|
||||
* @param $type
|
||||
*
|
||||
@@ -35,6 +68,14 @@ interface JournalRepositoryInterface
|
||||
*/
|
||||
public function getTransactionType($type);
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return TransactionJournal
|
||||
*/
|
||||
public function getWithDate($id, Carbon $date);
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
* @param array $array
|
||||
|
@@ -21,7 +21,6 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
|
||||
|
||||
/**
|
||||
* @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind.
|
||||
*
|
||||
* Based on the piggy bank, the reminder-setting and
|
||||
* other variables this method tries to divide the piggy bank into equal parts. Each is
|
||||
@@ -189,10 +188,11 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PiggyBank $account
|
||||
* @param PiggyBank $piggyBank
|
||||
* @param array $data
|
||||
*
|
||||
* @return PiggyBank
|
||||
* @internal param PiggyBank $account
|
||||
*/
|
||||
public function update(PiggyBank $piggyBank, array $data)
|
||||
{
|
||||
|
@@ -15,7 +15,6 @@ interface PiggyBankRepositoryInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind.
|
||||
*
|
||||
* Based on the piggy bank, the reminder-setting and
|
||||
* other variables this method tries to divide the piggy bank into equal parts. Each is
|
||||
@@ -95,7 +94,7 @@ interface PiggyBankRepositoryInterface
|
||||
public function store(array $data);
|
||||
|
||||
/**
|
||||
* @param PiggyBank $account
|
||||
* @param PiggyBank $piggyBank
|
||||
* @param array $data
|
||||
*
|
||||
* @return PiggyBank
|
||||
|
116
app/Repositories/Reminder/ReminderRepository.php
Normal file
116
app/Repositories/Reminder/ReminderRepository.php
Normal file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
namespace FireflyIII\Repositories\Reminder;
|
||||
|
||||
use App;
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Models\Reminder;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Class ReminderRepository
|
||||
*
|
||||
* @package FireflyIII\Repositories\Reminder
|
||||
*/
|
||||
class ReminderRepository implements ReminderRepositoryInterface
|
||||
{
|
||||
/** @var \FireflyIII\Helpers\Reminders\ReminderHelperInterface */
|
||||
protected $helper;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
/** @var \FireflyIII\Helpers\Reminders\ReminderHelperInterface helper */
|
||||
$this->helper = App::make('FireflyIII\Helpers\Reminders\ReminderHelperInterface');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function getActiveReminders()
|
||||
{
|
||||
$today = new Carbon;
|
||||
// active reminders:
|
||||
$active = Auth::user()->reminders()
|
||||
->where('notnow', 0)
|
||||
->where('active', 1)
|
||||
->where('startdate', '<=', $today->format('Y-m-d 00:00:00'))
|
||||
->where('enddate', '>=', $today->format('Y-m-d 00:00:00'))
|
||||
->get();
|
||||
|
||||
$active->each(
|
||||
function (Reminder $reminder) {
|
||||
$reminder->description = $this->helper->getReminderText($reminder);
|
||||
}
|
||||
);
|
||||
|
||||
return $active;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function getDismissedReminders()
|
||||
{
|
||||
$dismissed = Auth::user()->reminders()
|
||||
->where('notnow', 1)
|
||||
->get();
|
||||
|
||||
$dismissed->each(
|
||||
function (Reminder $reminder) {
|
||||
$reminder->description = $this->helper->getReminderText($reminder);
|
||||
}
|
||||
);
|
||||
|
||||
return $dismissed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function getExpiredReminders()
|
||||
{
|
||||
|
||||
$expired = Auth::user()->reminders()
|
||||
->where('notnow', 0)
|
||||
->where('active', 1)
|
||||
->where(
|
||||
function (Builder $q) {
|
||||
$today = new Carbon;
|
||||
$q->where('startdate', '>', $today->format('Y-m-d 00:00:00'));
|
||||
$q->orWhere('enddate', '<', $today->format('Y-m-d 00:00:00'));
|
||||
}
|
||||
)->get();
|
||||
|
||||
$expired->each(
|
||||
function (Reminder $reminder) {
|
||||
$reminder->description = $this->helper->getReminderText($reminder);
|
||||
}
|
||||
);
|
||||
|
||||
return $expired;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function getInactiveReminders()
|
||||
{
|
||||
$inactive = Auth::user()->reminders()
|
||||
->where('active', 0)
|
||||
->get();
|
||||
|
||||
$inactive->each(
|
||||
function (Reminder $reminder) {
|
||||
$reminder->description = $this->helper->getReminderText($reminder);
|
||||
}
|
||||
);
|
||||
|
||||
return $inactive;
|
||||
}
|
||||
}
|
35
app/Repositories/Reminder/ReminderRepositoryInterface.php
Normal file
35
app/Repositories/Reminder/ReminderRepositoryInterface.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace FireflyIII\Repositories\Reminder;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
|
||||
/**
|
||||
* Interface ReminderRepositoryInterface
|
||||
*
|
||||
* @package FireflyIII\Repositories\Reminder
|
||||
*/
|
||||
interface ReminderRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function getActiveReminders();
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function getDismissedReminders();
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function getExpiredReminders();
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function getInactiveReminders();
|
||||
|
||||
}
|
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace FireflyIII\Repositories\Tag;
|
||||
|
||||
use FireflyIII\Models\Tag;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use Illuminate\Support\Collection;
|
||||
@@ -11,7 +12,8 @@ use Illuminate\Support\Collection;
|
||||
*
|
||||
* @package FireflyIII\Repositories\Tag
|
||||
*/
|
||||
interface TagRepositoryInterface {
|
||||
interface TagRepositoryInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
@@ -34,7 +36,7 @@ interface TagRepositoryInterface {
|
||||
public function update(Tag $tag, array $data);
|
||||
|
||||
/**
|
||||
* @param Tag $tag
|
||||
* @param Tag $tag
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
|
@@ -84,9 +84,11 @@ class Amount
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
* @param bool $coloured
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function formatJournal(TransactionJournal $journal, $coloured = true)
|
||||
{
|
||||
@@ -151,15 +153,11 @@ class Amount
|
||||
if (defined('FFCURRENCYCODE')) {
|
||||
return FFCURRENCYCODE;
|
||||
}
|
||||
if (Cache::has('FFCURRENCYCODE')) {
|
||||
define('FFCURRENCYCODE', Cache::get('FFCURRENCYCODE'));
|
||||
|
||||
return FFCURRENCYCODE;
|
||||
}
|
||||
|
||||
|
||||
$currencyPreference = Prefs::get('currencyPreference', 'EUR');
|
||||
$currency = TransactionCurrency::whereCode($currencyPreference->data)->first();
|
||||
|
||||
$currency = TransactionCurrency::whereCode($currencyPreference->data)->first();
|
||||
if ($currency) {
|
||||
|
||||
Cache::forever('FFCURRENCYCODE', $currency->code);
|
||||
@@ -171,6 +169,9 @@ class Amount
|
||||
return 'EUR';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed|static
|
||||
*/
|
||||
public function getDefaultCurrency()
|
||||
{
|
||||
$currencyPreference = Prefs::get('currencyPreference', 'EUR');
|
||||
|
@@ -237,12 +237,11 @@ class ExpandedForm
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind.
|
||||
*
|
||||
* Takes any collection and tries to make a sensible select list compatible array of it.
|
||||
*
|
||||
* @param Collection $set
|
||||
* @param bool $addEmpty
|
||||
* @param \Illuminate\Support\Collection $set
|
||||
* @param bool $addEmpty
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
@@ -289,10 +288,12 @@ class ExpandedForm
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param null $value
|
||||
* @param array $list
|
||||
* @param null $selected
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
* @internal param null $value
|
||||
*/
|
||||
public function multiRadio($name, array $list = [], $selected = null, array $options = [])
|
||||
{
|
||||
|
@@ -15,7 +15,7 @@ class Navigation
|
||||
|
||||
|
||||
/**
|
||||
* @param Carbon $theDate
|
||||
* @param \Carbon\Carbon $theDate
|
||||
* @param $repeatFreq
|
||||
* @param $skip
|
||||
*
|
||||
@@ -64,10 +64,10 @@ class Navigation
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $theCurrentEnd
|
||||
* @param \Carbon\Carbon $theCurrentEnd
|
||||
* @param $repeatFreq
|
||||
*
|
||||
* @return Carbon
|
||||
* @return \Carbon\Carbon
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function endOfPeriod(Carbon $theCurrentEnd, $repeatFreq)
|
||||
@@ -148,9 +148,8 @@ class Navigation
|
||||
|
||||
}
|
||||
if (isset($specials[$repeatFreq])) {
|
||||
$month = intval($theCurrentEnd->format('m'));
|
||||
$currentEnd->endOfYear();
|
||||
if ($month <= 6) {
|
||||
if ($theCurrentEnd->month <= 6) {
|
||||
$currentEnd->subMonths(6);
|
||||
}
|
||||
}
|
||||
@@ -184,7 +183,7 @@ class Navigation
|
||||
$date->lastOfQuarter()->addDay();
|
||||
break;
|
||||
case '6M':
|
||||
if (intval($date->format('m')) >= 7) {
|
||||
if ($date->month >= 7) {
|
||||
$date->startOfYear()->addYear();
|
||||
} else {
|
||||
$date->startOfYear()->addMonths(6);
|
||||
@@ -230,9 +229,8 @@ class Navigation
|
||||
return $date;
|
||||
}
|
||||
if ($range == '6M') {
|
||||
$month = intval($date->format('m'));
|
||||
$date->startOfYear();
|
||||
if ($month <= 6) {
|
||||
if ($date->month <= 6) {
|
||||
$date->subMonths(6);
|
||||
}
|
||||
|
||||
@@ -260,16 +258,15 @@ class Navigation
|
||||
return $date->format($formatMap[$range]);
|
||||
}
|
||||
if ($range == '3M') {
|
||||
$month = intval($date->format('m'));
|
||||
|
||||
return 'Q' . ceil(($month / 12) * 4) . ' ' . $date->format('Y');
|
||||
|
||||
return 'Q' . ceil(($date->month / 12) * 4) . ' ' . $date->year;
|
||||
}
|
||||
if ($range == '6M') {
|
||||
$month = intval($date->format('m'));
|
||||
$half = ceil(($month / 12) * 2);
|
||||
$half = ceil(($date->month / 12) * 2);
|
||||
$halfName = $half == 1 ? 'first' : 'second';
|
||||
|
||||
return $halfName . ' half of ' . $date->format('Y');
|
||||
return $halfName . ' half of ' . $date->year;
|
||||
}
|
||||
throw new FireflyException('No _periodName() for range "' . $range . '"');
|
||||
}
|
||||
@@ -301,10 +298,10 @@ class Navigation
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $theDate
|
||||
* @param \Carbon\Carbon $theDate
|
||||
* @param $repeatFreq
|
||||
*
|
||||
* @return Carbon
|
||||
* @return \Carbon\Carbon
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function startOfPeriod(Carbon $theDate, $repeatFreq)
|
||||
@@ -333,7 +330,7 @@ class Navigation
|
||||
return $date;
|
||||
}
|
||||
if ($repeatFreq == 'half-year' || $repeatFreq == '6M') {
|
||||
$month = intval($date->format('m'));
|
||||
$month = $date->month;
|
||||
$date->startOfYear();
|
||||
if ($month >= 7) {
|
||||
$date->addMonths(6);
|
||||
@@ -388,9 +385,9 @@ class Navigation
|
||||
|
||||
/**
|
||||
* @param $range
|
||||
* @param Carbon $start
|
||||
* @param \Carbon\Carbon $start
|
||||
*
|
||||
* @return Carbon
|
||||
* @return \Carbon\Carbon
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function updateEndDate($range, Carbon $start)
|
||||
@@ -411,7 +408,7 @@ class Navigation
|
||||
return $end;
|
||||
}
|
||||
if ($range == '6M') {
|
||||
if (intval($start->format('m')) >= 7) {
|
||||
if ($start->month >= 7) {
|
||||
$end->endOfYear();
|
||||
} else {
|
||||
$end->startOfYear()->addMonths(6);
|
||||
@@ -423,10 +420,10 @@ class Navigation
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $range
|
||||
* @param Carbon $start
|
||||
* @param $range
|
||||
* @param \Carbon\Carbon $start
|
||||
*
|
||||
* @return Carbon
|
||||
* @return \Carbon\Carbon
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function updateStartDate($range, Carbon $start)
|
||||
@@ -445,7 +442,7 @@ class Navigation
|
||||
return $start;
|
||||
}
|
||||
if ($range == '6M') {
|
||||
if (intval($start->format('m')) >= 7) {
|
||||
if ($start->month >= 7) {
|
||||
$start->startOfYear()->addMonths(6);
|
||||
} else {
|
||||
$start->startOfYear();
|
||||
|
@@ -16,7 +16,7 @@ class Preferences
|
||||
* @param $name
|
||||
* @param null $default
|
||||
*
|
||||
* @return null|Preference
|
||||
* @return null|\FireflyIII\Models\Preference
|
||||
*/
|
||||
public function get($name, $default = null)
|
||||
{
|
||||
|
@@ -84,7 +84,6 @@ class Search implements SearchInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*
|
||||
* @param array $words
|
||||
*
|
||||
@@ -122,6 +121,7 @@ class Search implements SearchInterface
|
||||
return $journal;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
);
|
||||
|
@@ -17,8 +17,8 @@ class Steam
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @param Account $account
|
||||
* @param Carbon $date
|
||||
* @param \FireflyIII\Models\Account $account
|
||||
* @param \Carbon\Carbon $date
|
||||
* @param bool $ignoreVirtualBalance
|
||||
*
|
||||
* @return float
|
||||
@@ -91,7 +91,7 @@ class Steam
|
||||
* Turns a collection into an array. Needs the field 'id' for the key,
|
||||
* and saves only 'name' and 'amount' as a sub array.
|
||||
*
|
||||
* @param Collection $collection
|
||||
* @param \Illuminate\Support\Collection $collection
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
|
@@ -42,7 +42,7 @@ class General extends Twig_Extension
|
||||
$filters[] = new Twig_SimpleFilter(
|
||||
'formatAmountPlain', function ($string) {
|
||||
return App::make('amount')->format($string, false);
|
||||
}
|
||||
}, ['is_safe' => ['html']]
|
||||
);
|
||||
|
||||
$filters[] = new Twig_SimpleFilter(
|
||||
|
@@ -39,7 +39,7 @@ class Journal extends Twig_Extension
|
||||
if ($type == 'Opening balance') {
|
||||
return '<span class="glyphicon glyphicon-ban-circle" title="Opening balance"></span>';
|
||||
}
|
||||
|
||||
return '';
|
||||
|
||||
}, ['is_safe' => ['html']]
|
||||
);
|
||||
|
@@ -2,9 +2,9 @@
|
||||
|
||||
namespace FireflyIII\Support\Twig;
|
||||
|
||||
use FireflyIII\Models\PiggyBank as PB;
|
||||
use Twig_Extension;
|
||||
use Twig_SimpleFunction;
|
||||
use FireflyIII\Models\PiggyBank as PB;
|
||||
|
||||
/**
|
||||
* Class PiggyBank
|
||||
@@ -26,6 +26,7 @@ class PiggyBank extends Twig_Extension
|
||||
return $piggyBank->currentRelevantRep()->currentamount;
|
||||
}
|
||||
);
|
||||
|
||||
return $functions;
|
||||
}
|
||||
|
||||
|
@@ -203,7 +203,13 @@ class FireflyValidator extends Validator
|
||||
$alwaysEncrypted = true;
|
||||
}
|
||||
|
||||
$query = DB::table($table)->where('user_id', Auth::user()->id);
|
||||
if (is_null(Auth::user())) {
|
||||
// user is not logged in.. weird.
|
||||
return true;
|
||||
} else {
|
||||
$query = DB::table($table)->where('user_id', Auth::user()->id);
|
||||
}
|
||||
|
||||
|
||||
if (!is_null($exclude)) {
|
||||
$query->where('id', '!=', $exclude);
|
||||
|
22
composer.lock
generated
22
composer.lock
generated
@@ -1375,16 +1375,16 @@
|
||||
},
|
||||
{
|
||||
"name": "nikic/php-parser",
|
||||
"version": "v1.2.2",
|
||||
"version": "v1.3.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/nikic/PHP-Parser.git",
|
||||
"reference": "08f97eb4efa029e2fafb6d8c98b71731bf0cf621"
|
||||
"reference": "dff239267fd1befa1cd40430c9ed12591aa720ca"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/08f97eb4efa029e2fafb6d8c98b71731bf0cf621",
|
||||
"reference": "08f97eb4efa029e2fafb6d8c98b71731bf0cf621",
|
||||
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/dff239267fd1befa1cd40430c9ed12591aa720ca",
|
||||
"reference": "dff239267fd1befa1cd40430c9ed12591aa720ca",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -1394,7 +1394,7 @@
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.2-dev"
|
||||
"dev-master": "1.3-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
@@ -1416,7 +1416,7 @@
|
||||
"parser",
|
||||
"php"
|
||||
],
|
||||
"time": "2015-04-03 14:33:59"
|
||||
"time": "2015-05-02 15:40:40"
|
||||
},
|
||||
{
|
||||
"name": "psr/log",
|
||||
@@ -3582,16 +3582,16 @@
|
||||
},
|
||||
{
|
||||
"name": "phpunit/phpunit",
|
||||
"version": "4.6.4",
|
||||
"version": "4.6.6",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
||||
"reference": "163232991e652e6efed2f8470326fffa61e848e2"
|
||||
"reference": "3afe303d873a4d64c62ef84de491b97b006fbdac"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/163232991e652e6efed2f8470326fffa61e848e2",
|
||||
"reference": "163232991e652e6efed2f8470326fffa61e848e2",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3afe303d873a4d64c62ef84de491b97b006fbdac",
|
||||
"reference": "3afe303d873a4d64c62ef84de491b97b006fbdac",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -3650,7 +3650,7 @@
|
||||
"testing",
|
||||
"xunit"
|
||||
],
|
||||
"time": "2015-04-11 05:23:21"
|
||||
"time": "2015-04-29 15:18:52"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/phpunit-mock-objects",
|
||||
|
@@ -4,6 +4,8 @@ use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*
|
||||
* Class CreatePasswordResetsTable
|
||||
*/
|
||||
class CreatePasswordResetsTable extends Migration
|
||||
|
@@ -7,6 +7,7 @@ use FireflyIII\Models\Component;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName) // method names are mandated by laravel.
|
||||
* @SuppressWarnings("TooManyMethods") // I'm fine with this
|
||||
|
@@ -5,7 +5,7 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
* @SuppressWarnings("MethodLength") // I don't mind this in case of migrations.
|
||||
* @SuppressWarnings("PHPMD.ExcessiveMethodLength")
|
||||
*
|
||||
* Class ChangesForV322
|
||||
*/
|
||||
|
@@ -5,7 +5,7 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
* @SuppressWarnings("MethodLength") // I don't mind this in case of migrations.
|
||||
* @SuppressWarnings("PHPMD.ExcessiveMethodLength")
|
||||
*
|
||||
* Class ChangesForV325
|
||||
*/
|
||||
|
@@ -4,6 +4,8 @@ use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*
|
||||
* Class ChangesForV332
|
||||
*/
|
||||
class ChangesForV332 extends Migration
|
||||
|
@@ -3,6 +3,11 @@
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*
|
||||
* Class ChangesForV333
|
||||
*/
|
||||
class ChangesForV333 extends Migration
|
||||
{
|
||||
|
||||
|
@@ -4,6 +4,9 @@ use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
* @SuppressWarnings("PHPMD.ExcessiveMethodLength")
|
||||
*
|
||||
* Class ChangesForV336
|
||||
*/
|
||||
class ChangesForV336 extends Migration
|
||||
@@ -134,7 +137,7 @@ class ChangesForV336 extends Migration
|
||||
// reinstate a long forgotten index:
|
||||
Schema::table(
|
||||
'budget_limits', function (Blueprint $table) {
|
||||
$table->unique(['budget_id', 'startdate'],'unique_limit');
|
||||
$table->unique(['budget_id', 'startdate'], 'unique_limit');
|
||||
}
|
||||
);
|
||||
|
||||
|
@@ -3,6 +3,12 @@
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
* @SuppressWarnings("PHPMD.ExcessiveMethodLength")
|
||||
*
|
||||
* Class ChangesForV3310
|
||||
*/
|
||||
class ChangesForV3310 extends Migration
|
||||
{
|
||||
|
||||
@@ -57,7 +63,8 @@ class ChangesForV3310 extends Migration
|
||||
);
|
||||
|
||||
|
||||
Schema::create('tag_transaction_journal',function (Blueprint $table) {
|
||||
Schema::create(
|
||||
'tag_transaction_journal', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('tag_id')->unsigned();
|
||||
$table->integer('transaction_journal_id')->unsigned();
|
||||
@@ -69,7 +76,8 @@ class ChangesForV3310 extends Migration
|
||||
// add unique.
|
||||
$table->unique(['tag_id', 'transaction_journal_id'], 'tag_t_joined');
|
||||
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -4,6 +4,8 @@ use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*
|
||||
* Class ChangesForV3310a
|
||||
*/
|
||||
class ChangesForV3310a extends Migration
|
||||
|
@@ -1,32 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*
|
||||
* Class ChangesForV3310b
|
||||
*/
|
||||
class ChangesForV3310b extends Migration {
|
||||
class ChangesForV3310b extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
// set all current entries to be "balance"
|
||||
DB::table('transaction_groups')->update(['relation' => 'balance']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -14,9 +14,7 @@ function getBoxAmounts() {
|
||||
for (x in boxes) {
|
||||
var box = boxes[x];
|
||||
$.getJSON('/json/box/' + box).success(function (data) {
|
||||
if (data.amount_raw != 0) {
|
||||
$('#box-' + data.box).html(data.amount);
|
||||
}
|
||||
$('#box-' + data.box).html(data.amount);
|
||||
}).fail(function () {
|
||||
console.log('Failed to get box!')
|
||||
});
|
||||
|
@@ -122,11 +122,11 @@
|
||||
<!-- budget-info-X holds the input and the euro-sign: -->
|
||||
<span id="budget-info-{{ budget.id }}">
|
||||
{% if budget.currentRep.amount > budget.spent %}
|
||||
<span class="text-success">{{ getCurrencySymbol() }}</span> <input type="number" min="0" max="{{ budgetMaximum }}" data-id="{{ budget.id }}"
|
||||
<span class="text-success">{{ getCurrencySymbol()|raw }}</span> <input type="number" min="0" max="{{ budgetMaximum }}" data-id="{{ budget.id }}"
|
||||
step="1" value="{{ budget.currentRep.amount }}"
|
||||
style="width:90px;color:#3c763d;"/>
|
||||
{% else %}
|
||||
<span class="text-danger">{{ getCurrencySymbol() }}</span> <input type="number" min="0" max="{{ budgetMaximum }}" data-id="{{ budget.id }}"
|
||||
<span class="text-danger">{{ getCurrencySymbol()|raw }}</span> <input type="number" min="0" max="{{ budgetMaximum }}" data-id="{{ budget.id }}"
|
||||
step="1" value="{{ budget.currentRep.amount }}"
|
||||
style="width:90px;color:#a94442;"/>
|
||||
{% endif %}
|
||||
@@ -134,7 +134,7 @@
|
||||
{% else %}
|
||||
<span id="budget-description-{{ budget.id }}"><em>No budget</em></span>
|
||||
<span id="budget-info-{{ budget.id }}">
|
||||
<span class="text-success" style="display:none;">{{ Amount.getCurrencySymbol() }}</span> <input data-id="{{ budget.id }}" type="number"
|
||||
<span class="text-success" style="display:none;">{{ getCurrencySymbol()|raw }}</span> <input data-id="{{ budget.id }}" type="number"
|
||||
min="0" max="{{ budgetMaximum }}" step="1"
|
||||
value="0"
|
||||
style="width:50px;color:#3c763d;display:none;"/>
|
||||
|
@@ -75,12 +75,12 @@
|
||||
<div class="progress">
|
||||
<div class="progress-bar progress-bar-success progress-bar-striped" style="width: {{ 100 - account.percentage }}%">
|
||||
{% if account.percentage <= 50 %}
|
||||
{{account.difference|formatAmount}}
|
||||
{{account.difference|formatAmountPlain}}
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="progress-bar progress-bar-danger progress-bar-striped" style="width: {{ account.percentage }}%">
|
||||
{% if account.percentage > 50 %}
|
||||
{{account.difference|formatAmount}}
|
||||
{{account.difference|formatAmountPlain}}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
@@ -89,13 +89,13 @@
|
||||
<div class="progress">
|
||||
<div class="progress-bar progress-bar-success progress-bar-striped" style="width: {{account.percentage}}%">
|
||||
{% if account.percentage <= 50 %}
|
||||
{{account.difference|formatAmount}}
|
||||
{{account.difference|formatAmount}}
|
||||
{{account.difference|formatAmountPlain}}
|
||||
{{account.difference|formatAmountPlain}}
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="progress-bar progress-bar-info progress-bar-striped" style="width: {{100 - account.percentage}}%">
|
||||
{% if account.percentage > 50 %}
|
||||
{{account.difference|formatAmount}}
|
||||
{{account.difference|formatAmountPlain}}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
@@ -132,12 +132,12 @@
|
||||
<div class="progress">
|
||||
<div class="progress-bar progress-bar-info progress-bar-striped" style="width: {{100 - account.percentage}}%">
|
||||
{% if account.percentage <= 50 %}
|
||||
{{account.piggyBalance|formatAmount}} divided
|
||||
{{account.piggyBalance|formatAmountPlain}} divided
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="progress-bar progress-bar-success progress-bar-striped" style="width: {{account.percentage}}%">
|
||||
{% if account.percentage > 50 %}
|
||||
{{account.difference|formatAmount}} left to divide
|
||||
{{account.difference|formatAmountPlain}} left to divide
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
14
resources/twig/reports/modal-journal-list.twig
Normal file
14
resources/twig/reports/modal-journal-list.twig
Normal file
@@ -0,0 +1,14 @@
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
|
||||
<h4 class="modal-title">No budget bla bla.</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
{% include 'list/journals.twig' %}
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@@ -101,7 +101,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Out</td>
|
||||
<td>{{ (expenseSum*-1)|formatAmount }}</td>
|
||||
<td><span class="text-danger">{{ expenseSum|formatAmountPlain }}</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Difference</td>
|
||||
@@ -143,7 +143,7 @@
|
||||
{% for expense in groupedExpenses %}
|
||||
<tr>
|
||||
<td><a href="{{route('accounts.show',expense.id)}}">{{ expense.name }}</a></td>
|
||||
<td>{{ (expense.queryAmount*-1)|formatAmount }}</td>
|
||||
<td><span class="text-danger">{{ expense.queryAmount|formatAmountPlain }}</span></td>
|
||||
</tr>
|
||||
{% set sum = sum + (expense.queryAmount * -1) %}
|
||||
{% endfor %}
|
||||
|
@@ -1,2 +0,0 @@
|
||||
- replace \Session with Session
|
||||
- find all event::fire's, and see if they fire in new ff as well.
|
@@ -46,7 +46,7 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase
|
||||
|
||||
// create EUR currency
|
||||
/** @var TransactionCurrency $currency */
|
||||
$currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
|
||||
$currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
|
||||
$currency->code = 'EUR';
|
||||
$currency->save();
|
||||
Log::debug('Created new EUR currency.');
|
||||
@@ -66,8 +66,6 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -50,9 +50,6 @@ class AccountControllerTest extends TestCase
|
||||
{
|
||||
if (is_null($this->account)) {
|
||||
$this->account = FactoryMuffin::create('FireflyIII\Models\Account');
|
||||
Log::debug('Created a new account.');
|
||||
//$this->account->accountType->type = 'Asset account';
|
||||
//$this->account->accountType->save();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -75,7 +75,7 @@ class BillControllerTest extends TestCase
|
||||
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
|
||||
|
||||
$this->call('GET', '/bills/create');
|
||||
$this->assertViewHas('subTitle', 'Create new');
|
||||
$this->assertViewHas('subTitle', 'Create new bill');
|
||||
$this->assertResponseOk();
|
||||
|
||||
}
|
||||
@@ -191,7 +191,6 @@ class BillControllerTest extends TestCase
|
||||
Amount::shouldReceive('getCurrencyCode')->andReturn('XX');
|
||||
|
||||
|
||||
|
||||
$this->call('GET', '/bills/show/' . $bill->id);
|
||||
}
|
||||
|
||||
|
@@ -87,27 +87,35 @@ class GoogleChartControllerTest extends TestCase
|
||||
|
||||
public function testAllBudgetsHomeChart()
|
||||
{
|
||||
$budget = FactoryMuffin::create('FireflyIII\Models\Budget');
|
||||
|
||||
$budget1 = FactoryMuffin::create('FireflyIII\Models\Budget');
|
||||
$this->be($budget->user);
|
||||
$budget2 = FactoryMuffin::create('FireflyIII\Models\Budget');
|
||||
$budget3 = FactoryMuffin::create('FireflyIII\Models\Budget');
|
||||
$budget4 = FactoryMuffin::create('FireflyIII\Models\Budget');
|
||||
$budgets = new Collection([$budget1, $budget2, $budget3, $budget4]);
|
||||
|
||||
$start = Carbon::now()->startOfMonth();
|
||||
$end = Carbon::now()->endOfMonth();
|
||||
$rep1 = FactoryMuffin::create('FireflyIII\Models\LimitRepetition');
|
||||
$rep2 = FactoryMuffin::create('FireflyIII\Models\LimitRepetition');
|
||||
$rep3 = FactoryMuffin::create('FireflyIII\Models\LimitRepetition');
|
||||
|
||||
$repetition = FactoryMuffin::create('FireflyIII\Models\LimitRepetition');
|
||||
$repetitions = new Collection;
|
||||
$repetitions->push($repetition);
|
||||
$emptyRepetitions = new Collection;
|
||||
$rep1->amount = 6;
|
||||
$rep1->save();
|
||||
$rep2->amount = 18;
|
||||
$rep2->save();
|
||||
$this->be($budget1->user);
|
||||
|
||||
|
||||
$coll1 = new Collection([$rep1]);
|
||||
$coll2 = new Collection([$rep2]);
|
||||
$coll3 = new Collection([$rep3]);
|
||||
$coll4 = new Collection;
|
||||
|
||||
$collection = new Collection;
|
||||
$collection->push($budget);
|
||||
$collection->push($budget1);
|
||||
|
||||
// mock stuff:
|
||||
$repository = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
|
||||
$repository->shouldReceive('getBudgets')->andReturn($collection);
|
||||
$repository->shouldReceive('getBudgetLimitRepetitions')->once()->andReturn($repetitions, $emptyRepetitions);
|
||||
$repository->shouldReceive('sumBudgetExpensesInPeriod')->andReturn(12);
|
||||
$repository->shouldReceive('getBudgets')->andReturn($budgets);
|
||||
$repository->shouldReceive('getBudgetLimitRepetitions')->andReturn($coll1, $coll2, $coll3, $coll4);
|
||||
$repository->shouldReceive('sumBudgetExpensesInPeriod')->andReturn(12, 12, 12, -12);
|
||||
$repository->shouldReceive('getWithoutBudgetSum')->andReturn(0);
|
||||
|
||||
$this->call('GET', '/chart/home/budgets');
|
||||
@@ -194,7 +202,7 @@ class GoogleChartControllerTest extends TestCase
|
||||
$repetition->startdate = Carbon::now()->startOfMonth();
|
||||
$repetition->enddate = Carbon::now()->endOfMonth();
|
||||
$repetition->save();
|
||||
$budget = $repetition->budgetlimit->budget;
|
||||
$budget = $repetition->budgetlimit->budget;
|
||||
$this->be($budget->user);
|
||||
///chart/budget/{budget}/{limitrepetition}
|
||||
|
||||
|
@@ -84,7 +84,7 @@ class HelpControllerTest extends TestCase
|
||||
public function testGetHelpTextNoRoute()
|
||||
{
|
||||
// login
|
||||
$user = FactoryMuffin::create('FireflyIII\User');
|
||||
$user = FactoryMuffin::create('FireflyIII\User');
|
||||
|
||||
$this->be($user);
|
||||
// mock some stuff.
|
||||
|
@@ -210,7 +210,7 @@ class JsonControllerTest extends TestCase
|
||||
public function testTransactionJournals()
|
||||
{
|
||||
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
|
||||
$type = FactoryMuffin::create('FireflyIII\Models\TransactionType');
|
||||
$type = FactoryMuffin::create('FireflyIII\Models\TransactionType');
|
||||
$collection = new Collection([$journal]);
|
||||
$user = FactoryMuffin::create('FireflyIII\User');
|
||||
$this->be($user);
|
||||
|
@@ -6,6 +6,7 @@ use FireflyIII\Models\Preference;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use Illuminate\Support\Collection;
|
||||
use League\FactoryMuffin\Facade as FactoryMuffin;
|
||||
|
||||
/**
|
||||
* Class PiggyBankControllerTest
|
||||
*/
|
||||
@@ -110,7 +111,7 @@ class PiggyBankControllerTest extends TestCase
|
||||
|
||||
public function testEdit()
|
||||
{
|
||||
$piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
|
||||
$piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
|
||||
$piggyBank->targetdate = Carbon::now()->addYear();
|
||||
$piggyBank->save();
|
||||
$this->be($piggyBank->account->user);
|
||||
|
@@ -65,7 +65,7 @@ class PreferencesControllerTest extends TestCase
|
||||
|
||||
public function testPostIndex()
|
||||
{
|
||||
$user = FactoryMuffin::create('FireflyIII\User');
|
||||
$user = FactoryMuffin::create('FireflyIII\User');
|
||||
$this->be($user);
|
||||
|
||||
$data = [
|
||||
|
170
tests/controllers/ProfileControllerTest.php
Normal file
170
tests/controllers/ProfileControllerTest.php
Normal file
@@ -0,0 +1,170 @@
|
||||
<?php
|
||||
use League\FactoryMuffin\Facade as FactoryMuffin;
|
||||
|
||||
/**
|
||||
* Class ProfileControllerTest
|
||||
*/
|
||||
class ProfileControllerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Sets up the fixture, for example, opens a network connection.
|
||||
* This method is called before a test is executed.
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called before the first test of this test class is run.
|
||||
*
|
||||
* @since Method available since Release 3.4.0
|
||||
*/
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
parent::setUpBeforeClass();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tears down the fixture, for example, closes a network connection.
|
||||
* This method is called after a test is executed.
|
||||
*/
|
||||
public function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testChangePassword()
|
||||
{
|
||||
$user = FactoryMuffin::create('FireflyIII\User');
|
||||
$this->be($user);
|
||||
|
||||
$this->call('GET', '/profile/change-password');
|
||||
$this->assertResponseOk();
|
||||
}
|
||||
|
||||
public function testDeleteAccount()
|
||||
{
|
||||
$user = FactoryMuffin::create('FireflyIII\User');
|
||||
$this->be($user);
|
||||
|
||||
$this->call('GET', '/profile/delete-account');
|
||||
$this->assertResponseOk();
|
||||
}
|
||||
|
||||
public function testIndex()
|
||||
{
|
||||
$user = FactoryMuffin::create('FireflyIII\User');
|
||||
$this->be($user);
|
||||
|
||||
$this->call('GET', '/profile');
|
||||
$this->assertResponseOk();
|
||||
}
|
||||
|
||||
public function testPostChangePassword()
|
||||
{
|
||||
$user = FactoryMuffin::create('FireflyIII\User');
|
||||
$user->password = bcrypt('current');
|
||||
$user->save();
|
||||
$this->be($user);
|
||||
|
||||
$post = [
|
||||
'current_password' => 'current',
|
||||
'new_password' => 'something',
|
||||
'new_password_confirmation' => 'something',
|
||||
'_token' => 'replaceMe'
|
||||
];
|
||||
|
||||
$this->call('POST', '/profile/change-password', $post);
|
||||
|
||||
$this->assertRedirectedToRoute('profile');
|
||||
$this->assertSessionHas('success', 'Password changed!');
|
||||
$this->assertResponseStatus(302);
|
||||
|
||||
}
|
||||
|
||||
public function testPostChangePasswordInvalidCurrent()
|
||||
{
|
||||
$user = FactoryMuffin::create('FireflyIII\User');
|
||||
$user->password = bcrypt('current');
|
||||
$user->save();
|
||||
$this->be($user);
|
||||
|
||||
$post = [
|
||||
'current_password' => 'currentWrong',
|
||||
'new_password' => 'something',
|
||||
'new_password_confirmation' => 'something',
|
||||
'_token' => 'replaceMe'
|
||||
];
|
||||
|
||||
$this->call('POST', '/profile/change-password', $post);
|
||||
|
||||
$this->assertRedirectedToRoute('change-password');
|
||||
$this->assertSessionHas('error', 'Invalid current password!');
|
||||
$this->assertResponseStatus(302);
|
||||
|
||||
}
|
||||
|
||||
public function testPostChangePasswordNoNewPassword()
|
||||
{
|
||||
$user = FactoryMuffin::create('FireflyIII\User');
|
||||
$user->password = bcrypt('current');
|
||||
$user->save();
|
||||
$this->be($user);
|
||||
|
||||
$post = [
|
||||
'current_password' => 'current',
|
||||
'new_password' => 'current',
|
||||
'new_password_confirmation' => 'current',
|
||||
'_token' => 'replaceMe'
|
||||
];
|
||||
|
||||
$this->call('POST', '/profile/change-password', $post);
|
||||
|
||||
$this->assertSessionHas('error', 'The idea is to change your password.');
|
||||
$this->assertResponseStatus(302);
|
||||
$this->assertRedirectedToRoute('change-password');
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function testPostDeleteAccount()
|
||||
{
|
||||
$user = FactoryMuffin::create('FireflyIII\User');
|
||||
$user->password = bcrypt('current');
|
||||
$user->save();
|
||||
$this->be($user);
|
||||
|
||||
$post = [
|
||||
'password' => 'current',
|
||||
'_token' => 'replaceMe'
|
||||
];
|
||||
|
||||
$this->call('POST', '/profile/delete-account', $post);
|
||||
|
||||
$this->assertRedirectedToRoute('index');
|
||||
$this->assertResponseStatus(302);
|
||||
|
||||
}
|
||||
|
||||
public function testPostDeleteAccountInvalidPassword()
|
||||
{
|
||||
$user = FactoryMuffin::create('FireflyIII\User');
|
||||
$user->password = bcrypt('current');
|
||||
$user->save();
|
||||
$this->be($user);
|
||||
|
||||
$post = [
|
||||
'password' => 'currentXX',
|
||||
'_token' => 'replaceMe'
|
||||
];
|
||||
|
||||
$this->call('POST', '/profile/delete-account', $post);
|
||||
|
||||
$this->assertRedirectedToRoute('delete-account');
|
||||
$this->assertSessionHas('error', 'Invalid password!');
|
||||
$this->assertResponseStatus(302);
|
||||
|
||||
}
|
||||
|
||||
}
|
100
tests/controllers/ReminderControllerTest.php
Normal file
100
tests/controllers/ReminderControllerTest.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
use Illuminate\Support\Collection;
|
||||
use League\FactoryMuffin\Facade as FactoryMuffin;
|
||||
|
||||
/**
|
||||
* Class ReportControllerTest
|
||||
*/
|
||||
class ReminderControllerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Sets up the fixture, for example, opens a network connection.
|
||||
* This method is called before a test is executed.
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called before the first test of this test class is run.
|
||||
*
|
||||
* @since Method available since Release 3.4.0
|
||||
*/
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
parent::setUpBeforeClass();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tears down the fixture, for example, closes a network connection.
|
||||
* This method is called after a test is executed.
|
||||
*/
|
||||
public function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testAct()
|
||||
{
|
||||
$reminder = FactoryMuffin::create('FireflyIII\Models\Reminder');
|
||||
$this->be($reminder->remindersable->account->user);
|
||||
|
||||
$this->call('GET', '/reminder/act/' . $reminder->id);
|
||||
$this->assertResponseStatus(302);
|
||||
$this->assertRedirectedToRoute('transactions.create', ['transfer']);
|
||||
|
||||
}
|
||||
|
||||
public function testDismiss()
|
||||
{
|
||||
$reminder = FactoryMuffin::create('FireflyIII\Models\Reminder');
|
||||
$this->be($reminder->remindersable->account->user);
|
||||
|
||||
$this->call('GET', '/reminder/dismiss/' . $reminder->id);
|
||||
$this->assertResponseStatus(302);
|
||||
$this->assertRedirectedTo('/');
|
||||
}
|
||||
|
||||
public function testIndex()
|
||||
{
|
||||
$user = FactoryMuffin::create('FireflyIII\User');
|
||||
$this->be($user);
|
||||
$reminder = FactoryMuffin::create('FireflyIII\Models\Reminder');
|
||||
$collection = new Collection([$reminder]);
|
||||
|
||||
$repository = $this->mock('FireflyIII\Repositories\Reminder\ReminderRepositoryInterface');
|
||||
|
||||
$repository->shouldReceive('getActiveReminders')->andReturn($collection);
|
||||
$repository->shouldReceive('getExpiredReminders')->andReturn($collection);
|
||||
$repository->shouldReceive('getInactiveReminders')->andReturn($collection);
|
||||
$repository->shouldReceive('getDismissedReminders')->andReturn($collection);
|
||||
|
||||
$this->call('GET', '/reminders');
|
||||
$this->assertResponseOk();
|
||||
}
|
||||
|
||||
public function testShow()
|
||||
{
|
||||
$reminder = FactoryMuffin::create('FireflyIII\Models\Reminder');
|
||||
$reminder->notnow = false;
|
||||
$reminder->save();
|
||||
$this->be($reminder->remindersable->account->user);
|
||||
|
||||
$this->call('GET', '/reminder/' . $reminder->id);
|
||||
$this->assertResponseOk();
|
||||
}
|
||||
|
||||
public function testShowDismissed()
|
||||
{
|
||||
$reminder = FactoryMuffin::create('FireflyIII\Models\Reminder');
|
||||
$reminder->notnow = true;
|
||||
$reminder->save();
|
||||
$this->be($reminder->remindersable->account->user);
|
||||
|
||||
$this->call('GET', '/reminder/' . $reminder->id);
|
||||
$this->assertResponseOk();
|
||||
}
|
||||
|
||||
}
|
238
tests/controllers/ReportControllerTest.php
Normal file
238
tests/controllers/ReportControllerTest.php
Normal file
@@ -0,0 +1,238 @@
|
||||
<?php
|
||||
use Illuminate\Support\Collection;
|
||||
use League\FactoryMuffin\Facade as FactoryMuffin;
|
||||
|
||||
/**
|
||||
* Class ReportControllerTest
|
||||
*/
|
||||
class ReportControllerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Sets up the fixture, for example, opens a network connection.
|
||||
* This method is called before a test is executed.
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called before the first test of this test class is run.
|
||||
*
|
||||
* @since Method available since Release 3.4.0
|
||||
*/
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
parent::setUpBeforeClass();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tears down the fixture, for example, closes a network connection.
|
||||
* This method is called after a test is executed.
|
||||
*/
|
||||
public function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testBudget()
|
||||
{
|
||||
$user = FactoryMuffin::create('FireflyIII\User');
|
||||
$showSharedReports = FactoryMuffin::create('FireflyIII\Models\Preference');
|
||||
$currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
|
||||
$account = FactoryMuffin::create('FireflyIII\Models\Account');
|
||||
$budget = FactoryMuffin::create('FireflyIII\Models\Budget');
|
||||
$budget->queryAmount = 100;
|
||||
$accounts = new Collection([$account]);
|
||||
$budgets = new Collection([$budget]);
|
||||
$showSharedReports->data = false;
|
||||
$this->be($user);
|
||||
$showSharedReports->save();
|
||||
|
||||
// mock stuff
|
||||
$query = $this->mock('FireflyIII\Helpers\Report\ReportQueryInterface');
|
||||
$helper = $this->mock('FireflyIII\Helpers\Report\ReportHelperInterface');
|
||||
|
||||
// fake it!
|
||||
Preferences::shouldReceive('get')->withArgs(['showSharedReports', false])->andReturn($showSharedReports);
|
||||
Amount::shouldReceive('getDefaultCurrency')->once()->andReturn($currency);
|
||||
Amount::shouldReceive('getAllCurrencies')->once()->andReturn([$currency]);
|
||||
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
|
||||
Amount::shouldReceive('format')->andReturn('X');
|
||||
$query->shouldReceive('getAllAccounts')->withAnyArgs()->andReturn($accounts);
|
||||
$query->shouldReceive('getBudgetSummary')->withAnyArgs()->andReturn($budgets);
|
||||
$query->shouldReceive('balancedTransactionsSum')->withAnyArgs()->andReturn(100);
|
||||
$helper->shouldReceive('getBudgetsForMonth')->withAnyArgs()->andReturn($budgets);
|
||||
|
||||
|
||||
$this->call('GET', '/reports/budget/2015/1');
|
||||
$this->assertResponseOk();
|
||||
|
||||
}
|
||||
|
||||
public function testIndex()
|
||||
{
|
||||
$user = FactoryMuffin::create('FireflyIII\User');
|
||||
$this->be($user);
|
||||
|
||||
// mock stuff
|
||||
$helper = $this->mock('FireflyIII\Helpers\Report\ReportHelperInterface');
|
||||
|
||||
$helper->shouldReceive('listOfMonths')->andReturn([]);
|
||||
$helper->shouldReceive('listOfYears')->andReturn([]);
|
||||
|
||||
|
||||
$this->call('GET', '/reports');
|
||||
$this->assertResponseOk();
|
||||
|
||||
}
|
||||
|
||||
public function testModalBalancedTransfers()
|
||||
{
|
||||
$account = FactoryMuffin::create('FireflyIII\Models\Account');
|
||||
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
|
||||
$journals = new Collection([$journal]);
|
||||
$this->be($account->user);
|
||||
|
||||
$query = $this->mock('FireflyIII\Helpers\Report\ReportQueryInterface');
|
||||
$query->shouldReceive('balancedTransactionsList')->withAnyArgs()->andReturn($journals);
|
||||
|
||||
|
||||
$this->call('GET', '/reports/modal/' . $account->id . '/2015/1/balanced-transfers');
|
||||
$this->assertResponseOk();
|
||||
}
|
||||
|
||||
public function testModalLeftUnbalanced()
|
||||
{
|
||||
$account = FactoryMuffin::create('FireflyIII\Models\Account');
|
||||
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
|
||||
$secondJournal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
|
||||
$group = FactoryMuffin::create('FireflyIII\Models\TransactionGroup');
|
||||
$group->transactionjournals()->save($secondJournal);
|
||||
$journals = new Collection([$journal, $secondJournal]);
|
||||
$this->be($account->user);
|
||||
|
||||
$query = $this->mock('FireflyIII\Helpers\Report\ReportQueryInterface');
|
||||
$query->shouldReceive('getTransactionsWithoutBudget')->withAnyArgs()->andReturn($journals);
|
||||
|
||||
$this->call('GET', '/reports/modal/' . $account->id . '/2015/1/left-unbalanced');
|
||||
$this->assertResponseOk();
|
||||
|
||||
}
|
||||
|
||||
public function testModalNoBudget()
|
||||
{
|
||||
$account = FactoryMuffin::create('FireflyIII\Models\Account');
|
||||
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
|
||||
$journals = new Collection([$journal]);
|
||||
$this->be($account->user);
|
||||
|
||||
|
||||
$query = $this->mock('FireflyIII\Helpers\Report\ReportQueryInterface');
|
||||
$query->shouldReceive('getTransactionsWithoutBudget')->withAnyArgs()->andReturn($journals);
|
||||
|
||||
$this->call('GET', '/reports/modal/' . $account->id . '/2015/1/no-budget');
|
||||
$this->assertResponseOk();
|
||||
|
||||
}
|
||||
|
||||
public function testMonth()
|
||||
{
|
||||
$user = FactoryMuffin::create('FireflyIII\User');
|
||||
$currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
|
||||
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
|
||||
$budget = FactoryMuffin::create('FireflyIII\Models\Budget');
|
||||
$account = FactoryMuffin::create('FireflyIII\Models\Account');
|
||||
$journals = new Collection([$journal]);
|
||||
$budgets = new Collection([$budget]);
|
||||
$accounts = new Collection([$account]);
|
||||
$this->be($user);
|
||||
|
||||
$helper = $this->mock('FireflyIII\Helpers\Report\ReportHelperInterface');
|
||||
$query = $this->mock('FireflyIII\Helpers\Report\ReportQueryInterface');
|
||||
|
||||
$query->shouldReceive('incomeByPeriod')->withAnyArgs()->andReturn([]);
|
||||
$query->shouldReceive('journalsByExpenseAccount')->withAnyArgs()->andReturn($journals);
|
||||
$helper->shouldReceive('getBudgetsForMonth')->withAnyArgs()->andReturn($budgets);
|
||||
$query->shouldReceive('journalsByCategory')->withAnyArgs()->andReturn($journals);
|
||||
$query->shouldReceive('sharedExpensesByCategory')->withAnyArgs()->andReturn($journals);
|
||||
$query->shouldReceive('accountList')->withAnyArgs()->andReturn($accounts);
|
||||
|
||||
// mock stuff!
|
||||
Amount::shouldReceive('getDefaultCurrency')->once()->andReturn($currency);
|
||||
Amount::shouldReceive('getAllCurrencies')->once()->andReturn([$currency]);
|
||||
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
|
||||
Amount::shouldReceive('getCurrencySymbol')->andReturn('X');
|
||||
Amount::shouldReceive('format')->andReturn('X');
|
||||
|
||||
$this->call('GET', '/reports/2015/1');
|
||||
$this->assertResponseOk();
|
||||
}
|
||||
|
||||
public function testMonthWithShared()
|
||||
{
|
||||
$user = FactoryMuffin::create('FireflyIII\User');
|
||||
$currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
|
||||
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
|
||||
$budget = FactoryMuffin::create('FireflyIII\Models\Budget');
|
||||
$account = FactoryMuffin::create('FireflyIII\Models\Account');
|
||||
$showSharedReports = FactoryMuffin::create('FireflyIII\Models\Preference');
|
||||
$showSharedReports->data = true;
|
||||
|
||||
$journals = new Collection([$journal]);
|
||||
$budgets = new Collection([$budget]);
|
||||
$accounts = new Collection([$account]);
|
||||
$this->be($user);
|
||||
|
||||
$helper = $this->mock('FireflyIII\Helpers\Report\ReportHelperInterface');
|
||||
$query = $this->mock('FireflyIII\Helpers\Report\ReportQueryInterface');
|
||||
|
||||
$query->shouldReceive('incomeByPeriod')->withAnyArgs()->andReturn([]);
|
||||
$query->shouldReceive('journalsByExpenseAccount')->withAnyArgs()->andReturn($journals);
|
||||
$helper->shouldReceive('getBudgetsForMonth')->withAnyArgs()->andReturn($budgets);
|
||||
$query->shouldReceive('journalsByCategory')->withAnyArgs()->andReturn($journals);
|
||||
$query->shouldReceive('sharedExpensesByCategory')->withAnyArgs()->andReturn($journals);
|
||||
$query->shouldReceive('accountList')->withAnyArgs()->andReturn($accounts);
|
||||
|
||||
// mock stuff!
|
||||
Preferences::shouldReceive('get')->withArgs(['showSharedReports', false])->andReturn($showSharedReports);
|
||||
Amount::shouldReceive('getDefaultCurrency')->once()->andReturn($currency);
|
||||
Amount::shouldReceive('getAllCurrencies')->once()->andReturn([$currency]);
|
||||
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
|
||||
Amount::shouldReceive('getCurrencySymbol')->andReturn('X');
|
||||
Amount::shouldReceive('format')->andReturn('X');
|
||||
|
||||
$this->call('GET', '/reports/2015/1');
|
||||
$this->assertResponseOk();
|
||||
}
|
||||
|
||||
public function testYear()
|
||||
{
|
||||
$user = FactoryMuffin::create('FireflyIII\User');
|
||||
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
|
||||
$currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
|
||||
$journals = new Collection([$journal]);
|
||||
|
||||
$this->be($user);
|
||||
|
||||
$helper = $this->mock('FireflyIII\Helpers\Report\ReportHelperInterface');
|
||||
$query = $this->mock('FireflyIII\Helpers\Report\ReportQueryInterface');
|
||||
|
||||
$helper->shouldReceive('yearBalanceReport')->withAnyArgs()->andReturn([]);
|
||||
$query->shouldReceive('journalsByRevenueAccount')->withAnyArgs()->andReturn($journals);
|
||||
$query->shouldReceive('journalsByExpenseAccount')->withAnyArgs()->andReturn($journals);
|
||||
|
||||
// mock stuff!
|
||||
Amount::shouldReceive('getDefaultCurrency')->once()->andReturn($currency);
|
||||
Amount::shouldReceive('getAllCurrencies')->once()->andReturn([$currency]);
|
||||
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
|
||||
Amount::shouldReceive('getCurrencySymbol')->andReturn('X');
|
||||
Amount::shouldReceive('format')->andReturn('X');
|
||||
|
||||
$this->call('GET', '/reports/2015');
|
||||
$this->assertResponseOk();
|
||||
}
|
||||
|
||||
|
||||
}
|
55
tests/controllers/SearchControllerTest.php
Normal file
55
tests/controllers/SearchControllerTest.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
use League\FactoryMuffin\Facade as FactoryMuffin;
|
||||
|
||||
/**
|
||||
* Class SearchControllerTest
|
||||
*/
|
||||
class SearchControllerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Sets up the fixture, for example, opens a network connection.
|
||||
* This method is called before a test is executed.
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called before the first test of this test class is run.
|
||||
*
|
||||
* @since Method available since Release 3.4.0
|
||||
*/
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
parent::setUpBeforeClass();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tears down the fixture, for example, closes a network connection.
|
||||
* This method is called after a test is executed.
|
||||
*/
|
||||
public function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testSearch()
|
||||
{
|
||||
$user = FactoryMuffin::create('FireflyIII\User');
|
||||
$this->be($user);
|
||||
$words = ['Something'];
|
||||
// mock!
|
||||
$repository = $this->mock('FireflyIII\Support\Search\SearchInterface');
|
||||
$repository->shouldReceive('searchTransactions')->with($words)->once()->andReturn([]);
|
||||
$repository->shouldReceive('searchAccounts')->with($words)->once()->andReturn([]);
|
||||
$repository->shouldReceive('searchCategories')->with($words)->once()->andReturn([]);
|
||||
$repository->shouldReceive('searchBudgets')->with($words)->once()->andReturn([]);
|
||||
$repository->shouldReceive('searchTags')->with($words)->once()->andReturn([]);
|
||||
|
||||
$this->call('GET', '/search?q=Something');
|
||||
$this->assertResponseOk();
|
||||
}
|
||||
}
|
217
tests/controllers/TagControllerTest.php
Normal file
217
tests/controllers/TagControllerTest.php
Normal file
@@ -0,0 +1,217 @@
|
||||
<?php
|
||||
use League\FactoryMuffin\Facade as FactoryMuffin;
|
||||
|
||||
/**
|
||||
* Class TagControllerTest
|
||||
*/
|
||||
class TagControllerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Sets up the fixture, for example, opens a network connection.
|
||||
* This method is called before a test is executed.
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
FactoryMuffin::create('FireflyIII\User');
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called before the first test of this test class is run.
|
||||
*
|
||||
* @since Method available since Release 3.4.0
|
||||
*/
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
parent::setUpBeforeClass();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tears down the fixture, for example, closes a network connection.
|
||||
* This method is called after a test is executed.
|
||||
*/
|
||||
public function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testCreate()
|
||||
{
|
||||
$user = FactoryMuffin::create('FireflyIII\User');
|
||||
$this->be($user);
|
||||
|
||||
$this->call('GET', '/tags/create');
|
||||
$this->assertResponseOk();
|
||||
}
|
||||
|
||||
public function testDelete()
|
||||
{
|
||||
$tag = FactoryMuffin::create('FireflyIII\Models\Tag');
|
||||
$this->be($tag->user);
|
||||
|
||||
$this->call('GET', '/tags/delete/' . $tag->id);
|
||||
$this->assertResponseOk();
|
||||
}
|
||||
|
||||
public function testDestroy()
|
||||
{
|
||||
$tag = FactoryMuffin::create('FireflyIII\Models\Tag');
|
||||
$this->be($tag->user);
|
||||
|
||||
$this->call('POST', '/tags/destroy/' . $tag->id, ['_token' => 'replaceMe']);
|
||||
$this->assertSessionHas('success');
|
||||
$this->assertResponseStatus(302);
|
||||
|
||||
}
|
||||
|
||||
public function testEdit()
|
||||
{
|
||||
$tag = FactoryMuffin::create('FireflyIII\Models\Tag');
|
||||
$this->be($tag->user);
|
||||
|
||||
$this->call('GET', '/tags/edit/' . $tag->id);
|
||||
$this->assertResponseOk();
|
||||
}
|
||||
|
||||
public function testEditBalancingAct()
|
||||
{
|
||||
$tag = FactoryMuffin::create('FireflyIII\Models\Tag');
|
||||
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
|
||||
$type = FactoryMuffin::create('FireflyIII\Models\TransactionType');
|
||||
$type->type = 'Transfer';
|
||||
$type->save();
|
||||
$journal->transactionType()->associate($type);
|
||||
$journal->save();
|
||||
$tag->transactionJournals()->save($journal);
|
||||
$tag->tagMode = 'balancingAct';
|
||||
$tag->save();
|
||||
$this->be($tag->user);
|
||||
|
||||
$this->call('GET', '/tags/edit/' . $tag->id);
|
||||
$this->assertResponseOk();
|
||||
}
|
||||
|
||||
public function testEditThreeExpenses()
|
||||
{
|
||||
$tag = FactoryMuffin::create('FireflyIII\Models\Tag');
|
||||
$type = FactoryMuffin::create('FireflyIII\Models\TransactionType');
|
||||
$type->type = 'Withdrawal';
|
||||
$type->save();
|
||||
|
||||
for ($i = 0; $i < 3; $i++) {
|
||||
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
|
||||
$journal->transactionType()->associate($type);
|
||||
$journal->save();
|
||||
$tag->transactionJournals()->save($journal);
|
||||
}
|
||||
|
||||
|
||||
$tag->tagMode = 'nothing';
|
||||
$tag->save();
|
||||
$this->be($tag->user);
|
||||
|
||||
$this->call('GET', '/tags/edit/' . $tag->id);
|
||||
$this->assertResponseOk();
|
||||
}
|
||||
|
||||
|
||||
public function testHideTagHelp()
|
||||
{
|
||||
$tag = FactoryMuffin::create('FireflyIII\Models\Tag');
|
||||
$this->be($tag->user);
|
||||
|
||||
$this->call('POST', '/tags/hideTagHelp/true', ['_token' => 'replaceMe']);
|
||||
$this->assertResponseOk();
|
||||
}
|
||||
|
||||
public function testIndex()
|
||||
{
|
||||
$tag = FactoryMuffin::create('FireflyIII\Models\Tag');
|
||||
$this->be($tag->user);
|
||||
|
||||
$this->call('GET', '/tags');
|
||||
$this->assertResponseOk();
|
||||
}
|
||||
|
||||
public function testShow()
|
||||
{
|
||||
$tag = FactoryMuffin::create('FireflyIII\Models\Tag');
|
||||
$this->be($tag->user);
|
||||
|
||||
$this->call('GET', '/tags/show/' . $tag->id);
|
||||
$this->assertResponseOk();
|
||||
}
|
||||
|
||||
public function testStore()
|
||||
{
|
||||
$user = FactoryMuffin::create('FireflyIII\User');
|
||||
$this->be($user);
|
||||
$data = [
|
||||
'_token' => 'replaceMe',
|
||||
'tag' => 'BlaBla' . rand(1, 1000),
|
||||
'tagMode' => 'nothing'
|
||||
];
|
||||
|
||||
$this->call('POST', '/tags/store/', $data);
|
||||
$this->assertResponseStatus(302);
|
||||
}
|
||||
|
||||
public function testStoreWithLocation()
|
||||
{
|
||||
$user = FactoryMuffin::create('FireflyIII\User');
|
||||
$this->be($user);
|
||||
$data = [
|
||||
'_token' => 'replaceMe',
|
||||
'tag' => 'BlaBla' . rand(1, 1000),
|
||||
'tagMode' => 'nothing',
|
||||
'latitude' => 12,
|
||||
'longitude' => 13,
|
||||
'zoomLevel' => 3,
|
||||
'setTag' => 'true',
|
||||
'create_another' => 1,
|
||||
];
|
||||
|
||||
$this->call('POST', '/tags/store/', $data);
|
||||
$this->assertResponseStatus(302);
|
||||
}
|
||||
|
||||
public function testUpdate()
|
||||
{
|
||||
$tag = FactoryMuffin::create('FireflyIII\Models\Tag');
|
||||
$this->be($tag->user);
|
||||
|
||||
$data = [
|
||||
'_token' => 'replaceMe',
|
||||
'tag' => 'BlaBla' . rand(1, 1000),
|
||||
'tagMode' => 'nothing',
|
||||
'id' => $tag->id,
|
||||
];
|
||||
|
||||
$this->call('POST', '/tags/update/' . $tag->id, $data);
|
||||
$this->assertResponseStatus(302);
|
||||
}
|
||||
|
||||
public function testUpdateWithLocation()
|
||||
{
|
||||
$tag = FactoryMuffin::create('FireflyIII\Models\Tag');
|
||||
$this->be($tag->user);
|
||||
|
||||
$data = [
|
||||
'_token' => 'replaceMe',
|
||||
'tag' => 'BlaBla' . rand(1, 1000),
|
||||
'tagMode' => 'nothing',
|
||||
'id' => $tag->id,
|
||||
'latitude' => 12,
|
||||
'setTag' => 'true',
|
||||
'longitude' => 13,
|
||||
'zoomLevel' => 3,
|
||||
'return_to_edit' => 1,
|
||||
];
|
||||
|
||||
$this->call('POST', '/tags/update/' . $tag->id, $data);
|
||||
$this->assertResponseStatus(302);
|
||||
}
|
||||
|
||||
|
||||
}
|
363
tests/controllers/TransactionControllerTest.php
Normal file
363
tests/controllers/TransactionControllerTest.php
Normal file
@@ -0,0 +1,363 @@
|
||||
<?php
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Collection;
|
||||
use League\FactoryMuffin\Facade as FactoryMuffin;
|
||||
|
||||
/**
|
||||
* Class TransactionControllerTest
|
||||
*/
|
||||
class TransactionControllerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Sets up the fixture, for example, opens a network connection.
|
||||
* This method is called before a test is executed.
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called before the first test of this test class is run.
|
||||
*
|
||||
* @since Method available since Release 3.4.0
|
||||
*/
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
parent::setUpBeforeClass();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tears down the fixture, for example, closes a network connection.
|
||||
* This method is called after a test is executed.
|
||||
*/
|
||||
public function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
|
||||
public function testCreate()
|
||||
{
|
||||
$user = FactoryMuffin::create('FireflyIII\User');
|
||||
$this->be($user);
|
||||
|
||||
// mock!
|
||||
$repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface');
|
||||
|
||||
|
||||
// fake!
|
||||
$repository->shouldReceive('getAccounts')->andReturn(new Collection);
|
||||
|
||||
|
||||
$this->call('GET', '/transactions/create/withdrawal?account_id=12');
|
||||
$this->assertResponseOk();
|
||||
}
|
||||
|
||||
public function testDelete()
|
||||
{
|
||||
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
|
||||
$this->be($journal->user);
|
||||
|
||||
$this->call('GET', '/transaction/delete/' . $journal->id);
|
||||
$this->assertResponseOk();
|
||||
}
|
||||
|
||||
public function testDestroy()
|
||||
{
|
||||
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
|
||||
$this->be($journal->user);
|
||||
|
||||
// mock!
|
||||
$repository = $this->mock('FireflyIII\Repositories\Journal\JournalRepositoryInterface');
|
||||
|
||||
// fake!
|
||||
$repository->shouldReceive('delete')->andReturn(true);
|
||||
|
||||
$this->call('POST', '/transaction/destroy/' . $journal->id, ['_token' => 'replaceMe']);
|
||||
$this->assertResponseStatus(302);
|
||||
$this->assertSessionHas('success');
|
||||
|
||||
}
|
||||
|
||||
public function testEdit()
|
||||
{
|
||||
// make complete journal:
|
||||
$accountType = FactoryMuffin::create('FireflyIII\Models\AccountType');
|
||||
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
|
||||
$account = FactoryMuffin::create('FireflyIII\Models\Account');
|
||||
$transaction1 = FactoryMuffin::create('FireflyIII\Models\Transaction');
|
||||
$transaction2 = FactoryMuffin::create('FireflyIII\Models\Transaction');
|
||||
|
||||
$accountType->type = 'Asset account';
|
||||
$account->account_type_id = $accountType->id;
|
||||
|
||||
$account->save();
|
||||
$transaction1->account_id = $account->id;
|
||||
$transaction1->transaction_journal_id = $journal->id;
|
||||
$transaction1->save();
|
||||
|
||||
$transaction2->account_id = $account->id;
|
||||
$transaction2->transaction_journal_id = $journal->id;
|
||||
$transaction2->save();
|
||||
|
||||
// also add some tags:
|
||||
$tag = FactoryMuffin::create('FireflyIII\Models\Tag');
|
||||
$tag->transactionJournals()->save($journal);
|
||||
|
||||
// and a category and a budget:
|
||||
$budget = FactoryMuffin::create('FireflyIII\Models\Budget');
|
||||
$category = FactoryMuffin::create('FireflyIII\Models\Category');
|
||||
$category->transactionJournals()->save($journal);
|
||||
$budget->transactionJournals()->save($journal);
|
||||
|
||||
// and a piggy bank event:
|
||||
$pbEvent = FactoryMuffin::create('FireflyIII\Models\PiggyBankEvent');
|
||||
$pbEvent->transaction_journal_id = $journal->id;
|
||||
$pbEvent->save();
|
||||
|
||||
$this->be($journal->user);
|
||||
|
||||
|
||||
// mock!
|
||||
$repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface');
|
||||
|
||||
|
||||
// fake!
|
||||
$repository->shouldReceive('getAccounts')->andReturn(new Collection);
|
||||
|
||||
$this->call('GET', '/transaction/edit/' . $journal->id);
|
||||
$this->assertResponseOk();
|
||||
}
|
||||
|
||||
public function testIndexRevenue()
|
||||
{
|
||||
$user = FactoryMuffin::create('FireflyIII\User');
|
||||
$this->be($user);
|
||||
|
||||
// mock!
|
||||
$repository = $this->mock('FireflyIII\Repositories\Journal\JournalRepositoryInterface');
|
||||
|
||||
// fake!
|
||||
$repository->shouldReceive('getJournalsOfTypes')->withArgs([['Deposit'], 0, 0])->andReturn(new LengthAwarePaginator(new Collection, 0, 50));
|
||||
|
||||
$this->call('GET', '/transactions/deposit');
|
||||
$this->assertResponseOk();
|
||||
|
||||
}
|
||||
|
||||
public function testIndexTransfer()
|
||||
{
|
||||
$user = FactoryMuffin::create('FireflyIII\User');
|
||||
$this->be($user);
|
||||
|
||||
// mock!
|
||||
$repository = $this->mock('FireflyIII\Repositories\Journal\JournalRepositoryInterface');
|
||||
|
||||
// fake!
|
||||
$repository->shouldReceive('getJournalsOfTypes')->withArgs([['Transfer'], 0, 0])->andReturn(new LengthAwarePaginator(new Collection, 0, 50));
|
||||
|
||||
$this->call('GET', '/transactions/transfers');
|
||||
$this->assertResponseOk();
|
||||
}
|
||||
|
||||
public function testIndexWithdrawal()
|
||||
{
|
||||
$user = FactoryMuffin::create('FireflyIII\User');
|
||||
$this->be($user);
|
||||
|
||||
// mock!
|
||||
$repository = $this->mock('FireflyIII\Repositories\Journal\JournalRepositoryInterface');
|
||||
|
||||
// fake!
|
||||
$repository->shouldReceive('getJournalsOfTypes')->withArgs([['Withdrawal'], 0, 0])->andReturn(new LengthAwarePaginator(new Collection, 0, 50));
|
||||
|
||||
$this->call('GET', '/transactions/withdrawal');
|
||||
$this->assertResponseOk();
|
||||
}
|
||||
|
||||
public function testReorder()
|
||||
{
|
||||
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
|
||||
$this->be($journal->user);
|
||||
|
||||
// mock!
|
||||
$repository = $this->mock('FireflyIII\Repositories\Journal\JournalRepositoryInterface');
|
||||
|
||||
// fake!
|
||||
$repository->shouldReceive('getWithDate')->withAnyArgs()->andReturn($journal);
|
||||
|
||||
$data = [
|
||||
'items' => [$journal->id],
|
||||
'date' => $journal->date->format('Y-m-d'),
|
||||
'_token' => 'replaceMe'
|
||||
];
|
||||
|
||||
$this->call('POST', '/transaction/reorder', $data);
|
||||
$this->assertResponseOk();
|
||||
}
|
||||
|
||||
public function testShow()
|
||||
{
|
||||
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
|
||||
$transaction1 = FactoryMuffin::create('FireflyIII\Models\Transaction');
|
||||
$currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
|
||||
$transaction1->transaction_journal_id = $journal->id;
|
||||
$transaction1->save();
|
||||
$this->be($journal->user);
|
||||
|
||||
|
||||
// mock!
|
||||
$repository = $this->mock('FireflyIII\Repositories\Journal\JournalRepositoryInterface');
|
||||
|
||||
// fake!
|
||||
$repository->shouldReceive('getAmountBefore')->withAnyArgs()->andReturn(5);
|
||||
Amount::shouldReceive('getDefaultCurrency')->once()->andReturn($currency);
|
||||
Amount::shouldReceive('getAllCurrencies')->once()->andReturn([$currency]);
|
||||
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
|
||||
Amount::shouldReceive('formatTransaction')->andReturn('X');
|
||||
Amount::shouldReceive('format')->andReturn('X');
|
||||
|
||||
|
||||
$this->call('GET', '/transaction/show/' . $journal->id);
|
||||
$this->assertResponseOk();
|
||||
}
|
||||
|
||||
public function testStore()
|
||||
{
|
||||
$account = FactoryMuffin::create('FireflyIII\Models\Account');
|
||||
$currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
|
||||
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
|
||||
FactoryMuffin::create('FireflyIII\Models\TransactionType');
|
||||
FactoryMuffin::create('FireflyIII\Models\TransactionType');
|
||||
FactoryMuffin::create('FireflyIII\Models\TransactionType');
|
||||
$this->be($account->user);
|
||||
|
||||
$data = [
|
||||
'reminder_id' => '',
|
||||
'what' => 'withdrawal',
|
||||
'description' => 'Bla bla bla',
|
||||
'account_id' => $account->id,
|
||||
'expense_account' => 'Bla bla',
|
||||
'amount' => '100',
|
||||
'amount_currency_id' => $currency->id,
|
||||
'date' => '2015-05-05',
|
||||
'budget_id' => '0',
|
||||
'create_another' => '1',
|
||||
'category' => '',
|
||||
'tags' => '',
|
||||
'piggy_bank_id' => '0',
|
||||
'_token' => 'replaceMe',
|
||||
];
|
||||
|
||||
// mock!
|
||||
$repository = $this->mock('FireflyIII\Repositories\Journal\JournalRepositoryInterface');
|
||||
|
||||
// fake!
|
||||
$repository->shouldReceive('store')->andReturn($journal);
|
||||
$repository->shouldReceive('deactivateReminder')->andReturnNull();
|
||||
|
||||
|
||||
$this->call('POST', '/transactions/store/withdrawal', $data);
|
||||
|
||||
//$this->assertSessionHas('errors','bla');
|
||||
$this->assertResponseStatus(302);
|
||||
$this->assertSessionHas('success');
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function testUpdate()
|
||||
{
|
||||
$account = FactoryMuffin::create('FireflyIII\Models\Account');
|
||||
$currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
|
||||
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
|
||||
FactoryMuffin::create('FireflyIII\Models\TransactionType');
|
||||
FactoryMuffin::create('FireflyIII\Models\TransactionType');
|
||||
FactoryMuffin::create('FireflyIII\Models\TransactionType');
|
||||
$this->be($journal->user);
|
||||
$account->user_id = $journal->user_id;
|
||||
$account->save();
|
||||
|
||||
$data = [
|
||||
'_token' => 'replaceMe',
|
||||
'id' => $journal->id,
|
||||
'what' => 'withdrawal',
|
||||
'description' => 'LunchX',
|
||||
'account_id' => $account->id,
|
||||
'expense_account' => 'Lunch House',
|
||||
'amount' => '4.72',
|
||||
'amount_currency_id' => $currency->id,
|
||||
'date' => '2015-05-31',
|
||||
'budget_id' => '0',
|
||||
'category' => 'Lunch',
|
||||
'tags' => '',
|
||||
'piggy_bank_id' => '0',
|
||||
];
|
||||
|
||||
$this->call('POST', '/transactions/store/withdrawal', $data);
|
||||
|
||||
// mock!
|
||||
$repository = $this->mock('FireflyIII\Repositories\Journal\JournalRepositoryInterface');
|
||||
|
||||
// fake!
|
||||
$repository->shouldReceive('update')->andReturn($journal);
|
||||
|
||||
|
||||
$this->call('POST', '/transaction/update/' . $journal->id, $data);
|
||||
//$this->assertSessionHas('errors','bla');
|
||||
$this->assertResponseStatus(302);
|
||||
$this->assertSessionHas('success');
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function testUpdateWithRedirect()
|
||||
{
|
||||
$account = FactoryMuffin::create('FireflyIII\Models\Account');
|
||||
$currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
|
||||
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
|
||||
FactoryMuffin::create('FireflyIII\Models\TransactionType');
|
||||
FactoryMuffin::create('FireflyIII\Models\TransactionType');
|
||||
FactoryMuffin::create('FireflyIII\Models\TransactionType');
|
||||
$this->be($journal->user);
|
||||
$account->user_id = $journal->user_id;
|
||||
$account->save();
|
||||
|
||||
$data = [
|
||||
'_token' => 'replaceMe',
|
||||
'id' => $journal->id,
|
||||
'what' => 'withdrawal',
|
||||
'description' => 'LunchX',
|
||||
'account_id' => $account->id,
|
||||
'expense_account' => 'Lunch House',
|
||||
'amount' => '4.72',
|
||||
'amount_currency_id' => $currency->id,
|
||||
'date' => '2015-05-31',
|
||||
'budget_id' => '0',
|
||||
'category' => 'Lunch',
|
||||
'return_to_edit' => 1,
|
||||
'tags' => '',
|
||||
'piggy_bank_id' => '0',
|
||||
];
|
||||
|
||||
$this->call('POST', '/transactions/store/withdrawal', $data);
|
||||
|
||||
// mock!
|
||||
$repository = $this->mock('FireflyIII\Repositories\Journal\JournalRepositoryInterface');
|
||||
|
||||
// fake!
|
||||
$repository->shouldReceive('update')->andReturn($journal);
|
||||
|
||||
|
||||
$this->call('POST', '/transaction/update/' . $journal->id, $data);
|
||||
//$this->assertSessionHas('errors','bla');
|
||||
$this->assertResponseStatus(302);
|
||||
$this->assertSessionHas('success');
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -78,6 +78,7 @@ FactoryMuffin::define(
|
||||
'date' => 'date',
|
||||
'latitude' => 12,
|
||||
'longitude' => 13,
|
||||
'zoomLevel' => 3,
|
||||
]
|
||||
);
|
||||
|
||||
@@ -91,6 +92,37 @@ FactoryMuffin::define(
|
||||
]
|
||||
);
|
||||
|
||||
FactoryMuffin::define(
|
||||
'FireflyIII\Models\TransactionGroup',
|
||||
[
|
||||
'user_id' => 'factory|FireflyIII\User',
|
||||
'relation' => 'balance',
|
||||
]
|
||||
);
|
||||
|
||||
FactoryMuffin::define(
|
||||
'FireflyIII\Models\Reminder',
|
||||
[
|
||||
'user_id' => 'factory|FireflyIII\User',
|
||||
'startdate' => 'date',
|
||||
'enddate' => 'date',
|
||||
'active' => 'boolean',
|
||||
'notnow' => 'boolean',
|
||||
'remindersable_id' => 'factory|FireflyIII\Models\Piggybank',
|
||||
'remindersable_type' => 'FireflyIII\Models\Piggybank',
|
||||
'metadata' => function () {
|
||||
return [
|
||||
'perReminder' => 100,
|
||||
'rangesCount' => 0,
|
||||
'ranges' => [],
|
||||
'leftToSave' => 100,
|
||||
];
|
||||
},
|
||||
'encrypted' => 1,
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
FactoryMuffin::define(
|
||||
'FireflyIII\Models\Category',
|
||||
[
|
||||
@@ -138,8 +170,11 @@ FactoryMuffin::define(
|
||||
'type' => function () {
|
||||
$types = ['Expense account', 'Revenue account', 'Asset account'];
|
||||
$count = DB::table('account_types')->count();
|
||||
|
||||
return $types[$count];
|
||||
if ($count < 3) {
|
||||
return $types[$count];
|
||||
} else {
|
||||
return RandomString::generateRandomString(10);
|
||||
}
|
||||
},
|
||||
'editable' => 1,
|
||||
]
|
||||
@@ -170,7 +205,10 @@ FactoryMuffin::define(
|
||||
'FireflyIII\Models\Transaction',
|
||||
[
|
||||
'transaction_journal_id' => 'factory|FireflyIII\Models\TransactionJournal',
|
||||
'amount' => 'integer',
|
||||
'amount' => function () {
|
||||
return rand(1, 100);
|
||||
},
|
||||
'description' => 'sentence',
|
||||
'account_id' => 'factory|FireflyIII\Models\Account'
|
||||
]
|
||||
);
|
||||
@@ -189,6 +227,19 @@ FactoryMuffin::define(
|
||||
]
|
||||
);
|
||||
|
||||
FactoryMuffin::define(
|
||||
'FireflyIII\Models\PiggyBankEvent',
|
||||
[
|
||||
'piggy_bank_id' => 'factory|FireflyIII\Models\PiggyBank',
|
||||
'transaction_journal_id' => 'factory|FireflyIII\Models\TransactionJournal',
|
||||
'date' => 'date',
|
||||
'amount' => function () {
|
||||
return rand(1, 100);
|
||||
},
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
FactoryMuffin::define(
|
||||
'FireflyIII\Models\TransactionType',
|
||||
[
|
||||
|
Reference in New Issue
Block a user