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