Skip to content

Commit 0d5275c

Browse files
authored
Merge pull request #16 from erwindouna/refresh-account-creation
Add account creation
2 parents 74084c9 + aa14af7 commit 0d5275c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

importer2firefly.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ async def start_import(self) -> AsyncGenerator[Any, Any]:
144144
account_type = (
145145
"revenue" if transaction_type == "credit" else "Expense"
146146
)
147+
147148
yield f"No match, still a valid IBAN. Creating a new account: {txn} - {cp_iban} - {account_type}"
148149
response = await self._firefly_client.create_account(
149150
{
@@ -159,12 +160,19 @@ async def start_import(self) -> AsyncGenerator[Any, Any]:
159160
),
160161
}
161162
)
163+
162164
if response.status_code != 200:
163165
yield f"Error creating account in Firefly: {response.text}"
164166
continue
165167
yield f"New account created: {txn.get('meta', {}).get('counter_party_preferred_name')} - {cp_iban}"
166168
linked_account = response.json()["data"]
167169
newly_created += 1
170+
171+
yield "Firefly: Enforcing refresh accounts from Firefly"
172+
firefly_accounts = (
173+
await self._firefly_client.get_account_paginated()
174+
)
175+
yield f"Firefly: A total of {len(firefly_accounts)} account(s) found"
168176
else:
169177
unmatching += 1
170178
yield f"Transaction has no IBAN: {txn['description']}"

0 commit comments

Comments
 (0)