Calculate ending inventory using the lower of cost and net realizable value