From d00a204553f2e29c7962da09fdf0394e56c2135b Mon Sep 17 00:00:00 2001 From: chenzheng06 Date: Wed, 3 May 2017 22:57:28 -0400 Subject: [PATCH] Create get_first_year_noi func in Income_Statement_Table. Create test file for the func --- bpfin/financials/financial_lib.py | 13 +++++++++++++ bpfin/tests/test_financials/test_financial_lib.py | 3 +++ 2 files changed, 16 insertions(+) diff --git a/bpfin/financials/financial_lib.py b/bpfin/financials/financial_lib.py index 1180799..d005d1a 100644 --- a/bpfin/financials/financial_lib.py +++ b/bpfin/financials/financial_lib.py @@ -504,6 +504,19 @@ class Income_Statement_Table(): current_income_statement.year] = current_income_statement.noi return noi_dict + def get_first_year_noi(self, commission_date): + """ + Get first year noi after commissioning year, from post_saving income statement + Args: + commission_date (date): construction finishing date. Saving starts NEXT month/year + Return: + float: noi of the next year after commission date + """ + first_year = commission_date.year + 1 + for current_income_statement in self.table: + if current_income_statement.year == first_year: + return current_income_statement.noi + class Balance_Sheet(): def __init__(self): diff --git a/bpfin/tests/test_financials/test_financial_lib.py b/bpfin/tests/test_financials/test_financial_lib.py index e5a1bcb..0799fdb 100644 --- a/bpfin/tests/test_financials/test_financial_lib.py +++ b/bpfin/tests/test_financials/test_financial_lib.py @@ -22,6 +22,7 @@ def test_Income_Statement_Table(): output_average_table = db.income_statement_average output_noi_dict = db.noi_dict_average output_single_year = db.income_statement_2017_avg + output_first_year_noi = 33165.377210606544 IS_table = Income_Statement_Table(input_raw_income_input, input_annual_bill_table) @@ -33,6 +34,8 @@ def test_Income_Statement_Table(): assert IS_table.get_noi_dict() == output_noi_dict # test get_noi_dict assert IS_table.get_single_year( 2017) == output_single_year # test get_single_year + print(IS_table.get_single_year(2018)) + assert IS_table.get_first_year_noi(datetime.date(2017, 3, 14)) == output_first_year_noi def test_Balance_Sheet_Table(): -- GitLab