diff --git a/app/Api/V1/Requests/PiggyBankRequest.php b/app/Api/V1/Requests/PiggyBankRequest.php index 0e87661073..15a41bda01 100644 --- a/app/Api/V1/Requests/PiggyBankRequest.php +++ b/app/Api/V1/Requests/PiggyBankRequest.php @@ -78,8 +78,8 @@ class PiggyBankRequest extends Request case 'PUT': case 'PATCH': /** @var PiggyBank $piggyBank */ - $piggyBank = $this->route()->parameter('piggyBank'); - $rules['name'] = 'required|between:1,255|uniquePiggyBankForUser:' . $piggyBank->id; + $piggyBank = $this->route()->parameter('piggyBank'); + $rules['name'] = 'required|between:1,255|uniquePiggyBankForUser:' . $piggyBank->id; break; } diff --git a/app/Api/V1/Requests/RecurrenceRequest.php b/app/Api/V1/Requests/RecurrenceRequest.php index 6c7925fed6..3dce86b02f 100644 --- a/app/Api/V1/Requests/RecurrenceRequest.php +++ b/app/Api/V1/Requests/RecurrenceRequest.php @@ -64,7 +64,7 @@ class RecurrenceRequest extends Request 'meta' => [ 'piggy_bank_id' => $this->integer('piggy_bank_id'), 'piggy_bank_name' => $this->string('piggy_bank_name'), - 'tags' => explode(',', $this->string('tags')), + 'tags' => explode(',', $this->string('tags')), ], 'transactions' => [], 'repetitions' => [], @@ -88,26 +88,26 @@ class RecurrenceRequest extends Request /** @var array $transaction */ foreach ($transactions as $transaction) { $return['transactions'][] = [ - 'amount' => $transaction['amount'], + 'amount' => $transaction['amount'], - 'currency_id' => isset($transaction['currency_id']) ? (int)$transaction['currency_id'] : null, - 'currency_code' => $transaction['currency_code'] ?? null, + 'currency_id' => isset($transaction['currency_id']) ? (int)$transaction['currency_id'] : null, + 'currency_code' => $transaction['currency_code'] ?? null, 'foreign_amount' => $transaction['foreign_amount'] ?? null, 'foreign_currency_id' => isset($transaction['foreign_currency_id']) ? (int)$transaction['foreign_currency_id'] : null, 'foreign_currency_code' => $transaction['foreign_currency_code'] ?? null, - 'budget_id' => isset($transaction['budget_id']) ? (int)$transaction['budget_id'] : null, - 'budget_name' => $transaction['budget_name'] ?? null, - 'category_id' => isset($transaction['category_id']) ? (int)$transaction['category_id'] : null, - 'category_name' => $transaction['category_name'] ?? null, + 'budget_id' => isset($transaction['budget_id']) ? (int)$transaction['budget_id'] : null, + 'budget_name' => $transaction['budget_name'] ?? null, + 'category_id' => isset($transaction['category_id']) ? (int)$transaction['category_id'] : null, + 'category_name' => $transaction['category_name'] ?? null, - 'source_id' => isset($transaction['source_id']) ? (int)$transaction['source_id'] : null, - 'source_name' => isset($transaction['source_name']) ? (string)$transaction['source_name'] : null, - 'destination_id' => isset($transaction['destination_id']) ? (int)$transaction['destination_id'] : null, - 'destination_name' => isset($transaction['destination_name']) ? (string)$transaction['destination_name'] : null, + 'source_id' => isset($transaction['source_id']) ? (int)$transaction['source_id'] : null, + 'source_name' => isset($transaction['source_name']) ? (string)$transaction['source_name'] : null, + 'destination_id' => isset($transaction['destination_id']) ? (int)$transaction['destination_id'] : null, + 'destination_name' => isset($transaction['destination_name']) ? (string)$transaction['destination_name'] : null, - 'description' => $transaction['description'], + 'description' => $transaction['description'], ]; } diff --git a/app/Handlers/Events/AutomationHandler.php b/app/Handlers/Events/AutomationHandler.php index 697371afcf..3585e0ccf2 100644 --- a/app/Handlers/Events/AutomationHandler.php +++ b/app/Handlers/Events/AutomationHandler.php @@ -49,10 +49,12 @@ class AutomationHandler $user = $repository->findNull($event->userId); if (null === $user) { Log::debug('User is NULL'); + return true; } if ($event->journals->count() === 0) { Log::debug('No journals.'); + return true; } diff --git a/app/Helpers/Collector/JournalCollector.php b/app/Helpers/Collector/JournalCollector.php index a68b4cbec1..33d24fcaf7 100644 --- a/app/Helpers/Collector/JournalCollector.php +++ b/app/Helpers/Collector/JournalCollector.php @@ -321,6 +321,14 @@ class JournalCollector implements JournalCollectorInterface return $journals; } + /** + * @return EloquentBuilder + */ + public function getQuery(): EloquentBuilder + { + return $this->query; + } + /** * @return JournalCollectorInterface */ @@ -768,14 +776,6 @@ class JournalCollector implements JournalCollectorInterface return $this; } - /** - * @return EloquentBuilder - */ - public function getQuery(): EloquentBuilder - { - return $this->query; - } - /** * @param Collection $set * diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index c872ad7805..fc02ea3c55 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -110,7 +110,7 @@ class ProfileController extends Controller $image = Google2FA::getQRCodeInline($domain, auth()->user()->email, $secret, 200); - return view('profile.code', compact('image','secret')); + return view('profile.code', compact('image', 'secret')); } /** diff --git a/app/Http/Controllers/Recurring/DeleteController.php b/app/Http/Controllers/Recurring/DeleteController.php index d0d995822d..6af99cae02 100644 --- a/app/Http/Controllers/Recurring/DeleteController.php +++ b/app/Http/Controllers/Recurring/DeleteController.php @@ -48,7 +48,7 @@ class DeleteController extends Controller // todo actual number. $journalsCreated = 5; - return view('recurring.delete', compact('recurrence', 'subTitle','journalsCreated')); + return view('recurring.delete', compact('recurrence', 'subTitle', 'journalsCreated')); } /** diff --git a/app/Http/Controllers/Report/BalanceController.php b/app/Http/Controllers/Report/BalanceController.php index 2945a15b13..3b31be87de 100644 --- a/app/Http/Controllers/Report/BalanceController.php +++ b/app/Http/Controllers/Report/BalanceController.php @@ -56,7 +56,7 @@ class BalanceController extends Controller $balance = $helper->getBalanceReport($accounts, $start, $end); - $result = view('reports.partials.balance', compact( 'balance'))->render(); + $result = view('reports.partials.balance', compact('balance'))->render(); $cache->store($result); return $result; diff --git a/app/Http/Controllers/Transaction/MassController.php b/app/Http/Controllers/Transaction/MassController.php index 198cfc64ba..cd08cf2435 100644 --- a/app/Http/Controllers/Transaction/MassController.php +++ b/app/Http/Controllers/Transaction/MassController.php @@ -181,11 +181,11 @@ class MassController extends Controller if (null !== $journal) { // get optional fields: $what = strtolower($this->repository->getTransactionType($journal)); - $sourceAccountId = $request->get('source_account_id')[$journal->id] ?? null; + $sourceAccountId = $request->get('source_id')[$journal->id] ?? null; $currencyId = $request->get('transaction_currency_id')[$journal->id] ?? 1; - $sourceAccountName = $request->get('source_account_name')[$journal->id] ?? null; - $destAccountId = $request->get('destination_account_id')[$journal->id] ?? null; - $destAccountName = $request->get('destination_account_name')[$journal->id] ?? null; + $sourceAccountName = $request->get('source_name')[$journal->id] ?? null; + $destAccountId = $request->get('destination_id')[$journal->id] ?? null; + $destAccountName = $request->get('destination_name')[$journal->id] ?? null; $budgetId = (int)($request->get('budget_id')[$journal->id] ?? 0.0); $category = $request->get('category')[$journal->id]; $tags = $journal->tags->pluck('tag')->toArray(); diff --git a/app/Http/Controllers/Transaction/SingleController.php b/app/Http/Controllers/Transaction/SingleController.php index 8d91025d75..ebbecb07c0 100644 --- a/app/Http/Controllers/Transaction/SingleController.php +++ b/app/Http/Controllers/Transaction/SingleController.php @@ -99,10 +99,10 @@ class SingleController extends Controller $preFilled = [ 'description' => $journal->description, - 'source_account_id' => $source->id, - 'source_account_name' => $source->name, - 'destination_account_id' => $destination->id, - 'destination_account_name' => $destination->name, + 'source_id' => $source->id, + 'source_name' => $source->name, + 'destination_id' => $destination->id, + 'destination_name' => $destination->name, 'amount' => $amount, 'source_amount' => $amount, 'destination_amount' => $foreignAmount, @@ -152,10 +152,10 @@ class SingleController extends Controller $source = (int)$request->get('source'); if (($what === 'withdrawal' || $what === 'transfer') && $source > 0) { - $preFilled['source_account_id'] = $source; + $preFilled['source_id'] = $source; } if ($what === 'deposit' && $source > 0) { - $preFilled['destination_account_id'] = $source; + $preFilled['destination_id'] = $source; } session()->put('preFilled', $preFilled); @@ -259,35 +259,35 @@ class SingleController extends Controller $pTransaction = $repository->getFirstPosTransaction($journal); $foreignCurrency = $pTransaction->foreignCurrency ?? $pTransaction->transactionCurrency; $preFilled = [ - 'date' => $repository->getJournalDate($journal, null), // $journal->dateAsString() - 'interest_date' => $repository->getJournalDate($journal, 'interest_date'), - 'book_date' => $repository->getJournalDate($journal, 'book_date'), - 'process_date' => $repository->getJournalDate($journal, 'process_date'), - 'category' => $repository->getJournalCategoryName($journal), - 'budget_id' => $repository->getJournalBudgetId($journal), - 'tags' => implode(',', $repository->getTags($journal)), - 'source_account_id' => $sourceAccounts->first()->id, - 'source_account_name' => $sourceAccounts->first()->edit_name, - 'destination_account_id' => $destinationAccounts->first()->id, - 'destination_account_name' => $destinationAccounts->first()->edit_name, + 'date' => $repository->getJournalDate($journal, null), // $journal->dateAsString() + 'interest_date' => $repository->getJournalDate($journal, 'interest_date'), + 'book_date' => $repository->getJournalDate($journal, 'book_date'), + 'process_date' => $repository->getJournalDate($journal, 'process_date'), + 'category' => $repository->getJournalCategoryName($journal), + 'budget_id' => $repository->getJournalBudgetId($journal), + 'tags' => implode(',', $repository->getTags($journal)), + 'source_id' => $sourceAccounts->first()->id, + 'source_name' => $sourceAccounts->first()->edit_name, + 'destination_id' => $destinationAccounts->first()->id, + 'destination_name' => $destinationAccounts->first()->edit_name, // new custom fields: - 'due_date' => $repository->getJournalDate($journal, 'due_date'), - 'payment_date' => $repository->getJournalDate($journal, 'payment_date'), - 'invoice_date' => $repository->getJournalDate($journal, 'invoice_date'), - 'interal_reference' => $repository->getMetaField($journal, 'internal_reference'), - 'notes' => $repository->getNoteText($journal), + 'due_date' => $repository->getJournalDate($journal, 'due_date'), + 'payment_date' => $repository->getJournalDate($journal, 'payment_date'), + 'invoice_date' => $repository->getJournalDate($journal, 'invoice_date'), + 'interal_reference' => $repository->getMetaField($journal, 'internal_reference'), + 'notes' => $repository->getNoteText($journal), // amount fields - 'amount' => $pTransaction->amount, - 'source_amount' => $pTransaction->amount, - 'native_amount' => $pTransaction->amount, - 'destination_amount' => $pTransaction->foreign_amount, - 'currency' => $pTransaction->transactionCurrency, - 'source_currency' => $pTransaction->transactionCurrency, - 'native_currency' => $pTransaction->transactionCurrency, - 'foreign_currency' => $foreignCurrency, - 'destination_currency' => $foreignCurrency, + 'amount' => $pTransaction->amount, + 'source_amount' => $pTransaction->amount, + 'native_amount' => $pTransaction->amount, + 'destination_amount' => $pTransaction->foreign_amount, + 'currency' => $pTransaction->transactionCurrency, + 'source_currency' => $pTransaction->transactionCurrency, + 'native_currency' => $pTransaction->transactionCurrency, + 'foreign_currency' => $foreignCurrency, + 'destination_currency' => $foreignCurrency, ]; // amounts for withdrawals and deposits: diff --git a/app/Http/Controllers/Transaction/SplitController.php b/app/Http/Controllers/Transaction/SplitController.php index d5276872f5..a0b0014576 100644 --- a/app/Http/Controllers/Transaction/SplitController.php +++ b/app/Http/Controllers/Transaction/SplitController.php @@ -184,30 +184,30 @@ class SplitController extends Controller $sourceAccounts = $this->repository->getJournalSourceAccounts($journal); $destinationAccounts = $this->repository->getJournalDestinationAccounts($journal); $array = [ - 'journal_description' => $request->old('journal_description', $journal->description), - 'journal_amount' => '0', - 'journal_foreign_amount' => '0', - 'sourceAccounts' => $sourceAccounts, - 'journal_source_account_id' => $request->old('journal_source_account_id', $sourceAccounts->first()->id), - 'journal_source_account_name' => $request->old('journal_source_account_name', $sourceAccounts->first()->name), - 'journal_destination_account_id' => $request->old('journal_destination_account_id', $destinationAccounts->first()->id), - 'destinationAccounts' => $destinationAccounts, - 'what' => strtolower($this->repository->getTransactionType($journal)), - 'date' => $request->old('date', $this->repository->getJournalDate($journal, null)), - 'tags' => implode(',', $journal->tags->pluck('tag')->toArray()), + 'journal_description' => $request->old('journal_description', $journal->description), + 'journal_amount' => '0', + 'journal_foreign_amount' => '0', + 'sourceAccounts' => $sourceAccounts, + 'journal_source_id' => $request->old('journal_source_id', $sourceAccounts->first()->id), + 'journal_source_name' => $request->old('journal_source_name', $sourceAccounts->first()->name), + 'journal_destination_id' => $request->old('journal_destination_id', $destinationAccounts->first()->id), + 'destinationAccounts' => $destinationAccounts, + 'what' => strtolower($this->repository->getTransactionType($journal)), + 'date' => $request->old('date', $this->repository->getJournalDate($journal, null)), + 'tags' => implode(',', $journal->tags->pluck('tag')->toArray()), // all custom fields: - 'interest_date' => $request->old('interest_date', $this->repository->getMetaField($journal, 'interest_date')), - 'book_date' => $request->old('book_date', $this->repository->getMetaField($journal, 'book_date')), - 'process_date' => $request->old('process_date', $this->repository->getMetaField($journal, 'process_date')), - 'due_date' => $request->old('due_date', $this->repository->getMetaField($journal, 'due_date')), - 'payment_date' => $request->old('payment_date', $this->repository->getMetaField($journal, 'payment_date')), - 'invoice_date' => $request->old('invoice_date', $this->repository->getMetaField($journal, 'invoice_date')), - 'internal_reference' => $request->old('internal_reference', $this->repository->getMetaField($journal, 'internal_reference')), - 'notes' => $request->old('notes', $this->repository->getNoteText($journal)), + 'interest_date' => $request->old('interest_date', $this->repository->getMetaField($journal, 'interest_date')), + 'book_date' => $request->old('book_date', $this->repository->getMetaField($journal, 'book_date')), + 'process_date' => $request->old('process_date', $this->repository->getMetaField($journal, 'process_date')), + 'due_date' => $request->old('due_date', $this->repository->getMetaField($journal, 'due_date')), + 'payment_date' => $request->old('payment_date', $this->repository->getMetaField($journal, 'payment_date')), + 'invoice_date' => $request->old('invoice_date', $this->repository->getMetaField($journal, 'invoice_date')), + 'internal_reference' => $request->old('internal_reference', $this->repository->getMetaField($journal, 'internal_reference')), + 'notes' => $request->old('notes', $this->repository->getNoteText($journal)), // transactions. - 'transactions' => $this->getTransactionDataFromJournal($journal), + 'transactions' => $this->getTransactionDataFromJournal($journal), ]; // update transactions array with old request data. $array['transactions'] = $this->updateWithPrevious($array['transactions'], $request->old()); diff --git a/app/Http/Requests/JournalFormRequest.php b/app/Http/Requests/JournalFormRequest.php index eaa39797eb..d98c6f43ce 100644 --- a/app/Http/Requests/JournalFormRequest.php +++ b/app/Http/Requests/JournalFormRequest.php @@ -81,10 +81,10 @@ class JournalFormRequest extends Request 'budget_name' => null, 'category_id' => null, 'category_name' => $this->string('category'), - 'source_id' => $this->integer('source_account_id'), - 'source_name' => $this->string('source_account_name'), - 'destination_id' => $this->integer('destination_account_id'), - 'destination_name' => $this->string('destination_account_name'), + 'source_id' => $this->integer('source_id'), + 'source_name' => $this->string('source_name'), + 'destination_id' => $this->integer('destination_id'), + 'destination_name' => $this->string('destination_name'), 'foreign_currency_id' => null, 'foreign_currency_code' => null, 'foreign_amount' => null, @@ -161,11 +161,11 @@ class JournalFormRequest extends Request 'amount' => 'numeric|required|more:0', 'budget_id' => 'mustExist:budgets,id|belongsToUser:budgets,id|nullable', 'category' => 'between:1,255|nullable', - 'source_account_id' => 'numeric|belongsToUser:accounts,id|nullable', - 'source_account_name' => 'between:1,255|nullable', - 'destination_account_id' => 'numeric|belongsToUser:accounts,id|nullable', - 'destination_account_name' => 'between:1,255|nullable', - 'piggy_bank_id' => 'between:1,255|nullable', + 'source_id' => 'numeric|belongsToUser:accounts,id|nullable', + 'source_name' => 'between:1,255|nullable', + 'destination_id' => 'numeric|belongsToUser:accounts,id|nullable', + 'destination_name' => 'between:1,255|nullable', + 'piggy_bank_id' => 'numeric|nullable', // foreign currency amounts 'native_amount' => 'numeric|more:0|nullable', @@ -193,17 +193,17 @@ class JournalFormRequest extends Request { switch ($what) { case strtolower(TransactionType::WITHDRAWAL): - $rules['source_account_id'] = 'required|exists:accounts,id|belongsToUser:accounts'; - $rules['destination_account_name'] = 'between:1,255|nullable'; + $rules['source_id'] = 'required|exists:accounts,id|belongsToUser:accounts'; + $rules['destination_name'] = 'between:1,255|nullable'; break; case strtolower(TransactionType::DEPOSIT): - $rules['source_account_name'] = 'between:1,255|nullable'; - $rules['destination_account_id'] = 'required|exists:accounts,id|belongsToUser:accounts'; + $rules['source_name'] = 'between:1,255|nullable'; + $rules['destination_id'] = 'required|exists:accounts,id|belongsToUser:accounts'; break; case strtolower(TransactionType::TRANSFER): // this may not work: - $rules['source_account_id'] = 'required|exists:accounts,id|belongsToUser:accounts|different:destination_account_id'; - $rules['destination_account_id'] = 'required|exists:accounts,id|belongsToUser:accounts|different:source_account_id'; + $rules['source_id'] = 'required|exists:accounts,id|belongsToUser:accounts|different:destination_id'; + $rules['destination_id'] = 'required|exists:accounts,id|belongsToUser:accounts|different:source_id'; break; default: diff --git a/app/Http/Requests/MassEditJournalRequest.php b/app/Http/Requests/MassEditJournalRequest.php index e82e243c80..cd82765c6e 100644 --- a/app/Http/Requests/MassEditJournalRequest.php +++ b/app/Http/Requests/MassEditJournalRequest.php @@ -45,11 +45,11 @@ class MassEditJournalRequest extends Request // fixed return [ - 'description.*' => 'required|min:1,max:255', - 'source_account_id.*' => 'numeric|belongsToUser:accounts,id', - 'destination_account_id.*' => 'numeric|belongsToUser:accounts,id', - 'revenue_account' => 'max:255', - 'expense_account' => 'max:255', + 'description.*' => 'required|min:1,max:255', + 'source_id.*' => 'numeric|belongsToUser:accounts,id', + 'destination_id.*' => 'numeric|belongsToUser:accounts,id', + 'revenue_account' => 'max:255', + 'expense_account' => 'max:255', ]; } } diff --git a/app/Http/Requests/RecurrenceFormRequest.php b/app/Http/Requests/RecurrenceFormRequest.php index c05c6ea0a8..ad18aa3cf1 100644 --- a/app/Http/Requests/RecurrenceFormRequest.php +++ b/app/Http/Requests/RecurrenceFormRequest.php @@ -104,16 +104,16 @@ class RecurrenceFormRequest extends Request default: throw new FireflyException(sprintf('Cannot handle transaction type "%s"', $this->string('transaction_type'))); case 'withdrawal': - $return['transactions'][0]['source_account_id'] = $this->integer('source_account_id'); - $return['transactions'][0]['destination_account_name'] = $this->string('destination_account_name'); + $return['transactions'][0]['source_id'] = $this->integer('source_id'); + $return['transactions'][0]['destination_name'] = $this->string('destination_name'); break; case 'deposit': - $return['transactions'][0]['source_account_name'] = $this->string('source_account_name'); - $return['transactions'][0]['destination_account_id'] = $this->integer('destination_account_id'); + $return['transactions'][0]['source_name'] = $this->string('source_name'); + $return['transactions'][0]['destination_id'] = $this->integer('destination_id'); break; case 'transfer': - $return['transactions'][0]['source_account_id'] = $this->integer('source_account_id'); - $return['transactions'][0]['destination_account_id'] = $this->integer('destination_account_id'); + $return['transactions'][0]['source_id'] = $this->integer('source_id'); + $return['transactions'][0]['destination_id'] = $this->integer('destination_id'); break; } @@ -131,34 +131,34 @@ class RecurrenceFormRequest extends Request $tomorrow->addDay(); $rules = [ // mandatory info for recurrence. - 'title' => 'required|between:1,255|uniqueObjectForUser:recurrences,title', - 'first_date' => 'required|date|after:' . $today->format('Y-m-d'), - 'repetition_type' => ['required', new ValidRecurrenceRepetitionValue, new ValidRecurrenceRepetitionType, 'between:1,20'], - 'skip' => 'required|numeric|between:0,31', + 'title' => 'required|between:1,255|uniqueObjectForUser:recurrences,title', + 'first_date' => 'required|date|after:' . $today->format('Y-m-d'), + 'repetition_type' => ['required', new ValidRecurrenceRepetitionValue, new ValidRecurrenceRepetitionType, 'between:1,20'], + 'skip' => 'required|numeric|between:0,31', // optional for recurrence: - 'recurring_description' => 'between:0,65000', - 'active' => 'numeric|between:0,1', - 'apply_rules' => 'numeric|between:0,1', + 'recurring_description' => 'between:0,65000', + 'active' => 'numeric|between:0,1', + 'apply_rules' => 'numeric|between:0,1', // mandatory for transaction: - 'transaction_description' => 'required|between:1,255', - 'transaction_type' => 'required|in:withdrawal,deposit,transfer', - 'transaction_currency_id' => 'required|exists:transaction_currencies,id', - 'amount' => 'numeric|required|more:0', + 'transaction_description' => 'required|between:1,255', + 'transaction_type' => 'required|in:withdrawal,deposit,transfer', + 'transaction_currency_id' => 'required|exists:transaction_currencies,id', + 'amount' => 'numeric|required|more:0', // mandatory account info: - 'source_account_id' => 'numeric|belongsToUser:accounts,id|nullable', - 'source_account_name' => 'between:1,255|nullable', - 'destination_account_id' => 'numeric|belongsToUser:accounts,id|nullable', - 'destination_account_name' => 'between:1,255|nullable', + 'source_id' => 'numeric|belongsToUser:accounts,id|nullable', + 'source_name' => 'between:1,255|nullable', + 'destination_id' => 'numeric|belongsToUser:accounts,id|nullable', + 'destination_name' => 'between:1,255|nullable', // foreign amount data: - 'foreign_amount' => 'nullable|more:0', + 'foreign_amount' => 'nullable|more:0', // optional fields: - 'budget_id' => 'mustExist:budgets,id|belongsToUser:budgets,id|nullable', - 'category' => 'between:1,255|nullable', - 'tags' => 'between:1,255|nullable', + 'budget_id' => 'mustExist:budgets,id|belongsToUser:budgets,id|nullable', + 'category' => 'between:1,255|nullable', + 'tags' => 'between:1,255|nullable', ]; if ($this->integer('foreign_currency_id') > 0) { $rules['foreign_currency_id'] = 'exists:transaction_currencies,id'; @@ -181,17 +181,17 @@ class RecurrenceFormRequest extends Request // switchc on type to expand rules for source and destination accounts: switch ($this->string('transaction_type')) { case strtolower(TransactionType::WITHDRAWAL): - $rules['source_account_id'] = 'required|exists:accounts,id|belongsToUser:accounts'; - $rules['destination_account_name'] = 'between:1,255|nullable'; + $rules['source_id'] = 'required|exists:accounts,id|belongsToUser:accounts'; + $rules['destination_name'] = 'between:1,255|nullable'; break; case strtolower(TransactionType::DEPOSIT): - $rules['source_account_name'] = 'between:1,255|nullable'; - $rules['destination_account_id'] = 'required|exists:accounts,id|belongsToUser:accounts'; + $rules['source_name'] = 'between:1,255|nullable'; + $rules['destination_id'] = 'required|exists:accounts,id|belongsToUser:accounts'; break; case strtolower(TransactionType::TRANSFER): // this may not work: - $rules['source_account_id'] = 'required|exists:accounts,id|belongsToUser:accounts|different:destination_account_id'; - $rules['destination_account_id'] = 'required|exists:accounts,id|belongsToUser:accounts|different:source_account_id'; + $rules['source_id'] = 'required|exists:accounts,id|belongsToUser:accounts|different:destination_id'; + $rules['destination_id'] = 'required|exists:accounts,id|belongsToUser:accounts|different:source_id'; break; default: diff --git a/app/Http/Requests/SplitJournalFormRequest.php b/app/Http/Requests/SplitJournalFormRequest.php index bc989b5f7a..5e1a4d062f 100644 --- a/app/Http/Requests/SplitJournalFormRequest.php +++ b/app/Http/Requests/SplitJournalFormRequest.php @@ -64,16 +64,16 @@ class SplitJournalFormRequest extends Request foreach ($this->get('transactions') as $index => $transaction) { switch ($data['type']) { case 'withdrawal': - $sourceId = $this->integer('journal_source_account_id'); + $sourceId = $this->integer('journal_source_id'); $destinationName = $transaction['destination_name'] ?? ''; break; case 'deposit': $sourceName = $transaction['source_name'] ?? ''; - $destinationId = $this->integer('journal_destination_account_id'); + $destinationId = $this->integer('journal_destination_id'); break; case 'transfer': - $sourceId = $this->integer('journal_source_account_id'); - $destinationId = $this->integer('journal_destination_account_id'); + $sourceId = $this->integer('journal_source_id'); + $destinationId = $this->integer('journal_destination_id'); break; } $foreignAmount = $transaction['foreign_amount'] ?? null; @@ -112,20 +112,20 @@ class SplitJournalFormRequest extends Request 'what' => 'required|in:withdrawal,deposit,transfer', 'journal_description' => 'required|between:1,255', 'id' => 'numeric|belongsToUser:transaction_journals,id', - 'journal_source_account_id' => 'numeric|belongsToUser:accounts,id', - 'journal_source_account_name.*' => 'between:1,255', + 'journal_source_id' => 'numeric|belongsToUser:accounts,id', + 'journal_source_name.*' => 'between:1,255', 'journal_currency_id' => 'required|exists:transaction_currencies,id', 'date' => 'required|date', 'interest_date' => 'date|nullable', 'book_date' => 'date|nullable', 'process_date' => 'date|nullable', 'transactions.*.transaction_description' => 'required|between:1,255', - 'transactions.*.destination_account_id' => 'numeric|belongsToUser:accounts,id', + 'transactions.*.destination_id' => 'numeric|belongsToUser:accounts,id', 'transactions.*.destination_name' => 'between:1,255|nullable', 'transactions.*.amount' => 'required|numeric', 'transactions.*.budget_id' => 'belongsToUser:budgets,id', 'transactions.*.category_name' => 'between:1,255|nullable', - 'transactions.*.piggy_bank_id' => 'between:1,255|nullable', + 'transactions.*.piggy_bank_id' => 'numeric|nullable', ]; } @@ -155,8 +155,8 @@ class SplitJournalFormRequest extends Request /** @var array $array */ foreach ($transactions as $array) { if ($array['destination_id'] !== null && $array['source_id'] !== null && $array['destination_id'] === $array['source_id']) { - $validator->errors()->add('journal_source_account_id', trans('validation.source_equals_destination')); - $validator->errors()->add('journal_destination_account_id', trans('validation.source_equals_destination')); + $validator->errors()->add('journal_source_id', trans('validation.source_equals_destination')); + $validator->errors()->add('journal_destination_id', trans('validation.source_equals_destination')); } } diff --git a/app/Import/Storage/ImportArrayStorage.php b/app/Import/Storage/ImportArrayStorage.php index c7edae2e6f..15d5ae58fa 100644 --- a/app/Import/Storage/ImportArrayStorage.php +++ b/app/Import/Storage/ImportArrayStorage.php @@ -415,7 +415,7 @@ class ImportArrayStorage // store the journal. try { $journal = $this->journalRepos->store($store); - } catch(FireflyException $e) { + } catch (FireflyException $e) { Log::error($e->getMessage()); Log::error($e->getTraceAsString()); $this->repository->addErrorMessage($this->importJob, sprintf('Row #%d could not be imported. %s', $index, $e->getMessage())); diff --git a/app/Models/Account.php b/app/Models/Account.php index 3c2c4f761f..adcfb61dc7 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -44,7 +44,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; * @property AccountType $accountType * @property bool $active * @property string $virtual_balance - * @property User $user + * @property User $user */ class Account extends Model { diff --git a/app/Models/Bill.php b/app/Models/Bill.php index 81da6f180d..6693972b20 100644 --- a/app/Models/Bill.php +++ b/app/Models/Bill.php @@ -45,11 +45,11 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; * @property TransactionCurrency $transactionCurrency * @property Carbon $created_at * @property Carbon $updated_at - * @property Carbon $date - * @property string $repeat_freq - * @property int $skip - * @property bool $automatch - * @property User $user + * @property Carbon $date + * @property string $repeat_freq + * @property int $skip + * @property bool $automatch + * @property User $user */ class Bill extends Model { diff --git a/app/Models/Budget.php b/app/Models/Budget.php index 503495b411..d3c0ff820d 100644 --- a/app/Models/Budget.php +++ b/app/Models/Budget.php @@ -31,9 +31,10 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** * Class Budget. - * @property int $id + * + * @property int $id * @property string $name - * @property bool $active + * @property bool $active */ class Budget extends Model { diff --git a/app/Models/Category.php b/app/Models/Category.php index 7bc567f2b7..5f06f91fbe 100644 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -33,7 +33,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; * Class Category. * * @property string $name - * @property int $id + * @property int $id */ class Category extends Model { diff --git a/app/Models/Preference.php b/app/Models/Preference.php index 2aae7b4a6e..19a337bb5c 100644 --- a/app/Models/Preference.php +++ b/app/Models/Preference.php @@ -39,7 +39,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; * @property string $name * @property Carbon $updated_at * @property Carbon $created_at - * @property int $id + * @property int $id */ class Preference extends Model { diff --git a/app/Models/RuleGroup.php b/app/Models/RuleGroup.php index 8bbbc74e8b..6c607e49e0 100644 --- a/app/Models/RuleGroup.php +++ b/app/Models/RuleGroup.php @@ -37,8 +37,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; * @property Carbon $updated_at * @property string $title * @property string $text - * @property int $id - * @property int $order + * @property int $id + * @property int $order */ class RuleGroup extends Model { diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php index 4742467e29..d008f373e9 100644 --- a/app/Models/Transaction.php +++ b/app/Models/Transaction.php @@ -73,7 +73,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; * @property bool $is_split * @property int $attachmentCount * @property int $transaction_currency_id - * @property int $foreign_currency_id + * @property int $foreign_currency_id */ class Transaction extends Model { diff --git a/app/Models/TransactionCurrency.php b/app/Models/TransactionCurrency.php index 5948f38811..26e7d9fa0c 100644 --- a/app/Models/TransactionCurrency.php +++ b/app/Models/TransactionCurrency.php @@ -32,7 +32,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; * @property string $code * @property string $symbol * @property int $decimal_places - * @property int $id + * @property int $id * */ class TransactionCurrency extends Model diff --git a/app/Models/TransactionJournal.php b/app/Models/TransactionJournal.php index 28da385b2f..760f4831da 100644 --- a/app/Models/TransactionJournal.php +++ b/app/Models/TransactionJournal.php @@ -39,8 +39,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** * Class TransactionJournal. * - * @property User $user - * @property int $bill_id + * @property User $user + * @property int $bill_id * @property Collection $categories */ class TransactionJournal extends Model diff --git a/app/Models/TransactionType.php b/app/Models/TransactionType.php index 597dc1b612..4c9bc1f04a 100644 --- a/app/Models/TransactionType.php +++ b/app/Models/TransactionType.php @@ -30,7 +30,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; * Class TransactionType. * * @property string $type - * @property int $id + * @property int $id */ class TransactionType extends Model { diff --git a/app/Repositories/Account/FindAccountsTrait.php b/app/Repositories/Account/FindAccountsTrait.php index 347d458d4c..8cfadbe8dc 100644 --- a/app/Repositories/Account/FindAccountsTrait.php +++ b/app/Repositories/Account/FindAccountsTrait.php @@ -158,7 +158,7 @@ trait FindAccountsTrait Log::debug(sprintf('Found #%d (%s) with type id %d', $account->id, $account->name, $account->account_type_id)); return $account; - } else{ + } else { Log::debug(sprintf('"%s" does not equal "%s"', $account->name, $name)); } } diff --git a/app/Repositories/Budget/BudgetRepositoryInterface.php b/app/Repositories/Budget/BudgetRepositoryInterface.php index d08e406a3d..d8e69f2fef 100644 --- a/app/Repositories/Budget/BudgetRepositoryInterface.php +++ b/app/Repositories/Budget/BudgetRepositoryInterface.php @@ -250,6 +250,13 @@ interface BudgetRepositoryInterface */ public function store(array $data): Budget; + /** + * @param array $data + * + * @return BudgetLimit + */ + public function storeBudgetLimit(array $data): BudgetLimit; + /** * @param Budget $budget * @param array $data @@ -274,13 +281,6 @@ interface BudgetRepositoryInterface */ public function updateBudgetLimit(BudgetLimit $budgetLimit, array $data): BudgetLimit; - /** - * @param array $data - * - * @return BudgetLimit - */ - public function storeBudgetLimit(array $data): BudgetLimit; - /** * @param Budget $budget * @param Carbon $start diff --git a/app/Repositories/Journal/JournalRepositoryInterface.php b/app/Repositories/Journal/JournalRepositoryInterface.php index dc6bfe9b26..e0884a3858 100644 --- a/app/Repositories/Journal/JournalRepositoryInterface.php +++ b/app/Repositories/Journal/JournalRepositoryInterface.php @@ -326,6 +326,7 @@ interface JournalRepositoryInterface /** * @param array $data + * * @throws FireflyException * @return TransactionJournal */ diff --git a/app/Repositories/LinkType/LinkTypeRepositoryInterface.php b/app/Repositories/LinkType/LinkTypeRepositoryInterface.php index 9aa8c03757..617cb45b59 100644 --- a/app/Repositories/LinkType/LinkTypeRepositoryInterface.php +++ b/app/Repositories/LinkType/LinkTypeRepositoryInterface.php @@ -62,13 +62,6 @@ interface LinkTypeRepositoryInterface */ public function find(int $id): LinkType; - /** - * @param int $id - * - * @return LinkType|null - */ - public function findNull(int $id): ?LinkType; - /** * Find link type by name. * @@ -88,6 +81,13 @@ interface LinkTypeRepositoryInterface */ public function findLink(TransactionJournal $one, TransactionJournal $two): bool; + /** + * @param int $id + * + * @return LinkType|null + */ + public function findNull(int $id): ?LinkType; + /** * See if such a link already exists (and get it). * diff --git a/app/Repositories/PiggyBank/PiggyBankRepositoryInterface.php b/app/Repositories/PiggyBank/PiggyBankRepositoryInterface.php index f1ee19124a..4b4d7d062e 100644 --- a/app/Repositories/PiggyBank/PiggyBankRepositoryInterface.php +++ b/app/Repositories/PiggyBank/PiggyBankRepositoryInterface.php @@ -102,17 +102,12 @@ interface PiggyBankRepositoryInterface /** * @param int $piggyBankid + * * @deprecated * @return PiggyBank */ public function find(int $piggyBankid): PiggyBank; - /** - * @param int $piggyBankId - * @return PiggyBank|null - */ - public function findNull(int $piggyBankId): ?PiggyBank; - /** * Find by name or return NULL. * @@ -122,6 +117,13 @@ interface PiggyBankRepositoryInterface */ public function findByName(string $name): ?PiggyBank; + /** + * @param int $piggyBankId + * + * @return PiggyBank|null + */ + public function findNull(int $piggyBankId): ?PiggyBank; + /** * Get current amount saved in piggy bank. * diff --git a/app/Rules/IsValidAttachmentModel.php b/app/Rules/IsValidAttachmentModel.php index db2959c7c8..954e5a2151 100644 --- a/app/Rules/IsValidAttachmentModel.php +++ b/app/Rules/IsValidAttachmentModel.php @@ -79,7 +79,7 @@ class IsValidAttachmentModel implements Rule /** @var JournalRepositoryInterface $repository */ $repository = app(JournalRepositoryInterface::class); $repository->setUser($user); - $result = $repository->findNull((int)$value); + $result = $repository->findNull((int)$value); return null !== $result; break; diff --git a/app/Services/Currency/FixerIOv2.php b/app/Services/Currency/FixerIOv2.php index b5cf3cde09..b224e65de4 100644 --- a/app/Services/Currency/FixerIOv2.php +++ b/app/Services/Currency/FixerIOv2.php @@ -49,7 +49,7 @@ class FixerIOv2 implements ExchangeRateInterface public function getRate(TransactionCurrency $fromCurrency, TransactionCurrency $toCurrency, Carbon $date): CurrencyExchangeRate { // create new exchange rate with default values. - $rate = 0; + $rate = 0; $exchangeRate = new CurrencyExchangeRate; $exchangeRate->user()->associate($this->user); $exchangeRate->fromCurrency()->associate($fromCurrency); diff --git a/app/Transformers/AttachmentTransformer.php b/app/Transformers/AttachmentTransformer.php index f1c6ac01bd..d65d4db907 100644 --- a/app/Transformers/AttachmentTransformer.php +++ b/app/Transformers/AttachmentTransformer.php @@ -25,10 +25,10 @@ namespace FireflyIII\Transformers; use FireflyIII\Models\Attachment; +use League\Fractal\Resource\Collection as FractalCollection; use League\Fractal\Resource\Item; use League\Fractal\TransformerAbstract; use Symfony\Component\HttpFoundation\ParameterBag; -use League\Fractal\Resource\Collection as FractalCollection; /** * Class AttachmentTransformer @@ -40,13 +40,13 @@ class AttachmentTransformer extends TransformerAbstract * * @var array */ - protected $availableIncludes = ['user','notes']; + protected $availableIncludes = ['user', 'notes']; /** * List of resources to automatically include * * @var array */ - protected $defaultIncludes = ['user','notes']; + protected $defaultIncludes = ['user', 'notes']; /** @var ParameterBag */ protected $parameters; @@ -63,20 +63,6 @@ class AttachmentTransformer extends TransformerAbstract $this->parameters = $parameters; } - /** - * Attach the user. - * - * @codeCoverageIgnore - * - * @param Attachment $attachment - * - * @return Item - */ - public function includeUser(Attachment $attachment): Item - { - return $this->item($attachment->user, new UserTransformer($this->parameters), 'users'); - } - /** * Attach the notes. * @@ -91,6 +77,20 @@ class AttachmentTransformer extends TransformerAbstract return $this->collection($attachment->notes, new NoteTransformer($this->parameters), 'notes'); } + /** + * Attach the user. + * + * @codeCoverageIgnore + * + * @param Attachment $attachment + * + * @return Item + */ + public function includeUser(Attachment $attachment): Item + { + return $this->item($attachment->user, new UserTransformer($this->parameters), 'users'); + } + /** * Transform attachment. * diff --git a/app/Transformers/BudgetLimitTransformer.php b/app/Transformers/BudgetLimitTransformer.php index 462290fdb9..90e858bcdc 100644 --- a/app/Transformers/BudgetLimitTransformer.php +++ b/app/Transformers/BudgetLimitTransformer.php @@ -22,6 +22,7 @@ declare(strict_types=1); namespace FireflyIII\Transformers; + use FireflyIII\Models\BudgetLimit; use League\Fractal\Resource\Item; use League\Fractal\TransformerAbstract; diff --git a/app/Transformers/RecurrenceTransformer.php b/app/Transformers/RecurrenceTransformer.php index 0c23487c08..f0d83c5a21 100644 --- a/app/Transformers/RecurrenceTransformer.php +++ b/app/Transformers/RecurrenceTransformer.php @@ -157,19 +157,19 @@ class RecurrenceTransformer extends TransformerAbstract /** @var RecurrenceTransaction $transaction */ foreach ($recurrence->recurrenceTransactions as $transaction) { $transactionArray = [ - 'currency_id' => $transaction->transaction_currency_id, - 'currency_code' => $transaction->transactionCurrency->code, - 'currency_symbol' => $transaction->transactionCurrency->symbol, - 'currency_dp' => $transaction->transactionCurrency->decimal_places, - 'foreign_currency_id' => $transaction->foreign_currency_id, - 'source_account_id' => $transaction->source_account_id, - 'source_account_name' => $transaction->sourceAccount->name, - 'destination_account_id' => $transaction->destination_account_id, - 'destination_account_name' => $transaction->destinationAccount->name, - 'amount' => $transaction->amount, - 'foreign_amount' => $transaction->foreign_amount, - 'description' => $transaction->description, - 'meta' => [], + 'currency_id' => $transaction->transaction_currency_id, + 'currency_code' => $transaction->transactionCurrency->code, + 'currency_symbol' => $transaction->transactionCurrency->symbol, + 'currency_dp' => $transaction->transactionCurrency->decimal_places, + 'foreign_currency_id' => $transaction->foreign_currency_id, + 'source_id' => $transaction->source_id, + 'source_name' => $transaction->sourceAccount->name, + 'destination_id' => $transaction->destination_id, + 'destination_name' => $transaction->destinationAccount->name, + 'amount' => $transaction->amount, + 'foreign_amount' => $transaction->foreign_amount, + 'description' => $transaction->description, + 'meta' => [], ]; if (null !== $transaction->foreign_currency_id) { $transactionArray['foreign_currency_code'] = $transaction->foreignCurrency->code; diff --git a/app/Transformers/RuleActionTransformer.php b/app/Transformers/RuleActionTransformer.php index a0a8401716..b8b664dd49 100644 --- a/app/Transformers/RuleActionTransformer.php +++ b/app/Transformers/RuleActionTransformer.php @@ -25,7 +25,6 @@ namespace FireflyIII\Transformers; use FireflyIII\Models\RuleAction; -use FireflyIII\Models\RuleTrigger; use League\Fractal\TransformerAbstract; use Symfony\Component\HttpFoundation\ParameterBag; @@ -75,8 +74,8 @@ class RuleActionTransformer extends TransformerAbstract 'id' => (int)$ruleAction->id, 'updated_at' => $ruleAction->updated_at->toAtomString(), 'created_at' => $ruleAction->created_at->toAtomString(), - 'action_type' => $ruleAction->action_type, - 'action_value' => $ruleAction->action_value, + 'action_type' => $ruleAction->action_type, + 'action_value' => $ruleAction->action_value, 'order' => $ruleAction->order, 'active' => $ruleAction->active, 'stop_processing' => $ruleAction->stop_processing, diff --git a/app/Transformers/RuleTransformer.php b/app/Transformers/RuleTransformer.php index 35db378eeb..89f8353aa0 100644 --- a/app/Transformers/RuleTransformer.php +++ b/app/Transformers/RuleTransformer.php @@ -25,10 +25,10 @@ namespace FireflyIII\Transformers; use FireflyIII\Models\Rule; +use League\Fractal\Resource\Collection as FractalCollection; use League\Fractal\Resource\Item; use League\Fractal\TransformerAbstract; use Symfony\Component\HttpFoundation\ParameterBag; -use League\Fractal\Resource\Collection as FractalCollection; /** * Class RuleTransformer @@ -68,8 +68,22 @@ class RuleTransformer extends TransformerAbstract * * @return FractalCollection */ - public function includeRuleTriggers(Rule $rule): FractalCollection { - return $this->collection($rule->ruleTriggers, new RuleTriggerTransformer($this->parameters), 'rule_triggers'); + public function includeRuleActions(Rule $rule): FractalCollection + { + return $this->collection($rule->ruleActions, new RuleActionTransformer($this->parameters), 'rule_actions'); + } + + /** + * Include the rule group. + * + * @param Rule $rule + * + * @codeCoverageIgnore + * @return Item + */ + public function includeRuleGroup(Rule $rule): Item + { + return $this->item($rule->ruleGroup, new RuleGroupTransformer($this->parameters), 'rule_groups'); } /** @@ -77,8 +91,9 @@ class RuleTransformer extends TransformerAbstract * * @return FractalCollection */ - public function includeRuleActions(Rule $rule): FractalCollection { - return $this->collection($rule->ruleActions, new RuleActionTransformer($this->parameters), 'rule_actions'); + public function includeRuleTriggers(Rule $rule): FractalCollection + { + return $this->collection($rule->ruleTriggers, new RuleTriggerTransformer($this->parameters), 'rule_triggers'); } /** @@ -94,20 +109,6 @@ class RuleTransformer extends TransformerAbstract return $this->item($rule->user, new UserTransformer($this->parameters), 'users'); } - - /** - * Include the rule group. - * - * @param Rule $rule - * - * @codeCoverageIgnore - * @return Item - */ - public function includeRuleGroup(Rule $rule): Item - { - return $this->item($rule->ruleGroup, new RuleGroupTransformer($this->parameters), 'rule_groups'); - } - /** * Transform the rule. * diff --git a/database/factories/ModelFactory.php b/database/factories/ModelFactory.php index 04a90e6a2a..668e584a90 100644 --- a/database/factories/ModelFactory.php +++ b/database/factories/ModelFactory.php @@ -245,13 +245,13 @@ $factory->define( 'transaction_amount' => (string)$faker->randomFloat(2, -100, 100), 'destination_amount' => (string)$faker->randomFloat(2, -100, 100), 'opposing_account_id' => $faker->numberBetween(1, 10), - 'source_account_id' => $faker->numberBetween(1, 10), + 'source_id' => $faker->numberBetween(1, 10), 'opposing_account_name' => $faker->words(3, true), 'description' => $faker->words(3, true), - 'source_account_name' => $faker->words(3, true), - 'destination_account_id' => $faker->numberBetween(1, 10), + 'source_name' => $faker->words(3, true), + 'destination_id' => $faker->numberBetween(1, 10), 'date' => new Carbon, - 'destination_account_name' => $faker->words(3, true), + 'destination_name' => $faker->words(3, true), 'amount' => (string)$faker->randomFloat(2, -100, 100), 'budget_id' => 0, 'category' => $faker->words(3, true), diff --git a/public/js/ff/transactions/mass/edit.js b/public/js/ff/transactions/mass/edit.js index b267ab1bd0..9f98362fed 100644 --- a/public/js/ff/transactions/mass/edit.js +++ b/public/js/ff/transactions/mass/edit.js @@ -24,16 +24,16 @@ $(document).ready(function () { "use strict"; // destination account names: - if ($('input[name^="destination_account_name["]').length > 0) { + if ($('input[name^="destination_name["]').length > 0) { $.getJSON('json/expense-accounts').done(function (data) { - $('input[name^="destination_account_name["]').typeahead({source: data, autoSelect: false}); + $('input[name^="destination_name["]').typeahead({source: data, autoSelect: false}); }); } // source account name - if ($('input[name^="source_account_name["]').length > 0) { + if ($('input[name^="source_name["]').length > 0) { $.getJSON('json/revenue-accounts').done(function (data) { - $('input[name^="source_account_name["]').typeahead({source: data, autoSelect: false}); + $('input[name^="source_name["]').typeahead({source: data, autoSelect: false}); }); } diff --git a/public/js/ff/transactions/single/common.js b/public/js/ff/transactions/single/common.js index 47962ab6a8..122a71d591 100644 --- a/public/js/ff/transactions/single/common.js +++ b/public/js/ff/transactions/single/common.js @@ -65,15 +65,15 @@ function setCommonAutocomplete() { }); - if ($('input[name="destination_account_name"]').length > 0) { + if ($('input[name="destination_name"]').length > 0) { $.getJSON('json/expense-accounts').done(function (data) { - $('input[name="destination_account_name"]').typeahead({source: data, autoSelect: false}); + $('input[name="destination_name"]').typeahead({source: data, autoSelect: false}); }); } - if ($('input[name="source_account_name"]').length > 0) { + if ($('input[name="source_name"]').length > 0) { $.getJSON('json/revenue-accounts').done(function (data) { - $('input[name="source_account_name"]').typeahead({source: data, autoSelect: false}); + $('input[name="source_name"]').typeahead({source: data, autoSelect: false}); }); } @@ -160,8 +160,8 @@ function updateNativeAmount(data) { * Instructions for transfers */ function getTransferExchangeInstructions() { - var sourceAccount = $('select[name="source_account_id"]').val(); - var destAccount = $('select[name="destination_account_id"]').val(); + var sourceAccount = $('select[name="source_id"]').val(); + var destAccount = $('select[name="destination_id"]').val(); var sourceCurrency = accountInfo[sourceAccount].preferredCurrency; var destinationCurrency = accountInfo[destAccount].preferredCurrency; @@ -180,8 +180,8 @@ function validateCurrencyForTransfer() { return; } $('#source_amount_holder').show(); - var sourceAccount = $('select[name="source_account_id"]').val(); - var destAccount = $('select[name="destination_account_id"]').val(); + var sourceAccount = $('select[name="source_id"]').val(); + var destAccount = $('select[name="destination_id"]').val(); var sourceCurrency = accountInfo[sourceAccount].preferredCurrency; var sourceSymbol = currencyInfo[sourceCurrency].symbol; var destinationCurrency = accountInfo[destAccount].preferredCurrency; @@ -208,8 +208,8 @@ function validateCurrencyForTransfer() { * */ function convertSourceToDestination() { - var sourceAccount = $('select[name="source_account_id"]').val(); - var destAccount = $('select[name="destination_account_id"]').val(); + var sourceAccount = $('select[name="source_id"]').val(); + var destAccount = $('select[name="destination_id"]').val(); var sourceCurrency = accountInfo[sourceAccount].preferredCurrency; var destinationCurrency = accountInfo[destAccount].preferredCurrency; diff --git a/public/js/ff/transactions/single/create.js b/public/js/ff/transactions/single/create.js index b8729f2582..2f2294196c 100644 --- a/public/js/ff/transactions/single/create.js +++ b/public/js/ff/transactions/single/create.js @@ -38,20 +38,17 @@ $(document).ready(function () { // when user changes source account or destination, native currency may be different. - $('select[name="source_account_id"]').on('change', function() { + $('select[name="source_id"]').on('change', function() { selectsDifferentSource(); // do something for transfers: validateCurrencyForTransfer(); }); - $('select[name="destination_account_id"]').on('change', function() { + $('select[name="destination_id"]').on('change', function() { selectsDifferentDestination(); // do something for transfers: validateCurrencyForTransfer(); }); - //$('select[name="source_account_id"]').on('change', updateNativeCurrency); - //$('select[name="destination_account_id"]').on('change', updateNativeCurrency); - // convert foreign currency to native currency (when input changes, exchange rate) $('#ffInput_amount').on('change', convertForeignToNative); @@ -74,7 +71,7 @@ function selectsDifferentSource() { return; } // store original currency ID of the selected account in a separate var: - var sourceId = $('select[name="source_account_id"]').val(); + var sourceId = $('select[name="source_id"]').val(); var sourceCurrency = accountInfo[sourceId].preferredCurrency; $('input[name="source_account_currency"]').val(sourceCurrency); console.log('selectsDifferenctSource(): Set source account currency to ' + sourceCurrency); @@ -82,7 +79,7 @@ function selectsDifferentSource() { // change input thing: $('.currency-option[data-id="' + sourceCurrency + '"]').click(); $('[data-toggle="dropdown"]').parent().removeClass('open'); - $('select[name="source_account_id"]').focus(); + $('select[name="source_id"]').focus(); } /** @@ -96,7 +93,7 @@ function selectsDifferentDestination() { return; } // store original currency ID of the selected account in a separate var: - var destinationId = $('select[name="destination_account_id"]').val(); + var destinationId = $('select[name="destination_id"]').val(); var destinationCurrency = accountInfo[destinationId].preferredCurrency; $('input[name="destination_account_currency"]').val(destinationCurrency); console.log('selectsDifferentDestination(): Set destinationId account currency to ' + destinationCurrency); @@ -104,7 +101,7 @@ function selectsDifferentDestination() { // change input thing: $('.currency-option[data-id="' + destinationCurrency + '"]').click(); $('[data-toggle="dropdown"]').parent().removeClass('open'); - $('select[name="destination_account_id"]').focus(); + $('select[name="destination_id"]').focus(); } @@ -153,19 +150,19 @@ function updateForm() { $('input[name="what"]').val(what); - var destName = $('#ffInput_destination_account_name'); - var srcName = $('#ffInput_source_account_name'); + var destName = $('#ffInput_destination_name'); + var srcName = $('#ffInput_source_name'); switch (what) { case 'withdrawal': // show source_id and dest_name - document.getElementById('source_account_id_holder').style.display = 'block'; - document.getElementById('destination_account_name_holder').style.display = 'block'; + document.getElementById('source_id_holder').style.display = 'block'; + document.getElementById('destination_name_holder').style.display = 'block'; // hide others: - document.getElementById('source_account_name_holder').style.display = 'none'; - document.getElementById('destination_account_id_holder').style.display = 'none'; + document.getElementById('source_name_holder').style.display = 'none'; + document.getElementById('destination_id_holder').style.display = 'none'; document.getElementById('budget_id_holder').style.display = 'block'; // hide piggy bank: @@ -185,12 +182,12 @@ function updateForm() { break; case 'deposit': // show source_name and dest_id: - document.getElementById('source_account_name_holder').style.display = 'block'; - document.getElementById('destination_account_id_holder').style.display = 'block'; + document.getElementById('source_name_holder').style.display = 'block'; + document.getElementById('destination_id_holder').style.display = 'block'; // hide others: - document.getElementById('source_account_id_holder').style.display = 'none'; - document.getElementById('destination_account_name_holder').style.display = 'none'; + document.getElementById('source_id_holder').style.display = 'none'; + document.getElementById('destination_name_holder').style.display = 'none'; // hide budget document.getElementById('budget_id_holder').style.display = 'none'; @@ -212,12 +209,12 @@ function updateForm() { break; case 'transfer': // show source_id and dest_id: - document.getElementById('source_account_id_holder').style.display = 'block'; - document.getElementById('destination_account_id_holder').style.display = 'block'; + document.getElementById('source_id_holder').style.display = 'block'; + document.getElementById('destination_id_holder').style.display = 'block'; // hide others: - document.getElementById('source_account_name_holder').style.display = 'none'; - document.getElementById('destination_account_name_holder').style.display = 'none'; + document.getElementById('source_name_holder').style.display = 'none'; + document.getElementById('destination_name_holder').style.display = 'none'; // hide budget document.getElementById('budget_id_holder').style.display = 'none'; @@ -288,10 +285,10 @@ function clickButton(e) { */ function getAccountId() { if (what === "withdrawal") { - return $('select[name="source_account_id"]').val(); + return $('select[name="source_id"]').val(); } if (what === "deposit" || what === "transfer") { - return $('select[name="destination_account_id"]').val(); + return $('select[name="destination_id"]').val(); } return undefined; } diff --git a/public/js/ff/transactions/single/edit.js b/public/js/ff/transactions/single/edit.js index cf5248e021..30ce29ea8f 100644 --- a/public/js/ff/transactions/single/edit.js +++ b/public/js/ff/transactions/single/edit.js @@ -38,12 +38,12 @@ $(document).ready(function () { $('#ffInput_amount').on('change', convertForeignToNative); // respond to transfer changes: - $('#ffInput_source_account_id').on('change', function () { + $('#ffInput_source_id').on('change', function () { validateCurrencyForTransfer(); // update the two source account currency ID fields (initial value): initCurrencyIdValues(); }); - $('#ffInput_destination_account_id').on('change', function () { + $('#ffInput_destination_id').on('change', function () { validateCurrencyForTransfer(); // update the two source account currency ID fields (initial value): initCurrencyIdValues(); @@ -77,9 +77,9 @@ function initCurrencyIdValues() { $('input[name="destination_account_currency"]').val(currencyId); return; } - var sourceAccount = $('select[name="source_account_id"]').val(); + var sourceAccount = $('select[name="source_id"]').val(); console.log('Source account is ' + sourceAccount); - var destAccount = $('select[name="destination_account_id"]').val(); + var destAccount = $('select[name="destination_id"]').val(); console.log('Destination account is ' + destAccount); var sourceCurrency = parseInt(accountInfo[sourceAccount].preferredCurrency); @@ -134,10 +134,10 @@ function updateInitialPage() { function getAccountId() { console.log('in getAccountId()'); if (journal.transaction_type.type === "Withdrawal") { - return $('select[name="source_account_id"]').val(); + return $('select[name="source_id"]').val(); } if (journal.transaction_type.type === "Deposit") { - return $('select[name="destination_account_id"]').val(); + return $('select[name="destination_id"]').val(); } alert('Cannot handle ' + journal.transaction_type.type); diff --git a/public/js/ff/transactions/split/edit.js b/public/js/ff/transactions/split/edit.js index 61af5fc050..f3178e0f4e 100644 --- a/public/js/ff/transactions/split/edit.js +++ b/public/js/ff/transactions/split/edit.js @@ -191,12 +191,12 @@ function resetDivSplits() { var input = $(v); input.attr('name', 'transactions[' + i + '][transaction_description]'); }); - // ends with ][destination_account_name] + // ends with ][destination_name] $.each($('input[name$="][destination_name]"]'), function (i, v) { var input = $(v); input.attr('name', 'transactions[' + i + '][destination_name]'); }); - // ends with ][source_account_name] + // ends with ][source_name] $.each($('input[name$="][source_name]"]'), function (i, v) { var input = $(v); input.attr('name', 'transactions[' + i + '][source_name]'); diff --git a/resources/views/transactions/mass/edit.twig b/resources/views/transactions/mass/edit.twig index d6fcaff658..fa863e3847 100644 --- a/resources/views/transactions/mass/edit.twig +++ b/resources/views/transactions/mass/edit.twig @@ -70,7 +70,7 @@