Purchase order Invoice Total in Accounting Currency before posting in Ax 2012

If you want to get Purchase order Invoice Total in Accounting Currency before posting in Ax 2012 then you can apply below code sample.

Purchase Total form is as below.
 Purchase order Invoice Total


   PurchTotals purchTotals;  
   PurchTable purchTable = PurchTable::find('000035');  
   Amountmst InvAmount;  
   ;  
   purchTotals = PurchTotals::newPurchTable(purchTable);  
   purchTotals.calc();  
   InvAmount = purchTotals.purchTotalAmount() * (purchTotals.exchRate()/100) ;  

as per above code variable InvAmount will show in total amount for Accounting currency and method purchTotals.purchTotalAmount() will return Total Amount in Transaction currency. which is 165 in our screenshot.