add contracts

This commit is contained in:
2023-01-02 14:46:59 +01:00
parent 10b7f89831
commit 07dff73152
36 changed files with 1671 additions and 45 deletions

View File

@ -1584,3 +1584,103 @@ SELECT
}
)
def get_contracts(user, token_info):
return dbGetMany(user, token_info, {
"statement": """
SELECT
id
,supplier
,content
,identifier
,notes
FROM contract_t
ORDER BY
supplier
,content
""",
"params": ()
}
)
def insert_contract(user, token_info, **args):
try:
body = args["body"]
v_supplier = body["supplier"]
v_content = body["content"]
v_identifier = body["identifier"]
v_notes = body["notes"]
return dbInsert(user, token_info, {
"statement": """
INSERT INTO contract_t
(
supplier
,content
,identifier
,notes
) VALUES (
%s
,%s
,%s
,%s
)
RETURNING *
""",
"params": [
v_supplier
,v_content
,v_identifier
,v_notes
]
})
except KeyError as e:
logger.warning("insert_contract: parameter missing: {}".format(e))
raise werkzeug.exceptions.UnprocessableEntity("parameter missing: {}".format(e))
def get_contract(user, token_info, contractId=None):
return dbGetOne(user, token_info, {
"statement": """
SELECT
id
,supplier
,content
,identifier
,notes
FROM contract_t
WHERE id = %s
""",
"params": (contractId, )
}
)
def update_contract(user, token_info, contractId=None, **args):
try:
body = args["body"]
v_supplier = body["supplier"]
v_content = body["content"]
v_identifier = body["identifier"]
v_notes = body["notes"]
return dbUpdate(user, token_info, {
"statement": """
UPDATE contract_t
SET
supplier = %s
,content = %s
,identifier = %s
,notes = %s
WHERE id = %s
RETURNING *
""",
"params": [
v_supplier,
v_content,
v_identifier,
v_notes,
contractId
]
})
except KeyError as e:
logger.warning("update_contract: parameter missing: {}".format(e))
raise werkzeug.exceptions.UnprocessableEntity("parameter missing: {}".format(e))