The main problem in planning the optimal operation of renewable energy sources and battery storage systems is the amount of data that must be considered to cover an entire observation period. If the observation period is one year, the characteristic days or averaged data (daily, weekly or monthly averages) are considered to reduce the number of data. Since the average values of the entered data differ from the actual values, it is better to work with hourly or 15-minute data at the annual level. The study presents a framework for solving the problem of the optimal allocation and operation of renewable energy sources and battery storage systems. The proposed method simultaneously solves the optimal allocation and energy management problem considering hourly data at the annual level. The fuzzy inference-based system is proposed for scheduling optimal profiles of battery storage systems and renewable energy sources. The developed fuzzy inference system manages the power factors of the photovoltaic and wind power systems, the power factor and output of the biogas plant, and the operating status of the battery storage system. The presented method simultaneously finds the optimal parameters of the energy management system and the optimal allocation and operation of the renewable energy sources and the battery storage system. The developed method is based on the calculation of steady-state power flow. The proposed method is to be used in the design phase for the installation of various renewable energy sources and battery storage systems. In addition, the method is intended to be used to optimally control the power output of energy sources and the operation of energy storage systems during steady-state operation in order to operate the distribution network with minimum annual active energy losses. The developed method is applied to the test distribution system IEEE with 37 nodes. The reduction in annual energy losses in the tested distribution system is about 80% compared to the base case without renewable energy sources and battery storage system.