diff --git a/main.py b/main.py index 42dffb5..ad88de2 100644 --- a/main.py +++ b/main.py @@ -13,6 +13,8 @@ import pdfexcel4DNwithxlrd from ItemInventoryQuery import ItemInventoryQuery from SO_to_Inv import readSO import os +from icecream import ic +import pprint # app = FastAPI() app = FastAPI(docs_url="/itemreceipt", redoc_url=None) @@ -89,15 +91,38 @@ async def create_upload_file(uploaded_file: UploadFile): status = "OK" else: print("ERROR", status_msg) + print(f"ret:{ret}", type(ret)) status = "ERROR" msg = f"ERROR. replyfromqbxml:{ret}" msg = f"{status}. replyfrom qbxml:{ret}" else: print("create_upload_file->not all DN are added") - msg = f"Error. not all DN are added. \n these items not added in the list :\n{notinthelist}" - status = 'Error' + # ic(notinthelist) + # errmsg = ic(notinthelist) + # errmsg = pprint.pprint(notinthelist) + # errmsg = str(errmsg) + # print(errmsg, type(errmsg)) + errmsg = json.dumps(notinthelist, indent=2, sort_keys=True) + errmsg = json.loads(errmsg) - return {"info": f"file '{uploaded_file.filename}' saved at '{file_location}'", "status": status, "msg": msg} + # print(errmsg, type(errmsg)) + print(type(errmsg)) + # msg = f"Error. not all DN are added. \n these items not added in the list :\n{notinthelist}" + msg = f"Error. not all DN are added. \n these items not added in the list :\n{errmsg}" + + status = 'Error' + msgdict={} + msgdict["info"]=f'file {uploaded_file.filename} saved at {file_location}' + msgdict["status"]=status + msgdict["msg"]=errmsg + print(msgdict, type(msg)) + # jsonmsg = json.dumps(msgdict) + # jsonmsg = json.loads(jsonmsg) + + return msgdict + + + return [{"info": f"file '{uploaded_file.filename}' saved at '{file_location}'", "status": status, "msg": msg}] return {"info": f"file '{uploaded_file.filename}' is not Excel(.xls) file or it is not Delivery Note(TCO-DN)file. please upload the correct file", "status": status} @app.post('/getopenso')