Completes Phase 2: Adds reconciliation features

Implements balance assertions, reconciliation API endpoints, a reconciliation UI dashboard, and automated daily balance checks.

This provides comprehensive reconciliation tools to ensure accounting accuracy and catch discrepancies early.

Updates roadmap to mark Phase 2 as complete.
This commit is contained in:
padreug 2025-10-23 02:31:15 +02:00
parent c0277dfc98
commit 6d84479f7d
7 changed files with 963 additions and 6 deletions

View file

@ -76,6 +76,12 @@ window.app = Vue.createApp({
tolerance_sats: 0,
tolerance_fiat: 0,
loading: false
},
reconciliation: {
summary: null,
discrepancies: null,
checking: false,
showDiscrepancies: false
}
}
},
@ -718,6 +724,60 @@ window.app = Vue.createApp({
const account = this.accounts.find(a => a.id === accountId)
return account ? account.name : accountId
},
async loadReconciliationSummary() {
if (!this.isSuperUser) return
try {
const response = await LNbits.api.request(
'GET',
'/castle/api/v1/reconciliation/summary',
this.g.user.wallets[0].adminkey
)
this.reconciliation.summary = response.data
} catch (error) {
LNbits.utils.notifyApiError(error)
}
},
async loadReconciliationDiscrepancies() {
if (!this.isSuperUser) return
try {
const response = await LNbits.api.request(
'GET',
'/castle/api/v1/reconciliation/discrepancies',
this.g.user.wallets[0].adminkey
)
this.reconciliation.discrepancies = response.data
} catch (error) {
LNbits.utils.notifyApiError(error)
}
},
async runFullReconciliation() {
this.reconciliation.checking = true
try {
const response = await LNbits.api.request(
'POST',
'/castle/api/v1/reconciliation/check-all',
this.g.user.wallets[0].adminkey
)
const results = response.data
this.$q.notify({
type: results.failed > 0 ? 'warning' : 'positive',
message: `Checked ${results.checked} assertions: ${results.passed} passed, ${results.failed} failed`,
timeout: 3000
})
// Reload reconciliation data
await this.loadReconciliationSummary()
await this.loadReconciliationDiscrepancies()
await this.loadBalanceAssertions()
} catch (error) {
LNbits.utils.notifyApiError(error)
} finally {
this.reconciliation.checking = false
}
},
copyToClipboard(text) {
navigator.clipboard.writeText(text)
this.$q.notify({
@ -870,6 +930,8 @@ window.app = Vue.createApp({
await this.loadUsers()
await this.loadPendingExpenses()
await this.loadBalanceAssertions()
await this.loadReconciliationSummary()
await this.loadReconciliationDiscrepancies()
}
}
})