Need to get the price of an item that has a sales or purchase agreement? The PriceDisc class is here to save us!

Trying to catch the best price using the PriceDisc framework

This is one of those reference posts that I’m writing for the Adrià of the future, because it’s something I forget about a lot.

PriceDisc magic!

There’s an obsolete method, I think it was findItemPriceAgreement, to get the price, but it’s obsolete, as I’ve just said. So the easiest way to get a price is to use the PriceDisc class that replaces the obsolete method.

To use it, just instantiate a PriceDiscParameters object and call all the parm methods you need. Finally, create a PriceDisc object using the newFromPriceDiscParameters method and passing the PriceDiscParameters, and… well take a look at the code below:

public static Amount getPrice(AccountNum _accountNum, 
                                CurrencyCode _currencyCode,
                                InventDim _inventDim,
                                ItemId _itemId,
                                ModuleInventPurchSales _module,
                                TransDate _date,
                                Qty _qty,
                                UnitId _unitId,
                                PriceGroupId _priceGroupId)
    PriceDiscParameters priceDiscParameters = PriceDiscParameters::construct();            
    PriceDisc priceDisc = PriceDisc::newFromPriceDiscParameters(priceDiscParameters);
    return priceDisc.price();

And that’s all. I know it’s a stupid post, but so am I and forget this kind of things.


Receive an email when a new post is published

Microsoft Dynamics 365 Finance & Operations technical architect and developer. Business Applications MVP since 2020.

Write A Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.