mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-18 20:38:57 +00:00
Implemented some new tests.
This commit is contained in:
@@ -10,6 +10,7 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface as ARI;
|
||||
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Input;
|
||||
use Log;
|
||||
use Preferences;
|
||||
use Session;
|
||||
use Steam;
|
||||
@@ -244,6 +245,7 @@ class PiggyBankController extends Controller
|
||||
Session::flash('success', 'Added ' . Amount::format($amount, false) . ' to "' . e($piggyBank->name) . '".');
|
||||
Preferences::mark();
|
||||
} else {
|
||||
Log::error('Cannot add ' . $amount . ' because max amount is ' . $maxAmount . ' (left on account is ' . $leftOnAccount . ')');
|
||||
Session::flash('error', 'Could not add ' . Amount::format($amount, false) . ' to "' . e($piggyBank->name) . '".');
|
||||
}
|
||||
|
||||
@@ -322,6 +324,7 @@ class PiggyBankController extends Controller
|
||||
'targetamount' => round($request->get('targetamount'), 2),
|
||||
'remind_me' => false,
|
||||
'reminder_skip' => 0,
|
||||
'order' => $repository->getMaxOrder() + 1,
|
||||
'targetdate' => strlen($request->get('targetdate')) > 0 ? new Carbon($request->get('targetdate')) : null,
|
||||
];
|
||||
|
||||
|
||||
@@ -60,6 +60,14 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
return $piggyBank->piggyBankEvents()->orderBy('date', 'DESC')->orderBy('id', 'DESC')->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getMaxOrder()
|
||||
{
|
||||
return intval(Auth::user()->piggyBanks()->max('order'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
|
||||
@@ -42,6 +42,11 @@ interface PiggyBankRepositoryInterface
|
||||
*/
|
||||
public function getEvents(PiggyBank $piggyBank);
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getMaxOrder();
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user