41 lines
963 B
JavaScript
41 lines
963 B
JavaScript
async function loadTrialBalance() {
|
|
const from = document.getElementById("from").value;
|
|
const to = document.getElementById("to").value;
|
|
|
|
if (!from || !to) {
|
|
alert("期間を指定してください");
|
|
return;
|
|
}
|
|
|
|
try {
|
|
const data = await apiGet("/trial-balance", {
|
|
date_from: from,
|
|
date_to: to,
|
|
});
|
|
|
|
const tbody = document.querySelector("#trial-table tbody");
|
|
tbody.innerHTML = "";
|
|
|
|
data.accounts.forEach((acc) => {
|
|
const tr = document.createElement("tr");
|
|
|
|
tr.innerHTML = `
|
|
<td>${acc.account_code}</td>
|
|
<td>
|
|
<a href="ledger.html?account_id=${acc.account_id}&from=${from}&to=${to}">
|
|
${acc.account_name}
|
|
</a>
|
|
</td>
|
|
<td>${acc.opening_balance}</td>
|
|
<td>${acc.debit}</td>
|
|
<td>${acc.credit}</td>
|
|
<td>${acc.closing_balance}</td>
|
|
`;
|
|
|
|
tbody.appendChild(tr);
|
|
});
|
|
} catch (e) {
|
|
alert(e.message);
|
|
}
|
|
}
|