Create a gist now

Instantly share code, notes, and snippets.

@0bp /HTML.lua
Last active Jun 7, 2017

What would you like to do?
MoneyMoney HTML Export mit Kategorie und Kommentar
-- The MIT License (MIT)
--
-- Copyright (c) 2014 Boris Penck
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in
-- all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-- THE SOFTWARE.
Exporter{version = 1.01,
format = "HTML",
fileExtension = "html",
reverseOrder = true,
description = "Export to HTML"}
function WriteHeader (account, startDate, endDate, transactionCount)
assert(io.write([[
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>]] .. account.name .. [[, ]] .. os.date("%d.%m.%Y", startDate) .. [[ - ]] .. os.date("%d.%m.%Y", endDate) .. [[</title>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css">
</head>
<body>
<div class="page-heading">
<h1>]] .. account.name .. [[, ]] .. os.date("%d.%m.%Y", startDate) .. [[ - ]] .. os.date("%d.%m.%Y", endDate) .. [[</h1>
</div>
<table class="table table-hover">
<thead>
<th class="lead">Datum</th>
<th class="lead">Buchung</th>
<th class="text-right lead">Betrag</th>
<th class="lead">Kategorie</th>
<th class="lead">Kommentar</th>
</thead>
<tbody>
]]))
end
function WriteTransactions (account, transactions)
for _,transaction in ipairs(transactions) do
class = ""
if transaction.amount > 0 then
class="active"
end
assert(io.write([[
<tr class="]] .. class .. [[">
<td>]] .. os.date("%d.%m.%Y", transaction.bookingDate) .. [[</td>
<td><strong>]] .. transaction.name .. [[</strong><br>]] .. transaction.purpose .. [[</td>
<td class="text-right">]] .. string.format("%.02f", transaction.amount) .. [[&nbsp;]] .. transaction.currency .. [[</td>
<td><span class="badge">]] .. transaction.category .. [[</span></td>
<td>]] .. transaction.comment .. [[</td>
</tr>
]]))
end
end
function WriteTail (account)
assert(io.write([[
</tbody>
<tfoot>
<tr>
<td class="lead">]] .. os.date("%d.%m.%Y", account.balanceDate) .. [[</td>
<td class="lead">Kontostand</td>
<td class="text-right lead">]] .. string.format("%.02f", account.balance) .. [[&nbsp;]] .. account.currency .. [[</td>
<td></td>
<td></td>
</tr>
</tfoot>
</table>
</body>
</html>
]]))
end
Owner

0bp commented Jan 15, 2014

  1. Speichern in ~/Library/Application Support/MoneyMoney/Extensions/HTML.lua
  2. Preferences -> Extensions -> "Verify digital..." ausschalten

Cool, danke!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment