HI Farhan,
Thank you very much for your reply. The formula was calculating the values correctly on first payment of a particular vendor. But while making payment of second invoice of the same vendor, the system was calculating incorrect WHT Tax values. I have changed the settings as mentioned in your post and now it is working perfectly