diff --git a/bpfin/financials/financial_lib.py b/bpfin/financials/financial_lib.py index 118079960ed652e80b542056d721d67f7e5dd735..d005d1af82ac34bc00dac017a93249e611708143 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 e5a1bcb506050a046a5fe17aa1cb84c5a44ceec7..0799fdb84f7dfcb843c1e04f40ec170bae9be874 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():