Esempio n. 1
0
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()
Esempio n. 2
0
def extractAmount(row):
    amount = row[3].internal_value
    if (myString.isEmpty(amount)):
        return None
    amount = amount.replace(',', '')
    credit = amount[1:len(amount)]
    return credit
Esempio n. 3
0
 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
Esempio n. 4
0
 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)
Esempio n. 5
0
 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
Esempio n. 6
0
 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
Esempio n. 7
0
 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)
Esempio n. 8
0
 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
Esempio n. 9
0
    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
Esempio n. 10
0
 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
Esempio n. 11
0
 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
Esempio n. 12
0
    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
Esempio n. 13
0
    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
Esempio n. 14
0
 def formatDate(self, dateString):
     if (myString.isEmpty(dateString)):
         return None
     date = datetime.strptime(dateString,
                              '%d/%m/%y').date().strftime("%Y-%m-%d")
     return date
Esempio n. 15
0
def onMonthSelected(month, filter, newCategory):
    if newCategory is not None and myString.isEmpty(newCategory):
        addCategory(newCategory)
    return updatePieChart(month, filter)
Esempio n. 16
0
 def isMonthlyTotal(self, row):
     businessName = self.extractBusinessName(row)
     return myString.isEmpty(businessName)
Esempio n. 17
0
 def extractCurrency(self, row):
     amount = row[3]
     if (myString.isEmpty(amount)):
         return None
     currency = amount[0:1]
     return currency