This commit is contained in:
FNOS-WIN11ENT\choshoukaku
2025-12-15 17:57:49 +09:00
parent b6751ced18
commit 88163423e0
5 changed files with 603 additions and 470 deletions

View File

@@ -28,7 +28,7 @@
<th>日付</th>
<th>摘要</th>
<th>借方合計</th>
<th>方合</th>
<th>方合</th>
<th>操作</th>
</tr>
</thead>
@@ -63,7 +63,7 @@ async function search() {
<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>
<button onclick="reverseAndEdit(${e.journal_entry_id})">修正</button>
</td>
`;
tbody.appendChild(tr);
@@ -74,23 +74,34 @@ function view(id) {
window.open(`journal-view.html?id=${id}`, "_blank");
}
async function reverse(id) {
if (!confirm("この仕訳逆仕訳を作成します。よろしいですか?")) return;
// --------------------------------------------------
// 修正仕訳逆仕訳を作って修正画面へ遷移
// --------------------------------------------------
async function reverseAndEdit(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();
// ② 元仕訳内容を取得して修正画面へ遷移
const src = await fetch(`${API}/journal-entries/${id}`);
const srcData = await src.json();
localStorage.setItem("editSource", JSON.stringify(srcData));
window.open("journal-edit.html", "_blank");
}
</script>
</body>