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