mirror of
https://github.com/puppe/moneymoney-uberspace.git
synced 2025-12-20 01:12:17 +01:00
Fix error with newly created Uberspace accounts
Newly created Uberspace accounts do not display an account balance on the accounting page. The script has to handle that case.
This commit is contained in:
parent
a748cff082
commit
3e9464d858
1 changed files with 10 additions and 2 deletions
|
|
@ -52,6 +52,11 @@ function RefreshAccount (account, since)
|
|||
function ParseAmount (amountString)
|
||||
local pattern = '(%-?%d+),(%d%d)'
|
||||
local euro, cent = amountString:match(pattern)
|
||||
|
||||
if not euro or not cent then
|
||||
return nil
|
||||
end
|
||||
|
||||
euro = tonumber(euro)
|
||||
cent = tonumber(cent) / 100
|
||||
if euro < 0 then
|
||||
|
|
@ -90,8 +95,11 @@ function RefreshAccount (account, since)
|
|||
})
|
||||
end
|
||||
|
||||
balanceElement = html:xpath('//*[@id="total"]')
|
||||
balance = ParseAmount(balanceElement:text())
|
||||
local balanceElement = html:xpath('//*[@id="total"]')
|
||||
local balance = ParseAmount(balanceElement:text())
|
||||
if not balance then
|
||||
balance = 0
|
||||
end
|
||||
return {balance=balance, transactions=transactions}
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue