Browse Source

Accounting tracks item count

Fixes issue #6
pull/7/head
Xan-Asc 3 years ago committed by GitHub
parent
commit
82379ce80b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 23
      TradeSkillMaster_Accounting/Modules/data.lua

23
TradeSkillMaster_Accounting/Modules/data.lua

@ -373,26 +373,20 @@ function Data:ScanCollectedMail(oFunc, attempt, index, subIndex)
end end
end end
local quantity = 0
for j = 1, ATTACHMENTS_MAX_RECEIVE do
quantity = select(3, GetInboxItem(index, j))
end
if quantity == 0 then
quantity = 1
end
if invoiceType == "seller" and buyer and buyer ~= "" then -- AH Sales if invoiceType == "seller" and buyer and buyer ~= "" then -- AH Sales
local daysLeft = select(7, GetInboxHeaderInfo(index)) local daysLeft = select(7, GetInboxHeaderInfo(index))
local saleTime = (time() + (daysLeft - 30) * SECONDS_PER_DAY) local saleTime = (time() + (daysLeft - 30) * SECONDS_PER_DAY)
local link = select(2, TSMAPI:GetSafeItemInfo(itemName)) local link = select(2, TSMAPI:GetSafeItemInfo(itemName))
local itemString = TSM.db.global.itemStrings[itemName] or TSMAPI:GetItemString(link) local itemString = TSM.db.global.itemStrings[itemName] or TSMAPI:GetItemString(link)
local quantity = select(11, GetInboxInvoiceInfo(index)) or 1 -- WotLK doesn't provide quantity sold by default, Ascension does
if itemString and private:CanLootMailIndex(index) then if itemString and private:CanLootMailIndex(index) then
local copper = floor((bid - ahcut) / quantity + 0.5) local copper = floor((bid - ahcut) / quantity + 0.5)
Data:InsertItemSaleRecord(itemString, "Auction", quantity, copper, buyer, saleTime) Data:InsertItemSaleRecord(itemString, "Auction", quantity, copper, buyer, saleTime)
end end
elseif invoiceType == "buyer" and buyer and buyer ~= "" then -- AH Buys elseif invoiceType == "buyer" and buyer and buyer ~= "" then -- AH Buys
local link = GetInboxItemLink(index, subIndex or 1) local link = GetInboxItemLink(index, 1)
local itemString = TSMAPI:GetItemString(link) local itemString = TSMAPI:GetItemString(link)
local quantity = select(3, GetInboxItem(index, 1))
if itemString and private:CanLootMailIndex(index) then if itemString and private:CanLootMailIndex(index) then
--might as well grab the name for future lookups --might as well grab the name for future lookups
local name = TSMAPI:GetSafeItemInfo(link) local name = TSMAPI:GetSafeItemInfo(link)
@ -428,17 +422,18 @@ function Data:ScanCollectedMail(oFunc, attempt, index, subIndex)
end end
if total ~= 0 and not ignore and private:CanLootMailIndex(index) then if total ~= 0 and not ignore and private:CanLootMailIndex(index) then
local copper = floor(codAmount / total + 0.5) -- local copper = floor(codAmount / total + 0.5)
local daysLeft = select(7, GetInboxHeaderInfo(index)) local daysLeft = select(7, GetInboxHeaderInfo(index))
local buyTime = (time() + (daysLeft - 3) * SECONDS_PER_DAY) local buyTime = (time() + (daysLeft - 3) * SECONDS_PER_DAY)
local maxStack = select(8, TSMAPI:GetSafeItemInfo(link)) -- local maxStack = select(8, TSMAPI:GetSafeItemInfo(link))
for i = 1, stacks do Data:InsertItemBuyRecord(itemString, "COD", total, codAmount, sender, buyTime)
--[[ for i = 1, stacks do
local stackSize = (total >= maxStack) and maxStack or total local stackSize = (total >= maxStack) and maxStack or total
Data:InsertItemBuyRecord(itemString, "COD", stackSize, copper, sender, buyTime) Data:InsertItemBuyRecord(itemString, "COD", stackSize, copper, sender, buyTime)
total = total - stackSize total = total - stackSize
if total <= 0 then break end if total <= 0 then break end
end end
end ]] end
end end
elseif money > 0 and invoiceType ~= "seller" and not strfind(subject, outbid) then elseif money > 0 and invoiceType ~= "seller" and not strfind(subject, outbid) then
local str local str
@ -1265,4 +1260,4 @@ function Data:LogGold()
end end
tinsert(goldLog, { startMinute = currentMinute, endMinute = currentMinute, copper = currentGold }) tinsert(goldLog, { startMinute = currentMinute, endMinute = currentMinute, copper = currentGold })
end end
end end

Loading…
Cancel
Save