In order to select VAT, you should decide with the principal amount. In this situation two options are possible:
VAT included in the amount, in this case, you have to extract the VAT out of it;
VAT is not included in the amount, in this case, need to charge VAT on it.
To select VAT from the amount you need to divide the sum by (100+tax rate) and multiplying on the tax rate. The result is rounded according to mathematical rules to cents. For example, you must select VAT from 250 000 RUB., the rate of VAT is 18%. 250000 / 118 * 18 = 38135,60 (RUB.)
To charge VAT is somewhat simpler. In this case, we need to multiply the amount to which it is necessary to charge VATon the tax rate (in decimal terms). The result will be the amount of tax which also should be rounded. For example, it is necessary to charge VAT in the amount of 138 000 rbl., the tax rate is 10%. 138000 * 0,10 = 13800 (RUB)
If you multiply the amount you want to charge VAT, of (1+the tax rate in decimal terms), the resulting amount will already include the tax. Using the data of the last example, will get the final result:138000 * 1,10 = 151800 (RUB)