Thursday, 19 November 2020

PURCHASE price of trade agreement D365 code X++ get purchase trade agreement price

GET TRADE AGREEMENT PURCHASE PRICE x++ CODE D365

WITH THE BELOW CODE YOU CAN GET THE CURRENT TRADE AGREEMENT PRICE OF A A GIVEN PURCHASE ORDER LINE IN D365.


 public static price findPurchPrice(ItemId _itemId, VendAccount _vendAccount, InventDimId _inventDimId)

    {

        InventTable inventTable = InventTable::find(_itemId);

        VendTable vendTable = VendTable::find(_vendAccount);

        InventDim inventDimItem = InventDim::find(_inventDimId);

        UnitOfMeasureSymbol     unitId          = inventTable.inventTableModuleInvent().UnitId;

        PriceDisc priceDisc;

        Price retprice;


        PriceDiscParameters parameters = PriceDiscParameters::construct();


        parameters.parmModuleType(ModuleInventPurchSales::Purch);

        parameters.parmItemId(inventTable.ItemId);

        parameters.parmInventDim(inventDimItem);

        parameters.parmUnitID(unitId);

        parameters.parmPriceDiscDate(DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone()));

        parameters.parmQty(1);

        parameters.parmAccountNum(vendTable.AccountNum);

        parameters.parmCurrencyCode(vendTable.Currency);

        priceDisc = PriceDisc::newFromPriceDiscParameters(parameters);

        

        // From Trade agreement

        if (priceDisc.findPrice(vendTable.PriceGroup))

        {

            retPrice = priceDisc.price();

        }

        //From Item

        else if (priceDisc.findItemPrice())

        {

            retPrice = priceDisc.price();

        }

        return retprice;

    }

Thanks,
Vikas Mehta

No comments:

Post a Comment

AZURE INTERVIEW QUESTIONS AND ANSWERS

AZURE INTERVIEW QUESTIONS AND ANSWERES 2021 2. What is cloud computing? Explanation:  It is the use of servers on the internet to “store...