From 5393843da630c5b27728fc13217c71e88de6ce3f Mon Sep 17 00:00:00 2001 From: Sarey Hamarneh Date: Wed, 19 Jul 2017 12:34:40 -0400 Subject: [PATCH 1/4] Add sorted --- bpfin/financials/balance_sheet_projection.py | 2 +- bpfin/financials/borrower_schedule.py | 2 +- bpfin/financials/cash_balance.py | 4 ++-- bpfin/financials/financial_balance.py | 2 +- bpfin/financials/financial_lib.py | 2 +- bpfin/financials/financial_saving.py | 2 +- bpfin/financials/liability.py | 8 ++++---- bpfin/financials/scenario.py | 10 +++++----- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/bpfin/financials/balance_sheet_projection.py b/bpfin/financials/balance_sheet_projection.py index 8c460f7..2a34ef0 100644 --- a/bpfin/financials/balance_sheet_projection.py +++ b/bpfin/financials/balance_sheet_projection.py @@ -33,7 +33,7 @@ def balance_sheet_projection(cash_balance, liability, smallest_year = min(cash_balance) largest_year = max(cash_balance) - for an_year in analysis_years: + for an_year in sorted(analysis_years): if an_year in cash_balance: analysis_years[an_year] = cash_balance[an_year] # If the cash available value exists (balance sheet, bank statements), cash available = to that value diff --git a/bpfin/financials/borrower_schedule.py b/bpfin/financials/borrower_schedule.py index 00656a5..09ddb1b 100644 --- a/bpfin/financials/borrower_schedule.py +++ b/bpfin/financials/borrower_schedule.py @@ -7,7 +7,7 @@ def packaging_data(analysis_date, energy_expenses, loan_input, savings_input): for i in range(duration): analysis_years[start_year + i] = [] - for year in analysis_years: + for year in sorted(analysis_years): data_storage = {} if year in energy_expenses: data_storage['energy_expenses'] = energy_expenses[year] diff --git a/bpfin/financials/cash_balance.py b/bpfin/financials/cash_balance.py index cf342d0..dbd7b5a 100644 --- a/bpfin/financials/cash_balance.py +++ b/bpfin/financials/cash_balance.py @@ -41,13 +41,13 @@ def cash_balance(analysis_date, cash_dictionary): cash_balance_dictionary[year] = sum(value) / len(value) sum_cash = [] - for year in cash_balance_dictionary: + for year in sorted(cash_balance_dictionary): sum_cash.append(cash_balance_dictionary[year]) # cash_average = (sum(sum_cash)/len(sum_cash) if sum_cash else 0) cash_average = sum(sum_cash)/len(sum_cash) final_dict = {} - for year in analysis_years: + for year in sorted(analysis_years): # if cash_balance_dictionary: if year in cash_balance_dictionary: final_dict[year] = cash_balance_dictionary[year] diff --git a/bpfin/financials/financial_balance.py b/bpfin/financials/financial_balance.py index ca3fad2..5ec72d6 100644 --- a/bpfin/financials/financial_balance.py +++ b/bpfin/financials/financial_balance.py @@ -119,7 +119,7 @@ class Balance_Sheet_Table(): analysis_date['proforma_duration']) if self.hist_balance_sheet_table: current_table = copy.deepcopy(self.hist_balance_sheet_table) - for year in proforma_year: + for year in soroted(proforma_year): last_year_cash = current_table[-1].cash if year <= current_table[-1].year: continue diff --git a/bpfin/financials/financial_lib.py b/bpfin/financials/financial_lib.py index 236fa0f..08dbf55 100644 --- a/bpfin/financials/financial_lib.py +++ b/bpfin/financials/financial_lib.py @@ -47,7 +47,7 @@ def organize_bill_overview(bill_overview, analysis_date): average_bill_dict[i] = 0 # average_bill_dict[i] = float(sum(bill_dict[i][0][year] for year in bill_dict[i][0]))/len(bill_dict[i][0]) - for year in proforma_year: + for year in sorted(proforma_year): for i in range(1, 5): if year in bill_dict[i][0]: pass diff --git a/bpfin/financials/financial_saving.py b/bpfin/financials/financial_saving.py index 19a0524..0ac9c11 100644 --- a/bpfin/financials/financial_saving.py +++ b/bpfin/financials/financial_saving.py @@ -126,7 +126,7 @@ class Saving(): annual_saving_dict = {} annual_charge_dict = {} proforma_year = form_year_calendar(self.proforma_date[0], self.proforma_date[-1]) - for year in proforma_year: + for year in sorted(proforma_year): if year < self.commissioning_date.year: annual_saving_dict[year] = 0 annual_charge_dict[year] = annual_charge[year] diff --git a/bpfin/financials/liability.py b/bpfin/financials/liability.py index 0295991..b7f8774 100644 --- a/bpfin/financials/liability.py +++ b/bpfin/financials/liability.py @@ -69,7 +69,7 @@ def create_liability_dict(liability_dictionary): for key, value in liability_dictionary.items(): cal = liability_calendar(value[3], value[2]) temp_dict = {} - for current_date in cal: + for current_date in sorted(cal): temp_dict[current_date] = value[0] final_dict.append(temp_dict) return final_dict @@ -88,9 +88,9 @@ def final_liability_dict(analysis_date, liability_dictionary): analysis_date['proforma_start'], analysis_date['proforma_duration'] * 12) debt_list = create_liability_dict(liability_dictionary) - for pro_date in pro_forma_calendar: + for pro_date in sorted(pro_forma_calendar): for debt_date_dict in debt_list: - for debt_date in debt_date_dict: + for debt_date in sorted(debt_date_dict): if pro_date.year == debt_date.year and pro_date.month == debt_date.month: if (pro_date.year, pro_date.month, calendar.monthrange( pro_date.year, @@ -105,7 +105,7 @@ def final_liability_dict(analysis_date, liability_dictionary): pro_date.year, pro_date.month )[1])].append(debt_date_dict[debt_date]) - for pro_date in pro_forma_calendar: + for pro_date in sorted(pro_forma_calendar): if (pro_date.year, pro_date.month, calendar.monthrange( pro_date.year, pro_date.month)[1]) not in final_dict: final_dict[(pro_date.year, pro_date.month, calendar.monthrange( diff --git a/bpfin/financials/scenario.py b/bpfin/financials/scenario.py index b9f6d38..b9d9a40 100644 --- a/bpfin/financials/scenario.py +++ b/bpfin/financials/scenario.py @@ -180,7 +180,7 @@ class Scenario(): post_annual_bill_table = copy.deepcopy(self.saving_overview.get_post_annual_bill_table()) post_energy_bill = {} - for year in proforma_year: + for year in sorted(proforma_year): current_total_energy_bill = 0 for utility_type in UTILITY_TYPE_LIST: current_total_energy_bill += post_annual_bill_table[ @@ -197,14 +197,14 @@ class Scenario(): proforma_year = form_bill_year(self.analysis_date['proforma_start'], self.analysis_date['proforma_duration']) annual_debt_service_dict = {} - for year in proforma_year: + for year in sorted(proforma_year): annual_debt_service_dict[year] = 0 for current_loan in copy.deepcopy(self.scheduled_loan_list): current_loan_annual = annualizing_projection( current_loan.terms, current_loan.debt_service_due) - for year in proforma_year: - if year in current_loan_annual: + for year in sorted(proforma_year): + if year in sorted(current_loan_annual): annual_debt_service_dict[year] += current_loan_annual[year] return annual_debt_service_dict @@ -224,7 +224,7 @@ class Scenario(): annual_debt_service = copy.deepcopy(self.get_annual_debt_service()) prior_annual_bill = copy.deepcopy(self.prior_income_statement_table.get_total_energy_dict()) net_saving_dict = {} - for year in prior_annual_bill: + for year in sorted(prior_annual_bill): net_saving_dict[ year] = prior_annual_bill[year] - proforma_bill[year] - annual_debt_service[year] graph_dict = { -- GitLab From aef8c8835672cd70c3ebae46dd018074960146a9 Mon Sep 17 00:00:00 2001 From: Sarey Hamarneh Date: Fri, 21 Jul 2017 09:53:04 -0400 Subject: [PATCH 2/4] spelling mistake --- bpfin/financials/financial_balance.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bpfin/financials/financial_balance.py b/bpfin/financials/financial_balance.py index 5ec72d6..896c0fb 100644 --- a/bpfin/financials/financial_balance.py +++ b/bpfin/financials/financial_balance.py @@ -119,7 +119,7 @@ class Balance_Sheet_Table(): analysis_date['proforma_duration']) if self.hist_balance_sheet_table: current_table = copy.deepcopy(self.hist_balance_sheet_table) - for year in soroted(proforma_year): + for year in sorted(proforma_year): last_year_cash = current_table[-1].cash if year <= current_table[-1].year: continue -- GitLab From 12379745306878002a6236a82362dffcfd647e9f Mon Sep 17 00:00:00 2001 From: Sarey Hamarneh Date: Mon, 24 Jul 2017 13:13:06 -0400 Subject: [PATCH 3/4] push --- bpfin/financials/balance_sheet_projection.py | 4 ++-- bpfin/financials/borrower_schedule.py | 2 +- bpfin/financials/cash_balance.py | 2 +- bpfin/financials/financial_balance.py | 6 +++--- bpfin/financials/financial_lib.py | 2 +- bpfin/financials/financial_saving.py | 2 +- bpfin/financials/liability.py | 4 ++-- bpfin/financials/scenario.py | 6 +++--- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/bpfin/financials/balance_sheet_projection.py b/bpfin/financials/balance_sheet_projection.py index 2a34ef0..3697d40 100644 --- a/bpfin/financials/balance_sheet_projection.py +++ b/bpfin/financials/balance_sheet_projection.py @@ -33,8 +33,8 @@ def balance_sheet_projection(cash_balance, liability, smallest_year = min(cash_balance) largest_year = max(cash_balance) - for an_year in sorted(analysis_years): - if an_year in cash_balance: + for an_year in analysis_years: + if an_year in sorted(cash_balance): analysis_years[an_year] = cash_balance[an_year] # If the cash available value exists (balance sheet, bank statements), cash available = to that value elif an_year < smallest_year: diff --git a/bpfin/financials/borrower_schedule.py b/bpfin/financials/borrower_schedule.py index 09ddb1b..00656a5 100644 --- a/bpfin/financials/borrower_schedule.py +++ b/bpfin/financials/borrower_schedule.py @@ -7,7 +7,7 @@ def packaging_data(analysis_date, energy_expenses, loan_input, savings_input): for i in range(duration): analysis_years[start_year + i] = [] - for year in sorted(analysis_years): + for year in analysis_years: data_storage = {} if year in energy_expenses: data_storage['energy_expenses'] = energy_expenses[year] diff --git a/bpfin/financials/cash_balance.py b/bpfin/financials/cash_balance.py index dbd7b5a..86582b1 100644 --- a/bpfin/financials/cash_balance.py +++ b/bpfin/financials/cash_balance.py @@ -47,7 +47,7 @@ def cash_balance(analysis_date, cash_dictionary): cash_average = sum(sum_cash)/len(sum_cash) final_dict = {} - for year in sorted(analysis_years): + for year in analysis_years: # if cash_balance_dictionary: if year in cash_balance_dictionary: final_dict[year] = cash_balance_dictionary[year] diff --git a/bpfin/financials/financial_balance.py b/bpfin/financials/financial_balance.py index 896c0fb..96e1372 100644 --- a/bpfin/financials/financial_balance.py +++ b/bpfin/financials/financial_balance.py @@ -119,16 +119,16 @@ class Balance_Sheet_Table(): analysis_date['proforma_duration']) if self.hist_balance_sheet_table: current_table = copy.deepcopy(self.hist_balance_sheet_table) - for year in sorted(proforma_year): + for year in proforma_year: last_year_cash = current_table[-1].cash if year <= current_table[-1].year: continue current_other_debt_service = 0.00 current_net_income = 0.00 - if year in other_debt_service_dictionary: + if year in sorted(other_debt_service_dictionary): current_other_debt_service = other_debt_service_dictionary[ year] - if year in net_income_dictionary: + if year in sorted(net_income_dictionary): current_net_income = net_income_dictionary[year] current_balance_sheet = Balance_Sheet_Next( year, last_year_cash, current_other_debt_service, diff --git a/bpfin/financials/financial_lib.py b/bpfin/financials/financial_lib.py index 08dbf55..236fa0f 100644 --- a/bpfin/financials/financial_lib.py +++ b/bpfin/financials/financial_lib.py @@ -47,7 +47,7 @@ def organize_bill_overview(bill_overview, analysis_date): average_bill_dict[i] = 0 # average_bill_dict[i] = float(sum(bill_dict[i][0][year] for year in bill_dict[i][0]))/len(bill_dict[i][0]) - for year in sorted(proforma_year): + for year in proforma_year: for i in range(1, 5): if year in bill_dict[i][0]: pass diff --git a/bpfin/financials/financial_saving.py b/bpfin/financials/financial_saving.py index 0ac9c11..19a0524 100644 --- a/bpfin/financials/financial_saving.py +++ b/bpfin/financials/financial_saving.py @@ -126,7 +126,7 @@ class Saving(): annual_saving_dict = {} annual_charge_dict = {} proforma_year = form_year_calendar(self.proforma_date[0], self.proforma_date[-1]) - for year in sorted(proforma_year): + for year in proforma_year: if year < self.commissioning_date.year: annual_saving_dict[year] = 0 annual_charge_dict[year] = annual_charge[year] diff --git a/bpfin/financials/liability.py b/bpfin/financials/liability.py index b7f8774..ffc0f51 100644 --- a/bpfin/financials/liability.py +++ b/bpfin/financials/liability.py @@ -69,7 +69,7 @@ def create_liability_dict(liability_dictionary): for key, value in liability_dictionary.items(): cal = liability_calendar(value[3], value[2]) temp_dict = {} - for current_date in sorted(cal): + for current_date in cal: temp_dict[current_date] = value[0] final_dict.append(temp_dict) return final_dict @@ -88,7 +88,7 @@ def final_liability_dict(analysis_date, liability_dictionary): analysis_date['proforma_start'], analysis_date['proforma_duration'] * 12) debt_list = create_liability_dict(liability_dictionary) - for pro_date in sorted(pro_forma_calendar): + for pro_date in pro_forma_calendar: for debt_date_dict in debt_list: for debt_date in sorted(debt_date_dict): if pro_date.year == debt_date.year and pro_date.month == debt_date.month: diff --git a/bpfin/financials/scenario.py b/bpfin/financials/scenario.py index b9d9a40..c054820 100644 --- a/bpfin/financials/scenario.py +++ b/bpfin/financials/scenario.py @@ -180,7 +180,7 @@ class Scenario(): post_annual_bill_table = copy.deepcopy(self.saving_overview.get_post_annual_bill_table()) post_energy_bill = {} - for year in sorted(proforma_year): + for year in proforma_year: current_total_energy_bill = 0 for utility_type in UTILITY_TYPE_LIST: current_total_energy_bill += post_annual_bill_table[ @@ -197,13 +197,13 @@ class Scenario(): proforma_year = form_bill_year(self.analysis_date['proforma_start'], self.analysis_date['proforma_duration']) annual_debt_service_dict = {} - for year in sorted(proforma_year): + for year in proforma_year: annual_debt_service_dict[year] = 0 for current_loan in copy.deepcopy(self.scheduled_loan_list): current_loan_annual = annualizing_projection( current_loan.terms, current_loan.debt_service_due) - for year in sorted(proforma_year): + for year in proforma_year: if year in sorted(current_loan_annual): annual_debt_service_dict[year] += current_loan_annual[year] return annual_debt_service_dict -- GitLab From 4eb2c7fffff5efb96418fc187db584d362298406 Mon Sep 17 00:00:00 2001 From: chenzheng06 Date: Tue, 1 Aug 2017 10:47:28 -0400 Subject: [PATCH 4/4] Remove wrong sorting --- bpfin/financials/balance_sheet_projection.py | 4 ++-- bpfin/financials/cash_balance.py | 1 - bpfin/financials/financial_balance.py | 4 ++-- bpfin/financials/liability.py | 2 +- bpfin/financials/scenario.py | 4 ++-- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/bpfin/financials/balance_sheet_projection.py b/bpfin/financials/balance_sheet_projection.py index 3697d40..2a34ef0 100644 --- a/bpfin/financials/balance_sheet_projection.py +++ b/bpfin/financials/balance_sheet_projection.py @@ -33,8 +33,8 @@ def balance_sheet_projection(cash_balance, liability, smallest_year = min(cash_balance) largest_year = max(cash_balance) - for an_year in analysis_years: - if an_year in sorted(cash_balance): + for an_year in sorted(analysis_years): + if an_year in cash_balance: analysis_years[an_year] = cash_balance[an_year] # If the cash available value exists (balance sheet, bank statements), cash available = to that value elif an_year < smallest_year: diff --git a/bpfin/financials/cash_balance.py b/bpfin/financials/cash_balance.py index 86582b1..d28a045 100644 --- a/bpfin/financials/cash_balance.py +++ b/bpfin/financials/cash_balance.py @@ -48,7 +48,6 @@ def cash_balance(analysis_date, cash_dictionary): final_dict = {} for year in analysis_years: - # if cash_balance_dictionary: if year in cash_balance_dictionary: final_dict[year] = cash_balance_dictionary[year] if year < min(cash_balance_dictionary): diff --git a/bpfin/financials/financial_balance.py b/bpfin/financials/financial_balance.py index 96e1372..ca3fad2 100644 --- a/bpfin/financials/financial_balance.py +++ b/bpfin/financials/financial_balance.py @@ -125,10 +125,10 @@ class Balance_Sheet_Table(): continue current_other_debt_service = 0.00 current_net_income = 0.00 - if year in sorted(other_debt_service_dictionary): + if year in other_debt_service_dictionary: current_other_debt_service = other_debt_service_dictionary[ year] - if year in sorted(net_income_dictionary): + if year in net_income_dictionary: current_net_income = net_income_dictionary[year] current_balance_sheet = Balance_Sheet_Next( year, last_year_cash, current_other_debt_service, diff --git a/bpfin/financials/liability.py b/bpfin/financials/liability.py index ffc0f51..eaf71a1 100644 --- a/bpfin/financials/liability.py +++ b/bpfin/financials/liability.py @@ -105,7 +105,7 @@ def final_liability_dict(analysis_date, liability_dictionary): pro_date.year, pro_date.month )[1])].append(debt_date_dict[debt_date]) - for pro_date in sorted(pro_forma_calendar): + for pro_date in pro_forma_calendar: if (pro_date.year, pro_date.month, calendar.monthrange( pro_date.year, pro_date.month)[1]) not in final_dict: final_dict[(pro_date.year, pro_date.month, calendar.monthrange( diff --git a/bpfin/financials/scenario.py b/bpfin/financials/scenario.py index c054820..b9f6d38 100644 --- a/bpfin/financials/scenario.py +++ b/bpfin/financials/scenario.py @@ -204,7 +204,7 @@ class Scenario(): current_loan_annual = annualizing_projection( current_loan.terms, current_loan.debt_service_due) for year in proforma_year: - if year in sorted(current_loan_annual): + if year in current_loan_annual: annual_debt_service_dict[year] += current_loan_annual[year] return annual_debt_service_dict @@ -224,7 +224,7 @@ class Scenario(): annual_debt_service = copy.deepcopy(self.get_annual_debt_service()) prior_annual_bill = copy.deepcopy(self.prior_income_statement_table.get_total_energy_dict()) net_saving_dict = {} - for year in sorted(prior_annual_bill): + for year in prior_annual_bill: net_saving_dict[ year] = prior_annual_bill[year] - proforma_bill[year] - annual_debt_service[year] graph_dict = { -- GitLab