From b1f313f4fe7948eff36f23ab465001f1db278e7c Mon Sep 17 00:00:00 2001 From: bcomsugi Date: Thu, 3 Oct 2024 07:26:41 +0700 Subject: [PATCH] InventoryStockStatusByVendor updated --- QBClass/QBClasses.py | 36 ++++++++++++++++++++++++++---------- main.py | 4 ++-- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/QBClass/QBClasses.py b/QBClass/QBClasses.py index 6aab347..048098a 100644 --- a/QBClass/QBClasses.py +++ b/QBClass/QBClasses.py @@ -1095,11 +1095,11 @@ class InvoiceQuery(baseQBQuery): @timing -def InventoryStockStatusByVendor() -> dict: +def InventoryStockStatusByVendor(ReportEntityFilter_FullName:str='TACO') -> dict: # g= GeneralSummaryReportQuery(debug=False, GeneralSummaryReportType="ProfitAndLossStandard", ReportDateMacro="ThisYear") - g= GeneralSummaryReportQuery(debug=False, GeneralSummaryReportType="InventoryStockStatusByVendor", ReportEntityFilter_FullName='TACO', ) + g= GeneralSummaryReportQuery(debug=False, GeneralSummaryReportType="InventoryStockStatusByVendor", ReportEntityFilter_FullName=ReportEntityFilter_FullName, ) # g= GeneralSummaryReportQuery(debug=False, GeneralSummaryReportType="InventoryStockStatusByVendor", ReportItemFilter_FullName=['TACH:RLC:BBS009PO45-500','TACH:RLC:BBS009PO45-400'], ReportEntityFilter_FullName='TACO' ) - print(g, type(g)) + # print(g, type(g)) # print(type(g.all())) # print(g.all()) # print(g.response_string) @@ -1113,17 +1113,32 @@ def InventoryStockStatusByVendor() -> dict: # pprint.pprint(datarows, sort_dicts=False) # print(type(datarows)) dt = {} + if len(datarows[0]['DataRow'])==0: + return dt for datarow in datarows[0]['DataRow']: # print(datarow,) FullName=datarow['RowData']['@value'] if len(FullName.split(':'))==3: ShortName=datarow['ColData'][0]['@value'] - QOH=datarow['ColData'][2]['@value'] - QOSO=datarow['ColData'][3]['@value'] - QA=datarow['ColData'][5]['@value'] - UOM=datarow['ColData'][6]['@value'] - QOPO=datarow['ColData'][8]['@value'] - dt[FullName]={'ShortName':ShortName, 'QOH':QOH, 'QOSO':QOSO, 'QA':QA, 'QOPO':QOPO, 'UOM':UOM} + QOH, QOSO, QA, UOM, QOPO, min, max, ND = None, None, None, None, None, None, None, None + for coldata in datarow['ColData']: + if coldata['@colID']=='5': + QOH=coldata['@value'] + elif coldata['@colID']=='6': + QOSO=coldata['@value'] + elif coldata['@colID']=='8': + QA=coldata['@value'] + elif coldata['@colID']=='9': + UOM=coldata['@value'] + elif coldata['@colID']=='11': + QOPO=coldata['@value'] + elif coldata['@colID']=='3': + min=coldata['@value'] + elif coldata['@colID']=='4': + max=coldata['@value'] + elif coldata['@colID']=='13': + ND=coldata['@value'] #Next Delivery Date + dt[FullName]={'ShortName':ShortName, 'QOH':QOH, 'QOSO':QOSO, 'QA':QA, 'QOPO':QOPO, 'UOM':UOM, 'min':min, 'max':max, 'ND':ND} # print(f'{dt = }') # print(len(dt)) return dt @@ -1140,7 +1155,8 @@ def InventoryStockStatusByVendor() -> dict: {'@colID': '9', '@value': 'Roll'}, #base_uom {'@colID': '10', '@value': 'false'}, {'@colID': '11', '@value': '0'}, #QOPO - {'@colID': '12', '@value': '0'}, #ReorderPoint + {'@colID': '12', '@value': '0'}, #ReorderqTY + {'@colID': '13', '@value': '13/04/2022'}, #NextDeliver {'@colID': '14', '@value': '0'}], 'RowData': {'@rowType': 'item', '@value': 'TEDG:P142:EDG-P1251-1/42'}}, diff --git a/main.py b/main.py index ce46c0b..2523ae4 100644 --- a/main.py +++ b/main.py @@ -90,8 +90,8 @@ async def get_inventorystockstatusbyvendor(): items = InventoryStockStatusByVendor() if items: - data = json.dumps(items) - return data + # data = json.dumps(items) + return items else: return {'Info': f"CANNOT Get InventoryStockStatusByVendor TACO", 'Status':'ERROR', 'msg':items}