Specify compte_de_cheques/

This commit is contained in:
Benjamin Loison 2024-10-03 17:36:07 +02:00
parent f090374caf
commit ee6e850174
Signed by: Benjamin_Loison
SSH Key Fingerprint: SHA256:BtnEgYTlHdOg1u+RmYcDE0mnfz1rhv5dSbQ2gyxW8B8

View File

@ -9,7 +9,7 @@ import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
from datetime import datetime
path = f'/home/benjamin/Desktop/bens_folder/bazaar/documents/bnp/bank_statements/'
path = f'/home/benjamin/Desktop/bens_folder/bazaar/documents/bnp/bank_statements/compte_de_cheques/'
os.chdir(path)
@ -45,12 +45,11 @@ firstDatetime = None
lastDatetime = None
for folder in sorted(os.listdir()):
for file in sorted(os.listdir(folder)):
#folder = '2022'
#file = '20220321.pdf'
filePath = f'{folder}/{file}'
print(filePath)
currentDatetime = getDatetime(file)
if firstDatetime is None:
firstDatetime = file
firstDatetime = currentDatetime
content = getTextFromPdf(filePath)
lines = content.splitlines()
started = False
@ -86,7 +85,6 @@ for folder in sorted(os.listdir()):
totalMonthlyDebits += [totalMonthlyDebit]
totalMonthlyCredits += [totalMonthlyCredit]
totalMonthlyDifference = totalMonthlyCredit - totalMonthlyDebit
#print(totalMonthlyDifference)
totalMonthlyDifferences += [totalMonthlyDifference]
break
if firstLineOfPaymentRegex.match(line) is not None:
@ -102,7 +100,7 @@ for folder in sorted(os.listdir()):
comment += [line]
#break
#break
lastDatetime = file
lastDatetime = getDatetime(file)
fig, ax = plt.subplots()
plt.title('Monthly debits and credits')
@ -110,15 +108,14 @@ plt.xlabel('Date')
plt.ylabel('')
ALPHA = 0.5
def getMonthIndex(aDatetimeStr):
aDatetime = datetime.strptime(aDatetimeStr, '%Y%m%d.pdf')
def getDatetime(aDatetimeStr):
return datetime.strptime(aDatetimeStr, '%Y%m%d.pdf')
def getMonthIndex(aDatetime):
return aDatetime.year * 12 + aDatetime.month
xTicks = range(getMonthIndex(firstDatetime), getMonthIndex(lastDatetime) + 1)
# sign does not seem respected for `totalMonthlyDifferences`.
#print(totalMonthlyDifferences)
#print(f'{min(totalMonthlyDifferences)}')
#print(f'{max(totalMonthlyDifferences)}')
totalMonthlyAmountAndLabel = (
#(totalMonthlyDebits, 'Debit'),
#(totalMonthlyCredits, 'Credit'),
@ -129,7 +126,6 @@ for totalMonthlyAmount, totalMonthlyLabel in totalMonthlyAmountAndLabel:
plt.bar(xTicks, totalMonthlyAmount, alpha = ALPHA, label = totalMonthlyLabel)
plt.legend()
# Hides negative
#plt.yscale('symlog')
ax.yaxis.set_major_formatter(ticker.StrMethodFormatter('{x:,}'))