修正
This commit is contained in:
@@ -64,9 +64,34 @@ from app.modules.opening_balances.lock_router import router as opening_balance_l
|
||||
app.include_router(opening_balance_lock_router)
|
||||
|
||||
from app.routers import journal_entries
|
||||
from app.routers import cash
|
||||
from app.routers import accounts
|
||||
|
||||
app.include_router(journal_entries.router)
|
||||
app.include_router(cash.router)
|
||||
app.include_router(accounts.router)
|
||||
|
||||
|
||||
from app.routers import month_locks
|
||||
app.include_router(month_locks.router)
|
||||
|
||||
from app.routers import year_locks
|
||||
app.include_router(year_locks.router)
|
||||
|
||||
from app.routers import cash
|
||||
app.include_router(cash.router)
|
||||
|
||||
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
|
||||
app.mount(
|
||||
"/",
|
||||
StaticFiles(directory="app/static", html=True),
|
||||
name="static",
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
from fastapi import APIRouter
|
||||
from app.core.database import get_connection
|
||||
|
||||
router = APIRouter(prefix="/accounts", tags=["科目"])
|
||||
|
||||
@router.get("", summary="科目一覧取得")
|
||||
def get_accounts():
|
||||
"""
|
||||
科目マスタ一覧を返す
|
||||
"""
|
||||
with get_connection() as conn, conn.cursor() as cur:
|
||||
cur.execute("""
|
||||
SELECT
|
||||
account_id,
|
||||
account_code,
|
||||
account_name,
|
||||
account_type
|
||||
FROM accounts
|
||||
ORDER BY account_code
|
||||
""")
|
||||
rows = cur.fetchall()
|
||||
|
||||
return rows
|
||||
|
||||
105
backend/app/routers/cash.py
Normal file
105
backend/app/routers/cash.py
Normal file
@@ -0,0 +1,105 @@
|
||||
from fastapi import APIRouter, Query
|
||||
from datetime import date
|
||||
from app.core.database import get_connection
|
||||
|
||||
router = APIRouter(prefix="/cash", tags=["资金"])
|
||||
|
||||
|
||||
# ※ 临时方案:资金系科目(现金 / 银行)
|
||||
CASH_ACCOUNT_IDS = [101, 102]
|
||||
|
||||
|
||||
# -------------------------
|
||||
# 资金余额
|
||||
# -------------------------
|
||||
@router.get("/balance", summary="资金余额取得")
|
||||
def get_cash_balance():
|
||||
"""
|
||||
取得当前资金余额(现金・银行)
|
||||
"""
|
||||
with get_connection() as conn, conn.cursor() as cur:
|
||||
cur.execute("""
|
||||
SELECT
|
||||
a.account_id,
|
||||
a.account_name,
|
||||
COALESCE(SUM(l.debit), 0) - COALESCE(SUM(l.credit), 0) AS balance
|
||||
FROM accounts a
|
||||
LEFT JOIN journal_lines l
|
||||
ON l.account_id = a.account_id
|
||||
LEFT JOIN journal_entries e
|
||||
ON e.journal_id = l.journal_id
|
||||
AND e.is_deleted = false
|
||||
WHERE a.account_id = ANY(%s)
|
||||
GROUP BY a.account_id, a.account_name
|
||||
ORDER BY a.account_id
|
||||
""", (CASH_ACCOUNT_IDS,))
|
||||
|
||||
rows = cur.fetchall()
|
||||
|
||||
total = sum(r["balance"] for r in rows)
|
||||
|
||||
return {
|
||||
"items": rows,
|
||||
"total_balance": total
|
||||
}
|
||||
|
||||
|
||||
# -------------------------
|
||||
# 资金流水
|
||||
# -------------------------
|
||||
@router.get("/transactions", summary="资金流水取得")
|
||||
def get_cash_transactions(
|
||||
account_id: int = Query(..., description="资金账户ID"),
|
||||
from_date: date | None = Query(None, alias="from"),
|
||||
to_date: date | None = Query(None, alias="to"),
|
||||
):
|
||||
"""
|
||||
指定资金账户的资金流水
|
||||
"""
|
||||
with get_connection() as conn, conn.cursor() as cur:
|
||||
sql = """
|
||||
SELECT
|
||||
e.journal_date,
|
||||
e.description,
|
||||
l.debit,
|
||||
l.credit,
|
||||
COALESCE(a2.account_name, '(未指定)') AS counter_account
|
||||
FROM journal_lines l
|
||||
JOIN journal_entries e
|
||||
ON e.journal_id = l.journal_id
|
||||
LEFT JOIN journal_lines l2
|
||||
ON l2.journal_id = l.journal_id
|
||||
AND l2.account_id <> l.account_id
|
||||
LEFT JOIN accounts a2
|
||||
ON a2.account_id = l2.account_id
|
||||
WHERE l.account_id = %s
|
||||
AND e.is_deleted = false
|
||||
"""
|
||||
|
||||
params = [account_id]
|
||||
|
||||
if from_date:
|
||||
sql += " AND e.journal_date >= %s"
|
||||
params.append(from_date)
|
||||
|
||||
if to_date:
|
||||
sql += " AND e.journal_date <= %s"
|
||||
params.append(to_date)
|
||||
|
||||
sql += " ORDER BY e.journal_date, e.journal_id"
|
||||
|
||||
cur.execute(sql, params)
|
||||
rows = cur.fetchall()
|
||||
|
||||
result = []
|
||||
for r in rows:
|
||||
amount = r["debit"] - r["credit"]
|
||||
result.append({
|
||||
"journal_date": r["journal_date"],
|
||||
"description": r["description"],
|
||||
"counter_account": r["counter_account"],
|
||||
"amount": amount,
|
||||
"direction": "in" if amount > 0 else "out" if amount < 0 else "none",
|
||||
})
|
||||
|
||||
return result
|
||||
49
backend/app/routers/year_locks.py
Normal file
49
backend/app/routers/year_locks.py
Normal file
@@ -0,0 +1,49 @@
|
||||
from fastapi import APIRouter, HTTPException
|
||||
from app.core.database import get_connection
|
||||
|
||||
router = APIRouter(prefix="/year-locks", tags=["年度锁定"])
|
||||
|
||||
|
||||
@router.get("", summary="年度锁定一覧")
|
||||
def get_year_locks():
|
||||
with get_connection() as conn, conn.cursor() as cur:
|
||||
cur.execute("""
|
||||
SELECT fiscal_year, is_locked, locked_at, locked_by
|
||||
FROM year_locks
|
||||
ORDER BY fiscal_year
|
||||
""")
|
||||
return cur.fetchall()
|
||||
|
||||
|
||||
@router.post("/lock", summary="年度锁定")
|
||||
def lock_year(fiscal_year: int):
|
||||
with get_connection() as conn, conn.cursor() as cur:
|
||||
cur.execute("""
|
||||
INSERT INTO year_locks (fiscal_year, is_locked, locked_at, locked_by)
|
||||
VALUES (%s, true, NOW(), %s)
|
||||
ON CONFLICT (fiscal_year)
|
||||
DO UPDATE
|
||||
SET is_locked = true,
|
||||
locked_at = NOW(),
|
||||
locked_by = EXCLUDED.locked_by
|
||||
""", (fiscal_year, "system"))
|
||||
conn.commit()
|
||||
|
||||
return {"status": "locked", "fiscal_year": fiscal_year}
|
||||
|
||||
|
||||
@router.post("/unlock", summary="年度解锁")
|
||||
def unlock_year(fiscal_year: int):
|
||||
with get_connection() as conn, conn.cursor() as cur:
|
||||
cur.execute("""
|
||||
UPDATE year_locks
|
||||
SET is_locked = false
|
||||
WHERE fiscal_year = %s
|
||||
""", (fiscal_year,))
|
||||
|
||||
if cur.rowcount == 0:
|
||||
raise HTTPException(status_code=404, detail="指定年度不存在")
|
||||
|
||||
conn.commit()
|
||||
|
||||
return {"status": "unlocked", "fiscal_year": fiscal_year}
|
||||
96
backend/app/static/cash-transactions.html
Normal file
96
backend/app/static/cash-transactions.html
Normal file
@@ -0,0 +1,96 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ja">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>资金流水</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>📄 资金流水</h2>
|
||||
|
||||
<div>
|
||||
<label>账户ID:</label>
|
||||
<input id="accountId" type="number" value="101" style="width: 80px" />
|
||||
<label>从:</label>
|
||||
<input id="fromDate" type="date" />
|
||||
<label>到:</label>
|
||||
<input id="toDate" type="date" />
|
||||
<button onclick="loadTransactions()">查询</button>
|
||||
</div>
|
||||
|
||||
<table
|
||||
border="1"
|
||||
cellpadding="6"
|
||||
style="margin-top: 10px; border-collapse: collapse"
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>日期</th>
|
||||
<th>摘要</th>
|
||||
<th style="text-align: right">金额</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="txBody">
|
||||
<tr>
|
||||
<td colspan="3">请输入条件后查询</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<script>
|
||||
function formatYen(v) {
|
||||
return "¥ " + Number(v).toLocaleString("ja-JP");
|
||||
}
|
||||
|
||||
async function loadTransactions() {
|
||||
const accountId = document.getElementById("accountId").value;
|
||||
const from = document.getElementById("fromDate").value;
|
||||
const to = document.getElementById("toDate").value;
|
||||
|
||||
let url = `/cash/transactions?account_id=${accountId}`;
|
||||
if (from) url += `&from=${from}`;
|
||||
if (to) url += `&to=${to}`;
|
||||
|
||||
const body = document.getElementById("txBody");
|
||||
body.innerHTML = "<tr><td colspan='3'>读取中...</td></tr>";
|
||||
|
||||
try {
|
||||
const res = await fetch(url);
|
||||
const data = await res.json();
|
||||
|
||||
body.innerHTML = "";
|
||||
if (data.length === 0) {
|
||||
body.innerHTML = "<tr><td colspan='3'>无数据</td></tr>";
|
||||
return;
|
||||
}
|
||||
|
||||
data.forEach((row) => {
|
||||
const tr = document.createElement("tr");
|
||||
tr.innerHTML = `
|
||||
<td>${row.journal_date}</td>
|
||||
<td>${row.description}</td>
|
||||
<td style="text-align:right;color:${row.amount < 0 ? "red" : "black"};">
|
||||
${formatYen(row.amount)}
|
||||
</td>
|
||||
`;
|
||||
body.appendChild(tr);
|
||||
});
|
||||
} catch (e) {
|
||||
body.innerHTML = "<tr><td colspan='3'>读取失败</td></tr>";
|
||||
}
|
||||
}
|
||||
|
||||
function getQueryParam(name) {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
return params.get(name);
|
||||
}
|
||||
|
||||
window.onload = () => {
|
||||
const accountId = getQueryParam("account_id");
|
||||
if (accountId) {
|
||||
document.getElementById("accountId").value = accountId;
|
||||
loadTransactions();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
76
backend/app/static/cash.html
Normal file
76
backend/app/static/cash.html
Normal file
@@ -0,0 +1,76 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ja">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>资金余额</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>💰 当前资金状况</h2>
|
||||
|
||||
<table border="1" cellpadding="6" style="border-collapse: collapse">
|
||||
<thead>
|
||||
<tr style="background: #f5f5f5">
|
||||
<th>账户</th>
|
||||
<th style="text-align: right">余额</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="cashBalanceBody">
|
||||
<tr>
|
||||
<td colspan="2">读取中...</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr style="font-weight: bold">
|
||||
<td>合计</td>
|
||||
<td id="cashBalanceTotal" style="text-align: right">-</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
<script>
|
||||
const API_BASE = "http://127.0.0.1:8080";
|
||||
|
||||
function formatYen(v) {
|
||||
return "¥ " + Number(v).toLocaleString("ja-JP");
|
||||
}
|
||||
|
||||
async function loadCashBalance() {
|
||||
const body = document.getElementById("cashBalanceBody");
|
||||
const totalEl = document.getElementById("cashBalanceTotal");
|
||||
|
||||
try {
|
||||
const res = await fetch("/cash/balance");
|
||||
const data = await res.json();
|
||||
|
||||
body.innerHTML = "";
|
||||
|
||||
data.items.forEach((item) => {
|
||||
const tr = document.createElement("tr");
|
||||
|
||||
tr.style.cursor = "pointer";
|
||||
tr.onclick = () => {
|
||||
window.location.href = `/cash-transactions.html?account_id=${item.account_id}`;
|
||||
};
|
||||
|
||||
tr.innerHTML = `
|
||||
<td style="color:#007acc; text-decoration:underline;">
|
||||
${item.account_name}
|
||||
</td>
|
||||
<td style="text-align:right;">
|
||||
${formatYen(item.balance)}
|
||||
</td>
|
||||
`;
|
||||
|
||||
tbody.appendChild(tr);
|
||||
});
|
||||
|
||||
totalEl.innerText = formatYen(data.total_balance);
|
||||
} catch (e) {
|
||||
body.innerHTML = `<tr><td colspan="2">读取失败</td></tr>`;
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener("DOMContentLoaded", loadCashBalance);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -30,7 +30,67 @@
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
|
||||
<h3>💰 当前资金状况</h3>
|
||||
|
||||
<table border="1" cellpadding="6" style="border-collapse: collapse">
|
||||
<thead>
|
||||
<tr style="background: #f5f5f5">
|
||||
<th>账户</th>
|
||||
<th style="text-align: right">余额</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="cashBalanceBody">
|
||||
<tr>
|
||||
<td colspan="2">读取中...</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr style="font-weight: bold">
|
||||
<td>合计</td>
|
||||
<td id="cashBalanceTotal" style="text-align: right">-</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
<script src="js/api.js"></script>
|
||||
<script src="js/trial_balance.js"></script>
|
||||
<script>
|
||||
const API_BASE = "http://127.0.0.1:18080";
|
||||
|
||||
function formatYen(v) {
|
||||
return "¥ " + Number(v).toLocaleString("ja-JP");
|
||||
}
|
||||
|
||||
async function loadCashBalance() {
|
||||
const body = document.getElementById("cashBalanceBody");
|
||||
const totalEl = document.getElementById("cashBalanceTotal");
|
||||
|
||||
body.innerHTML = "<tr><td colspan='2'>读取中...</td></tr>";
|
||||
totalEl.innerText = "-";
|
||||
|
||||
try {
|
||||
const res = await fetch(`${API_BASE}/cash/balance`);
|
||||
const data = await res.json();
|
||||
|
||||
body.innerHTML = "";
|
||||
|
||||
data.items.forEach((item) => {
|
||||
const tr = document.createElement("tr");
|
||||
tr.innerHTML = `
|
||||
<td>${item.account_name}</td>
|
||||
<td style="text-align:right;">${formatYen(item.balance)}</td>
|
||||
`;
|
||||
body.appendChild(tr);
|
||||
});
|
||||
|
||||
totalEl.innerText = formatYen(data.total_balance);
|
||||
} catch (e) {
|
||||
body.innerHTML = `<tr><td colspan="2">读取失败</td></tr>`;
|
||||
}
|
||||
}
|
||||
|
||||
// 页面加载时自动读取
|
||||
window.addEventListener("DOMContentLoaded", loadCashBalance);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
0
frontend/pages/cash-transactions.html
Normal file
0
frontend/pages/cash-transactions.html
Normal file
202
frontend/pages/cash.html
Normal file
202
frontend/pages/cash.html
Normal file
@@ -0,0 +1,202 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ja">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>資金状況</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: sans-serif;
|
||||
margin: 24px;
|
||||
}
|
||||
h2,
|
||||
h3 {
|
||||
margin-top: 0;
|
||||
}
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
margin-top: 12px;
|
||||
}
|
||||
th,
|
||||
td {
|
||||
border: 1px solid #ccc;
|
||||
padding: 6px;
|
||||
text-align: right;
|
||||
}
|
||||
th {
|
||||
background: #f5f5f5;
|
||||
}
|
||||
th.left,
|
||||
td.left {
|
||||
text-align: left;
|
||||
}
|
||||
.total {
|
||||
font-weight: bold;
|
||||
background: #f0f0f0;
|
||||
}
|
||||
.filter {
|
||||
margin: 8px 0;
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
}
|
||||
input,
|
||||
select,
|
||||
button {
|
||||
padding: 4px 6px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h2>💰 現在の資金状況</h2>
|
||||
|
||||
<!-- 残高 -->
|
||||
<table id="balanceTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="left">口座</th>
|
||||
<th>残高</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
<tfoot>
|
||||
<tr class="total">
|
||||
<td class="left">合計</td>
|
||||
<td id="totalBalance">-</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
<hr />
|
||||
|
||||
<h3>📄 資金流水</h3>
|
||||
|
||||
<!-- 条件 -->
|
||||
<div class="filter">
|
||||
<label>口座:</label>
|
||||
<select id="accountSelect"></select>
|
||||
|
||||
<label>期間:</label>
|
||||
<input type="date" id="fromDate" />
|
||||
〜
|
||||
<input type="date" id="toDate" />
|
||||
|
||||
<button onclick="reloadTransactions()">表示</button>
|
||||
</div>
|
||||
|
||||
<!-- 流水表 -->
|
||||
<table id="txTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="left">日付</th>
|
||||
<th class="left">摘要</th>
|
||||
<th class="left">相手科目</th>
|
||||
<th>入金</th>
|
||||
<th>出金</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
|
||||
<script>
|
||||
const API = "http://127.0.0.1:8000";
|
||||
|
||||
// --------------------
|
||||
// 初期化
|
||||
// --------------------
|
||||
async function init() {
|
||||
await loadBalances();
|
||||
await loadAccounts();
|
||||
|
||||
// 初期期間:当月
|
||||
const now = new Date();
|
||||
const first = new Date(now.getFullYear(), now.getMonth(), 1);
|
||||
document.getElementById("fromDate").value = first
|
||||
.toISOString()
|
||||
.slice(0, 10);
|
||||
document.getElementById("toDate").value = now
|
||||
.toISOString()
|
||||
.slice(0, 10);
|
||||
}
|
||||
init();
|
||||
|
||||
// --------------------
|
||||
// 残高
|
||||
// --------------------
|
||||
async function loadBalances() {
|
||||
const res = await fetch(`${API}/cash/balance`);
|
||||
const data = await res.json();
|
||||
|
||||
const tbody = document.querySelector("#balanceTable tbody");
|
||||
tbody.innerHTML = "";
|
||||
|
||||
data.items.forEach((i) => {
|
||||
tbody.innerHTML += `
|
||||
<tr>
|
||||
<td class="left">${i.account_name}</td>
|
||||
<td>${Number(i.balance).toLocaleString()}</td>
|
||||
</tr>`;
|
||||
});
|
||||
|
||||
document.getElementById("totalBalance").innerText = Number(
|
||||
data.total_balance
|
||||
).toLocaleString();
|
||||
}
|
||||
|
||||
// --------------------
|
||||
// 口座一覧
|
||||
// --------------------
|
||||
async function loadAccounts() {
|
||||
const res = await fetch(`${API}/cash/balance`);
|
||||
const data = await res.json();
|
||||
|
||||
const sel = document.getElementById("accountSelect");
|
||||
sel.innerHTML = data.items
|
||||
.map(
|
||||
(i) => `<option value="${i.account_id}">${i.account_name}</option>`
|
||||
)
|
||||
.join("");
|
||||
|
||||
reloadTransactions();
|
||||
}
|
||||
|
||||
// --------------------
|
||||
// 再表示
|
||||
// --------------------
|
||||
function reloadTransactions() {
|
||||
const accountId = document.getElementById("accountSelect").value;
|
||||
const from = document.getElementById("fromDate").value;
|
||||
const to = document.getElementById("toDate").value;
|
||||
|
||||
loadTransactions(accountId, from, to);
|
||||
}
|
||||
|
||||
// --------------------
|
||||
// 流水
|
||||
// --------------------
|
||||
async function loadTransactions(accountId, from, to) {
|
||||
let url = `${API}/cash/transactions?account_id=${accountId}`;
|
||||
if (from) url += `&from=${from}`;
|
||||
if (to) url += `&to=${to}`;
|
||||
|
||||
const res = await fetch(url);
|
||||
const rows = await res.json();
|
||||
|
||||
const tbody = document.querySelector("#txTable tbody");
|
||||
tbody.innerHTML = "";
|
||||
|
||||
rows.forEach((r) => {
|
||||
tbody.innerHTML += `
|
||||
<tr>
|
||||
<td class="left">${r.journal_date}</td>
|
||||
<td class="left">${r.description}</td>
|
||||
<td class="left">${r.counter_account}</td>
|
||||
<td>${r.amount > 0 ? r.amount.toLocaleString() : ""}</td>
|
||||
<td>${r.amount < 0 ? (-r.amount).toLocaleString() : ""}</td>
|
||||
</tr>`;
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,56 +1,107 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ja">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>试算表</title>
|
||||
<style>
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
}
|
||||
th, td {
|
||||
border: 1px solid #ccc;
|
||||
padding: 6px 10px;
|
||||
text-align: right;
|
||||
}
|
||||
th {
|
||||
background: #f5f5f5;
|
||||
}
|
||||
td.left {
|
||||
text-align: left;
|
||||
}
|
||||
tfoot td {
|
||||
font-weight: bold;
|
||||
background: #fafafa;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>試算表</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: sans-serif;
|
||||
margin: 24px;
|
||||
}
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
}
|
||||
th,
|
||||
td {
|
||||
border: 1px solid #ccc;
|
||||
padding: 6px 10px;
|
||||
text-align: right;
|
||||
}
|
||||
th {
|
||||
background: #f5f5f5;
|
||||
}
|
||||
td.left {
|
||||
text-align: left;
|
||||
}
|
||||
tfoot td {
|
||||
font-weight: bold;
|
||||
background: #fafafa;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h2>試算表</h2>
|
||||
|
||||
<h2>試算表</h2>
|
||||
<table id="trialBalanceTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="left">科目コード</th>
|
||||
<th class="left">科目名称</th>
|
||||
<th>期首残高</th>
|
||||
<th>借方合計</th>
|
||||
<th>贷方合計</th>
|
||||
<th>期末残高</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- JS 动态插入 -->
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="2" class="left">合計</td>
|
||||
<td id="totalOpening">0</td>
|
||||
<td id="totalDebit">0</td>
|
||||
<td id="totalCredit">0</td>
|
||||
<td id="totalClosing">0</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
<table id="trialBalanceTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>科目代码</th>
|
||||
<th>科目名称</th>
|
||||
<th>借方合计</th>
|
||||
<th>贷方合计</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- JS 动态插入 -->
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="2">合计</td>
|
||||
<td id="totalDebit">0</td>
|
||||
<td id="totalCredit">0</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<script>
|
||||
const API_BASE = "http://127.0.0.1:18080"; // 和你后端一致
|
||||
|
||||
<script src="./js/trial-balance.js"></script>
|
||||
async function loadTrialBalance() {
|
||||
const res = await fetch(`${API_BASE}/trial-balance`);
|
||||
if (!res.ok) {
|
||||
alert("試算表の取得に失敗しました");
|
||||
return;
|
||||
}
|
||||
|
||||
</body>
|
||||
const data = await res.json();
|
||||
|
||||
const tbody = document.querySelector("#trialBalanceTable tbody");
|
||||
tbody.innerHTML = "";
|
||||
|
||||
data.accounts.forEach((acc) => {
|
||||
const tr = document.createElement("tr");
|
||||
tr.innerHTML = `
|
||||
<td class="left">${acc.account_code}</td>
|
||||
<td class="left">${acc.account_name}</td>
|
||||
<td>${Number(acc.opening_balance).toLocaleString()}</td>
|
||||
<td>${Number(acc.debit).toLocaleString()}</td>
|
||||
<td>${Number(acc.credit).toLocaleString()}</td>
|
||||
<td>${Number(acc.closing_balance).toLocaleString()}</td>
|
||||
`;
|
||||
tbody.appendChild(tr);
|
||||
});
|
||||
|
||||
// totals
|
||||
document.getElementById("totalOpening").innerText = Number(
|
||||
data.totals.opening_balance
|
||||
).toLocaleString();
|
||||
document.getElementById("totalDebit").innerText = Number(
|
||||
data.totals.debit
|
||||
).toLocaleString();
|
||||
document.getElementById("totalCredit").innerText = Number(
|
||||
data.totals.credit
|
||||
).toLocaleString();
|
||||
document.getElementById("totalClosing").innerText = Number(
|
||||
data.totals.closing_balance
|
||||
).toLocaleString();
|
||||
}
|
||||
|
||||
loadTrialBalance();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
22
メモ.txt
22
メモ.txt
@@ -118,4 +118,24 @@ updated_reason:
|
||||
|
||||
可空
|
||||
|
||||
例如:金额修正、补录摘要、对账调整
|
||||
例如:金额修正、补录摘要、对账调整
|
||||
|
||||
|
||||
-------------------------------
|
||||
/volume1/docker/rc_ollama_bot/
|
||||
bot.py
|
||||
① 停掉并删除旧容器(非常关键)
|
||||
docker stop ollama-rc-bot
|
||||
docker rm ollama-rc-bot
|
||||
docker build --no-cache -t ollama-rc-bot .
|
||||
② 重新 build 镜像(必须)
|
||||
docker build --no-cache -t ollama-rc-bot .
|
||||
③ 重新启动容器
|
||||
docker run -d \
|
||||
--name ollama-rc-bot \
|
||||
-p 5100:5005 \
|
||||
ollama-rc-bot
|
||||
|
||||
docker run -d --name ollama-rc-bot -p 5100:5005 ollama-rc-bot
|
||||
④ 看日志,确认新代码真的在跑
|
||||
docker logs -f ollama-rc-bot
|
||||
|
||||
Reference in New Issue
Block a user