Compare commits

...

2 Commits

2 changed files with 80 additions and 3 deletions

View File

@ -76,7 +76,7 @@ class GeneralSummaryReportQuery(baseQBQuery):
print(f'{kwargs = }')
super().__init__( )
## Required variable
self.includeRetElements_allowed = ["ReportTitle", "ReportSubtitle", "ReportBasis", "NumRows", "NumColumns", "NumColTitleRows", "ReportData", ]
self.includeRetElements_allowed = ["ReportTitle", "ReportSubtitle", "ReportBasis", "NumRows", "NumColumns", "NumColTitleRows", "ReportData", "DataRow"]
self.onError = "stopOnError"
self.retName = 'ReportRet'
self.defaultFilterKey = "ListID"
@ -97,7 +97,7 @@ class GeneralSummaryReportQuery(baseQBQuery):
if 'GeneralSummaryReportType' in kwargs:
enum=cleanIncludeRetElements(self.ENUM_GeneralSummaryReportType, kwargs['GeneralSummaryReportType'])
print(enum)
self.QBDict[self.classRq]["GeneralSummaryReportType"]=enum[0]
self.QBDict[self.classNameRq]["GeneralSummaryReportType"]=enum[0]
else:
print("Error -> GeneralSummaryReportType is required")
return
@ -1094,6 +1094,74 @@ class InvoiceQuery(baseQBQuery):
self.runCheck() ### running the qbxml connection to get data ###
@timing
def InventoryStockStatusByVendor(ReportEntityFilter_FullName:str='TACO') -> dict:
# g= GeneralSummaryReportQuery(debug=False, GeneralSummaryReportType="ProfitAndLossStandard", ReportDateMacro="ThisYear")
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(type(g.all()))
# print(g.all())
# print(g.response_string)
# print(g.all())
# pprint.pprint(g.filter("reportdata").all())
# abc = g.filter("reportdata").all()
# print(abc)
# print()
# pprint.pprint(g.filter('datarow').all(abc), sort_dicts=False)
datarows = g.filter('datarow').all()
# 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, 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
"""
{'@rowNumber': '1016',
'ColData': [{'@colID': '1',
'@value': 'EDG-P1251-1/42'},
{'@colID': '2',
'@value': 'EDGING 42 X 1 MM P1251'},
{'@colID': '5', '@value': '1'}, # QOH
{'@colID': '6', '@value': '0'}, # QOSO
{'@colID': '7', '@value': '0'}, #assembly
{'@colID': '8', '@value': '1'}, # QA(available)(QOH-QOSO-assembly)
{'@colID': '9', '@value': 'Roll'}, #base_uom
{'@colID': '10', '@value': 'false'},
{'@colID': '11', '@value': '0'}, #QOPO
{'@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'}},
"""
if __name__ == "__main__":
@timing

11
main.py
View File

@ -18,7 +18,7 @@ import pdfexcel4DNwithxlrd
from ItemInventoryQuery import ItemInventoryQuery
from SO_to_Inv import readSO, CustomerQuery
import os
from QBClass.QBClasses import SalesOrderAdd
from QBClass.QBClasses import SalesOrderAdd, InventoryStockStatusByVendor
import pprint
@ -85,6 +85,15 @@ async def get_customer_fullname(maxreturned:Union[int, None] = None):
else:
return {'Info': f"NOT Saved", 'Status':'ERROR', 'msg':data}
@app.get('/get-inventorystockstatusbyvendor')
async def get_inventorystockstatusbyvendor():
items = InventoryStockStatusByVendor()
if items:
# data = json.dumps(items)
return items
else:
return {'Info': f"CANNOT Get InventoryStockStatusByVendor TACO", 'Status':'ERROR', 'msg':items}
@app.post("/upload-file/")
async def create_upload_file(uploaded_file: UploadFile):