I have recently found an interesting article about using .NET Microsoft.Dynamics.Commerce.Runtime.Services.PricingEngine.PricingEngine to calculate the price and discount for an order: (https://community.dynamics.com/365/financeandoperations/b/kurthatlevik/posts/dax2012-r3-playing-with-retail-crt)
I modified the author's code by adding these two lines at the end of the job to get the total amount and the total number of items of the order (off course, I already changed my ItemId and InventDimId to values which are suitable with my AX 2012 R3 system):
Price = crtSalesTransaction.get_TotalAmount();
qty = crtSalesTransaction.get_NumberOfItems();
All I received are 0s.
I tried to check the MS document about the class, but the information there is quite limited (https://learn.microsoft.com/en-us/dynamicsax-2012/appuser-itpro/pricingengine-methods-microsoft-dynamics-commerce-runtime-services-pricingengine). I also tried all other related methods of the class Microsoft.Dynamics.Commerce.Runtime.DataModel.SalesTransaction, but no luck. So I'm quite confused. Does the code need something more or is it a bug of AX? Could someone give me a hint?
Thank you.