RE: PriceDiscTable::find() returns expired price
Hi Ichiban,
The PriceDiscTable is not a Valid Time State Table, which means that it will not filter the active records automatically.
To find prices use the PriceDisc class.
Here is a sample code, you may change the module and the parameters according to your needs:
public Price findPurchPrice(ItemId _itemId, VendTable vendTable, InventDim _inventDim, Qty _qty)
{
Price price;
PriceDisc priceDisc = new PriceDisc(
ModuleInventPurchSales::Purch,
_itemId,
_inventDim,
InventTable::find(_itemId).inventTableModuleInvent().UnitId,
DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone()),
_qty,
vendTable.AccountNum);
if (priceDisc.findPrice(vendTable.PriceGroup))
{
price = priceDisc.price();
}
else(priceDisc.findItemPrice())
{
price = priceDisc.price();
}
return price;
}