update expense

This commit is contained in:
2026-05-25 13:07:41 -05:00
parent dc3064acc6
commit f535f35eee
5 changed files with 243 additions and 17 deletions

View File

@@ -623,6 +623,11 @@ function renderExpensesTable(expenses) {
</details>`
: escapeHtml(e.lines[0]?.accountName || '');
const editBtn = expOnlyMine
? `<button onclick='window.accountingView.editExpense(${JSON.stringify(JSON.stringify(e))})'
class="text-blue-600 hover:text-blue-800 text-xs font-medium">Edit</button>`
: `<span class="text-gray-300 text-xs" title="Only expenses created from this app can be edited">—</span>`;
return `
<tr class="border-t hover:bg-gray-50 align-top">
<td class="px-3 py-2 text-sm whitespace-nowrap">${escapeHtml(e.txnDate || '')}</td>
@@ -632,6 +637,7 @@ function renderExpensesTable(expenses) {
<td class="px-3 py-2 text-sm">${escapeHtml(e.refNo || '')}</td>
<td class="px-3 py-2 text-sm text-gray-500">${escapeHtml(e.memo || '')}</td>
<td class="px-3 py-2 text-sm text-right whitespace-nowrap text-red-600">${fmtMoney(e.totalAmt)}</td>
<td class="px-3 py-2 text-sm text-center">${editBtn}</td>
</tr>`;
}).join('');
@@ -647,6 +653,7 @@ function renderExpensesTable(expenses) {
<th class="px-3 py-2 text-left font-medium text-gray-700">Ref</th>
<th class="px-3 py-2 text-left font-medium text-gray-700">Memo</th>
<th class="px-3 py-2 text-right font-medium text-gray-700">Amount</th>
<th class="px-3 py-2 text-center font-medium text-gray-700">Action</th>
</tr>
</thead>
<tbody>${tbody}</tbody>
@@ -683,7 +690,19 @@ export function refreshAll() {
loadAccountsOverview();
if (registerAccountId) loadRegister();
}
export async function editExpense(expenseJson) {
let expense;
try {
expense = typeof expenseJson === 'string' ? JSON.parse(expenseJson) : expenseJson;
} catch (e) {
alert('Could not open expense for editing.');
return;
}
await openExpenseModal({
expense,
onSaved: () => loadExpenses()
});
}
window.accountingView = {
renderAccountingView,
refreshAll,
@@ -695,5 +714,6 @@ window.accountingView = {
loadBalanceSheet,
loadExpenses,
openNewExpense,
editExpense,
toggleSection
};