From 78fef48bdf69361ed2774e7e8272e9cc4787adfc Mon Sep 17 00:00:00 2001 From: Simon Elsbrock Date: Wed, 23 Aug 2017 22:59:38 +0200 Subject: [PATCH] Fix parsing of amounts for rich people (> triple digit) For amounts greater than 999,99 fairr displays a decimal point, e.g. 3.1415,92. This commit removes all decimal points before casting to a number. --- fairr.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fairr.lua b/fairr.lua index d293a3c..2a4834c 100644 --- a/fairr.lua +++ b/fairr.lua @@ -101,9 +101,9 @@ function RefreshAccount (account, since) name = row:xpath("td[1]/a"):text(), market = "Fairr", currency = nil, - quantity = tonumber((row:xpath("td[3]"):text():gsub(",", "."))), - amount = tonumber((row:xpath("td[6]"):text():gsub(",", "."))) + tonumber((row:xpath("td[7]"):text():gsub(",", "."))), - price = tonumber((row:xpath("td[4]"):text():gsub("EUR", ""):gsub(",", "."))) + quantity = tonumber((row:xpath("td[3]"):text():gsub("%.", ""):gsub(",(%d+)$", ".%1"))), + amount = tonumber((row:xpath("td[6]"):text():gsub("%.", ""):gsub(",(%d+)$", ".%1"))) + tonumber((row:xpath("td[7]"):text():gsub("%.", ""):gsub(",(%d+)$", ".%1"))), + price = tonumber((row:xpath("td[4]"):text():gsub("EUR", ""):gsub("%.", ""):gsub(",(%d+)$", ".%1"))) } table.insert(transactions, transaction)