from server import baseQBQuery import pprint class ItemInventoryQuery(baseQBQuery): def __init__(self, *args, **kwargs): print(f'{args = }') print(f'{kwargs = }') super().__init__(*args, **kwargs) self.retName = 'ItemInventoryRet' self.QBDict[self.__class__.__name__ + "Rq"]={} if 'ListID' in kwargs: self.QBDict[self.__class__.__name__ + "Rq"]["ListID"]=kwargs['ListID'] elif 'FullName' in kwargs: self.QBDict[self.__class__.__name__ + "Rq"]["FullName"]=kwargs['FullName'] else: if 'MaxReturned' in kwargs: self.QBDict[self.__class__.__name__ + "Rq"]["MaxReturned"]=kwargs['MaxReturned'] if 'ActiveStatus' in kwargs: self.QBDict[self.__class__.__name__ + "Rq"]["ActiveStatus"]=kwargs['ActiveStatus'] if 'FromModifiedDate' in kwargs: self.QBDict[self.__class__.__name__ + "Rq"]["FromModifiedDate"]=kwargs['FromModifiedDate'] if 'ToModifiedDate' in kwargs: self.QBDict[self.__class__.__name__ + "Rq"]["ToModifiedDate"]=kwargs['ToModifiedDate'] if 'MatchCriterion' in kwargs and 'Name' in kwargs: self.QBDict[self.__class__.__name__ + "Rq"]["NameFilter"]={'MatchCriterion':kwargs['MatchCriterion', 'Name':kwargs['Name']]} if 'FromName' in kwargs or 'ToName' in kwargs: self.QBDict[self.__class__.__name__ + "Rq"]["NameRangeFilter"]={'FromName':kwargs.get('FromName', ""), 'ToName':kwargs.get('ToName', "")} if 'IncludeRetElement' in kwargs: self.QBDict[self.__class__.__name__ + "Rq"]["IncludeRetElement"]=kwargs['IncludeRetElement'] if 'OwnerID' in kwargs: self.QBDict[self.__class__.__name__ + "Rq"]["OwnerID"]=kwargs['OwnerID'] # print(self.__class__.__name__ + "Rq") # print(self.QBDict) class GeneralSummaryReportQuery(baseQBQuery): def __init__(self, *args, **kwargs): print(f'{args = }') print(f'{kwargs = }') super().__init__( ) self.retName = 'ReportRet' self.QBDict[self.__class__.__name__ + "Rq"]={} self.QBDict[self.__class__.__name__ + "Rq"]["GeneralSummaryReportType"]="InventoryStockStatusByItem" if 'GeneralSummaryReportType' in kwargs: self.QBDict[self.__class__.__name__ + "Rq"]["GeneralSummaryReportType"]=kwargs['GeneralSummaryReportType'] else: return None if 'FromReportDate' in kwargs or 'ToReportDate' in kwargs: self.QBDict[self.__class__.__name__ + "Rq"]["ReportPeriod"]={'FromReportDate':kwargs.get('FromReportDate', ""), 'ToReportDate':kwargs.get('ToReportDate', "")} elif 'ReportDateMacro' in kwargs: self.QBDict[self.__class__.__name__ + "Rq"]["ReportDateMacro"]=kwargs.get('ReportDateMacro', "") elif 'FullName' in kwargs: self.QBDict[self.__class__.__name__ + "Rq"]["FullName"]=kwargs['FullName'] else: if 'MaxReturned' in kwargs: self.QBDict[self.__class__.__name__ + "Rq"]["MaxReturned"]=kwargs['MaxReturned'] if 'ActiveStatus' in kwargs: self.QBDict[self.__class__.__name__ + "Rq"]["ActiveStatus"]=kwargs['ActiveStatus'] if 'FromModifiedDate' in kwargs: self.QBDict[self.__class__.__name__ + "Rq"]["FromModifiedDate"]=kwargs['FromModifiedDate'] if 'ToModifiedDate' in kwargs: self.QBDict[self.__class__.__name__ + "Rq"]["ToModifiedDate"]=kwargs['ToModifiedDate'] if 'MatchCriterion' in kwargs and 'Name' in kwargs: self.QBDict[self.__class__.__name__ + "Rq"]["NameFilter"]={'MatchCriterion':kwargs['MatchCriterion', 'Name':kwargs['Name']]} if 'FromName' in kwargs or 'ToName' in kwargs: self.QBDict[self.__class__.__name__ + "Rq"]["NameRangeFilter"]={'FromName':kwargs.get('FromName', ""), 'ToName':kwargs.get('ToName', "")} if 'IncludeRetElement' in kwargs: self.QBDict[self.__class__.__name__ + "Rq"]["IncludeRetElement"]=kwargs['IncludeRetElement'] if 'OwnerID' in kwargs: self.QBDict[self.__class__.__name__ + "Rq"]["OwnerID"]=kwargs['OwnerID'] print(self.__class__.__name__ + "Rq") print(f'{self.QBDict = }') # x=ItemInventoryQuery('bagus', 'kedua', key5=5, key2="hore", FullName1='hooooo', FromName1="sg", ToName1="sugi", IncludeRetElement1=['Name', 'FullName'], MaxReturned="2") # x.create_QBXML() # x.connect_to_quickbooks() # # print(x.find_firstListOfDict("FullName")['FullName']) # # print(x.find_firstListOfDictValue("PurchaseCost")) # # print(x.find_firstListOfDict("PurchaseCost")) # # print(x.find_allListOfDict("FullName")) # # pprint.pprint(x.Rs) # # print("ada" if list(x.find_listOfDict("FullName")) else "ga") # print(x.filter("FullName")) # y=x.filter("Name") # print(type(x.filter("FullName1"))) # print(type(y)) # print(x.filter("FullName1").all()) # _test=x.filter("FullName1").all() # if _test: # print(_test) # try: # print(x.filter("FullName1").all()[-1]) # except Exception as e: # print(e) # print(x.filter("FullName1").first()) # print(x.filter("FullName1").firstValue()) # print(x.filter("FullName1").last()) # print(x.filter("FullName1").lastValue()) # print(x.filter("FullName").count()) # print(y.last()) # print(y.lastValue()) # pprint.pprint(x.all()) # a1=x.filter("FullName") # print(a1) # a2 = x.filter("Name") # print(a2) # print(a1) g= GeneralSummaryReportQuery(GeneralSummaryReportType="ProfitAndLossStandard", ReportDateMacro="ThisYear") print(type(g.all())) print(g.all()) pprint.pprint(g.filter("ColData").all())