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;
}
No comments:
Post a Comment