inseret monthly forderungen

This commit is contained in:
Wolfgang Hottgenroth 2021-02-22 17:16:44 +01:00
parent 59625cac68
commit d69e4be6a9
Signed by: wn
GPG Key ID: E49AF3B9EF6DD469
3 changed files with 39 additions and 2 deletions

View File

@ -1,4 +1,4 @@
from dbpool import getConnection, getOne, getMany, putOne
from dbpool import getConnection, getOne, getMany, putOne, call
import datetime
import decimal
import dateparser
@ -122,3 +122,6 @@ INSERT INTO zahlung (datum_soll, datum_ist, mieter, betrag, kommentar)
except KeyError as e:
print("Some parameter missing: {}".format(e))
return str(e), 500
def insertAllForMonth():
return call("insert_monatl_miet_forderung")

View File

@ -94,4 +94,27 @@ def putOne(stmt, params, objName):
cur.close()
if dbh:
dbh.close()
def call(procName):
dbh = None
cur = None
try:
dbh = getConnection()
cur = dbh.cursor(dictionary=True)
cur.execute("CALL {}(null)".format(procName))
dbh.commit()
return "{} successfully called {}".format(procName), 202
except mariadb.Error as err:
dbh.rollback()
print("Database error in call {}: {}".format(procName, err))
return str(err), 500
except Exception as err:
dbh.rollback()
print("Some error in call {}: {}".format(procName, err))
return str(err), 500
finally:
print("return connection in call {}".format(procName))
if cur:
cur.close()
if dbh:
dbh.close()

View File

@ -330,6 +330,17 @@ paths:
description: Zahlung successfully inserted
500:
description: Some server or database error
/hv/forderung/insertAllForMonth:
post:
tags: [ "Forderung" ]
operationId: ZahlungenForderungen.insertAllForMonth
summary: Insert the Forderungen for the insertAllForMonth
responses:
202:
description: Forderungen successfully inserted
500:
description: Some server or database error
components: