The personal finance app for everyone
Fix unable to create Deposit entries in investment portfolio (#1125)
Tony Vincente1efe97e6f75
diff --git a/app/models/account/transaction_builder.rb b/app/models/account/transaction_builder.rbindex 457170f6..b6968443 100644--- a/app/models/account/transaction_builder.rb+++ b/app/models/account/transaction_builder.rb@@ -21,7 +21,7 @@ class Account::TransactionBuilderenddef create_transfer- return create_unlinked_transfer(account.id, signed_amount) unless transfer_account_id+ return create_unlinked_transfer(account.id, signed_amount) if transfer_account_id.blank?from_account_id = type == "transfer_in" ? transfer_account_id : account.idto_account_id = type == "transfer_in" ? account.id : transfer_account_iddiff --git a/test/system/transactions_test.rb b/test/system/transactions_test.rbindex 25a75223..8b31372b 100644--- a/test/system/transactions_test.rb+++ b/test/system/transactions_test.rb@@ -150,6 +150,24 @@ class TransactionsTest < ApplicationSystemTestCaseassert_selection_count(0)end++ test "can create deposit transaction for investment account" do+ investment_account = accounts(:investment)+ transfer_date = Date.current+ visit account_path(investment_account)+ click_on "New transaction"+ select "Deposit", from: "Type"+ fill_in "Date", with: transfer_date+ fill_in "account_entry[amount]", with: 175.25+ click_button "Add transaction"+ within "#account_" + investment_account.id do+ click_on "Transactions"+ end+ within "#entry-group-" + transfer_date.to_s do+ assert_text "175.25"+ end+ end+privatedef create_transaction(name, date, amount, category: nil, merchant: nil, tags: [])