修正
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user