mirror of
https://github.com/bcomsugi/Quickbooks-API.git
synced 2026-01-10 02:02:38 +07:00
add SalesOrderQuery Class
This commit is contained in:
parent
7ba1611a1d
commit
26e1cd2bbc
87
QBClasses.py
87
QBClasses.py
@ -366,12 +366,92 @@ class TransactionQuery(baseQBQuery):
|
|||||||
self.runCheck() ### running the qbxml connection to get data ###
|
self.runCheck() ### running the qbxml connection to get data ###
|
||||||
|
|
||||||
|
|
||||||
|
class SalesOrderQuery(baseQBQuery):
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
print(f'{args = }')
|
||||||
|
print(f'{kwargs = }')
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
### Required Variable
|
||||||
|
self.includeRetElements_allowed = ["TxnID", "TimeCreated", "TimeModified", "EditSequence", "TxnNumber", "CustomerRef", "ClassRef", "TemplateRef",
|
||||||
|
"TxnDate", "RefNumber", "BillAddress", "BillAddressBlock", "ShipAddress", "ShipAddressBlock", "PONumber,", "TermsRef", "DueDate",
|
||||||
|
"SalesRefRef", "FOB", "ShipDate", "ShipMethodRef", "SubTotal", "ItemSalesTaxRef", "SalesTaxPercentage", "SalesTaxTotal", "TotalAmount",
|
||||||
|
"CurrencyRef", "ExchangeRate", "TotalAmountInHomeCurrency", "IsManuallyClosed", "IsFullyInvoiced", "Memo", "CustomerMsgRef", "IsToBePrinted",
|
||||||
|
"IsToBeEmailed", "IsTaxIncluded", "CustomerSalesTaxCodeRef", "Other", "ExternalGUID", "LinkedTxn", "SalesOrderLineRet", "SalesOrderLineGroupRet"
|
||||||
|
]
|
||||||
|
self.onError = "stopOnError"
|
||||||
|
self.retName = 'SalesOrderRet'
|
||||||
|
self.defaultFilterKey = "TxnID"
|
||||||
|
if 'debug' in kwargs and isinstance(kwargs['debug'], bool):
|
||||||
|
self.class_debug=kwargs["debug"]
|
||||||
|
|
||||||
|
self.QBDict[self.__class__.__name__ + "Rq"]={}
|
||||||
|
### End Required Variable. can put ENUM list below this (eg: self.ENUM_GeneralSummaryReportQuery=[])
|
||||||
|
|
||||||
|
if 'TxnID' in kwargs:
|
||||||
|
self.QBDict[self.__class__.__name__ + "Rq"]["TxnID"]=kwargs['TxnID']
|
||||||
|
elif 'RefNumber' in kwargs:
|
||||||
|
self.QBDict[self.__class__.__name__ + "Rq"]["RefNumber"]=kwargs['RefNumber']
|
||||||
|
elif 'RefNumberCaseSensitive' in kwargs:
|
||||||
|
self.QBDict[self.__class__.__name__ + "Rq"]["RefNumberCaseSensitive"]=kwargs['RefNumberCaseSensitive']
|
||||||
|
else:
|
||||||
|
if 'MaxReturned' in kwargs:
|
||||||
|
self.QBDict[self.__class__.__name__ + "Rq"]["MaxReturned"]=kwargs['MaxReturned']
|
||||||
|
if 'ModifiedDateRangeFilter_FromModifiedDate' in kwargs or 'ModifiedDateRangeFilter_ToModifiedDate' in kwargs: #if or then use {'key1':kwargs.get('key1',""), 'key2':kwargs.get('key2', "")}
|
||||||
|
self.QBDict[self.__class__.__name__ + "Rq"]["ModifiedDateRangeFilter"]={'FromModifiedDate':kwargs.get('ModifiedDateRangeFilter_FromModifiedDate', ""), 'ToModifiedDate':kwargs.get('ModifiedDateRangeFilter_ToModifiedDate', "")}
|
||||||
|
elif 'TxnDateRangeFilter_FromTxnDate' in kwargs or 'TxnDateRangeFilter_ToTxnDate' in kwargs: #if or then use {'key1':kwargs.get('key1',""), 'key2':kwargs.get('key2', "")}
|
||||||
|
self.QBDict[self.__class__.__name__ + "Rq"]["TxnDateRangeFilter"]={'FromTxnDate':kwargs.get('TxnDateRangeFilter_FromTxnDate', ""), 'ToTxnDate':kwargs.get('TxnDateRangeFilter_ToTxnDate', "")}
|
||||||
|
elif 'TxnDateRangeFilter_DateMacro' in kwargs:
|
||||||
|
self.QBDict[self.__class__.__name__ + "Rq"]["TxnDateRangeFilter"]={'DateMacro':kwargs['TxnDateRangeFilter_DateMacro']}
|
||||||
|
|
||||||
|
if 'EntityFilter_ListID' in kwargs:
|
||||||
|
self.QBDict[self.__class__.__name__ + "Rq"]["EntityFilter"]={'ListID':kwargs['EntityFilter_ListID']}
|
||||||
|
elif 'EntityFilter_FullName' in kwargs:
|
||||||
|
self.QBDict[self.__class__.__name__ + "Rq"]["EntityFilter"]={'FullName':kwargs['EntityFilter_FullName']}
|
||||||
|
elif 'EntityFilter_ListIDWithChildren' in kwargs:
|
||||||
|
self.QBDict[self.__class__.__name__ + "Rq"]["EntityFilter"]={'ListIDWithChildren':kwargs['EntityFilter_ListIDWithChildren']}
|
||||||
|
elif 'EntityFilter_FullNameWithChildren' in kwargs:
|
||||||
|
self.QBDict[self.__class__.__name__ + "Rq"]["EntityFilter"]={'FullNameWithChildren':kwargs['EntityFilter_FullNameWithChildren']}
|
||||||
|
|
||||||
|
if 'RefNumberFilter_MatchCriterion' in kwargs and 'RefNumberFilter_RefNumber' in kwargs:
|
||||||
|
self.QBDict[self.__class__.__name__ + "Rq"]["RefNumberFilter"]={'MatchCriterion':kwargs['RefNumberFilter_MatchCriterion', 'RefNumber':kwargs['RefNumberFilter_RefNumber']]}
|
||||||
|
elif 'RefNumberRangeFilter_FromRefNumber' in kwargs or 'RefNumberRangeFilter_ToRefNumber' in kwargs: #if or then use {'key1':kwargs.get('key1',""), 'key2':kwargs.get('key2', "")}
|
||||||
|
self.QBDict[self.__class__.__name__ + "Rq"]["RefNumberRangeFilter"]={'FromRefNumber':kwargs.get('RefNumberRangeFilter_FromRefNumber', ""), 'ToRefNumber':kwargs.get('RefNumberRangeFilter_ToRefNumber', "")}
|
||||||
|
|
||||||
|
if 'CurrencyFilter_ListID' in kwargs:
|
||||||
|
self.QBDict[self.__class__.__name__ + "Rq"]["CurrencyFilter"]=kwargs['CurrencyFilter_ListID']
|
||||||
|
elif 'CurrencyFilter_FullName' in kwargs:
|
||||||
|
self.QBDict[self.__class__.__name__ + "Rq"]["CurrencyFilter"]=kwargs['CurrencyFilter_FullName']
|
||||||
|
|
||||||
|
if 'IncludeLineItems' in kwargs:
|
||||||
|
self.QBDict[self.__class__.__name__ + "Rq"]["IncludeLineItems"]=kwargs['IncludeLineItems']
|
||||||
|
if 'IncludeLinkedTxns' in kwargs:
|
||||||
|
self.QBDict[self.__class__.__name__ + "Rq"]["IncludeLinkedTxns"]=kwargs['IncludeLinkedTxns']
|
||||||
|
if 'IncludeRetElement' in kwargs:
|
||||||
|
IRE = cleanIncludeRetElements(self.includeRetElements_allowed, kwargs["IncludeRetElement"]) # IRE->IncludeRetElements cleaned version
|
||||||
|
print(f"{IRE = }")
|
||||||
|
if len(IRE)>0:
|
||||||
|
if self.defaultFilterKey not in IRE: # defaultFilterKey is for BaseClass.count() eg: after instantiate, then print obj.count()
|
||||||
|
IRE.append(self.defaultFilterKey)
|
||||||
|
self.QBDict[self.__class__.__name__ + "Rq"]["IncludeRetElement"]=IRE
|
||||||
|
|
||||||
|
if 'OwnerID' in kwargs: # usually value=0 to get to DataExtRet (additional data)
|
||||||
|
self.QBDict[self.__class__.__name__ + "Rq"]["OwnerID"]=kwargs['OwnerID']
|
||||||
|
|
||||||
|
# print(self.__class__.__name__ + "Rq")
|
||||||
|
# print(self.QBDict)
|
||||||
|
self.runCheck() ### running the qbxml connection to get data ###
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
@timing
|
@timing
|
||||||
|
def salesorderquery():
|
||||||
|
g=SalesOrderQuery(debug=False, MaxReturned = 2, EntityFilter_FullName="Abadi Serpong", TxnID="1786D5-1689047665", IncludeLineItems="true", IncludeLinkedTxns="true")
|
||||||
|
print(json.dumps(g.filter().all(), indent=3))
|
||||||
|
print(g.count())
|
||||||
|
@timing
|
||||||
def transactionquery():
|
def transactionquery():
|
||||||
g=TransactionQuery(debug=False, MaxReturned=None, TransactionTypeFilter_TxnTypeFilter="SalesOrder", TransactionEntityFilter_FullName="Abadi Serpong",
|
g=TransactionQuery(debug=False, MaxReturned=None, TransactionTypeFilter_TxnTypeFilter="Invoice", TransactionEntityFilter_FullName="Abadi Serpong",
|
||||||
TransactionDetailLevelFilter="All", TransactionPaidStatusFilter="Open", TransactionDateRangeFilter_DateMacro="LastFiscalYear")
|
TransactionDetailLevelFilter="All", TransactionPaidStatusFilter="Open", TransactionDateRangeFilter_DateMacro="ThisFiscalYear")
|
||||||
# print(g.response_string)
|
# print(g.response_string)
|
||||||
# pprint.pprint({"temp":g.filter(['TxnType', 'TxnID', 'Entityref', 'accountref', 'txndate', 'refnumber'])})
|
# pprint.pprint({"temp":g.filter(['TxnType', 'TxnID', 'Entityref', 'accountref', 'txndate', 'refnumber'])})
|
||||||
# print(json.dumps(g.filter(['TxnType', 'TxnID', 'Entityref', 'accountref', 'refnumber','txndate',"amount" ]).all(), indent=3))
|
# print(json.dumps(g.filter(['TxnType', 'TxnID', 'Entityref', 'accountref', 'refnumber','txndate',"amount" ]).all(), indent=3))
|
||||||
@ -482,7 +562,8 @@ if __name__ == "__main__":
|
|||||||
print(recursiveDict(varDict, f, enumDict))
|
print(recursiveDict(varDict, f, enumDict))
|
||||||
f.close
|
f.close
|
||||||
|
|
||||||
transactionquery()
|
salesorderquery()
|
||||||
|
# transactionquery()
|
||||||
# main()
|
# main()
|
||||||
# iteminventoryquery()
|
# iteminventoryquery()
|
||||||
# customerquery()
|
# customerquery()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user