This commit is contained in:
admin
2026-03-04 23:20:42 +09:00
parent 99d16d8219
commit 31a64d5b59
11 changed files with 674 additions and 201 deletions

View File

@@ -129,6 +129,7 @@
<th style="width: 220px">科目</th>
<th style="width: 120px">借方</th>
<th style="width: 120px">貸方</th>
<th style="width: 90px">税率</th>
<th style="width: 180px">摘要(行)</th>
<th style="width: 60px">操作</th>
</tr>
@@ -141,6 +142,7 @@
<th id="creditTotal" class="right">0</th>
<th></th>
<th></th>
<th></th>
</tr>
</tfoot>
</table>
@@ -159,6 +161,43 @@
const API = "";
let accounts = [];
// カスタムアラートモーダル
function showAlert(msg, type, callback) {
const configs = {
success: {
icon: "✔",
iconColor: "#22a84b",
bg: "#f0faf4",
borderTop: "#22a84b",
},
error: {
icon: "✖",
iconColor: "#e53935",
bg: "#fff5f5",
borderTop: "#e53935",
},
warning: {
icon: "⚠",
iconColor: "#e67e00",
bg: "#fffbf0",
borderTop: "#f0a500",
},
};
const c = configs[type] || configs.warning;
const overlay = document.getElementById("alertModalOverlay");
document.getElementById("alertModalIcon").innerHTML =
`<span style="font-size:52px;line-height:1;color:${c.iconColor};">${c.icon}</span>`;
document.getElementById("alertModalMsg").textContent = msg;
const box = document.getElementById("alertModalBox");
box.style.borderTop = `5px solid ${c.borderTop}`;
box.style.background = c.bg;
overlay.style.display = "flex";
document.getElementById("alertModalOkBtn").onclick = function () {
overlay.style.display = "none";
if (callback) callback();
};
}
// 科目グループ定義(仕訳入力と同期)
const ACCOUNT_GROUPS = [
// 資産の部
@@ -438,6 +477,14 @@
</td>
<td><input type="number" min="0" style="text-align:right"></td>
<td><input type="number" min="0" style="text-align:right"></td>
<td>
<select class="tax-rate-select" style="width:100%;padding:4px;">
<option value="">—</option>
<option value="10">10%</option>
<option value="8">8%(軽減)</option>
<option value="0">0%(非課税)</option>
</select>
</td>
<td><input type="text" class="line-memo-input" placeholder="行摘要(任意)"></td>
<td><button onclick="removeRow(this)">削除</button></td>
`;
@@ -464,6 +511,11 @@
const creditVal = Number(line.credit) || 0;
numberInputs[0].value = debitVal > 0 ? String(debitVal) : "";
numberInputs[1].value = creditVal > 0 ? String(creditVal) : "";
// 税率を設定
if (line.tax_rate != null) {
const sel = tr.querySelector(".tax-rate-select");
sel.value = String(line.tax_rate);
}
// 摘要(行)を設定
const memoInput = tr.querySelector(".line-memo-input");
if (memoInput) memoInput.value = line.line_description || "";
@@ -556,11 +608,17 @@
const credit = Number(numberInputs[1]?.value || 0);
const lineDesc =
tr.querySelector(".line-memo-input")?.value.trim() || undefined;
const taxRateRaw = tr.querySelector(".tax-rate-select")?.value;
const taxRate =
taxRateRaw !== "" && taxRateRaw != null
? Number(taxRateRaw)
: undefined;
if (debit === 0 && credit === 0) return;
lines.push({
account_id: accountId,
debit,
credit,
...(taxRate !== undefined ? { tax_rate: taxRate } : {}),
...(lineDesc ? { line_description: lineDesc } : {}),
});
d += debit;
@@ -599,15 +657,17 @@
if (!res.ok) return showError(data.detail || "登録失敗");
// 登録成功 - 親窓口の検索を再実行してから画面を閉じる
alert(`登録しましたID: ${data.journal_entry_id}`);
localStorage.removeItem("editSource");
// 親窓口(列表页)の searchJournalsを呼び出す
if (window.opener && window.opener.searchJournals) {
window.opener.searchJournals();
}
window.close();
showAlert(
`登録しましたID: ${data.journal_entry_id}`,
"success",
() => {
localStorage.removeItem("editSource");
if (window.opener && window.opener.searchJournals) {
window.opener.searchJournals();
}
window.close();
},
);
} catch {
showError("通信エラー");
}
@@ -629,5 +689,57 @@
window.close();
}
</script>
<!-- アラートモーダル -->
<div
id="alertModalOverlay"
style="
display: none;
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.45);
z-index: 9999;
align-items: center;
justify-content: center;
"
>
<div
id="alertModalBox"
style="
background: #fff;
border-radius: 10px;
padding: 32px 36px;
min-width: 320px;
max-width: 480px;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
text-align: center;
"
>
<div id="alertModalIcon" style="margin-bottom: 14px"></div>
<div
id="alertModalMsg"
style="
font-size: 15px;
color: #333;
margin-bottom: 26px;
white-space: pre-wrap;
"
></div>
<button
id="alertModalOkBtn"
style="
padding: 9px 36px;
border-radius: 6px;
border: none;
font-size: 14px;
cursor: pointer;
background: #4a90d9;
color: #fff;
font-weight: 600;
"
>
OK
</button>
</div>
</div>
</body>
</html>