From 9c93b4de13c4c3542d511dd3bc64d3bb9650165f Mon Sep 17 00:00:00 2001 From: Sugiarto Date: Fri, 2 Feb 2024 20:03:51 +0700 Subject: [PATCH] et-06. fix reading uom with empty column in excel --- pdfexcel4DNwithxlrd.py | 12 ++++++++---- qbpurchaseorderquery.py | 7 +++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/pdfexcel4DNwithxlrd.py b/pdfexcel4DNwithxlrd.py index 23248b8..b561739 100644 --- a/pdfexcel4DNwithxlrd.py +++ b/pdfexcel4DNwithxlrd.py @@ -179,12 +179,9 @@ def read_DN_excel(filename): else: data.append(row) - # print (f'data: {data}') + print (f'data: {data}') for idx, x in enumerate(data): - if x[0].upper() == "ET-06/A1.": ### Change the source from "ET-06/A1." to "ET-06/A1.BOX_100" and replace the UOM from "BOX_100" to "BOX" - x[0] = "ET-06/A1.BOX_100" - x[2] = x[2].replace("BOX_100", "BOX") for colidx, col in enumerate(x): ### change the empty cell into None if col == "": data[idx][colidx]=None @@ -229,6 +226,13 @@ def read_DN_excel(filename): print(f'len data={len(data)}') + for idx, x in enumerate(data): + # print(idx, x) + if x[0] !=None and x[0].upper() == "ET-06/A1.": ### Change the source from "ET-06/A1." to "ET-06/A1.BOX_100" and replace the UOM from "BOX_100" to "BOX" + print(idx, x) + x[0] = "ET-06/A1.BOX_100" + x[2] = x[2].replace("BOX_100", "BOX") + print(idx, x) newdata=[] diff --git a/qbpurchaseorderquery.py b/qbpurchaseorderquery.py index 4be1ef6..cc0b21a 100644 --- a/qbpurchaseorderquery.py +++ b/qbpurchaseorderquery.py @@ -229,6 +229,7 @@ class PurchaseOrderQuery: _bolfoundrefnum=False _bol_dictisadded=False Error_msg = None + for poidx, _po in enumerate(self.PurchaseOrderList): if _po['RefNumber']==_dict['RefNum']: _bolfoundrefnum=True @@ -303,7 +304,9 @@ class PurchaseOrderQuery: else: _dflist = self.dfDN.to_dict('records') # print(self.dfDN) - # print(f'_dflist:{_dflist}') + # print(f'_dflist1:{_dflist}') + # print("") + # print(f'self.PurchaseOrderList: {self.PurchaseOrderList}') for idx, xdf in enumerate(_dflist): _boladdDN, _Errormsg = self.addDNQtyToPurchaseOrderList(xdf) # print(f'prepareItemReceipt->_Errormsg:{_Errormsg}') @@ -341,7 +344,7 @@ class PurchaseOrderQuery: else: dnlist = self.DN df = pd.DataFrame(dnlist) - # print(df) + print(f'df from dnlist: {df}') df['RefNum']= df['No.SO'].apply(lambda x: "L"+ x.split("L-")[1]) # print(df) ext_doc_no=df['RefNum'].unique().tolist()