/ AX

[X++] Find Price Disc (Trade Agreements)

To find the price from trade agreements for a specific item to a specific vendor, you can use the following code snipped (i wrote it as static method so you can easily integrate it).
FOr customers just change the module to sales.

public static Price findPurchPrice(ItemId _itemId, VendAccount _vendAccount, InventDimId _inventDimId, Qty _qty)
    {
        PriceDisc               priceDisc;
        InventTable				inventTable = InventTable::find(_itemId);
        VendTable				vendTable = VendTable::find(_vendAccount);
        //InventDim               inventDimItem       = inventTable.inventItemInventSetup().inventDim();
        InventDim				inventDimItem = InventDim::find(_inventDimId);
        UnitOfMeasureSymbol     unitId              = inventTable.inventTableModuleInvent().UnitId;
        Price                   retPrice;

        priceDisc = new PriceDisc(ModuleInventPurchSales::Purch, _itemId, inventDimItem, unitId, systemDateGet(), _qty , _vendAccount);

        if (priceDisc.findPrice(_vendTable.PriceGroup))
            retPrice = priceDisc.price();
        else if (priceDisc.findItemPrice())
            retPrice = priceDisc.price();

        return retPrice;
    }

[X++] Find Price Disc (Trade Agreements)
Share this

Subscribe to robsCode