mirror of
https://github.com/bcomsugi/dasaproject.git
synced 2026-01-10 00:52:37 +07:00
exim updated
This commit is contained in:
parent
e66a26a98d
commit
b4c3df0813
@ -345,7 +345,7 @@ class InvoiceAdd(baseQBQuery):
|
|||||||
self.qbdictlist.append(self.QBDict.copy())
|
self.qbdictlist.append(self.QBDict.copy())
|
||||||
del self.QBDict[self.__class__.__name__]
|
del self.QBDict[self.__class__.__name__]
|
||||||
self.QBDict[self.classNameRq]=self.qbdictlist
|
self.QBDict[self.classNameRq]=self.qbdictlist
|
||||||
pprint.pprint(self.QBDict, sort_dicts=False)
|
# pprint.pprint(self.QBDict, sort_dicts=False)
|
||||||
|
|
||||||
|
|
||||||
def create_data(self, kwargs):
|
def create_data(self, kwargs):
|
||||||
@ -590,8 +590,8 @@ class InvoiceAdd(baseQBQuery):
|
|||||||
self.QBDict[self.classNameRq]["IncludeRetElement"]=kwargs['IncludeRetElement']
|
self.QBDict[self.classNameRq]["IncludeRetElement"]=kwargs['IncludeRetElement']
|
||||||
|
|
||||||
# print(self.classNameRq)
|
# print(self.classNameRq)
|
||||||
print('self.QBDICT')
|
# print('self.QBDICT')
|
||||||
pprint.pprint(self.QBDict, sort_dicts=False)
|
# pprint.pprint(self.QBDict, sort_dicts=False)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -75,7 +75,7 @@ class baseQBQuery:
|
|||||||
# }
|
# }
|
||||||
# }
|
# }
|
||||||
firstKey = str(list(self.QBDict.keys())[0])
|
firstKey = str(list(self.QBDict.keys())[0])
|
||||||
print(f'{firstKey = } {self.QBDict}')
|
# print(f'{firstKey = } {self.QBDict}')
|
||||||
dataDict["?qbxml"]["QBXML"] = {"QBXMLMsgsRq": { ### Example with multiple FullName Item ###
|
dataDict["?qbxml"]["QBXML"] = {"QBXMLMsgsRq": { ### Example with multiple FullName Item ###
|
||||||
"@onError": self.onError,
|
"@onError": self.onError,
|
||||||
firstKey: self.QBDict[firstKey]}}
|
firstKey: self.QBDict[firstKey]}}
|
||||||
|
|||||||
48
exim.py
48
exim.py
@ -20,7 +20,7 @@ def timer(func):
|
|||||||
result = func(*args, **kwargs)
|
result = func(*args, **kwargs)
|
||||||
duration = time.time() - start
|
duration = time.time() - start
|
||||||
total += duration
|
total += duration
|
||||||
print(f"Execution time: {duration} Total: {total}")
|
print(f"Function:{func.__name__} Execution time: {duration} Total: {total}")
|
||||||
return result
|
return result
|
||||||
|
|
||||||
total = 0
|
total = 0
|
||||||
@ -269,7 +269,7 @@ def process_data(iq_list, so_dict):
|
|||||||
is_inv_so_line_ok = False
|
is_inv_so_line_ok = False
|
||||||
if sorate:
|
if sorate:
|
||||||
if float(inv_line.get('Rate',0))!=float(sorate):
|
if float(inv_line.get('Rate',0))!=float(sorate):
|
||||||
print(f"{inv_line['ItemRef']['FullName'] = } {inv_line['Rate']=} <> {sorate=} ; {float(inv_line.get('Rate',0)) = } {float(sorate) = }")
|
print(f"{txn['RefNumber'] = } {inv_line['ItemRef']['FullName'] = } {inv_line['Rate']=} <> {sorate=} ; {float(inv_line.get('Rate',0)) = } {float(sorate) = }")
|
||||||
is_inv_so_line_ok = False
|
is_inv_so_line_ok = False
|
||||||
# if soamount:
|
# if soamount:
|
||||||
# if float(inv_line.get('Amount',0))!=float(soamount):
|
# if float(inv_line.get('Amount',0))!=float(soamount):
|
||||||
@ -309,7 +309,7 @@ def process_data(iq_list, so_dict):
|
|||||||
# c =next(iter(iq_list))
|
# c =next(iter(iq_list))
|
||||||
# print('TEST RESULT:')
|
# print('TEST RESULT:')
|
||||||
# pprint(c, sort_dicts=False)
|
# pprint(c, sort_dicts=False)
|
||||||
print(f'{len(nolinkInv) = }\n{nolinkInv = }\n{soNotInOneInv = }\n{manuallyClosedSO = }\n{openSO = }\n{len(fullyInvoicedSO) = }')
|
# print(f'{len(nolinkInv) = }\n{nolinkInv = }\n{soNotInOneInv = }\n{manuallyClosedSO = }\n{openSO = }\n{len(fullyInvoicedSO) = }')
|
||||||
c = [item for item in so_list if item not in fullyInvoicedSO]
|
c = [item for item in so_list if item not in fullyInvoicedSO]
|
||||||
print(f'not fuuly invoice, leftover SO: {c}')
|
print(f'not fuuly invoice, leftover SO: {c}')
|
||||||
return iq_list
|
return iq_list
|
||||||
@ -379,16 +379,17 @@ def make_invoiceadd_dict(iq_list):
|
|||||||
invadddict['TemplateRef_FullName'] = inv_line['TemplateRef']['FullName']
|
invadddict['TemplateRef_FullName'] = inv_line['TemplateRef']['FullName']
|
||||||
invadddict['TxnDate'] = inv_line['TxnDate']
|
invadddict['TxnDate'] = inv_line['TxnDate']
|
||||||
invadddict['RefNumber'] = inv_line['RefNumber']
|
invadddict['RefNumber'] = inv_line['RefNumber']
|
||||||
invadddict['BillAddress_Addr1'] = inv_line['BillAddress'].get('Addr1')
|
if 'BillAddress' in inv_line:
|
||||||
invadddict['BillAddress_Addr2'] = inv_line['BillAddress'].get('Addr2')
|
invadddict['BillAddress_Addr1'] = inv_line['BillAddress'].get('Addr1')
|
||||||
invadddict['BillAddress_Addr3'] = inv_line['BillAddress'].get('Addr3')
|
invadddict['BillAddress_Addr2'] = inv_line['BillAddress'].get('Addr2')
|
||||||
invadddict['BillAddress_Addr4'] = inv_line['BillAddress'].get('Addr4')
|
invadddict['BillAddress_Addr3'] = inv_line['BillAddress'].get('Addr3')
|
||||||
invadddict['BillAddress_Addr5'] = inv_line['BillAddress'].get('Addr5')
|
invadddict['BillAddress_Addr4'] = inv_line['BillAddress'].get('Addr4')
|
||||||
invadddict['BillAddress_City'] = inv_line['BillAddress'].get('City')
|
invadddict['BillAddress_Addr5'] = inv_line['BillAddress'].get('Addr5')
|
||||||
invadddict['BillAddress_State'] = inv_line['BillAddress'].get('State')
|
invadddict['BillAddress_City'] = inv_line['BillAddress'].get('City')
|
||||||
invadddict['BillAddress_PostalCode'] = inv_line['BillAddress'].get('PostalCode')
|
invadddict['BillAddress_State'] = inv_line['BillAddress'].get('State')
|
||||||
invadddict['BillAddress_Country'] = inv_line['BillAddress'].get('Country')
|
invadddict['BillAddress_PostalCode'] = inv_line['BillAddress'].get('PostalCode')
|
||||||
invadddict['BillAddress_Note'] = inv_line['BillAddress'].get('Note')
|
invadddict['BillAddress_Country'] = inv_line['BillAddress'].get('Country')
|
||||||
|
invadddict['BillAddress_Note'] = inv_line['BillAddress'].get('Note')
|
||||||
if 'ShipAddress' in inv_line:
|
if 'ShipAddress' in inv_line:
|
||||||
invadddict['ShipAddress_Addr1'] = inv_line['ShipAddress'].get('Addr1')
|
invadddict['ShipAddress_Addr1'] = inv_line['ShipAddress'].get('Addr1')
|
||||||
invadddict['ShipAddress_Addr2'] = inv_line['ShipAddress'].get('Addr2')
|
invadddict['ShipAddress_Addr2'] = inv_line['ShipAddress'].get('Addr2')
|
||||||
@ -402,7 +403,8 @@ def make_invoiceadd_dict(iq_list):
|
|||||||
invadddict['ShipAddress_Note'] = inv_line['ShipAddress'].get('Note')
|
invadddict['ShipAddress_Note'] = inv_line['ShipAddress'].get('Note')
|
||||||
if inv_line.get('PONumber'):
|
if inv_line.get('PONumber'):
|
||||||
invadddict['PONumber'] = inv_line.get('PONumber')
|
invadddict['PONumber'] = inv_line.get('PONumber')
|
||||||
invadddict['TermsRef_FullName'] = inv_line['TermsRef']['FullName']
|
if 'TermsRef' in inv_line:
|
||||||
|
invadddict['TermsRef_FullName'] = inv_line['TermsRef']['FullName']
|
||||||
invadddict['DueDate'] = inv_line['DueDate']
|
invadddict['DueDate'] = inv_line['DueDate']
|
||||||
if 'SalesRepRef' in inv_line:
|
if 'SalesRepRef' in inv_line:
|
||||||
invadddict['SalesRepRef_FullName'] = inv_line['SalesRepRef']['FullName']
|
invadddict['SalesRepRef_FullName'] = inv_line['SalesRepRef']['FullName']
|
||||||
@ -456,7 +458,9 @@ def make_invoiceadd_dict(iq_list):
|
|||||||
invoiceaddlist.append(invadddict)
|
invoiceaddlist.append(invadddict)
|
||||||
|
|
||||||
# pprint(invadddict, sort_dicts=False)
|
# pprint(invadddict, sort_dicts=False)
|
||||||
pprint(invoiceaddlist, sort_dicts=False)
|
|
||||||
|
# pprint(invoiceaddlist, sort_dicts=False)
|
||||||
|
|
||||||
for x in invoiceaddlist:
|
for x in invoiceaddlist:
|
||||||
if '10671' in x['RefNumber']:
|
if '10671' in x['RefNumber']:
|
||||||
pprint(x, sort_dicts=False)
|
pprint(x, sort_dicts=False)
|
||||||
@ -527,6 +531,7 @@ def get_last_date_of_month(stryearmonth:str):
|
|||||||
|
|
||||||
return f"{datesplit[0]}-{datesplit[1]}-{str(res.day)}"
|
return f"{datesplit[0]}-{datesplit[1]}-{str(res.day)}"
|
||||||
|
|
||||||
|
@timer
|
||||||
def main(fromtxndate, totxndate, maxreturned:int=None):
|
def main(fromtxndate, totxndate, maxreturned:int=None):
|
||||||
# print(timeit.repeat(process, repeat=1))
|
# print(timeit.repeat(process, repeat=1))
|
||||||
# process()
|
# process()
|
||||||
@ -564,14 +569,19 @@ def main(fromtxndate, totxndate, maxreturned:int=None):
|
|||||||
|
|
||||||
if __name__=='__main__':
|
if __name__=='__main__':
|
||||||
# print(np.arange('2021-02', '2021-03', dtype='datetime64[D]'))
|
# print(np.arange('2021-02', '2021-03', dtype='datetime64[D]'))
|
||||||
fromtxndate = '2022-07-02'
|
fromtxndate = '2024-07-01'
|
||||||
totxndate = get_last_date_of_month(fromtxndate)
|
totxndate = get_last_date_of_month(fromtxndate)
|
||||||
_fromdate = datetime.datetime.fromisoformat(fromtxndate)
|
_fromdate = datetime.datetime.fromisoformat(fromtxndate)
|
||||||
|
|
||||||
print(fromtxndate)
|
print(fromtxndate)
|
||||||
readydata = main(fromtxndate, totxndate, 2)
|
|
||||||
|
readydata = main(fromtxndate, totxndate)
|
||||||
# pprint(readydata, sort_dicts=False)
|
# pprint(readydata, sort_dicts=False)
|
||||||
|
|
||||||
IA = InvoiceAdd(*readydata, debug=True)
|
IA = InvoiceAdd(*readydata, debug=False)
|
||||||
print(IA.create_QBXML())
|
# print(IA.create_QBXML())
|
||||||
|
filename = f'exim\Data\{fromtxndate}_qbxml.txt'
|
||||||
|
|
||||||
|
with open(f"{filename}", "w") as outfile:
|
||||||
|
outfile.write(IA.create_QBXML())
|
||||||
# IA.all()
|
# IA.all()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user