Why do you want to calculate with the latest cost price if you are running weighted average and this form is already based on the current calculated average?
The margin is a bit useless as after the inventory recalculation the margin will be impacted as well.