private static ItemCost FetchSiteLastCost(PXGraph graph, InventoryItem item, INItemCost cost, int?siteID) { decimal?result = null; INItemStats res = null; if (siteID != null) { res = (INItemStats)PXSelect <INItemStats, Where <INItemStats.inventoryID, Equal <Required <INItemStats.inventoryID> >, And <INItemStats.siteID, Equal <Required <INItemStats.siteID> > > > > . Select(graph, item.InventoryID, siteID); } else { res = (INItemStats)PXSelect <INItemStats, Where <INItemStats.inventoryID, Equal <Required <INItemStats.inventoryID> > >, OrderBy <Desc <INItemStats.lastCostDate> > > .Select(graph, item.InventoryID); } if (res != null) { result = res.LastCost; } return(new ItemCost(item, (result ?? cost.LastCost).GetValueOrDefault())); }
protected virtual decimal?GetLastCost(INSiteStatus siteStatus) { INItemStats itemStats = SelectFrom <INItemStats> .Where <INItemStats.inventoryID.IsEqual <INSiteStatus.inventoryID.FromCurrent> .And <INItemStats.siteID.IsEqual <INSiteStatus.siteID.FromCurrent> > > .OrderBy <INItemStats.lastCostDate.Desc> .View.ReadOnly.SelectSingleBound(this, new object[] { siteStatus }); return(itemStats?.LastCost); }