diff --git a/bpfin/financials/cash_balance.py b/bpfin/financials/cash_balance.py index 1076083e300d40a76adfe14997125056032ce947..28f48e9cc114fa2e1c31b009e302bd08fe48c6d9 100644 --- a/bpfin/financials/cash_balance.py +++ b/bpfin/financials/cash_balance.py @@ -1,8 +1,14 @@ +"""Calculate historical cash balance value for each year from the proforma start date.""" + + def cash_balance(analysis_date, cash_dictionary): - """Returns current cash balance + """Returns current cash balance. If more than 1 balance sheet per year, raise ValueError. + Args: - analysis_date (dictionary) = {starting_date: months} + analysis_date (dict) = {start_date, duration in years} cash_dictionary (dictionary): {datetime:(cash value,year)} + Raises: + ValueError when more than 1 balance sheet for one year. Returns: dictionary: {datetime, cash value} """ @@ -18,6 +24,8 @@ def cash_balance(analysis_date, cash_dictionary): for date, value_tuple in cash_dictionary.items(): if value_tuple[1] is True: + if date.year in cash_dictionary: + raise ValueError("Only one balance sheet per year is allowed") cash_balance_dictionary[date.year] = value_tuple[0] else: if date.year not in bank_statement: