WIP gather all transactions over bank accounts

This commit is contained in:
Benjamin Loison 2024-10-03 21:33:38 +02:00
parent 046835064d
commit 9e8de4b4c7
Signed by: Benjamin_Loison
SSH Key Fingerprint: SHA256:BtnEgYTlHdOg1u+RmYcDE0mnfz1rhv5dSbQ2gyxW8B8

View File

@ -19,18 +19,29 @@ credits_ = []
# Precise bank account
allTransactions = []
def appendTransactions()
'''
def appendTransactions(x):
global allTransactions
allTransactions += [x]
'''
def appendTransactions(transactions, bankAccount):
global allTransactions
#print('Before')
#pprint(allTransactions)
for transaction in transactions:
transaction['bank account'] = bankAccount
allTransactions += [transaction]
#print('After')
#pprint(allTransactions)
for folder in os.listdir():
if folder != MAIN_BANK_ACCOUNT:
print(folder)
for file in os.listdir(folder):
print(file)
filePath = f'{folder}/{file}'
_initialAmount, _totalMonthlyDebit, _totalMonthlyCredit, transactions, fileDatetime = readPdfBankStatement(filePath)
for transaction in transactions:
transaction['bank account'] = folder
allTransactions += [transaction]
print(filePath)
transactions = readPdfBankStatement(filePath)[3]
appendTransactions(transactions, folder)
#exit(1)
os.chdir(f'{MAIN_BANK_ACCOUNT}/')
@ -39,16 +50,19 @@ for folder in sorted(os.listdir()):
for file in sorted(os.listdir(folder)):
filePath = f'{folder}/{file}'
print(filePath)
initialAmount, totalMonthlyDebit, totalMonthlyCredit, transactions, fileDatetime = readPdfBankStatement(filePath)
for transaction in transactions:
transaction['bank account'] = MAIN_BANK_ACCOUNT
allTransactions += [transaction]
transactions = readPdfBankStatement(filePath)[3]
appendTransactions(transactions, MAIN_BANK_ACCOUNT)
if PRINT_TRANSACTIONS:
for transaction in transactions:
printTransaction(transaction)
#break
#break
lastDatetime = getDatetimeFromFileName(file)
from pprint import pprint
#pprint(transactions)
pprint(allTransactions)
exit(0)
fig, ax = plt.subplots()
plt.title('Monthly debits and credits')