def calc_roi(revenue_time_series, opex_time_series, cogs_time_series, interest, tax_time_series, capex):
    """
        Return on Investment Equation
        Notes
        -----
            Calculates ROI by calculating profit divided by total investment, and then multiplying by 100 for a percentage.
            The profit is calculated as the revenue computed from Eqn. 5, subtracting OpEx (Eqn. 1), COGS (Eqn. 2), the interest from the loan or investment,
            and taxes associated with the specified operation. The user has two options, to calculate ROI for a tax-year with annual revenue, or to calculate
            by using the computed monthly revenue with risk and uncertainty analysis applied on yield and sales. The ROI is calculated per month,
            which is then used for risk assessment
    """
    r = revenue_time_series - opex_time_series - cogs_time_series - interest - tax_time_series
    roi_array = (r / capex) * 100
    return roi_array

# ====================================================================================================================#
# ============================================== SCRIPT ==============================================================#
# ====================================================================================================================#


# OPEX

# opex_time_series: int = 0
# days = 366
# opex_array = []
# sales: int = 0
# sales_array = []
#
# print("days",days-1)
# input_file = 'input_file.json'
# scenario = get_scenario(input_file)
#
# no_of_racks = calc_no_of_racks(scenario.system, scenario.area)
# no_of_lights = calc_no_of_lights(scenario.system, no_of_racks)
# lights_daily_energy = calc_lights_energy(scenario.lights, no_of_lights)
#
# hvac_daily_energy = calc_hvac_energy(surface_area=scenario.surface, building_type=scenario.building,
#                                 Tin=get_temp_crop_reqs(scenario.crop), Tout=scenario.toutdoors)
# daily_energy_consumption_farm, monthly_energy_consumption_farm = calc_energy_consumption(hvac_daily_energy, lights_daily_energy)
# farm_plant_capacity, standard_yield = calc_plant_capacity(scenario.crop, scenario.system, no_of_racks)
# ys = standard_yield
# crop_ppfd_reqs = calc_crop_ppfd_reqs(scenario.crop)
# ppfd_lights = 295  # placeholder
#
# tf = 1
# opex_array.append(opex_time_series)
# # ARRAY conversion
# sales_array.append(sales)
# sales_array = np.asarray(sales_array) # Sales as an array
# opex_array = np.asarray(opex_array)  # OpEx as an array
# profit_array = profit(sales_array, opex_array)


# gross_profit_margin(sales_array, cogs)

# print("Profit £:", profit_array[-1])

# plt.plot(profit_array)
# plt.xlabel('Days')
# plt.ylabel('Gross Profit')
# plt.show()

# plt.figure()
# plt.plot(gross_profit_margin)
# plt.xlabel('Days')
# plt.ylabel('Gross Profit Margin')
# plt.show()
#
# print("Gross Profit Margin:",gross_profit_margin[-1])

# print("GOT costs ", costs)
    r = revenue_time_series - opex_time_series - cogs_time_series - interest - tax_time_series
    roi_array = (r / capex) * 100
    return roi_array