login画面追加

This commit is contained in:
admin
2026-02-07 14:25:28 +09:00
parent 9d1ad5594d
commit 331953bb7f
22 changed files with 763 additions and 135 deletions

View File

@@ -1,7 +1,8 @@
<!DOCTYPE html>
<!doctype html>
<html lang="ja">
<head>
<meta charset="UTF-8" />
<script src="js/auth.js"></script>
<title>仕訳入力</title>
<style>
body {
@@ -393,12 +394,12 @@
// 仮払消費税等(あなたの DB では 505 は「未払消費税等」)
taxPaidAccounts = accounts.filter((a) =>
a.account_name.includes("仮払")
a.account_name.includes("仮払"),
);
// 仮受消費税等
taxReceivedAccounts = accounts.filter((a) =>
a.account_name.includes("仮受")
a.account_name.includes("仮受"),
);
setupTaxSelectors();
@@ -432,7 +433,7 @@
.addEventListener("change", () => {
// 端数処理変更時は全ての税行を再計算
const rows = document.querySelectorAll(
"#linesTable tbody tr:not(.tax-row)"
"#linesTable tbody tr:not(.tax-row)",
);
rows.forEach((row) => handleTax(row));
});
@@ -452,7 +453,7 @@
optgroup.label = group.label;
const groupAccounts = accounts.filter((a) =>
group.codes.includes(a.account_code)
group.codes.includes(a.account_code),
);
groupAccounts.forEach((acc) => {
@@ -471,7 +472,7 @@
// -----------------------------
function loadDescriptionHistory() {
const history = JSON.parse(
localStorage.getItem("descriptionHistory") || "[]"
localStorage.getItem("descriptionHistory") || "[]",
);
const datalist = document.getElementById("descriptionHistory");
datalist.innerHTML = "";
@@ -487,7 +488,7 @@
if (!description || description.trim() === "") return;
let history = JSON.parse(
localStorage.getItem("descriptionHistory") || "[]"
localStorage.getItem("descriptionHistory") || "[]",
);
// 重複を避け、先頭に追加
@@ -512,7 +513,7 @@
taxPaidAccounts
.map(
(a) =>
`<option value="${a.account_id}">${a.account_code} ${a.account_name}</option>`
`<option value="${a.account_id}">${a.account_code} ${a.account_name}</option>`,
)
.join("");
@@ -521,7 +522,7 @@
taxReceivedAccounts
.map(
(a) =>
`<option value="${a.account_id}">${a.account_code} ${a.account_name}</option>`
`<option value="${a.account_id}">${a.account_code} ${a.account_name}</option>`,
)
.join("");
}
@@ -660,7 +661,7 @@
balanceStatus.style.background = "";
} else {
balanceStatus.textContent = `✗ 差額: ${Math.abs(
totalDebit - totalCredit
totalDebit - totalCredit,
).toLocaleString()}`;
balanceStatus.style.background = "#f8d7da";
balanceStatus.style.color = "#721c24";
@@ -677,10 +678,10 @@
const taxType = row.querySelector(".taxType").value;
const taxDir = row.querySelector(".taxDirection").value;
const debit = Number(
row.querySelector(".debit").value.replace(/,/g, "") || 0
row.querySelector(".debit").value.replace(/,/g, "") || 0,
);
const credit = Number(
row.querySelector(".credit").value.replace(/,/g, "") || 0
row.querySelector(".credit").value.replace(/,/g, "") || 0,
);
if (taxType === "none" || taxDir === "none") {
@@ -722,7 +723,7 @@
addRow(
true,
{ accountId: taxAcc, amount: taxAmount, side: "debit" },
parentId
parentId,
);
}
if (taxDir === "received") {
@@ -734,7 +735,7 @@
addRow(
true,
{ accountId: taxAcc, amount: taxAmount, side: "credit" },
parentId
parentId,
);
}
@@ -781,10 +782,10 @@
const accountId = Number(row.querySelector(".account").value);
const debit = Number(
row.querySelector(".debit").value.replace(/,/g, "") || 0
row.querySelector(".debit").value.replace(/,/g, "") || 0,
);
const credit = Number(
row.querySelector(".credit").value.replace(/,/g, "") || 0
row.querySelector(".credit").value.replace(/,/g, "") || 0,
);
const taxType = row.querySelector(".taxType").value;
const taxDirection = row.querySelector(".taxDirection").value;
@@ -818,7 +819,7 @@
// 税科目(仮払消費税等・仮受消費税等)が存在するかチェック
const hasTaxAccount = lines.some((line) => {
const account = accounts.find(
(a) => a.account_id === line.account_id
(a) => a.account_id === line.account_id,
);
return (
account &&
@@ -829,7 +830,7 @@
// 税科目が存在し、かつ税情報を持つ行がある場合は警告
const hasTaxInfo = lines.some(
(line) => line.tax_rate != null && line.tax_direction != null
(line) => line.tax_rate != null && line.tax_direction != null,
);
if (hasTaxAccount && hasTaxInfo) {
@@ -838,7 +839,7 @@
"警告:仮払消費税等・仮受消費税等の行がすでに存在していますが、他の行に税区分・税方向が設定されています。\n" +
"このまま登録すると税が二重計算され、借貸不平衡になります。\n\n" +
"税区分・税方向をすべて「対象外」に設定してから登録することをお勧めします。\n\n" +
"このまま登録しますか?"
"このまま登録しますか?",
)
) {
return;
@@ -903,7 +904,7 @@
} catch (error) {
console.error("送信エラー:", error);
alert(
`エラーが発生しました: ${error.message}\n\nサーバーが起動しているか確認してください。`
`エラーが発生しました: ${error.message}\n\nサーバーが起動しているか確認してください。`,
);
}
}
@@ -955,7 +956,7 @@
try {
await callApi(
`/month-locks/unlock?fiscal_year=${year}&month=${month}`
`/month-locks/unlock?fiscal_year=${year}&month=${month}`,
);
el.innerText = `${year}${month}月 已解锁`;
await refreshMonthLocks(); // 可选:自动刷新列表
@@ -985,8 +986,8 @@
(x) =>
`${x.fiscal_year}-${String(x.month).padStart(
2,
"0"
)} locked_by=${x.locked_by ?? ""}`
"0",
)} locked_by=${x.locked_by ?? ""}`,
)
.join("\n");
} catch (e) {
@@ -1005,7 +1006,7 @@
const data = await res.json();
return (data || []).some(
(x) => x.fiscal_year === year && x.month === month && x.is_locked
(x) => x.fiscal_year === year && x.month === month && x.is_locked,
);
}
@@ -1049,7 +1050,7 @@
// 最近使った科目を表示
const recentAccountIds = JSON.parse(
localStorage.getItem("recentAccounts") || "[]"
localStorage.getItem("recentAccounts") || "[]",
);
if (recentAccountIds.length > 0) {
html += `<optgroup label="⭐ 最近使った科目">`;
@@ -1080,7 +1081,7 @@
// 未分组的其他科目
const groupedCodes = ACCOUNT_GROUPS.flatMap((g) => g.codes);
const others = accounts.filter(
(a) => !groupedCodes.includes(a.account_code)
(a) => !groupedCodes.includes(a.account_code),
);
if (others.length > 0) {
@@ -1101,7 +1102,7 @@
if (!accountId) return;
let recentAccounts = JSON.parse(
localStorage.getItem("recentAccounts") || "[]"
localStorage.getItem("recentAccounts") || "[]",
);
// 重複を除去して先頭に追加
@@ -1127,7 +1128,7 @@
const key = document.getElementById("searchKeyword").value;
const accountId = document.getElementById("searchAccountId").value;
const includeHistory = document.getElementById(
"searchIncludeHistory"
"searchIncludeHistory",
).checked;
const qs = new URLSearchParams();
@@ -1191,7 +1192,7 @@
{
year: "numeric",
month: "long",
}
},
);
const section = document.createElement("div");
@@ -1287,7 +1288,7 @@
const key = document.getElementById("searchKeyword").value;
const accountId = document.getElementById("searchAccountId").value;
const includeHistory = document.getElementById(
"searchIncludeHistory"
"searchIncludeHistory",
).checked;
// 検索条件を保存
@@ -1299,7 +1300,7 @@
keyword: key,
accountId: accountId,
includeHistory: includeHistory,
})
}),
);
const qs = new URLSearchParams();
@@ -1358,7 +1359,7 @@
{
year: "numeric",
month: "long",
}
},
);
const section = document.createElement("div");
@@ -1512,10 +1513,10 @@
console.log("コピーされたデータ:", data); // デバッグ用
console.log(
`${data.lines.length}行をコピーしました。税区分・税方向はすべて「対象外」に設定されています。`
`${data.lines.length}行をコピーしました。税区分・税方向はすべて「対象外」に設定されています。`,
);
alert(
`仕訳を複製しました(${data.lines.length}行)。\n税の自動計算を防ぐため、すべての行の税区分・税方向を「対象外」に設定しています。\n必要に応じて修正してから登録してください。`
`仕訳を複製しました(${data.lines.length}行)。\n税の自動計算を防ぐため、すべての行の税区分・税方向を「対象外」に設定しています。\n必要に応じて修正してから登録してください。`,
);
} catch (error) {
console.error("Error:", error);
@@ -1529,7 +1530,7 @@
async function reverseAndEdit(id) {
if (
!confirm(
"この仕訳の逆仕訳を作成し、修正仕訳入力画面を開きます。よろしいですか?"
"この仕訳の逆仕訳を作成し、修正仕訳入力画面を開きます。よろしいですか?",
)
)
return;
@@ -1543,14 +1544,14 @@
if (!res.ok) {
const data = await res.json().catch(() => ({}));
alert(
data.detail || `逆仕訳の作成に失敗しました (HTTP ${res.status})`
data.detail || `逆仕訳の作成に失敗しました (HTTP ${res.status})`,
);
return;
}
const data = await res.json();
alert(
`逆仕訳を作成しましたID: ${data.reversed_journal_entry_id}`
`逆仕訳を作成しましたID: ${data.reversed_journal_entry_id}`,
);
// ② 元仕訳内容を取得して修正画面へ遷移