class DemoClass
{
public static price findPurchPrice(ItemId _itemId, CustAccount _custAccount, InventDimId _inventDimId, VendAccount _vendAccount)
{
InventTable inventTable = InventTable::find(_itemId);
CustTable custTable = CustTable::find(_custAccount);
InventDim inventDimItem = InventDim::find(_inventDimId);
VendTable vendTable = VendTable::find(_vendAccount).PriceGroup;
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;
}
}
Please mark verify if this resolves your issue and help community.
Regards
Mav
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 284,876 Super User
Ludwig Reinhard Microsoft Employee
Martin Dráb 225,425 Super User