[FIX] stock: compute average price on action_done

the average price computation is now deduplicated and moved to
a separate function called in stock_move action_done.

fixes #2991
opw-615491
[ADD] purchase: average price computation test