This commit is contained in:
James Cole
2018-03-26 19:19:11 +02:00
parent 5ca31ea3dd
commit 413c1bc2fe
11 changed files with 26 additions and 19 deletions

View File

@@ -53,7 +53,7 @@ class AboutController extends Controller
$search = ['~', '#']; $search = ['~', '#'];
$replace = ['\~', '# ']; $replace = ['\~', '# '];
$phpVersion = str_replace($search, $replace, PHP_VERSION); $phpVersion = str_replace($search, $replace, PHP_VERSION);
$phpOs = str_replace($search, $replace, php_uname()); $phpOs = str_replace($search, $replace, PHP_OS);
$currentDriver = DB::getDriverName(); $currentDriver = DB::getDriverName();
$data $data
= [ = [

View File

@@ -30,6 +30,7 @@ use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController; use Illuminate\Routing\Controller as BaseController;
use Log;
use Symfony\Component\HttpFoundation\ParameterBag; use Symfony\Component\HttpFoundation\ParameterBag;
/** /**
@@ -111,6 +112,7 @@ class Controller extends BaseController
$obj = new Carbon($date); $obj = new Carbon($date);
} catch (InvalidDateException $e) { } catch (InvalidDateException $e) {
// don't care // don't care
Log::error(sprintf('Invalid date exception in API controller: %s', $e->getMessage()));
} }
} }
$bag->set($field, $obj); $bag->set($field, $obj);

View File

@@ -70,6 +70,7 @@ class UserController extends Controller
* @param \FireflyIII\User $user * @param \FireflyIII\User $user
* *
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
* @throws \Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException
*/ */
public function delete(User $user) public function delete(User $user)
{ {

View File

@@ -70,9 +70,9 @@ class AccountRequest extends Request
*/ */
public function rules(): array public function rules(): array
{ {
$accountRoles = join(',', config('firefly.accountRoles')); $accountRoles = implode(',', config('firefly.accountRoles'));
$types = join(',', array_keys(config('firefly.subTitlesByIdentifier'))); $types = implode(',', array_keys(config('firefly.subTitlesByIdentifier')));
$ccPaymentTypes = join(',', array_keys(config('firefly.ccTypes'))); $ccPaymentTypes = implode(',', array_keys(config('firefly.ccTypes')));
$rules = [ $rules = [
'name' => 'required|min:1|uniqueAccountForUser', 'name' => 'required|min:1|uniqueAccountForUser',
'opening_balance' => 'numeric|required_with:opening_balance_date|nullable', 'opening_balance' => 'numeric|required_with:opening_balance_date|nullable',

View File

@@ -168,6 +168,7 @@ class TransactionRequest extends Request
* @param Validator $validator * @param Validator $validator
* *
* @return void * @return void
* @throws \FireflyIII\Exceptions\FireflyException
*/ */
public function withValidator(Validator $validator): void public function withValidator(Validator $validator): void
{ {
@@ -438,10 +439,8 @@ class TransactionRequest extends Request
} }
// add some errors in case of same account submitted: // add some errors in case of same account submitted:
if (!is_null($sourceAccount) && !is_null($destinationAccount)) { if (!is_null($sourceAccount) && !is_null($destinationAccount) && $sourceAccount->id === $destinationAccount->id) {
if ($sourceAccount->id === $destinationAccount->id) { $validator->errors()->add($idField, trans('validation.source_equals_destination'));
$validator->errors()->add($idField, trans('validation.source_equals_destination'));
}
} }
} }
} }
@@ -506,8 +505,6 @@ class TransactionRequest extends Request
); );
// @codeCoverageIgnoreEnd // @codeCoverageIgnoreEnd
} }
return;
} }
} }

View File

@@ -70,6 +70,7 @@ class BulkController extends Controller
* @param Collection $journals * @param Collection $journals
* *
* @return View * @return View
* @throws \RuntimeException
*/ */
public function edit(Request $request, Collection $journals) public function edit(Request $request, Collection $journals)
{ {
@@ -139,6 +140,7 @@ class BulkController extends Controller
* @param JournalRepositoryInterface $repository * @param JournalRepositoryInterface $repository
* *
* @return mixed * @return mixed
* @throws \RuntimeException
*/ */
public function update(BulkEditJournalRequest $request, JournalRepositoryInterface $repository) public function update(BulkEditJournalRequest $request, JournalRepositoryInterface $repository)
{ {

View File

@@ -110,6 +110,13 @@ class LinkController extends Controller
} }
$other = $this->journalRepository->find($linkInfo['transaction_journal_id']); $other = $this->journalRepository->find($linkInfo['transaction_journal_id']);
$alreadyLinked = $this->repository->findLink($journal, $other); $alreadyLinked = $this->repository->findLink($journal, $other);
if($other->id === $journal->id) {
Session::flash('error', trans('firefly.journals_link_to_self'));
return redirect(route('transactions.show', [$journal->id]));
}
if ($alreadyLinked) { if ($alreadyLinked) {
Session::flash('error', trans('firefly.journals_error_linked')); Session::flash('error', trans('firefly.journals_error_linked'));

View File

@@ -102,7 +102,7 @@ class SingleController extends Controller
$budgetId = $this->repository->getJournalBudgetId($journal); $budgetId = $this->repository->getJournalBudgetId($journal);
$categoryName = $this->repository->getJournalCategoryName($journal); $categoryName = $this->repository->getJournalCategoryName($journal);
$tags = join(',', $this->repository->getTags($journal)); $tags = implode(',', $this->repository->getTags($journal));
/** @var Transaction $transaction */ /** @var Transaction $transaction */
$transaction = $journal->transactions()->first(); $transaction = $journal->transactions()->first();
$amount = app('steam')->positive($transaction->amount); $amount = app('steam')->positive($transaction->amount);
@@ -280,7 +280,7 @@ class SingleController extends Controller
'process_date' => $repository->getJournalDate($journal, 'process_date'), 'process_date' => $repository->getJournalDate($journal, 'process_date'),
'category' => $repository->getJournalCategoryName($journal), 'category' => $repository->getJournalCategoryName($journal),
'budget_id' => $repository->getJournalBudgetId($journal), 'budget_id' => $repository->getJournalBudgetId($journal),
'tags' => join(',', $repository->getTags($journal)), 'tags' => implode(',', $repository->getTags($journal)),
'source_account_id' => $sourceAccounts->first()->id, 'source_account_id' => $sourceAccounts->first()->id,
'source_account_name' => $sourceAccounts->first()->edit_name, 'source_account_name' => $sourceAccounts->first()->edit_name,
'destination_account_id' => $destinationAccounts->first()->id, 'destination_account_id' => $destinationAccounts->first()->id,
@@ -441,10 +441,6 @@ class SingleController extends Controller
{ {
$count = $this->repository->countTransactions($journal); $count = $this->repository->countTransactions($journal);
if ($count > 2) { return $count > 2;
return true; // @codeCoverageIgnore
}
return false;
} }
} }

View File

@@ -125,7 +125,7 @@ class SplitController extends Controller
return view( return view(
'transactions.split.edit', compact( 'transactions.split.edit', compact(
'subTitleIcon', 'currencies', 'optionalFields', 'preFilled', 'subTitle', 'uploadSize', 'assetAccounts', 'budgets', 'subTitleIcon', 'currencies', 'optionalFields', 'preFilled', 'subTitle', 'uploadSize', 'budgets',
'journal', 'accountArray', 'journal', 'accountArray',
'previous' 'previous'
) )
@@ -197,7 +197,7 @@ class SplitController extends Controller
'destinationAccounts' => $destinationAccounts, 'destinationAccounts' => $destinationAccounts,
'what' => strtolower($this->repository->getTransactionType($journal)), 'what' => strtolower($this->repository->getTransactionType($journal)),
'date' => $request->old('date', $this->repository->getJournalDate($journal, null)), 'date' => $request->old('date', $this->repository->getJournalDate($journal, null)),
'tags' => join(',', $journal->tags->pluck('tag')->toArray()), 'tags' => implode(',', $journal->tags->pluck('tag')->toArray()),
// all custom fields: // all custom fields:
'interest_date' => $request->old('interest_date', $this->repository->getMetaField($journal, 'interest_date')), 'interest_date' => $request->old('interest_date', $this->repository->getMetaField($journal, 'interest_date')),

View File

@@ -76,6 +76,7 @@ class User extends Authenticatable
* @param string $value * @param string $value
* *
* @return User * @return User
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
*/ */
public static function routeBinder(string $value): User public static function routeBinder(string $value): User
{ {

View File

@@ -1086,6 +1086,7 @@ return [
'invalid_link_selection' => 'Cannot link these transactions', 'invalid_link_selection' => 'Cannot link these transactions',
'journals_linked' => 'Transactions are linked.', 'journals_linked' => 'Transactions are linked.',
'journals_error_linked' => 'These transactions are already linked.', 'journals_error_linked' => 'These transactions are already linked.',
'journals_link_to_self' => 'You cannot link a transaction to itself',
'journal_links' => 'Transaction links', 'journal_links' => 'Transaction links',
'this_withdrawal' => 'This withdrawal', 'this_withdrawal' => 'This withdrawal',
'this_deposit' => 'This deposit', 'this_deposit' => 'This deposit',