Friday, April 24, 2020

Get sales price from trade agreements in D365 F&O via X++

Below is the code to get sales price from trade agreements in D365 F&O via X++.


    SalesPrice      price;
    InventDim       inventDim;
    PriceDisc       priceDisc;
    InventTable     inventTable = InventTable::find('A0001');
    CustTable       custTable   = CustTable::find('US-001');
  
    inventDim.InventSiteId      = '1';
    inventDim.InventLocationId  = '11';
    inventDim.wMSLocationId  = '11';
    inventDim = InventDim::findOrCreate(inventDim);

    PriceDiscParameters parameters =  PriceDiscParameters::construct();
    parameters.parmAccountNum(custTable.AccountNum);
    parameters.parmCurrencyCode(custTable.Currency);
    parameters.parmInventDim(inventDim);
    parameters.parmItemId(inventTable.itemid);
    parameters.parmModuleType(ModuleInventPurchSales::Sales);
    parameters.parmPriceDiscDate(systemDateGet());
    parameters.parmQty(1);
    parameters.parmUnitID('pcs');;


    priceDisc = PriceDisc::newFromPriceDiscParameters(parameters);
      
    if(priceDisc.findPrice(custTable.PriceGroup,false))
    {
        price = priceDisc.price();
    }
    info (strFmt("Price = %1", price));


No comments:

Post a Comment