Verified Commit bc31b484 authored by Jakob Moser's avatar Jakob Moser
Browse files

Print new transactions after sync command

parent 3d6f3b95
Loading
Loading
Loading
Loading
+16 −2
Changes for poolpay/fints/__main__.py: 16 added lines, 2 removed lines.
Original line number Diff line number Diff line
import getpass
import re
import sys
from collections.abc import Sequence
from pathlib import Path
from typing import Annotated

@@ -29,13 +30,26 @@ def _guess_db_path() -> Path:


@app.command()
def sync() -> None:
def sync() -> Sequence[Transaction]:
    """
    Download transactions for all nw bank accounts and store them in the database.

    :return: sequence of all newly added transactions (if any)
    """
    new_transactions: list[Transaction] = []

    for bank_account in BankAccount.get_all():
        password = getpass.getpass(f"Password for {bank_account.user}: ")
        bank_account.sync(password)
        new_transactions += bank_account.sync(password)

    if len(new_transactions) == 0:
        print("No new transactions.")
    else:
        print(f"{len(new_transactions)} new transactions:")
        for transaction in new_transactions:
            print(str(transaction))

    return tuple(new_transactions)


def _encrypt_if_requested(content: str, encrypt: bool) -> str: