From 269852a19ae76f588d00c39a3b234bfa0446036e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lien=20Sell=C3=A6g?= Date: Wed, 14 Jan 2026 21:46:11 +0100 Subject: [PATCH] show last buy price in tooltips --- README.md | 1 + TradeSkillMaster/TradeSkillMaster.toc | 2 +- TradeSkillMaster_Accounting/Locale/enUS.lua | 2 ++ .../TradeSkillMaster_Accounting.lua | 22 +++++++++++++++++++ .../TradeSkillMaster_AuctionDB.toc | 4 ++-- 5 files changed, 28 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b805b11..fa7eeae 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ TSM price strings can reference built-in data sources and combine them with math - `avgSell`: Average sell price. - `avgBuy`: Average buy price. - `smartAvgBuy`: Smart average buy price (uses current holdings to weight recent buys). +- `lastBuy`: Last buy price (most recent purchase; also shown under Last Purchased in Accounting tooltips). - `maxSell`: Maximum sell price. - `maxBuy`: Maximum buy price. - `minSell`: Minimum sell price. diff --git a/TradeSkillMaster/TradeSkillMaster.toc b/TradeSkillMaster/TradeSkillMaster.toc index 4f7cf06..b95eba2 100644 --- a/TradeSkillMaster/TradeSkillMaster.toc +++ b/TradeSkillMaster/TradeSkillMaster.toc @@ -2,7 +2,7 @@ ## Title: |cff00fe00TradeSkillMaster: Revived|r ## Notes: Core addon for the TradeSkillMaster suite, revived for Wrath of the Lich King. Does nothing without modules installed. ## Author: Sapu94, Bart39, Gnomezilla [Warmane-Icecrown(A)], BlueAo [Warmane], andrew6180, Yoshiyuka, DimaSheiko, and other contributors... -## Version: 2.3.25 +## Version: 2.3.27 ## SavedVariables: TradeSkillMasterAppDB, AscensionTSMDB ## OptionalDeps: AccurateTime, Ace3, LibDataBroker-1.1, LibDBIcon-1.0, LibExtraTip, TipHelper, LibParse, LibCompress, LibGraph-2.0, SharedMedia, TheUndermineJournal, TheUndermineJournalGE ## X-Embeds: AccurateTime, Ace3, LibDataBroker-1.1, LibDBIcon-1.0, LibExtraTip, TipHelper, LibParse, LibCompress, LibGraph-2.0 diff --git a/TradeSkillMaster_Accounting/Locale/enUS.lua b/TradeSkillMaster_Accounting/Locale/enUS.lua index e9369dc..55c50f6 100644 --- a/TradeSkillMaster_Accounting/Locale/enUS.lua +++ b/TradeSkillMaster_Accounting/Locale/enUS.lua @@ -24,6 +24,8 @@ L["Average Prices:"] = true L["Avg Buy Price"] = true L["Avg Resale Profit"] = true L["Avg Sell Price"] = true +L["Last Buy Price"] = true +L["Last Buy Price:"] = true L["Smart Avg Buy Price:"] = true L["Smart Avg Buy Price"] = true L["Back to Previous Page"] = true diff --git a/TradeSkillMaster_Accounting/TradeSkillMaster_Accounting.lua b/TradeSkillMaster_Accounting/TradeSkillMaster_Accounting.lua index 9e1eb9b..6ab116c 100644 --- a/TradeSkillMaster_Accounting/TradeSkillMaster_Accounting.lua +++ b/TradeSkillMaster_Accounting/TradeSkillMaster_Accounting.lua @@ -126,6 +126,7 @@ function TSM:RegisterModule() { key = "avgSell", label = L["Avg Sell Price"], callback = "GetAvgSellPrice" }, { key = "avgBuy", label = L["Avg Buy Price"], callback = "GetAvgBuyPrice" }, { key = "smartAvgBuy", label = L["Smart Avg Buy Price"], callback = "GetSmartAvgBuyPrice" }, + { key = "lastBuy", label = L["Last Buy Price"], callback = "GetLastBuyPrice" }, { key = "maxSell", label = L["Max Sell Price"], callback = "GetMaxSellPrice" }, { key = "maxBuy", label = L["Max Buy Price"], callback = "GetMaxBuyPrice" }, { key = "minSell", label = L["Min Sell Price"], callback = "GetMinSellPrice" }, @@ -188,6 +189,7 @@ function TSM:GetTooltip(itemString) if TSM.db.realm.tooltip.purchase and TSM.items[itemString] and #TSM.items[itemString].buys > 0 then local lastPurchased = TSM.items[itemString].buys[#TSM.items[itemString].buys].time + local lastBuyPrice = TSM:GetLastBuyPrice(itemString) local totalPrice, totalNum = 0, 0 for _, record in ipairs(TSM.items[itemString].buys) do totalNum = totalNum + record.quantity @@ -220,6 +222,13 @@ function TSM:GetTooltip(itemString) if lastPurchased then local timeDiff = SecondsToTime(time() - lastPurchased) tinsert(text, { left = " " .. L["Last Purchased:"], right = "|cffffffff" .. format(L["%s ago"], timeDiff) }) + if lastBuyPrice then + if moneyCoinsTooltip then + tinsert(text, { left = " " .. L["Last Buy Price:"], right = (TSMAPI:FormatTextMoneyIcon(lastBuyPrice, "|cffffffff", true) or ("|cffffffff" .. "?")) }) + else + tinsert(text, { left = " " .. L["Last Buy Price:"], right = (TSMAPI:FormatTextMoney(lastBuyPrice, "|cffffffff", true) or ("|cffffffff" .. "?")) }) + end + end end end @@ -575,6 +584,19 @@ function TSM:GetMinBuyPrice(itemString) return TSM.cache[itemString].minBuyPrice end +function TSM:GetLastBuyPrice(itemString) + itemString = TSMAPI:GetItemString(select(2, TSMAPI:GetSafeItemInfo(itemString))) + if not (itemString and TSM.items[itemString] and #TSM.items[itemString].buys > 0) then return end + TSM.cache[itemString] = TSM.cache[itemString] or {} + + if not TSM.cache[itemString].lastBuyPrice then + local lastRecord = TSM.items[itemString].buys[#TSM.items[itemString].buys] + TSM.cache[itemString].lastBuyPrice = lastRecord and lastRecord.copper or nil + end + + return TSM.cache[itemString].lastBuyPrice +end + function TSM:Round(value, sig) sig = sig or 1 local gold = value / sig diff --git a/TradeSkillMaster_AuctionDB/TradeSkillMaster_AuctionDB.toc b/TradeSkillMaster_AuctionDB/TradeSkillMaster_AuctionDB.toc index 4875a6c..aa9b995 100644 --- a/TradeSkillMaster_AuctionDB/TradeSkillMaster_AuctionDB.toc +++ b/TradeSkillMaster_AuctionDB/TradeSkillMaster_AuctionDB.toc @@ -2,10 +2,10 @@ ## Title: |cff00ff00TradeSkillMaster_AuctionDB|r ## Notes: Stores auction house data and calculates market prices. ## Author: Sapu94, Bart39 -## Version: 2.3.25 +## Version: 2.3.27 ## SavedVariables: AscensionTSM_AuctionDB ## Dependency: TradeSkillMaster -## X-Curse-Packaged-Version: 2.3.25 +## X-Curse-Packaged-Version: 2.3.27 ## X-Curse-Project-Name: TradeSkillMaster_AuctionDB ## X-Curse-Project-ID: tradeskillmaster_auctiondb ## X-Curse-Repository-ID: wow/tradeskillmaster_auctiondb/mainline