def f_gen_rep (): f_gen_rep_summary() f_gen_rep_detailed_income () f_gen_rep_detailed_spend () f_gen_rep_detailed_invst () f_monthly_report () n = len(months_list) x_data = [] for i in range(n): x_data.append(misc_utils.split_month(months_list[i].name)) f_gen_charts(x_data, plot_data) f1 = proj_path + "SummaryReport.pdf" f2 = proj_path + "IncomeReport.pdf" f3 = proj_path + "InvestmentReport.pdf" f4 = proj_path + "spendReport.pdf" f5 = proj_path + "Graphs.pdf" f6 = proj_path + "Monthly_analysis.pdf" files_list = [f1,f2,f3,f4,f5,f6] misc_utils.merge_pdf(outname, files_list, logo) for i in range(len(files_list)): system("rm -rf %s" %files_list[i]) system("cp -rf %s %s" %(outname, dest_dir))
def f_gen_rep_detailed_income (): title_name = 'Income Report' subtitle_name = 'Break-up details of Monthly Income' col_headings = ["#", "Month", "Type", "Amount", "Source", "Date"] fields = [] datas = [] file_name = "IncomeReport" data_incm_name = [] data_incm_val = [] data_comment = [] data_dt_of_incm = [] styles = ["bold=True, width=0.3","bold=True, width=0.7","bold=True, width=0.7","money=True, width=0.7", "width=0.7", "width=0.7"] for idx in range(len(months_list)): temp_month = months_list[idx] for keys in add_inc_commands.keys(): incm_name = add_inc_commands[keys] if incm_name == 'SALARY': incm_type = temp_month.ttl_incm.salary elif incm_name == 'DIVIDEND': incm_type = temp_month.ttl_incm.dividend elif incm_name == 'INTEREST': incm_type = temp_month.ttl_incm.interest elif incm_name == 'SHARES': incm_type = temp_month.ttl_incm.share_trxn elif incm_name == 'BONUS': incm_type = temp_month.ttl_incm.bonus else: print "unsupported option" for sub_idx in range(len(incm_type.val)): data_incm_name.append(incm_name) data_incm_val.append(incm_type.val[sub_idx]) data_comment.append(incm_type.src_of_incm[sub_idx]) data_dt_of_incm.append(incm_type.dt_of_incm[sub_idx]) fields.append(misc_utils.split_month(temp_month.name)) datas.append(data_incm_name) datas.append(data_incm_val) datas.append(data_comment) datas.append(data_dt_of_incm) fields.append('TOTAL') # compute the totals datas[0].append("") datas[1].append(sum(datas[1][::-1])) datas[1] = misc_utils.comma_sep(datas[1],1) datas[2].append("") datas[3].append("") #pprint(fields) #pprint(datas) create_reports(fields, fileTypes, title_name, subtitle_name, col_headings, datas, proj_path, file_name, styles)
def f_gen_rep_detailed_invst (): title_name = 'Investments Report' subtitle_name = 'Break-up details of Monthly Investments' col_headings = ["#", "Category"] fields = [] datas = [] file_name = "InvestmentReport" data_invst_val = [] styles = ["bold=True, width=0.15","bold=False, width=0.85"] months_data = [] for keys in add_invst_commands.keys(): invst_name = add_invst_commands[keys] fields.append(invst_name) for idx in range(len(months_list)): m = 0 invst_val = [] temp_month = months_list[idx] for keys in add_invst_commands.keys(): m = m + 1 tmp_invst = temp_month.ttl_investment # Parse the input and take appropriate action eval_str = "tmp_typ = tmp_invst.typ%d" %(m) exec(eval_str) invst_val.append(tmp_typ.total_bal) datas.append(invst_val) col_headings.append(misc_utils.split_month(months_list[idx].name)) styles.append("width=0.5, money=True") fields.append('TOTAL') # compute the totals y_data = [] for j in range(len(datas)): datas[j].append(sum(datas[j][::-1])) y_data.append(datas[j][-1]) horz_total = [] for k in range(len(datas[0])): tmp_sum = 0 for j in range(len(datas)): tmp_sum = tmp_sum + datas[j][k] horz_total.append(tmp_sum) datas = misc_utils.comma_sep(datas,2) #pprint(datas) #pprint(styles) #pprint(col_headings) #pprint(fields) create_reports(fields, fileTypes, title_name, subtitle_name, col_headings, datas, proj_path, file_name, styles)
def f_gen_rep_summary (): title_name = 'Expense Report' subtitle_name = 'Summary of Monthly Expenses' col_headings = ["#", "Month", "Income", "Spend", "Investments"] fields = [] file_name = "SummaryReport" n = len(months_list) months_data = [] styles = ["bold=True, width=0.3","bold=True, width=0.8","money=True, width=0.8","money=True, width=0.8", "money=True, width=0.7"] for idx in range(n): months_data.append(months_list[idx].ttl_incm.total_val) months_data.append(months_list[idx].ttl_spend.total_val) months_data.append(months_list[idx].ttl_investment.total_val) fields.append(misc_utils.split_month(months_list[idx].name)) fields.append('TOTAL') datas = [] y_data = [] for i in [0,1,2]: datas.append([]) y_data.append([]) for i in [0,1,2]: datas[i] = months_data[i::3] y_data[i] = months_data[i::3] labels = ['Income', 'Expenditure', 'Investments'] plot_data.append(y_data) plot_data.append(labels) # compute the totals datas[0].append(sum(datas[0][::-1])) datas[1].append(sum(datas[1][::-1])) datas[2].append(sum(datas[2][::-1])) datas = misc_utils.comma_sep(datas,2) #pprint(datas) #pprint(fields) #pprint(col_headings) create_reports(fields, fileTypes, title_name, subtitle_name, col_headings, datas, proj_path, file_name, styles)
def f_monthly_report (): no_types = 15 no_months = len(months_list) cash = [0] * no_months non_bank_debt = [0] * no_months equity = [0] * no_months bank_debt = [0] * no_months x_data = [] fname = proj_path + "Monthly_analysis.pdf" for idx in range(no_months): temp_month = months_list[idx] m_name = misc_utils.split_month(temp_month.name) tmp_invst = temp_month.ttl_investment x_data.append(misc_utils.split_month(temp_month.name)) notes = [] val = [] for i in range(no_types): eval_str = "tmp_typ = tmp_invst.typ%d" %(i+1) exec(eval_str) eval_str = "no_items = tmp_typ.no_items" exec(eval_str) if no_items != 0: for j in range(tmp_typ.no_items): eval_str = "tmp_item = tmp_typ.item%d" %(j+1) exec(eval_str) if tmp_item.notes != '': notes.append(tmp_item.notes) val.append(tmp_item.val) if (tmp_item.notes[:-1] == "FD" or tmp_item.notes[:-1] == "RD"): bank_debt[idx] = bank_debt[idx] + tmp_item.val elif (tmp_item.notes[:-1] == "PPF" or tmp_item.notes[:-1] == "LIC" or tmp_item.notes[:-1] == "EPF" or tmp_item.notes[:-1] == "INFRA_BONDS"): non_bank_debt[idx] = non_bank_debt[idx] + tmp_item.val elif (tmp_item.notes[:-1] == "MF" or tmp_item.notes[:-1] == "IND_EQUITY" or tmp_item.notes[:-1] == "FOREIGN_EQUITY"): equity[idx] = equity[idx] + tmp_item.val elif (tmp_item.notes[:-1] == "BANKS"): cash[idx] = cash[idx] + tmp_item.val # Break up bar graph fig = plt.figure() ind = np.arange(no_months) # the x locations for the groups width = 0.2 # the width of the bars ax = fig.add_subplot(2,1,1) rects1 = ax.bar(ind, cash, width, color='b') rects2 = ax.bar(ind+width, equity, width, color='y') rects3 = ax.bar(ind+2*width, bank_debt, width, color='g') rects4 = ax.bar(ind+3*width, non_bank_debt, width, color='r') # add some ax.set_ylabel('Amount in Rupees', fontsize=10) ax.set_title('Monthly Trends', fontsize=10) ax.set_xticks(ind + 2.2*width) ax.set_xticklabels(x_data) ax.spines['right'].set_color('none') ax.spines['left'].set_color('none') ax.spines['top'].set_color('none') ax.spines['bottom'].set_color('none') ax.legend( (rects1[0], rects2[0], rects3[0], rects4[0]), ("Cash", "Equity", "Bank Debt", "Non Bank Debt"), labelspacing=0.05,prop={'size':8} ) plt.tick_params(axis='both', which='major', labelsize=9) plt.tick_params(axis='both', which='minor', labelsize=9) plt.grid('on') x_data = [] temp_month = cm m_name = misc_utils.split_month(temp_month.name) tmp_invst = temp_month.ttl_investment notes = [] val = [] for i in range(no_types): eval_str = "tmp_typ = tmp_invst.typ%d" %(i+1) exec(eval_str) eval_str = "no_items = tmp_typ.no_items" exec(eval_str) if no_items != 0: for j in range(tmp_typ.no_items): eval_str = "tmp_item = tmp_typ.item%d" %(j+1) exec(eval_str) if tmp_item.notes != '': notes.append(tmp_item.notes) val.append(tmp_item.val) ind = np.arange(len(notes)) # the x locations for the groups width = 0.08 # the width of the bars ind = ind * 0.15 ax = fig.add_subplot(2,1,2) rects1 = ax.bar(ind, val, width, color='y') # add some ax.set_ylabel('Amount in Rupees', fontsize=10) ax.set_title('Current Month analysis', fontsize=10) ax.set_xticks(ind + 0.05) ax.set_xticklabels(notes) ax.spines['right'].set_color('none') ax.spines['left'].set_color('none') ax.spines['top'].set_color('none') ax.spines['bottom'].set_color('none') plt.tick_params(axis='both', which='major', labelsize=9) plt.tick_params(axis='both', which='minor', labelsize=9) plt.xticks(rotation='vertical') plt.grid('on') #plt.show() plt.savefig(fname)
def f_gen_rep_detailed_spend (): title_name = 'Spend Report' subtitle_name = 'Break-up details of Monthly Expenses' col_headings = ["#", "Spend Category"] fields = [] datas = [] file_name = "spendReport" data_spend_val = [] styles = ["bold=True, width=0.3","bold=True, width=0.9"] k = -1 months_data = [] for keys in add_spn_commands.keys(): spend_name = add_spn_commands[keys] k = k + 1 fields.append(spend_name) for idx in range(len(months_list)): temp_month = months_list[idx] if spend_name == 'FOOD': spend_type = temp_month.ttl_spend.food elif spend_name == 'FUEL': spend_type = temp_month.ttl_spend.fuel elif spend_name == 'VEHICLE': spend_type = temp_month.ttl_spend.vehicle elif spend_name == 'COMMUTATION': spend_type = temp_month.ttl_spend.commutation elif spend_name == 'RENT': spend_type = temp_month.ttl_spend.rent elif spend_name == 'ELECTRICITY': spend_type = temp_month.ttl_spend.electricity elif spend_name == 'WATER_BILL': spend_type = temp_month.ttl_spend.water_bill elif spend_name == 'INVESTMENTS': spend_type = temp_month.ttl_spend.investment elif spend_name == 'TEL_BILLS': spend_type = temp_month.ttl_spend.tel_bills elif spend_name == 'INSURANCE': spend_type = temp_month.ttl_spend.insurance elif spend_name == 'STATIONARIES': spend_type = temp_month.ttl_spend.stationaries elif spend_name == 'EMIS': spend_type = temp_month.ttl_spend.emis elif spend_name == 'MEDICAL': spend_type = temp_month.ttl_spend.medical elif spend_name == 'MISC': spend_type = temp_month.ttl_spend.misc else: print "unsupported option" months_data.append(spend_type.value) datas = [] n = len(months_list) for i in range(n): col_headings.append(misc_utils.split_month(months_list[i].name)) styles.append("width=0.5, money=True") datas.append([]) if n != 1: for i in range(n): datas[i] = months_data[i::n] else: datas = [months_data] fields.append('TOTAL') # compute the totals y_data = [] for j in range(len(datas)): datas[j].append(sum(datas[j][::-1])) y_data.append(datas[j][-1]) horz_total = [] for k in range(len(datas[0])): tmp_sum = 0 for j in range(len(datas)): tmp_sum = tmp_sum + datas[j][k] horz_total.append(tmp_sum) col_headings.append('TOTAL') styles.append("width=0.5, money=True") datas.append(horz_total) datas = misc_utils.comma_sep(datas,2) #pprint(horz_total) #pprint(months_data) #pprint(datas) #pprint(col_headings) #pprint(fields) create_reports(fields, fileTypes, title_name, subtitle_name, col_headings, datas, proj_path, file_name, styles)