This repository was archived by the owner on Jul 27, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed
app/models/plaid_account/investments
test/models/plaid_account/investments Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ def account
2424 end
2525
2626 def cash_transaction? ( transaction )
27- transaction [ "type" ] == "cash" || transaction [ "type" ] == "fee"
27+ transaction [ "type" ] == "cash" || transaction [ "type" ] == "fee" || transaction [ "type" ] == "transfer"
2828 end
2929
3030 def find_or_create_trade_entry ( transaction )
Original file line number Diff line number Diff line change @@ -147,4 +147,37 @@ class PlaidAccount::Investments::TransactionsProcessorTest < ActiveSupport::Test
147147
148148 assert_equal -1 , entry . trade . qty
149149 end
150+
151+ test "creates transfer transactions as cash transactions" do
152+ test_investments_payload = {
153+ transactions : [
154+ {
155+ "investment_transaction_id" => "123" ,
156+ "type" => "transfer" ,
157+ "amount" => -100.0 ,
158+ "iso_currency_code" => "USD" ,
159+ "date" => Date . current ,
160+ "name" => "Bank Transfer"
161+ }
162+ ]
163+ }
164+
165+ @plaid_account . update! ( raw_investments_payload : test_investments_payload )
166+
167+ @security_resolver . expects ( :resolve ) . never
168+
169+ processor = PlaidAccount ::Investments ::TransactionsProcessor . new ( @plaid_account , security_resolver : @security_resolver )
170+
171+ assert_difference [ "Entry.count" , "Transaction.count" ] , 1 do
172+ processor . process
173+ end
174+
175+ entry = Entry . order ( created_at : :desc ) . first
176+
177+ assert_equal -100.0 , entry . amount
178+ assert_equal "USD" , entry . currency
179+ assert_equal Date . current , entry . date
180+ assert_equal "Bank Transfer" , entry . name
181+ assert_instance_of Transaction , entry . entryable
182+ end
150183end
You can’t perform that action at this time.
0 commit comments