diff --git a/bpfin/back_end_call/back_end_inputs.py b/bpfin/back_end_call/back_end_inputs.py index 8c7b283f7a7f4acd5a202ea5616adbe249c79c3c..65a7f4a8963b6f49757e3a51d107a007d163e07b 100644 --- a/bpfin/back_end_call/back_end_inputs.py +++ b/bpfin/back_end_call/back_end_inputs.py @@ -18,9 +18,10 @@ def form_annual_bill_table(raw_monthly_bill_table, raw_annual_bill_table, analys raw_annual_bill_table (dictionary): dictionary of dictionary of annual bills, at lease 0 year data is required Returns: - list: list of lists, display prior_annual_bill and manual_input indicators in displaying formatting bill_overview_dict (dictionary): dictionary of dictionary of annual bills, see description for detail - # manual_input_dict (dictionary): dictionary of boolean values, keys are utilities + manual_input_dict (dictionary): this return is not used anywhere else, it's a placeholder + prior_month_bill_dict (dictionary): dictionary of dictionary, keys are utilities, see description for detail + bill_overview_instance (dictionary): dictionary of dictionaries, see description for API detail Error Validate: raw_monthly_bill_table, analysis_date == None, Raise empty error @@ -56,6 +57,30 @@ def form_annual_bill_table(raw_monthly_bill_table, raw_annual_bill_table, analys 'oil': dict of oil_bill, 'gas': dict of gas_bill, 'water': dict of water_bill} + prior_month_bill_dict = { + 'electric': { + 'date_from': list, prior_bill_start, month by month, + 'date_to': list, prior_bill_end, month by month, + 'usage': list of float,prior_monthly_usage, + 'charge': list of float,prior_monthly_charge, + 'price': list of float,prior_monthly_price}, + 'gas': same, + 'oil': same, + 'water': same} + bill_overview_instance = { + "instance": + { + "electric":{"2012": 44497.03, "2013": 45283.79, ... "2036": 70045.62}, + "gas":{"2012": 10847.97, "2013": 11045.45, ... "2036": 17077.7}, + "oil":{"2012": null, ... "2036": null}, + "water":{"2012": null, ... "2036": null}, + "electric_user": 'Annual Estimate', + "gas_user": 'Monthly Bill', + "oil_user": 'Not Available', + "water_user": 'Annual Estimate', + "total_annual_charge": {"2012": 55345.0, "2013": 56329.240000000005, ... "2036": 87123.31999999999} + } + } To Do: from utilbills.bill.py merge form_prior_month_bill(), and delete that one * this work is done. need all units test and then can delete that @@ -87,23 +112,20 @@ def form_annual_bill_table(raw_monthly_bill_table, raw_annual_bill_table, analys raise ValueError('Bill_Overview - monthly_bill has incomplete result of monthly_proj') # formatting annual bill (bill overview on front end) - proforma_year = sorted(bill_overview_dict[UTILITY_TYPE_LIST[0]]) - bill_overview_front_end_list = [] - - bill_overview_front_end_list.append(['Data Source', 'Utility/Year']) - bill_overview_front_end_list[0] += proforma_year - + instance = {} for utility in UTILITY_TYPE_LIST: - utility_expense_list = [] - utility_expense_list.append('Annual Estimate' if manual_input_dict[utility] else 'Monthly Bill') - utility_expense_list.append(utility) - utility_expense_list += [bill_overview_dict[utility][year] for year in proforma_year] - bill_overview_front_end_list.append(utility_expense_list) + # assign 4 annual bills under proforma years to instance. keys are 4 utilities + instance[utility] = bill_overview_dict[utility] + # assign 4 user input type to instance. + utility_user = utility + '_user' + instance[utility_user] = 'Annual Estimate' if manual_input_dict[utility] else 'Monthly Bill' + # assign total charge to instance. UI display: "Total Energy Expense" + instance["total_annual_charge"] = sum_energy_opex(bill_overview_dict)[0] - bill_overview_front_end_list.append(['', 'Total Energy Expense']) - bill_overview_front_end_list[-1] += sum_energy_opex(bill_overview_dict)[1] + bill_overview_instance = {"instance":instance} + # print('\ninstance = ', bill_overview_instance) - return bill_overview_dict, manual_input_dict, prior_month_bill_dict, bill_overview_front_end_list + return bill_overview_dict, manual_input_dict, prior_month_bill_dict, bill_overview_instance def form_prior_income_table( @@ -171,10 +193,11 @@ def form_prior_income_table( # from bpfin.financials.liability import final_liability_dict # from bpfin.financials.financial_balance import Balance_Sheet_Table # from bpfin.tests.testdata import feature_data as db -# print('\nannual_bill =', form_annual_bill_table(db.raw_monthly_bill_table, db.raw_annual_bill_table, db.analysis_date)[-1]) # pp = pprint.PrettyPrinter(width=120, indent=4, compact=True) -# pp.pprint(form_annual_bill_table(db.raw_monthly_bill_table, db.raw_annual_bill_table, db.analysis_date)[-1]) +# pp.pprint(form_annual_bill_table(db.raw_monthly_bill_table, db.raw_annual_bill_table, db.analysis_date)[1]) + +# print('\nannual_bill =', form_annual_bill_table(db.raw_monthly_bill_table, db.raw_annual_bill_table, db.analysis_date)[-1]) # print('\nprior_income_statement =', form_prior_income_table( # db.raw_income_input,