1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-24 15:49:39 +02:00

Feature: Add "amount type" configuration column for CSV imports (#1947)

* Rough draft

* Schema conflict update

* Implement signage

* Update system tests

* Lint fixes
This commit is contained in:
Zach Gollwitzer 2025-04-18 10:48:10 -04:00 committed by GitHub
parent 8cf077f28d
commit c88fe2e3b2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 366 additions and 83 deletions

View file

@ -68,4 +68,36 @@ class TransactionImportTest < ActiveSupport::TestCase
assert_equal "complete", @import.status
end
test "imports transactions with separate type column for signage convention" do
import = <<~CSV
date,amount,amount_type
01/01/2024,100,debit
01/02/2024,200,credit
01/03/2024,300,debit
CSV
@import.update!(
account: accounts(:depository),
raw_file_str: import,
date_col_label: "date",
date_format: "%m/%d/%Y",
amount_col_label: "amount",
entity_type_col_label: "amount_type",
amount_type_inflow_value: "debit",
amount_type_strategy: "custom_column",
signage_convention: nil # Explicitly set to nil to prove this is not needed
)
@import.generate_rows_from_csv
@import.reload
assert_difference -> { Entry.count } => 3,
-> { Transaction.count } => 3 do
@import.publish
end
assert_equal [ -100, 200, -300 ], @import.entries.map(&:amount)
end
end