diff --git a/README.md b/README.md index cb03d9e..99f101e 100644 --- a/README.md +++ b/README.md @@ -153,7 +153,7 @@ The other Console tabs: | Roster | Reads the guild roster for the website and lists inactive members. | | Recruits | An Add recruit form that fills in your target, plus applicants and trials with yes/no votes from officers. | | Payouts | Recruitment drive winners and their prize, settled a week after each drive ends. Stand at a mailbox and click Mail to send it; nothing sends until then, and a row disappears once it's paid. | -| Bank | Saves the open guild bank tab's log for the website. | +| Bank | Lists everyone who has used the guild bank, biggest giver first: gold and items put in (items valued at the guild's auction prices) and gold, repairs and items taken out. It also saves the open tab's log for the website. These totals only count what your own copy of the addon has read from the bank log; the website's Guild page adds up every officer's reads, counts each member's characters together, and shows the totals to all members. The game keeps only each tab's latest entries, so open every tab now and then. | | Announce | Posts a message to guild chat and every member's News tab, and to Discord if you tick the box. | | Sync | Shows what hasn't been sent to the website yet, with Export and Import buttons. **Update calendar** puts the site's upcoming events on the in-game guild calendar. | | Debug | Guild Master only. Lists what the game blocked SideQuest from doing and errors the addon caught, with a box to copy them. **View as** shows the windows as a non-member, member or officer sees them; **Back to my view**, closing the window or `/sq viewas off` ends it. | diff --git a/SideQuest/Bank.lua b/SideQuest/Bank.lua index edb6d72..e17692e 100755 --- a/SideQuest/Bank.lua +++ b/SideQuest/Bank.lua @@ -28,6 +28,13 @@ -- timestamp across exports, keyed by its unchanging content, and a repeat -- capture matches against it within a tolerance that absorbs both the -- elapsed-hour rounding and the hour that passes between two captures. +-- +-- Every new row is also credited to SideQuestDB.bankContrib, a running +-- per-character tally of gold and items put in and taken out. Unlike +-- pending.bank it is never cleared, so officers can see who has given what +-- since this client started counting. It only knows the rows this client +-- captured: the game keeps a short log per tab, so anything that scrolls +-- off before an officer opens that tab is never counted. SideQuest = SideQuest or {} SideQuest.Bank = {} @@ -123,6 +130,60 @@ local function recordIfNew(key, at, matchedThisPass) return true, id end +local function newContributor() + return { gold_in = 0, gold_out = 0, repairs = 0, items_in = 0, items_out = 0, items = {} } +end + +-- Adds one newly recorded log row to its character's running totals. Tab +-- moves and tab purchases aren't anyone's contribution, so they're skipped. +local function credit(row) + if row.character == "" then + return + end + local kind, ledger = row.kind, SideQuestDB.bankContrib + local isItem = kind == "deposit" or kind == "withdraw" + if not (isItem or kind == "deposit_money" or kind == "withdraw_money" or kind == "repair") then + return + end + local c = ledger.players[row.character] + if not c then + c = newContributor() + ledger.players[row.character] = c + end + if kind == "deposit_money" then + c.gold_in = c.gold_in + row.money + elseif kind == "withdraw_money" then + c.gold_out = c.gold_out + row.money + elseif kind == "repair" then + c.repairs = c.repairs + row.money + else + local count = row.count or 0 + local item = row.item_id and c.items[row.item_id] + if row.item_id and not item then + item = { given = 0, taken = 0 } + c.items[row.item_id] = item + end + if kind == "deposit" then + c.items_in = c.items_in + count + if item then item.given = item.given + count end + else + c.items_out = c.items_out + count + if item then item.taken = item.taken + count end + end + end + if not c.last_at or row.at > c.last_at then + c.last_at = row.at + end + if not ledger.since or row.at < ledger.since then + ledger.since = row.at + end +end + +local function record(row) + table.insert(SideQuestDB.pending.bank, row) + credit(row) +end + --- Capture a guild bank tab's item transaction log into pending.bank. -- Reads whatever QueryGuildBankLog(tab) has already delivered; call once -- GUILDBANKLOG_UPDATE has fired. Returns the number of new rows, or nil if @@ -144,7 +205,7 @@ function Bank.CaptureItemLog(tabIndex) local at = estimateAt(years, months, days, hours) local isNew, id = recordIfNew(key, at, matchedThisPass) if isNew then - table.insert(SideQuestDB.pending.bank, { + record({ id = id, at = at, character = normalized(name), @@ -196,7 +257,7 @@ function Bank.CaptureMoneyLog() local at = estimateAt(years, months, days, hours) local isNew, id = recordIfNew(key, at, matchedThisPass) if isNew then - table.insert(SideQuestDB.pending.bank, { + record({ id = id, at = at, character = normalized(name), @@ -217,6 +278,69 @@ function Bank.CaptureMoneyLog() return added end +-- What a character's deposited items would fetch at the guild's last +-- imported auction prices (SideQuestDB.prices), in copper. Items with no +-- known price add nothing. +local function depositedItemValue(items) + local value = 0 + for itemId, item in pairs(items) do + local price = SideQuest.Market.AuctionPrice(itemId) + if price and price.p then + value = value + price.p * item.given + end + end + return value +end + +--- Everyone this client has seen use the guild bank, biggest contributor +-- first: gold deposited plus the auction value of items deposited, then +-- items deposited, then name. Each entry is { character, gold_in, +-- gold_out, repairs, items_in, items_out, item_value, last_at, items }, +-- where items lists { item_id, given, taken }, most given first. +function Bank.Contributors() + local list = {} + for character, c in pairs(SideQuestDB.bankContrib.players) do + local items = {} + for itemId, item in pairs(c.items) do + table.insert(items, { item_id = itemId, given = item.given, taken = item.taken }) + end + table.sort(items, function(a, b) + if a.given ~= b.given then + return a.given > b.given + end + return a.item_id < b.item_id + end) + table.insert(list, { + character = character, + gold_in = c.gold_in, + gold_out = c.gold_out, + repairs = c.repairs, + items_in = c.items_in, + items_out = c.items_out, + item_value = depositedItemValue(c.items), + last_at = c.last_at, + items = items, + }) + end + table.sort(list, function(a, b) + local av, bv = a.gold_in + a.item_value, b.gold_in + b.item_value + if av ~= bv then + return av > bv + end + if a.items_in ~= b.items_in then + return a.items_in > b.items_in + end + return a.character < b.character + end) + return list +end + +--- When the earliest row this client has counted happened, or nil before +-- any capture. +function Bank.ContributionsSince() + return SideQuestDB.bankContrib.since +end + --- Ask the server for the item and money logs; results land asynchronously -- via GUILDBANKLOG_UPDATE, captured below. Safe to call with the bank -- closed (QueryGuildBankLog is simply a no-op then); does nothing if the diff --git a/SideQuest/Core.lua b/SideQuest/Core.lua index f30ab16..7748b1c 100755 --- a/SideQuest/Core.lua +++ b/SideQuest/Core.lua @@ -61,6 +61,11 @@ local function defaultDB() -- row whose reported elapsed time has grown. Survives `/sq export clear` -- (pending.bank doesn't); pruned at 120 days. bankSeen = {}, + -- Bank.lua: per-character running totals of what each player put into and took out of the guild bank, + -- built from every log row this client captures. Never cleared by `/sq export clear`. `since` is the + -- earliest row counted; players[character] = { gold_in, gold_out, repairs, items_in, items_out, + -- last_at, items = { [item_id] = { given, taken } } } (copper for gold, counts for items). + bankContrib = { since = nil, players = {} }, standby = {}, -- list of normalized "Name-Realm" settings = { officerRankIndex = nil, -- lowest guild rank that counts as officer; 0 is the Guild Master, like GetGuildInfo diff --git a/SideQuest/UI/Main.lua b/SideQuest/UI/Main.lua index 0076767..1066847 100755 --- a/SideQuest/UI/Main.lua +++ b/SideQuest/UI/Main.lua @@ -4945,7 +4945,8 @@ function UI.RefreshConsolePayouts() setScrollContentHeight(chamber.scroll, 46 * #rows) end --- Bank ledger sub-view +-- Bank sub-view: who has put what into the guild bank (Bank.Contributors, kept across syncs), then the log rows +-- captured since the last sync. function UI.BuildConsoleBank(panel) local sub = makeConsoleSub(panel, "Bank") local chamber = createChamber(sub, "SideQuestConsoleBankChamber") @@ -4957,11 +4958,58 @@ function UI.BuildConsoleBank(panel) SideQuest.Bank.RequestCapture() end) - local scroll, content = buildScroll(chamber.inner, -58) - chamber.scroll, chamber.content, chamber.rows = scroll, content, {} + local captureHint = makeFontString(chamber.inner, FONT_BODY_ITALIC, 10, C.mist2, "LEFT") + captureHint:SetPoint("TOPLEFT", captureBtn, "BOTTOMLEFT", 0, -4) + captureHint:SetWidth(540) + captureHint:SetText("The game only keeps each tab's latest entries. Open every tab now and then so no gift is missed.") + + local scroll, content = buildScroll(chamber.inner, -78) + chamber.scroll, chamber.content, chamber.rows, chamber.contribRows = scroll, content, {}, {} + chamber.captureHint = captureHint panel.bankChamber = chamber end +local BANK_TOP_ITEMS = 3 + +-- "12g 30s and 45 items (~3g at AH)" for what a contributor gave. +local function bankGaveText(c) + local parts = {} + if c.gold_in > 0 then + table.insert(parts, money(c.gold_in)) + end + if c.items_in > 0 then + local value = c.item_value > 0 and (" (~" .. money(c.item_value) .. " at AH)") or "" + table.insert(parts, c.items_in .. (c.items_in == 1 and " item" or " items") .. value) + end + return #parts > 0 and table.concat(parts, " and ") or "nothing" +end + +-- "2g, 50s in repairs and 5 items" for what a contributor took out. +local function bankTookText(c) + local parts = {} + if c.gold_out > 0 then + table.insert(parts, money(c.gold_out)) + end + if c.repairs > 0 then + table.insert(parts, money(c.repairs) .. " in repairs") + end + if c.items_out > 0 then + table.insert(parts, c.items_out .. (c.items_out == 1 and " item" or " items")) + end + return #parts > 0 and table.concat(parts, ", ") or "nothing" +end + +local function bankTopItemsText(items) + local parts = {} + for _, item in ipairs(items) do + if item.given == 0 or #parts == BANK_TOP_ITEMS then + break + end + table.insert(parts, SideQuest.ItemName(item.item_id) .. " x" .. item.given) + end + return #parts > 0 and (" Most given: " .. table.concat(parts, ", ") .. ".") or "" +end + function UI.RefreshConsoleBank() local panel = UI.panels[OFFICER_TAB] if not panel or not panel.bankChamber then @@ -4969,26 +5017,74 @@ function UI.RefreshConsoleBank() end local chamber = panel.bankChamber local rows = SideQuestDB.pending.bank or {} + local contributors = SideQuest.Bank.Contributors() for _, r in ipairs(chamber.rows) do r:Hide() end + for _, r in ipairs(chamber.contribRows) do + r:Hide() + end + if chamber.contribHeading then + chamber.contribHeading:Hide() + chamber.pendingHeading:Hide() + end + if not chamber.emptyText then + chamber.emptyText = makeFontString(chamber.content, FONT_BODY, 12, C.mist2, "LEFT") + chamber.emptyText:SetPoint("TOPLEFT") + end if not SideQuest.Bank.IsAvailable() then - if not chamber.emptyText then - chamber.emptyText = makeFontString(chamber.content, FONT_BODY, 12, C.mist2, "LEFT") - chamber.emptyText:SetPoint("TOPLEFT") - end setStateText(chamber.emptyText, "Guild bank log API unavailable here; record deposits/withdrawals on the site.", true) + setScrollContentHeight(chamber.scroll, 0) return - elseif #rows == 0 then - if not chamber.emptyText then - chamber.emptyText = makeFontString(chamber.content, FONT_BODY, 12, C.mist2, "LEFT") - chamber.emptyText:SetPoint("TOPLEFT") - end + elseif #rows == 0 and #contributors == 0 then setStateText(chamber.emptyText, "Open the guild bank to read its log; rows appear here automatically.", true) + setScrollContentHeight(chamber.scroll, 0) return - elseif chamber.emptyText then - chamber.emptyText:SetText("") end + chamber.emptyText:SetText("") + + if not chamber.contribHeading then + chamber.contribHeading = createSubHeading(chamber.content, "Contributors") + chamber.contribHeading:SetWidth(540) + chamber.pendingHeading = createSubHeading(chamber.content, "Waiting to sync") + chamber.pendingHeading:SetWidth(540) + end + local y = 0 + local since = SideQuest.Bank.ContributionsSince() + chamber.contribHeading:ClearAllPoints() + chamber.contribHeading:SetPoint("TOPLEFT", 0, -y) + chamber.contribHeading.label:SetText(trackedCaps("Contributors (" .. #contributors .. ")" + .. (since and (" since " .. date("%Y-%m-%d", since)) or ""))) + chamber.contribHeading:Show() + y = y + 20 + for i, c in ipairs(contributors) do + local row = chamber.contribRows[i] + if not row then + row = CreateFrame("Frame", nil, chamber.content) + row:SetSize(540, 46) + row.titleText = makeFontString(row, FONT_BODY, 13, C.ink, "LEFT") + row.titleText:SetPoint("TOPLEFT") + row.metaText = makeFontString(row, FONT_BODY, 11, C.mist2, "LEFT") + row.metaText:SetPoint("TOPLEFT", row.titleText, "BOTTOMLEFT", 0, -2) + row.metaText:SetWidth(540) + row.metaText:SetWordWrap(true) + chamber.contribRows[i] = row + end + row:ClearAllPoints() + row:SetPoint("TOPLEFT", 0, -y) + row.titleText:SetText(displayName(c.character) .. " -- last used the bank " .. ago(c.last_at)) + row.metaText:SetText("Gave " .. bankGaveText(c) .. ". Took " .. bankTookText(c) .. "." + .. bankTopItemsText(c.items)) + row:Show() + y = y + 50 + end + + y = y + 8 + chamber.pendingHeading:ClearAllPoints() + chamber.pendingHeading:SetPoint("TOPLEFT", 0, -y) + chamber.pendingHeading.label:SetText(trackedCaps("Waiting to sync (" .. #rows .. ")")) + chamber.pendingHeading:Show() + y = y + 20 for i, b in ipairs(rows) do local row = chamber.rows[i] if not row then @@ -4998,11 +5094,14 @@ function UI.RefreshConsoleBank() row.text:SetPoint("LEFT") chamber.rows[i] = row end - row:SetPoint("TOPLEFT", 0, -20 * (i - 1)) - row.text:SetText(b.kind .. " " .. (b.item_name or "") .. " x" .. (b.count or 0) .. " " .. displayName(b.character or "")) + row:ClearAllPoints() + row:SetPoint("TOPLEFT", 0, -y) + local what = b.money and b.money > 0 and money(b.money) or ((b.item_name or "") .. " x" .. (b.count or 0)) + row.text:SetText(b.kind .. " " .. what .. " " .. displayName(b.character or "")) row:Show() + y = y + 20 end - setScrollContentHeight(chamber.scroll, 20 * #rows) + setScrollContentHeight(chamber.scroll, y) end -- Announce sub-view: compose -> toast + guild chat + queued for Discord, diff --git a/tests/preview/html/console-bank-064.html b/tests/preview/html/console-bank-064.html index 621a466..9617b7c 100644 --- a/tests/preview/html/console-bank-064.html +++ b/tests/preview/html/console-bank-064.html @@ -174,8 +174,9 @@
+
The game only keeps each tab's latest entries. Open every tab now and then so no gift is missed.
Capture bank log
-
+
@@ -183,14 +184,32 @@
Capture bank log
-
-
-
-
-
-
-
-
deposit Demo Linen Cloth x20 Demo5
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
C O N T R I B U T O R S   ( 3 )   S I N C E   2 0 2 6 - 1 0 - 1 0
+
W A I T I N G   T O   S Y N C   ( 1 )
+
Demo5 -- last used the bank 1h ago
+
Gave 25g and 60 items (~74g at AH). Took nothing. Most given: Bolt of Runecloth x40, Felcloth x20.
+
Demo2 -- last used the bank 2d ago
+
Gave 12g. Took 45s 50c in repairs.
+
Demo9 -- last used the bank 5d ago
+
Gave nothing. Took 3g, 12 items.
+
deposit Demo Linen Cloth x20 Demo5
diff --git a/tests/preview/html/console-bank.html b/tests/preview/html/console-bank.html index 3943272..9d0e3ad 100644 --- a/tests/preview/html/console-bank.html +++ b/tests/preview/html/console-bank.html @@ -174,8 +174,9 @@
+
The game only keeps each tab's latest entries. Open every tab now and then so no gift is missed.
Capture bank log
-
+
@@ -183,14 +184,32 @@
Capture bank log
-
-
-
-
-
-
-
-
deposit Demo Linen Cloth x20 Demo5
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
C O N T R I B U T O R S   ( 3 )   S I N C E   2 0 2 6 - 1 0 - 1 0
+
W A I T I N G   T O   S Y N C   ( 1 )
+
Demo5 -- last used the bank 1h ago
+
Gave 25g and 60 items (~74g at AH). Took nothing. Most given: Bolt of Runecloth x40, Felcloth x20.
+
Demo2 -- last used the bank 2d ago
+
Gave 12g. Took 45s 50c in repairs.
+
Demo9 -- last used the bank 5d ago
+
Gave nothing. Took 3g, 12 items.
+
deposit Demo Linen Cloth x20 Demo5
diff --git a/tests/preview/out/console-bank-064.png b/tests/preview/out/console-bank-064.png index 98b2e46..337fb95 100644 Binary files a/tests/preview/out/console-bank-064.png and b/tests/preview/out/console-bank-064.png differ diff --git a/tests/preview/out/console-bank.png b/tests/preview/out/console-bank.png index b54b474..010213f 100644 Binary files a/tests/preview/out/console-bank.png and b/tests/preview/out/console-bank.png differ diff --git a/tests/preview/record.lua b/tests/preview/record.lua index 8be190e..aaf5873 100755 --- a/tests/preview/record.lua +++ b/tests/preview/record.lua @@ -309,6 +309,20 @@ SideQuestDB.officerData.recruit_payouts = { SideQuestDB.pending.bank = { { id = "b1", at = WowStub.time, character = "Demo5-Whitemane", kind = "deposit", item_id = 1, item_name = "Demo Linen Cloth", count = 20, money = 0, tab = 1 }, } +-- Bank.lua running contributions: one gold-and-cloth giver (cloth priced by `prices` above), one gold-only +-- giver who also repairs on the guild, one who has only taken. +SideQuestDB.bankContrib = { + since = WowStub.time - 21 * 86400, + players = { + ["Demo5-Whitemane"] = { gold_in = 250000, gold_out = 0, repairs = 0, items_in = 60, items_out = 0, + last_at = WowStub.time - 3600, + items = { [14048] = { given = 40, taken = 0 }, [14256] = { given = 20, taken = 0 } } }, + ["Demo2-Whitemane"] = { gold_in = 120000, gold_out = 0, repairs = 4550, items_in = 0, items_out = 0, + last_at = WowStub.time - 2 * 86400, items = {} }, + ["Demo9-Whitemane"] = { gold_in = 0, gold_out = 30000, repairs = 0, items_in = 0, items_out = 12, + last_at = WowStub.time - 5 * 86400, items = { [12360] = { given = 0, taken = 12 } } }, + }, +} SideQuestDB.pending.announcements = { { id = "ann-demo-1", text = "Flasks for Friday please", officer = "Demo1-Whitemane", at = WowStub.time - 5400, discord = true }, } diff --git a/tests/test_bank.lua b/tests/test_bank.lua index d6ad89a..0156d5a 100644 --- a/tests/test_bank.lua +++ b/tests/test_bank.lua @@ -201,4 +201,113 @@ return function(h) h.assertTrue(chamber.rows[1]:IsShown(), "a row is shown") h.assertTrue(chamber.rows[1].text:GetText():find("deposit", 1, true) ~= nil, "row text shows the kind") end) + + local LINEN_LINK = "|cffffffff|Hitem:2589:0:0:0:0:0:0:0:0:0:0|h[Linen Cloth]|h|r" + + local function contributor(name) + for _, c in ipairs(SideQuest.Bank.Contributors()) do + if c.character == name then + return c + end + end + end + + h.test("contributions: gold and items given and taken add up per player; tab moves and tab purchases count for no one", function() + reset() + WowStub.bankTransactions[1] = { + { kind = "deposit", name = "Alice", itemLink = ITEM_LINK, count = 20, year = 0, month = 0, day = 0, hour = 1 }, + { kind = "deposit", name = "Alice", itemLink = ITEM_LINK, count = 5, year = 0, month = 0, day = 0, hour = 3 }, + { kind = "deposit", name = "Alice", itemLink = LINEN_LINK, count = 10, year = 0, month = 0, day = 0, hour = 4 }, + { kind = "withdraw", name = "Alice", itemLink = LINEN_LINK, count = 2, year = 0, month = 0, day = 0, hour = 5 }, + { kind = "move", name = "Bob", itemLink = ITEM_LINK, count = 7, year = 0, month = 0, day = 0, hour = 1 }, + } + WowStub.bankMoneyTransactions = { + { kind = "deposit", name = "Alice", amount = 10000, year = 0, month = 0, day = 0, hour = 1 }, + { kind = "deposit", name = "Alice", amount = 2500, year = 0, month = 0, day = 1, hour = 0 }, + { kind = "withdraw", name = "Alice", amount = 3000, year = 0, month = 0, day = 0, hour = 2 }, + { kind = "repair", name = "Alice", amount = 400, year = 0, month = 0, day = 0, hour = 2 }, + { kind = "buyTab", name = "Dave", amount = 100000, year = 0, month = 0, day = 0, hour = 4 }, + } + SideQuest.Fire("GUILDBANKLOG_UPDATE") + + local alice = contributor("Alice-Whitemane") + h.assertEq(alice.gold_in, 12500, "both gold deposits") + h.assertEq(alice.gold_out, 3000, "gold withdrawn") + h.assertEq(alice.repairs, 400, "guild-paid repairs kept apart from withdrawals") + h.assertEq(alice.items_in, 35, "every item deposited") + h.assertEq(alice.items_out, 2, "items withdrawn") + h.assertEq(alice.items[1].item_id, 14048, "most-given item first") + h.assertEq(alice.items[1].given, 25, "both Runecloth deposits on one item") + h.assertEq(alice.items[2].taken, 2, "Linen withdrawal on the Linen entry") + h.assertEq(contributor("Bob-Whitemane"), nil, "a tab-to-tab move is no one's contribution") + h.assertEq(contributor("Dave-Whitemane"), nil, "buying a tab is no one's contribution") + h.assertEq(SideQuest.Bank.ContributionsSince(), WowStub.time - 86400, "since = earliest row counted") + end) + + h.test("contributions: kept through `/sq export clear`, and a re-captured row a day later isn't counted twice", function() + reset() + WowStub.bankTransactions[1] = { + { kind = "deposit", name = "Alice", itemLink = ITEM_LINK, count = 5, year = 0, month = 0, day = 2, hour = 5 }, + } + WowStub.bankMoneyTransactions = { + { kind = "deposit", name = "Alice", amount = 10000, year = 0, month = 0, day = 2, hour = 5 }, + } + SideQuest.Fire("GUILDBANKLOG_UPDATE") + SideQuest.Sync.ClearPending() + + WowStub.Advance(DAY) + WowStub.bankTransactions[1][1].day = 3 + WowStub.bankMoneyTransactions[1].day = 3 + SideQuest.Fire("GUILDBANKLOG_UPDATE") + + local alice = contributor("Alice-Whitemane") + h.assertEq(alice.items_in, 5, "same deposit, counted once") + h.assertEq(alice.gold_in, 10000, "same gold deposit, counted once") + + WowStub.bankMoneyTransactions[2] = { kind = "deposit", name = "Alice", amount = 500, year = 0, month = 0, day = 0, hour = 0 } + SideQuest.Fire("GUILDBANKLOG_UPDATE") + h.assertEq(contributor("Alice-Whitemane").gold_in, 10500, "a new deposit after the clear still adds") + end) + + h.test("contributions: ranked by gold given plus what given items fetch at the guild's AH prices", function() + reset() + SideQuestDB.prices = { [14048] = { p = 1000, q = 50, at = WowStub.time } } -- Runecloth 10s each + WowStub.bankTransactions[1] = { + { kind = "deposit", name = "Carl", itemLink = LINEN_LINK, count = 200, year = 0, month = 0, day = 0, hour = 1 }, -- no price + { kind = "deposit", name = "Alice", itemLink = ITEM_LINK, count = 30, year = 0, month = 0, day = 0, hour = 1 }, -- 3g + } + WowStub.bankMoneyTransactions = { + { kind = "deposit", name = "Bob", amount = 20000, year = 0, month = 0, day = 0, hour = 1 }, -- 2g + } + SideQuest.Fire("GUILDBANKLOG_UPDATE") + + local order = {} + for _, c in ipairs(SideQuest.Bank.Contributors()) do + table.insert(order, c.character) + end + h.assertEq(table.concat(order, ","), "Alice-Whitemane,Bob-Whitemane,Carl-Whitemane", + "3g of priced cloth beats 2g of gold; unpriced items rank last") + h.assertEq(contributor("Alice-Whitemane").item_value, 30000, "item value = count x AH unit price") + end) + + h.test("console Bank view: contributors stay listed after the captured rows have synced", function() + reset() + SideQuest.UI.main = nil + SideQuest.UI.Show() + SideQuest.UI.ShowTab("Console") + SideQuest.UI.ShowConsoleSub("Bank") + WowStub.bankMoneyTransactions = { + { kind = "deposit", name = "Alice", amount = 12345, year = 0, month = 0, day = 0, hour = 1 }, + } + SideQuest.Fire("GUILDBANKLOG_UPDATE") + SideQuest.Sync.ClearPending() + SideQuest.UI.RefreshConsoleBank() + + local chamber = SideQuest.UI.panels.Console.bankChamber + h.assertEq(chamber.emptyText:GetText(), "", "no 'open the guild bank' prompt while contributors are known") + h.assertTrue(chamber.contribRows[1]:IsShown(), "contributor row shown") + local meta = chamber.contribRows[1].metaText:GetText() + h.assertTrue(meta:find("Gave 1g 23s 45c", 1, true) ~= nil, "shows the gold given: " .. meta) + h.assertTrue(chamber.rows[1] == nil or not chamber.rows[1]:IsShown(), "no synced log rows left") + end) end