calculation of closing stock