GET TRADE AGREEMENT SALES PRICE x++ CODE D365
WITH THE BELOW CODE YOU CAN GET THE CURRENT TRADE AGREEMENT PRICE OF A A GIVEN SALES ORDER LINE IN D365.
public static price findPurchPrice(ItemId _itemId, CustAccount _custAccount, InventDimId _inventDimId)
{
InventTable inventTable = InventTable::find(_itemId);
CustTable custTable = CustTable::find(_custAccount);
InventDim inventDimItem = InventDim::find(_inventDimId);
UnitOfMeasureSymbol unitId = inventTable.inventTableModuleInvent().UnitId;
PriceDisc priceDisc;
Price retprice;
PriceDiscParameters parameters = PriceDiscParameters::construct();
parameters.parmModuleType(ModuleInventPurchSales::Sales);
parameters.parmItemId(inventTable.ItemId);
parameters.parmInventDim(inventDimItem);
parameters.parmUnitID(unitId);
parameters.parmPriceDiscDate(DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone()));
parameters.parmQty(1);
parameters.parmAccountNum(custTable.AccountNum);
parameters.parmCurrencyCode(custTable.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