Files
njts-accounting-core/frontend/journal-list.html
FNOS-WIN11ENT\choshoukaku b6751ced18 20251215滴修正
2025-12-15 14:49:59 +09:00

98 lines
2.3 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>仕訳一覧</title>
<style>
body { font-family: sans-serif; margin: 24px; }
table { border-collapse: collapse; width: 100%; margin-top: 12px; }
th, td { border: 1px solid #ccc; padding: 6px; }
th { background: #f5f5f5; }
</style>
</head>
<body>
<h2>仕訳一覧</h2>
<label>期間</label>
<input type="date" id="fromDate"> <input type="date" id="toDate">
<label>摘要</label>
<input type="text" id="keyword">
<button onclick="search()">検索</button>
<table>
<thead>
<tr>
<th>日付</th>
<th>摘要</th>
<th>借方合計</th>
<th>贷方合计</th>
<th>操作</th>
</tr>
</thead>
<tbody id="list"></tbody>
</table>
<script>
const API = "http://127.0.0.1:18080";
async function search() {
const from = document.getElementById("fromDate").value;
const to = document.getElementById("toDate").value;
const key = document.getElementById("keyword").value;
const qs = new URLSearchParams();
if (from) qs.append("from_date", from);
if (to) qs.append("to_date", to);
if (key) qs.append("keyword", key);
const res = await fetch(`${API}/journal-entries?${qs.toString()}`);
const data = await res.json();
const tbody = document.getElementById("list");
tbody.innerHTML = "";
data.forEach(e => {
const tr = document.createElement("tr");
tr.innerHTML = `
<td>${e.entry_date}</td>
<td>${e.description}</td>
<td style="text-align:right">${e.debit_total.toLocaleString()}</td>
<td style="text-align:right">${e.credit_total.toLocaleString()}</td>
<td>
<button onclick="view(${e.journal_entry_id})">表示</button>
<button onclick="reverse(${e.journal_entry_id})">修正</button>
</td>
`;
tbody.appendChild(tr);
});
}
function view(id) {
window.open(`journal-view.html?id=${id}`, "_blank");
}
async function reverse(id) {
if (!confirm("この仕訳の逆仕訳を作成します。よろしいですか?")) return;
const res = await fetch(`${API}/journal-entries/${id}/reverse`, {
method: "POST"
});
const data = await res.json();
if (!res.ok) {
alert(data.detail || "逆仕訳の作成に失敗しました");
return;
}
alert(`逆仕訳を作成しましたID: ${data.reversed_journal_entry_id}`);
search();
}
</script>
</body>
</html>