Purchase tax calculation

I need to do tax calculation purch line wise before posting purchase order.Suggest me plz.

Use the method Tax::calcTaxAmount