fixed /newtransaction

This commit is contained in:
Linus E 2022-04-26 12:36:01 +02:00
parent b347c10653
commit 0c9cc0b4ef
2 changed files with 3 additions and 2 deletions

View File

@ -288,6 +288,7 @@ class API_Handler:
int: status code int: status code
""" """
with r.Session() as s: with r.Session() as s:
time = time[:-3] + "Z" # remove last character and add Z to make it a valid date for db
headers = {'Authorization': 'Bearer ' + self.token + ":" + str(user_id)} headers = {'Authorization': 'Bearer ' + self.token + ":" + str(user_id)}
transaction = {"comment": str(comment), "count": float(count), "isin": str(isin), "price": float(price), "time": str(time)} # set transaction as JSON with all the attributes needed according to Swagger docs transaction = {"comment": str(comment), "count": float(count), "isin": str(isin), "price": float(price), "time": str(time)} # set transaction as JSON with all the attributes needed according to Swagger docs
req = s.post(self.db_adress + "/transaction", json=transaction, headers=headers) req = s.post(self.db_adress + "/transaction", json=transaction, headers=headers)

View File

@ -483,8 +483,8 @@ def set_new_transaction_step(message):
amount = float(transaction_data[2]) amount = float(transaction_data[2])
price = float(transaction_data[3]) price = float(transaction_data[3])
time = dt.datetime.now().isoformat() time = dt.datetime.now().isoformat()
#print("\n\n\n\n\n") print("\n\n\n\n\n")
#print(f"{symbol},{amount},{price},{time}") print(f"{isin},{amount},{price},{time}")
status = api_handler.set_transaction(user_id, desc, isin, amount, price, time) status = api_handler.set_transaction(user_id, desc, isin, amount, price, time)
if status == 200: if status == 200: