first Durchstich: comdirect Giro to DB
This commit is contained in:
+32
-4
@@ -2,8 +2,8 @@ from typing import Any
|
||||
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from src.models import B4wExport, Category
|
||||
from src.models_db import B4wDb, BaseModelDb, CategoryDb
|
||||
from src.models import B4wExport, Category, ComdirectGiro
|
||||
from src.models_db import B4wDb, BaseModelDb, CategoryDb, ComdirectGiroDb
|
||||
|
||||
|
||||
def _query_existing(
|
||||
@@ -62,17 +62,18 @@ def upsert_b4w(
|
||||
) -> B4wDb | None:
|
||||
category_db = upsert_category(session, data.category)
|
||||
|
||||
parameters_existing = {"id_b4w": data.id}
|
||||
parameters_existing = {"hash_id": data.hash_id}
|
||||
|
||||
parameters_new = {
|
||||
"id_b4w": data.id,
|
||||
"hash_id": data.hash_id,
|
||||
"account_iban": data.account_iban,
|
||||
"account_currency": data.account_currency.value,
|
||||
"date_valid": data.date_valid,
|
||||
"date_book": data.date_book,
|
||||
"amount": data.amount_signed,
|
||||
"amount_currency": data.amount_currency.value,
|
||||
"reference": data.reference,
|
||||
"text": data.reference,
|
||||
"other_name": data.other_name,
|
||||
"other_iban": data.other_iban,
|
||||
"category": category_db,
|
||||
@@ -87,3 +88,30 @@ def upsert_b4w(
|
||||
do_update=do_update,
|
||||
do_commit=do_commit,
|
||||
)
|
||||
|
||||
|
||||
def upsert_comdirect_giro(
|
||||
session: Session, data: ComdirectGiro, do_update=False, do_commit=True
|
||||
) -> ComdirectGiroDb | None:
|
||||
parameters_existing = {"hash_id": data.hash_id}
|
||||
|
||||
if not data.date_val:
|
||||
return
|
||||
|
||||
parameters_new = {
|
||||
"hash_id": data.hash_id,
|
||||
"date_valid": data.date_val,
|
||||
"amount": data.amount_eur,
|
||||
"date_book": data.date_book,
|
||||
"type": data.type,
|
||||
"text": data.text,
|
||||
}
|
||||
|
||||
return _upsert(
|
||||
session,
|
||||
ComdirectGiroDb,
|
||||
parameters_existing,
|
||||
parameters_new,
|
||||
do_update=do_update,
|
||||
do_commit=do_commit,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user