I think you can just use an expression that calculates the total cost and will get updated automatically.