This issue you mentioned i have faced with FIFO not with weighted average valuation. Anyway try this it may work.