Consider last transaction
This commit is contained in:
parent
4123118020
commit
9eed49c344
@ -10,7 +10,7 @@ PATH = f'/home/benjamin/Desktop/bens_folder/bazaar/documents/bnp/bank_statements
|
||||
|
||||
os.chdir(PATH)
|
||||
|
||||
PRINT_TRANSACTIONS = False
|
||||
PRINT_TRANSACTIONS = True
|
||||
|
||||
MAIN_BANK_ACCOUNT = 'compte_de_cheques'
|
||||
|
||||
@ -22,10 +22,13 @@ for folder in os.listdir():
|
||||
print(folder)
|
||||
for file in os.listdir(folder):
|
||||
print(file)
|
||||
fileDatetime = getDatetimeFromFileName(file)
|
||||
print(fileDatetime)
|
||||
#otherBankAccountsCredits[fileDatetime] = otherBankAccountsCredits.get(fileDatetime, 0) +
|
||||
filePath = f'{folder}/{file}'
|
||||
initialAmount, totalMonthlyDebit, totalMonthlyCredit, transactions, fileDatetime = readPdfBankStatement(filePath)
|
||||
print(totalMonthlyCredit)
|
||||
print(transactions)
|
||||
otherBankAccountsCredits[fileDatetime] = otherBankAccountsCredits.get(fileDatetime, 0) + totalMonthlyCredit
|
||||
|
||||
#exit(1)
|
||||
os.chdir(f'{MAIN_BANK_ACCOUNT}/')
|
||||
|
||||
totalMonthlyDebits = []
|
||||
@ -45,13 +48,14 @@ for folder in sorted(os.listdir()):
|
||||
print(f'Total monthly debit: {totalMonthlyDebit}')
|
||||
print(f'Total monthly credit: {totalMonthlyCredit}')
|
||||
totalMonthlyDebits += [totalMonthlyDebit]
|
||||
totalMonthlyCredit += otherBankAccountsCredits.get(fileDatetime, 0)
|
||||
totalMonthlyCredits += [totalMonthlyCredit]
|
||||
totalMonthlyDifference = totalMonthlyCredit - totalMonthlyDebit
|
||||
totalMonthlyDifferences += [totalMonthlyDifference]
|
||||
if PRINT_TRANSACTIONS:
|
||||
for transaction in transactions:
|
||||
print(transaction['date'], transaction['valeur'], transaction['amount'], transaction['currentAmount'])
|
||||
print('\n'.join(transaction['comment']))
|
||||
print(transaction['comment'])
|
||||
print()
|
||||
if firstDatetime is None:
|
||||
firstDatetime = fileDatetime
|
||||
|
13
utils.py
13
utils.py
@ -63,11 +63,9 @@ def readPdfBankStatement(filePath):
|
||||
else:
|
||||
totalMonthlyCredit = toFloat(TOTAL_DES_OPERATIONS_CREDIT_ONLY_REGEX.match(line).group(1))
|
||||
totalMonthlyDebit = 0
|
||||
#if os.getcwd().endswith(f'/{MAIN_BANK_ACCOUNT}'):
|
||||
# totalMonthlyCredit += otherBankAccountsCredits[fileDatetime]
|
||||
|
||||
break
|
||||
if FIRST_LINE_OF_PAYMENT_REGEX.match(line) is not None:
|
||||
#print(line)
|
||||
if date is not None:
|
||||
transactions += [{
|
||||
'date': date,
|
||||
@ -76,10 +74,19 @@ def readPdfBankStatement(filePath):
|
||||
'currentAmount': currentAmount,
|
||||
'comment': '\n'.join(comment)
|
||||
}]
|
||||
date = None
|
||||
date, valeur, amount = line.split()
|
||||
amount = float(amount.replace(',', '.'))
|
||||
currentAmount -= amount
|
||||
comment = []
|
||||
else:
|
||||
comment += [line]
|
||||
if date is not None:
|
||||
transactions += [{
|
||||
'date': date,
|
||||
'valeur': valeur,
|
||||
'amount': amount,
|
||||
'currentAmount': currentAmount,
|
||||
'comment': '\n'.join(comment)
|
||||
}]
|
||||
return initialAmount, totalMonthlyDebit, totalMonthlyCredit, transactions, fileDatetime
|
Loading…
Reference in New Issue
Block a user