2026-07-05 06:41:32 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
|
<html lang="sv">
|
|
|
|
|
<head>
|
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
|
|
|
<title>LandveX AB - Test</title>
|
|
|
|
|
<style>
|
|
|
|
|
body { font-family: -apple-system, sans-serif; padding: 20px; background: #f2f2f7; }
|
2026-07-07 07:11:50 +00:00
|
|
|
.card { background: white; border-radius: var(--radius-md); padding: 16px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
|
2026-07-05 06:41:32 +00:00
|
|
|
h1 { font-size: 28px; margin-bottom: 8px; }
|
|
|
|
|
.entry { padding: 8px 0; border-bottom: 1px solid #eee; }
|
|
|
|
|
.entry:last-child { border-bottom: none; }
|
|
|
|
|
.amount { font-weight: 600; }
|
|
|
|
|
.debit { color: #34c759; }
|
|
|
|
|
.credit { color: #ff3b30; }
|
|
|
|
|
</style>
|
|
|
|
|
</head>
|
|
|
|
|
<body>
|
|
|
|
|
<h1>LandveX AB</h1>
|
|
|
|
|
<div id="content">Laddar...</div>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
const API = 'http://bernt.wavult.com:3250';
|
|
|
|
|
|
|
|
|
|
async function loadData() {
|
|
|
|
|
// Login
|
|
|
|
|
const loginRes = await fetch(`${API}/login`, {
|
|
|
|
|
method: 'POST',
|
|
|
|
|
headers: { 'Content-Type': 'application/json' },
|
|
|
|
|
body: JSON.stringify({ username: 'admin', password: 'password' })
|
|
|
|
|
});
|
|
|
|
|
const { token } = await loginRes.json();
|
|
|
|
|
const headers = { 'Authorization': `Bearer ${token}` };
|
|
|
|
|
|
|
|
|
|
// Hämta konton
|
|
|
|
|
const accountsRes = await fetch(`${API}/api/v1/accounts`, { headers });
|
|
|
|
|
const accounts = await accountsRes.json();
|
|
|
|
|
|
|
|
|
|
// Hämta trial balance
|
|
|
|
|
const tbRes = await fetch(`${API}/api/v1/trial-balance`, { headers });
|
|
|
|
|
const tb = await tbRes.json();
|
|
|
|
|
|
|
|
|
|
// Hämta verifikat
|
|
|
|
|
const entriesRes = await fetch(`${API}/api/v1/journal-entries`, { headers });
|
|
|
|
|
const entries = await entriesRes.json();
|
|
|
|
|
|
|
|
|
|
let html = '<div class="card"><h2>Konton</h2>';
|
|
|
|
|
accounts.forEach(a => {
|
|
|
|
|
html += `<div class="entry">${a.code} ${a.name}</div>`;
|
|
|
|
|
});
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
html += '<div class="card"><h2>Trial Balance</h2>';
|
|
|
|
|
tb.forEach(row => {
|
|
|
|
|
const balance = row.balance || 0;
|
|
|
|
|
const color = balance >= 0 ? 'debit' : 'credit';
|
|
|
|
|
html += `<div class="entry">${row.account_code} ${row.account_name}: <span class="amount ${color}">${balance.toFixed(2)}</span></div>`;
|
|
|
|
|
});
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
html += `<div class="card"><h2>Verifikat (${entries.length})</h2>`;
|
|
|
|
|
entries.forEach(e => {
|
|
|
|
|
html += `<div class="entry">${e.entry_number}: ${e.description}</div>`;
|
|
|
|
|
});
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
document.getElementById('content').innerHTML = html;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
loadData().catch(e => {
|
|
|
|
|
document.getElementById('content').innerHTML = `<div class="card" style="color:red">Fel: ${e.message}</div>`;
|
|
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
</body>
|
|
|
|
|
</html>
|