Ending inventory is the book value of inventory at the end of a financial or accounting reporting period.
The ending inventory of the one financial year, becomes the opening inventory of the subsequent financial year.
Ending inventory is an important component in the calculation of cost of goods sold.
Formula to calculate ending inventory.

Beginning inventory is monetary values that a company assigns to their current inventory.
Purchases are new inventory that was purchased during the current accounting period.
COGS this is the cost of goods sold.
Example:
The total beginning inventory of a firm for a certain financial period was worth $ 500,000. The total purchases for that year was $ 2,000,000 and the value of the cost of goods sold was $ 1,000,000.

Therefore, the ending inventory of the firm was $ 1,500,000.