def getData(transacts,budget): total_spent = total(transacts) spent_per_week = round(total_spent / 52, 2) budget_per_week = round(budget / 52, 2) deficit = round(total_spent + budget, 2) data = {'Total Expenses': total_spent}
def showTags(): for i in range(1, 10): month = str(i) transacts = getTransacts(month, "2019") print(month + " : " + str(total(transacts))) tags = perTag(transacts) print(tags) print(biggestTag(tags))
def createGraphCollection(months): for month in months: transacts = readCSVtoObject(month) tags = perTag(transacts) print(tags) tot = -total(transacts) print("tot : " + str(tot)) max = biggestTag(tags)[1] print("max : " + str(max)) createGraph(tags, month, tot, max, 19)
def createPDF(year): years = str(year)[2:] + "_" + str(year + 1)[2:] file_name = "Yearly Sheet"+years+".pdf" image_path_budget = "images/Budget "+str(year)+".svg" image_path_expenses = "images/Expenses "+str(year)+".svg" document_title = "Balance Sheet "+str(year) title = "Balance Sheet "+str(year) transacts = getExpensesData(year) total_spent = total(transacts) budget = getBudget(year) pdf = canvas.Canvas(file_name) pdf.setTitle(document_title) pdf.setFont("Helvetica-Bold", 30) pdf.drawCentredString(300, 790, title) drawImage(image_path_expenses, pdf, 245, 460, 0.6) drawImage(image_path_budget, pdf, -25, 510,0.5) pdf.setFont("Helvetica-Bold", 18) pdf.drawString(80, 430, "Budget: " + str(budget) + " €") pdf.drawString(320, 430, "Gesamtausgaben: " + str(total_spent) + " €") tags = perTag(transacts) drawCategoryTable(pdf, tags) pdf.line(50,165,530,165) drawBalanceTable(pdf, budget, total_spent, 50, 50) ''' weeks = perWeek(transacts) drawWeeksTable(pdf, weeks, int(month), int(year)) pdf.line(50, 220, 540, 220) budget = getBudgetPerMonth(getBudget(2018)) drawBalanceTable(pdf, budget, total_spent) pdf.setFont("Helvetica-Bold", 22) pdf.drawString(50, 50, "Gesamtausgaben: " + str(total_spent) + " €") ''' pdf.save()
def drawPDF(file,month,year,start_year): years = str(start_year)[2:]+"_"+str(start_year+1)[2:] file_name = "Balance Sheets"+years+"/"+year+"-"+str(month)+".pdf" image_path = file+".svg" document_title = month+" "+year title = monthNumberToMonthName(int(month)-1)+" "+year transacts = readCSVtoObjectExpense(file) total_spent = total(transacts) pdf = canvas.Canvas(file_name) pdf.setTitle(document_title) drawImage(image_path,pdf,-40, 390,0.7) tags = perTag(transacts) drawCategoryTable(pdf,tags) pdf.setFont("Helvetica-Bold", 30) pdf.drawCentredString(300, 780, title) weeks = perWeek(transacts) drawWeeksTable(pdf,weeks,int(month),int(year)) pdf.line(50, 220, 540, 220) try: payback = tags['Rückzahlung'] except KeyError: payback = 0 budget = getBudgetPerMonth(getBudget(int(start_year))) drawBalanceTable(pdf,budget,-total_spent,payback,50,75) pdf.setFont("Helvetica-Bold", 22) pdf.drawString(50,35,"Gesamtausgaben: "+str(-total_spent)+" €") if not ("Balance Sheets"+years in os.listdir()): os.mkdir("Balance Sheets"+years) pdf.save()
def main(): files = defineFiles(2018,".csv") budget = getTotalIncome(files) transacts = readCSVtoObjectExpense(7,"2019") getData(transacts,budget) total_spent = total(transacts)