diff --git a/app/Http/Controllers/Transaction/SplitController.php b/app/Http/Controllers/Transaction/SplitController.php index d942b44664..84858d3b61 100644 --- a/app/Http/Controllers/Transaction/SplitController.php +++ b/app/Http/Controllers/Transaction/SplitController.php @@ -58,6 +58,8 @@ class SplitController extends Controller $uploadSize = min(Steam::phpBytes(ini_get('upload_max_filesize')), Steam::phpBytes(ini_get('post_max_size'))); $currencies = ExpandedForm::makeSelectList($currencyRepository->get()); $budgets = ExpandedForm::makeSelectListWithEmpty($budgetRepository->getActiveBudgets()); + $subTitle = trans('form.add_new_' . $sessionData['what']); + $subTitleIcon = 'fa-plus'; $preFilled = [ 'what' => $sessionData['what'] ?? 'withdrawal', 'journal_amount' => $sessionData['amount'] ?? 0, @@ -71,7 +73,9 @@ class SplitController extends Controller 'category' => [$sessionData['category']], ]; - return view('split.journals.create', compact('journal', 'preFilled', 'assetAccounts', 'currencies', 'budgets', 'uploadSize')); + return view( + 'split.journals.create', compact('journal', 'subTitle', 'subTitleIcon', 'preFilled', 'assetAccounts', 'currencies', 'budgets', 'uploadSize') + ); } /** @@ -90,6 +94,8 @@ class SplitController extends Controller $assetAccounts = ExpandedForm::makeSelectList($accountRepository->getAccountsByType(['Default account', 'Asset account'])); $budgets = ExpandedForm::makeSelectListWithEmpty($budgetRepository->getActiveBudgets()); $preFilled = $this->arrayFromJournal($request, $journal); + $subTitle = trans('breadcrumbs.edit_journal', ['description' => $journal->description]); + $subTitleIcon = 'fa-pencil'; Session::flash('gaEventCategory', 'transactions'); Session::flash('gaEventAction', 'edit-split-' . $preFilled['what']); @@ -102,7 +108,10 @@ class SplitController extends Controller return view( 'split.journals.edit', - compact('currencies', 'preFilled', 'amount', 'sourceAccounts', 'uploadSize', 'destinationAccounts', 'assetAccounts', 'budgets', 'journal') + compact( + 'subTitleIcon', 'currencies', 'preFilled', 'subTitle', 'amount', 'sourceAccounts', 'uploadSize', 'destinationAccounts', 'assetAccounts', + 'budgets', 'journal' + ) ); } diff --git a/app/Http/Controllers/TransactionController.php b/app/Http/Controllers/TransactionController.php index ec0a137efb..24c1193125 100644 --- a/app/Http/Controllers/TransactionController.php +++ b/app/Http/Controllers/TransactionController.php @@ -68,6 +68,7 @@ class TransactionController extends Controller $piggies = ExpandedForm::makeSelectListWithEmpty($piggyBanks); $preFilled = Session::has('preFilled') ? session('preFilled') : []; $subTitle = trans('form.add_new_' . $what); + $subTitleIcon = 'fa-plus'; Session::put('preFilled', $preFilled); @@ -84,7 +85,7 @@ class TransactionController extends Controller asort($piggies); - return view('transactions.create', compact('assetAccounts', 'uploadSize', 'budgets', 'what', 'piggies', 'subTitle')); + return view('transactions.create', compact('assetAccounts', 'subTitleIcon', 'uploadSize', 'budgets', 'what', 'piggies', 'subTitle')); } /** diff --git a/app/Http/breadcrumbs.php b/app/Http/breadcrumbs.php index a8364edd5e..9d93656e25 100644 --- a/app/Http/breadcrumbs.php +++ b/app/Http/breadcrumbs.php @@ -502,6 +502,7 @@ Breadcrumbs::register( } ); + /** * TAGS */ @@ -579,3 +580,20 @@ Breadcrumbs::register( } ); + +/** + * SPLIT + */ +Breadcrumbs::register( + 'split.journal.edit', function (BreadCrumbGenerator $breadcrumbs, TransactionJournal $journal) { + $breadcrumbs->parent('transactions.show', $journal); + $breadcrumbs->push(trans('breadcrumbs.edit_journal', ['description' => $journal->description]), route('split.journal.edit', [$journal->id])); +} +); + +Breadcrumbs::register( + 'split.journal.create', function (BreadCrumbGenerator $breadcrumbs, string $what) { + $breadcrumbs->parent('transactions.index', $what); + $breadcrumbs->push(trans('breadcrumbs.create_' . e($what)), route('split.journal.create', [$what])); +} +); \ No newline at end of file diff --git a/app/Support/Migration/TestData.php b/app/Support/Migration/TestData.php index d8d4e64e76..9da28f94a6 100644 --- a/app/Support/Migration/TestData.php +++ b/app/Support/Migration/TestData.php @@ -482,6 +482,70 @@ class TestData } } + private function createMultiTransfers() + { + foreach ($this->data['multi-transfers'] as $transfer) { + $journalId = DB::table('transaction_journals')->insertGetId( + [ + 'created_at' => DB::raw('NOW()'), + 'updated_at' => DB::raw('NOW()'), + 'user_id' => $transfer['user_id'], + 'transaction_type_id' => 3, + 'transaction_currency_id' => 1, + 'description' => Crypt::encrypt($transfer['description']), + 'completed' => 1, + 'date' => $transfer['date'], + 'interest_date' => $transfer['interest_date'] ?? null, + 'book_date' => $transfer['book_date'] ?? null, + 'process_date' => $transfer['process_date'] ?? null, + 'encrypted' => 1, + 'order' => 0, + 'tag_count' => 0, + ] + ); + foreach ($transfer['destination_ids'] as $index => $destination) { + $description = $transfer['description'] . ' (#' . ($index + 1) . ')'; + $amount = $transfer['amounts'][$index]; + $source = $transfer['source_ids'][$index]; + $first = DB::table('transactions')->insertGetId( + [ + 'created_at' => DB::raw('NOW()'), + 'updated_at' => DB::raw('NOW()'), + 'account_id' => $source, + 'transaction_journal_id' => $journalId, + 'description' => $description, + 'amount' => $amount * -1, + ] + ); + $second = DB::table('transactions')->insertGetId( + [ + 'created_at' => DB::raw('NOW()'), + 'updated_at' => DB::raw('NOW()'), + 'account_id' => $destination, + 'transaction_journal_id' => $journalId, + 'description' => $description, + 'amount' => $amount, + ] + ); + + if (isset($transfer['category_ids'][$index])) { + DB::table('category_transaction')->insert( + [ + 'category_id' => $transfer['category_ids'][$index], + 'transaction_id' => $first, + ] + ); + DB::table('category_transaction')->insert( + [ + 'category_id' => $transfer['category_ids'][$index], + 'transaction_id' => $second, + ] + ); + } + } + } + } + /** * */ @@ -728,6 +792,7 @@ class TestData $this->createAttachments(); $this->createMultiWithdrawals(); $this->createMultiDeposits(); + $this->createMultiTransfers(); } } diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.php index 7bd6d7fd79..b886ce6817 100644 --- a/resources/lang/en_US/firefly.php +++ b/resources/lang/en_US/firefly.php @@ -70,6 +70,8 @@ return [ 'registered' => 'You have registered successfully!', 'search' => 'Search', 'no_budget_pointer' => 'You seem to have no budgets yet. You should create some on the budgets-page. Budgets can help you keep track of expenses.', + 'source_accounts' => 'Source account(s)', + 'destination_accounts' => 'Destination account(s)', // repeat frequencies: 'repeat_freq_monthly' => 'monthly', @@ -811,7 +813,7 @@ return [ 'split_intro_three_withdrawal' => 'For example: you could split your :total groceries so you pay :split_one from your "daily groceries" budget and :split_two from your "cigarettes" budget.', 'split_table_intro_withdrawal' => 'Split your withdrawal in as many things as you want. By default the transaction will not split, there is just one entry. Add as many splits as you want to, below. Remember that you should not deviate from your total amount. If you do, Firefly will warn you but not correct you.', 'store_splitted_withdrawal' => 'Store splitted withdrawal', - 'update_splitted_withdrawal' => 'Update splitted withdrawal', + 'update_splitted_withdrawal' => 'Update splitted withdrawal', 'split_title_deposit' => 'Split your new deposit', 'split_intro_one_deposit' => 'Firefly supports the "splitting" of a deposit.', diff --git a/resources/views/split/journals/create.twig b/resources/views/split/journals/create.twig index ccb615c0ee..2240809186 100644 --- a/resources/views/split/journals/create.twig +++ b/resources/views/split/journals/create.twig @@ -1,7 +1,7 @@ {% extends "./layout/default.twig" %} {% block breadcrumbs %} - {{ Breadcrumbs.renderIfExists }} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, preFilled.what) }} {% endblock %} {% block content %}