Removes redundant payment recording

Removes the explicit call to the record-payment API when settling a receivable.

The webhook (on_invoice_paid in tasks.py) automatically handles recording the payment in Fava, making the API call redundant. This simplifies the frontend logic.

Also, in the `showPayUserDialog` function, it now correctly identifies users who are owed payments based on a negative balance instead of a positive balance.
This commit is contained in:
padreug 2025-11-10 11:13:25 +01:00
parent 490b361268
commit 1d605be021

View file

@ -1184,38 +1184,21 @@ window.app = Vue.createApp({
clearInterval(this.settleReceivableDialog.pollIntervalId)
this.settleReceivableDialog.pollIntervalId = null
// Record payment in accounting - this creates the journal entry
// that settles the receivable
try {
const recordResponse = await LNbits.api.request(
'POST',
'/castle/api/v1/record-payment',
this.g.user.wallets[0].adminkey,
{
payment_hash: paymentHash
}
)
console.log('Settlement payment recorded:', recordResponse.data)
// Payment detected! The webhook (on_invoice_paid in tasks.py) will automatically
// record this in Fava, so we don't need to call record-payment API here.
// Just notify the user and refresh the UI.
this.$q.notify({
type: 'positive',
message: 'Payment received! Receivable has been settled.',
timeout: 3000
})
this.$q.notify({
type: 'positive',
message: 'Payment received! Receivable has been settled.',
timeout: 3000
})
// Close dialog and refresh
this.settleReceivableDialog.show = false
await this.loadBalance()
await this.loadTransactions()
await this.loadAllUserBalances()
// Close dialog and refresh
this.settleReceivableDialog.show = false
await this.loadBalance()
await this.loadTransactions()
await this.loadAllUserBalances()
} catch (error) {
console.error('Error recording settlement payment:', error)
this.$q.notify({
type: 'negative',
message: 'Payment detected but failed to record: ' + (error.response?.data?.detail || error.message),
timeout: 5000
})
}
return true
}
return false
@ -1297,8 +1280,8 @@ window.app = Vue.createApp({
}
},
showPayUserDialog(userBalance) {
// Only show for users castle owes (positive balance)
if (userBalance.balance <= 0) return
// Only show for users castle owes (negative balance = payable)
if (userBalance.balance >= 0) return
// Extract fiat balances (e.g., EUR)
const fiatBalances = userBalance.fiat_balances || {}