from QBClasses import SalesOrderQuery, InvoiceQuery, TransactionQuery from utils import timing, makeAList, makeLinkedTxnList from pprint import pprint, PrettyPrinter # h1="17b2d5" # h2="17b2c1" # res = int(h2,16)-int(h1,16) # print(res, type(res), hex(res)[2:]) # print(h11: is_soRefNumber_duplicated=True print(f"there is duplicate in one of there refnumbers:{sorefNumber=}") raise Exception(f"there is duplicate in one of there refnumbers:{sorefNumber=}") break print(f'{checkduplicateRefNumber.count() = }') if is_soRefNumber_duplicated: return #prepare SOOrders to be a list of dict soorders = SOOrders.all() if isinstance(soorders, dict): soorders=[soorders] #start comparing inv to so line by line invLineRets = InvoiceLineRet[0].get('InvoiceLineRet') for invLineRet in invLineRets: FullName_inv = invLineRet['ItemRef']['FullName'] TxnLineID_inv = invLineRet['TxnLineID'] Quantity_inv = invLineRet['Quantity'] UnitOfMeasure_inv = invLineRet['UnitOfMeasure'] OverrideUOMSetRef_inv = invLineRet['OverrideUOMSetRef']['FullName'] Rate_inv = invLineRet['Rate'] Amount_inv = invLineRet['Amount'] for soorder in soorders: pass TxnID_so = soorder['TxnID'] RefNumber_so = soorder['RefNumber'] IsFullyInvoiced_so = soorder['IsFullyInvoiced'] IsManuallyClosed_so = soorder['IsManuallyClosed'] SalesOrderLineRet_so = soorder['SalesOrderLineRet'] LinkedTxn_so = soorder['LinkedTxn'] #prepare SalesOrderLineRet to be a list of dict if isinstance(SalesOrderLineRet_so, dict): SalesOrderLineRet_so = [SalesOrderLineRet_so] # print(f'{SalesOrderLineRet_so = }') for soLineRet_idx, soLineRet in enumerate(SalesOrderLineRet_so): # print(soLineRet_idx, soLineRet) print(f"{soLineRet_idx} {soLineRet.get('checked', False) = }") if soLineRet.get('checked', False): # if can find checked key and not True, then skip next soLineRet # print(soLineRet_idx,"continue") continue print(f'{soLineRet_idx = }->{soLineRet}') FullName_so = soLineRet['ItemRef']['FullName'] TxnLineID_so = soLineRet['TxnLineID'] Quantity_so = soLineRet['Quantity'] UnitOfMeasure_so = soLineRet['UnitOfMeasure'] OverrideUOMSetRef_so = soLineRet['OverrideUOMSetRef']['FullName'] Rate_so = soLineRet['Rate'] Amount_so = soLineRet['Amount'] Invoiced_so = soLineRet.get('Invoiced',0) IsManuallyClosed_so = soLineRet['IsManuallyClosed'] SalesOrderLineRet_so[soLineRet_idx]['checked']=True # break only if match with invlineret==solineret # pprint(solineret, sort_dicts=False) # pprint(SOOrders.all(), sort_dicts=False) # pprint(invQ.all()) print(f'{SOOrders.count() = }') if __name__=='__main__': # main() if True: print("trueeee"); print("again") print("before") if True else 0 d={'a':""} if d['a']: print("Ada") else: print('Tak ada') main()