diff --git a/app/Repositories/Journal/JournalRepository.php b/app/Repositories/Journal/JournalRepository.php index 8bf49ad731..484aca23f3 100644 --- a/app/Repositories/Journal/JournalRepository.php +++ b/app/Repositories/Journal/JournalRepository.php @@ -11,6 +11,7 @@ use FireflyIII\Models\Transaction; use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionType; use Illuminate\Support\Collection; +use Log; /** * Class JournalRepository @@ -153,6 +154,7 @@ class JournalRepository implements JournalRepositoryInterface $toType = AccountType::where('type', 'Cash account')->first(); $to = Account::firstOrCreate(['user_id' => $data['user'], 'account_type_id' => $toType->id, 'name' => 'Cash account', 'active' => 1]); } + Log::error('Could not store TO account for Withdrawal (Expense account) because: ' .$to->getErrors()->toJson()); break; case 'Deposit': diff --git a/app/Validation/FireflyValidator.php b/app/Validation/FireflyValidator.php index c4ecc34cd3..a3323f06f6 100644 --- a/app/Validation/FireflyValidator.php +++ b/app/Validation/FireflyValidator.php @@ -80,10 +80,12 @@ class FireflyValidator extends Validator public function validateUniqueAccountForUser($attribute, $value, $parameters) { // get account type from data, we must have this: - $type = isset($this->data['what']) ? $this->data['what'] : null; + $validTypes = [array_keys(Config::get('firefly.subTitlesByIdentifier'))]; + + $type = isset($this->data['what']) && in_array($this->data['what'],$validTypes) ? $this->data['what'] : null; // some fallback: if(is_null($type)) { - $type = Input::get('what'); + $type = in_array(Input::get('what'),$validTypes) ? Input::get('what') : null; } // still null? if(is_null($type)) {