diff --git a/beanhub_import/processor.py b/beanhub_import/processor.py index e5b74c3..c00d1dd 100644 --- a/beanhub_import/processor.py +++ b/beanhub_import/processor.py @@ -341,7 +341,9 @@ def process_imports( continue rel_filepath = filepath.relative_to(input_dir) extractor_name = ( - input_config.config.extractor if input_config is not None else None + input_config.config.extractor + if input_config.config is not None + else None ) if extractor_name is None: with filepath.open("rt") as fo: diff --git a/tests/fixtures/processor/auto-detect/import.yaml b/tests/fixtures/processor/auto-detect/import.yaml index 1c83033..f1ea2a1 100644 --- a/tests/fixtures/processor/auto-detect/import.yaml +++ b/tests/fixtures/processor/auto-detect/import.yaml @@ -1,11 +1,5 @@ inputs: - match: "*.csv" - config: - prepend_postings: - - account: Assets:Bank:US:Mercury - amount: - number: "{{ amount }}" - currency: "{{ currency | default('USD', true) }}" imports: - match: @@ -16,6 +10,10 @@ imports: file: "output.bean" txn: postings: + - account: Assets:Bank:US:Mercury + amount: + number: "{{ amount }}" + currency: "{{ currency | default('USD', true) }}" - account: "Expenses" amount: number: "{{ -amount }}" diff --git a/tests/fixtures/processor/input-without-config/import.yaml b/tests/fixtures/processor/input-without-config/import.yaml new file mode 100644 index 0000000..1c83033 --- /dev/null +++ b/tests/fixtures/processor/input-without-config/import.yaml @@ -0,0 +1,22 @@ +inputs: +- match: "*.csv" + config: + prepend_postings: + - account: Assets:Bank:US:Mercury + amount: + number: "{{ amount }}" + currency: "{{ currency | default('USD', true) }}" + +imports: + - match: + extractor: + equals: "mercury" + actions: + - type: add_txn + file: "output.bean" + txn: + postings: + - account: "Expenses" + amount: + number: "{{ -amount }}" + currency: "{{ currency | default('USD', true) }}" diff --git a/tests/fixtures/processor/input-without-config/mercury.csv b/tests/fixtures/processor/input-without-config/mercury.csv new file mode 100644 index 0000000..88ced83 --- /dev/null +++ b/tests/fixtures/processor/input-without-config/mercury.csv @@ -0,0 +1,2 @@ +Date (UTC),Description,Amount,Status,Source Account,Bank Description,Reference,Note,Last Four Digits,Name On Card,Category,GL Code,Timestamp,Original Currency +04-15-2024,Jane Doe,-1500.00,Sent,Mercury Checking xx1234,Send Money transaction initiated on Mercury,Profit distribution,,,,,,04-15-2024 14:35:37, diff --git a/tests/test_processor.py b/tests/test_processor.py index edf69cd..e415287 100644 --- a/tests/test_processor.py +++ b/tests/test_processor.py @@ -993,6 +993,29 @@ def get_result(): ), ], ), + ( + "input-without-config", + [ + GeneratedTransaction( + file="output.bean", + id="mercury.csv:-1", + sources=["mercury.csv"], + date="2024-04-15", + flag="*", + narration="Jane Doe", + postings=[ + GeneratedPosting( + account="Assets:Bank:US:Mercury", + amount=Amount(number="-1500.00", currency="USD"), + ), + GeneratedPosting( + account="Expenses", + amount=Amount(number="1500.00", currency="USD"), + ), + ], + ), + ], + ), ], ) def test_process_imports(