def processRow(row, date): for cell in row: print(cell.internal_value) #date = ; #replace = ; #refID = ; purchaseDate = extractDate(row) reportDate = date.strftime("%Y-%m-%d") businessName = row[1].internal_value amount = extractAmount(row) comment = row[4].internal_value #entry = BankEntry(date,action,"7872","",amount,"") bankId = "8547" if (myString.isEmpty(businessName)): handleTotal(amount, bankId) businessName = "__TOTAL__" business = BusinessEntry.selectBy(businessName=businessName).getOne(None) if (business == None): business = BusinessEntry(businessName=businessName, marketingName=businessName, category="") entry = CreditEntry(reportDate=reportDate, purchaseDate=purchaseDate, business=business.id, cardNumber="7872", bankId="8547", credit=0, debit=amount, balance=0) entry.toCSV()
def extractAmount(row): amount = row[3].internal_value if (myString.isEmpty(amount)): return None amount = amount.replace(',', '') credit = amount[1:len(amount)] return credit
def extractAmount(self, row): amount = str(row[6].internal_value) if myString.isEmpty(amount): return None amount = amount.replace(',', '') #credit = amount[1:len(amount)] credit = float(amount) return credit
def extractDebit(self, row): # In the leumi files, the debit is in a td with class=AmountDebitUniqeClass data = myString.strip( row.find("td", {"class": "AmountDebitUniqeClass"})).replace(',', '') if (myString.isEmpty(data)): return None return Decimal(data)
def extractAmount(self, row): amount = row[3] if (myString.isEmpty(amount)): return None amount = amount.replace(',', '') creditStr = amount[1:len(amount)] credit = float(creditStr) return credit
def extractPurchaseDate(self, row): dateString = str(row[0].internal_value) if (myString.isEmpty(dateString)): return None try: date = datetime.strptime( dateString, '%Y-%m-%d %H:%M:%S').date().strftime("%Y-%m-%d") except: date = None return date
def extractBalance(self, row): # In the leumi files, the balance is in a td with class=number_column # There are 3 such td in each row: debit, credit, balance. Balance is always the 3rd. totals = row.find_all("td", {"class": "number_column"}) total = "" if (len(totals) > 1): total = myString.strip(totals[2]).replace(',', '') if (myString.isEmpty(total)): return None return Decimal(total)
def extractReportDate(self, row): dateString = row['תאריך חיוב'] if (myString.isEmpty(dateString)): return None try: date = datetime.strptime(dateString, '%d/%m/%Y').date().strftime("%Y-%m-%d") except: date = None return date
def extractDate(self, row): # In the leumi files, the date is in a td with class=ExtendedActivityColumnDate dateString = myString.strip( row.find("td", {"class": "ExtendedActivityColumnDate"})) if (myString.isEmpty(dateString)): return None date = datetime.strptime(dateString, '%d/%m/%y').date().strftime("%Y-%m-%d") return date
def extractPurchaseDate(self, row): dateString = row[0] if (myString.isEmpty(dateString)): return None try: date = datetime.strptime(dateString, '%d/%m/%Y').date().strftime("%Y-%m-%d") except: date = None return date
def extractReportDate(self, row): dateString = self.getValue(row, 9) if (myString.isEmpty(dateString)): return None try: date = datetime.strptime(dateString, '%d/%m/%Y').date().strftime("%Y-%m-%d") except: date = None return date
def processRow(self, row): date = self.extractDate(row) businessName = self.extractBusiness(row) refId = self.extractRefId(row) credit = self.extractCredit(row) debit = self.extractDebit(row) balance = self.extractBalance(row) if (myString.isEmpty(date)): return None business = self.getBusinessEntry(businessName) entry = BankEntry(date=date, business=business.id, hide=0, refId=refId, credit=credit, debit=debit, balance=balance, trackerId=0, userId=session.getUserId()) entry.toCSV( ) # for debugging, find a better way to log only when in debug mode return entry
def processRow(self, row): date = self.extractDate(row) action = self.extractAction(row) refId = self.extractRefId(row) credit = self.extractCredit(row) debit = self.extractDebit(row) balance = self.extractBalance(row) if (myString.isEmpty(date)): return None business = BusinessEntry.selectBy(businessName=action).getOne(None) if (business == None): business = BusinessEntry(businessName=action, marketingName=action, category="") entry = BankEntry(date=date, business=business.id, hide=0, refId=refId, credit=credit, debit=debit, balance=balance) return entry
def formatDate(self, dateString): if (myString.isEmpty(dateString)): return None date = datetime.strptime(dateString, '%d/%m/%y').date().strftime("%Y-%m-%d") return date
def onMonthSelected(month, filter, newCategory): if newCategory is not None and myString.isEmpty(newCategory): addCategory(newCategory) return updatePieChart(month, filter)
def isMonthlyTotal(self, row): businessName = self.extractBusinessName(row) return myString.isEmpty(businessName)
def extractCurrency(self, row): amount = row[3] if (myString.isEmpty(amount)): return None currency = amount[0:1] return currency