Two situations.
You want to transfer all the money in an account and want to compute the right amount of gas and tax suc that you transfer all that is possible and leave the account with 0.
You want to transfer a specific amount of money and want to compute the right amount of gas and tax such that you transfer exactly the desired amount.
How do you compute both values?