heavy refactor
This commit is contained in:
+14
-24
@@ -1,26 +1,9 @@
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
|
||||
from src.db import get_session
|
||||
from src.helper_db import upsert_b4w, upsert_comdirect_giro
|
||||
from src.reader import reader_b4w, reader_comdirect
|
||||
|
||||
|
||||
def ingest_b4w(path: Path):
|
||||
data = reader_b4w(path)
|
||||
with get_session() as session:
|
||||
for row in data:
|
||||
upsert_b4w(session, row, do_commit=False)
|
||||
session.commit()
|
||||
|
||||
|
||||
def ingest_comdirect(path: Path):
|
||||
data = reader_comdirect(path).get("Girokonto")
|
||||
assert isinstance(data, list)
|
||||
with get_session() as session:
|
||||
for row in data:
|
||||
upsert_comdirect_giro(session, row, do_commit=False)
|
||||
session.commit()
|
||||
from src.ingest.b4w import ingest_b4w
|
||||
from src.ingest.comdirect import ingest_comdirect
|
||||
from src.models.settings import Account
|
||||
|
||||
|
||||
def main():
|
||||
@@ -35,11 +18,18 @@ def main():
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
path_b4w = Path(args.input_b4w)
|
||||
path_comdirect = Path(args.input_comdirect)
|
||||
if args.input_b4w:
|
||||
ingest_b4w(Path(args.input_b4w))
|
||||
if args.input_comdirect:
|
||||
import settings
|
||||
|
||||
ingest_b4w(path_b4w)
|
||||
ingest_comdirect(path_comdirect)
|
||||
giro_account = settings.BANK_ACCOUNTS["comdirect"].get_account("Girokonto")
|
||||
assert isinstance(giro_account, Account)
|
||||
ingest_comdirect(
|
||||
Path(args.input_comdirect),
|
||||
account_iban=giro_account.iban,
|
||||
account_currency=giro_account.currency,
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user